Page 1 of 2

Compass App, Javascript, CSS and other terrible things.

Posted: Sun Sep 01, 2013 8:19 pm
by Adam Tucker

Hello, at the moment I'm trying to set up a compass with my app.
At the moment I have got to the point where I can get the gyro to give a heading reading in the form of an alert in a radial fashion (0-360) using this code:

function onSuccess(heading) {
alert('Heading: ' + heading.magneticHeading);
};

function onError() {
alert('onError!');
};

Firstly how can I change this to get this to a label and to get it constantly updating in (nearly) real time.

I was then thinking of using this label as a variable for CSS to rotate a needle around a compass anyone got any ideas with anything

Trying to make this for android if that helps

I am not a programmer so explain it like I'm 5 pretty please
Kind regards


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Sep 01, 2013 9:06 pm
by maxkatz

You can place a Label on a page and simply update it (instead of JavaScript alert).

You can invoke the script every x-seconds to get a constant update.


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Sep 01, 2013 9:25 pm
by Adam Tucker

I've placed a label on the page ready for this I understand that I can do that I just don't know how to. I have a very limited understanding of Javascript and this is one of the only bits of code I really have in my app.

Can you help me out I would really appreciate it?


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Sep 01, 2013 10:52 pm
by Adam Tucker

Basically I don't know the javascript to get it to display on a label and how to get it to invoke constantly. It's getting late here in the UK and I haven't even got into the CSS yet :'(


Compass App, Javascript, CSS and other terrible things.

Posted: Mon Sep 02, 2013 1:01 am
by maxkatz

Here is how to read/update a Label component on a page: http://docs.appery.io/javascript-api/


Compass App, Javascript, CSS and other terrible things.

Posted: Mon Sep 02, 2013 1:03 am
by maxkatz

Something like this:
code
Appery('component_name').text (heading.magneticHeading);
/code

where 'component_name' is the name of the Label component.


Compass App, Javascript, CSS and other terrible things.

Posted: Mon Sep 02, 2013 1:06 am
by Adam Tucker

Thank you very much


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Jan 12, 2014 6:55 pm
by Michael2210441

In the OP, is that really all there is to get the heading or do I need to be invoking a service first?

I've tried getting the heading returned by the geolocate service, but that returns null on both test page (expectedly) and the device.

I'm sure it's so simple, but I'm missing something.


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Jan 12, 2014 7:22 pm
by Michael2210441

It occurs to me that I am testing using the browser tester, even on the device, because I can't get the tester app that's installed on my phone to work most of the time.

Could this be why I see null results?


Compass App, Javascript, CSS and other terrible things.

Posted: Sun Jan 12, 2014 7:40 pm
by Illya Stepanov

Hi Michael - can you give us a publick link to test this? Or share your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a