Geolocation: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "NSB/App Studio programs run within a special version of a web browser. As a result, they can inherit a lot of the properties of the environment they run in. You can access t...")
 
No edit summary
Line 7: Line 7:
navigator.geolocation.getCurrentPosition(<i>showMap</i>)
navigator.geolocation.getCurrentPosition(<i>showMap</i>)


<p><i>showMap</i> is the name of a function in your program, which will be called by the above statement. It is passed a single parameter: an object with the following fields:
<i>showMap</i> is the name of a function in your program, which will be called by the above statement. It is passed a single parameter: an object with the following fields:
 
<p><table class="nsbtable" class="reference">
  <tr>
    <td width=180>location.coords.longitude</a></td>
    <td>The current longitude of the device. GPS required.</td>
    </tr>
  <tr>
    <td>location.coords.latitude</a></td>
    <td>The current latitude of the device. GPS required.</td>
    </tr>
  <tr>
    <td>location.coords.accuracy</a></td>
    <td>The accuracy of the location. GPS required.</td>
    </tr>
  </table>
 
<p>For more information on Google Maps, read <a href="http://code.google.com/apis/maps/documentation/staticmaps/" target="_top">Google's documentation</a>.
 
 


'''geolocation object members'''
'''geolocation object members'''
Line 32: Line 13:
{| class="wikitable"
{| class="wikitable"
|-
|-
|location.coords.longitude</a> || The current longitude of the device. GPS required.
|location.coords.longitude || The current longitude of the device. GPS required.
|-
|-
|location.coords.latitude</a> || The current latitude of the device. GPS required.
|location.coords.latitude || The current latitude of the device. GPS required.
|-
|-
|location.coords.accuracy</a> || The accuracy of the location. GPS required.
|location.coords.accuracy || The accuracy of the location. GPS required.
|}
|}
For more information on Google Maps, read http://code.google.com/apis/maps/documentation/staticmaps/.


== Example ==
== Example ==

Revision as of 21:09, 2 September 2012

NSB/App Studio programs run within a special version of a web browser. As a result, they can inherit a lot of the properties of the environment they run in. You can access these properties from within your app.

It is not a complete list: there are additional items in the full HTML documentation. In addition, some browsers may have additional members not shown here.

navigator.geolocation.getCurrentPosition(showMap)

showMap is the name of a function in your program, which will be called by the above statement. It is passed a single parameter: an object with the following fields:

geolocation object members

location.coords.longitude The current longitude of the device. GPS required.
location.coords.latitude The current latitude of the device. GPS required.
location.coords.accuracy The accuracy of the location. GPS required.

For more information on Google Maps, read http://code.google.com/apis/maps/documentation/staticmaps/.

Example

REM Geolocation
Function handler(location)
  Dim s
  Print "Longitude: " + location.coords.longitude 
  Print "Latitude: " + location.coords.latitude 
  Print "Accuracy: " + location.coords.accuracy
  s = "<img src='http://maps.google.com/maps/api/staticmap?center=" & _
  location.coords.latitude & "," & location.coords.longitude & _
  "&zoom=14&size=300x200&maptype=roadmap&sensor=false'>"
  print s
End Function

navigator.geolocation.getCurrentPosition(handler);

Output

Longitude: -79.2098782
Latitude: 43.73776441
Accuracy: 100
(map of current location)