Acquiring Location With the PointAbout Springboard

« Return to previous page.

You can easily acquire location by using the PointAbout Springboard using JavaScript.

First import the interface script:

[sourcecode language="jscript"]

[/sourcecode]

please make sure to change the X.X with the correct version number which has been given to you.  You code should look similar to the one below:

[sourcecode language="jscript"]

[/sourcecode]

The javascript interface allows PointAbout’s Springboard to communicate with your webpage by passing messages using JavaScript.    Next we’ll create callbacks so that when the Springboard recieves an update in location from the phone it will be passed into your scripts.   This file can be hosted on either your server or you can keep calling the version on our server.

[sourcecode language="jscript"]

initPA = function() {

Device.init();
Device.Location.callback = updateLocation;
Device.Location.init();

}
updateLocation = function(lat,lon) {
currLat = lat;
currLon = lon;
}

[/sourcecode]

So let’s take a look at what’s really going on.

line 1:  we’re creating a function that can be called on the document’s onload.
line 3:  Here we init the device and tells the Springboard to set device variables
line 4:  Set the callback function which is defined later.  This is the function that is called everytime the device recieves either a    new location for the device or a more accurate location.
line 4:  This will initialize the GPS radios on the device.  This may take a few moments since the radios are not always on so we can preserve battery life.

line 8:  Define a new function that is the callback for the location function.  The function will receive two parameters, lat and long.
line 9 & 10:  Assign the new lat and long to a variable to use.

[sourcecode language="html"]

[/sourcecode]

lastly we need to call our initialization function “initPA()” with the body’s onload.

Feel free to leave comments below if you run into any problems.

diggFacebookTechnoratiTwitter