Adam Tucker
Posts: 0
Joined: Sun Sep 01, 2013 8:17 pm

Compass App, Javascript, CSS and other terrible things.

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Compass App, Javascript, CSS and other terrible things.

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.

Adam Tucker
Posts: 0
Joined: Sun Sep 01, 2013 8:17 pm

Compass App, Javascript, CSS and other terrible things.

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?

Adam Tucker
Posts: 0
Joined: Sun Sep 01, 2013 8:17 pm

Compass App, Javascript, CSS and other terrible things.

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 :'(

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Compass App, Javascript, CSS and other terrible things.

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Compass App, Javascript, CSS and other terrible things.

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

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

Adam Tucker
Posts: 0
Joined: Sun Sep 01, 2013 8:17 pm

Compass App, Javascript, CSS and other terrible things.

Thank you very much

Michael2210441
Posts: 0
Joined: Sat Jan 04, 2014 5:42 pm

Compass App, Javascript, CSS and other terrible things.

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.

Michael2210441
Posts: 0
Joined: Sat Jan 04, 2014 5:42 pm

Compass App, Javascript, CSS and other terrible things.

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Compass App, Javascript, CSS and other terrible things.

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

Return to “Issues”