SiteWatch API Help

showMyLocation

showMyLocation

Previous topic Next topic  

showMyLocation

Previous topic Next topic  

A method that shows your current GPS location on the map.

 

Parameter

Value

showMyLocation: boolean

Track your GPS location on the map.

 

Example:

map.showMyLocation(true);

 

Or

 

Parameter

Value

 showOnStart: boolean (default=false) (optional)

Show GPS location when map is loaded.

 setView: boolean (default=false) (optional)

Go to the current GPS location on the map.

 errorFunction: name (optional)

 Example: function errorResult(e) { alert(e); }

An asynchronous JavaScript function that implements the logic when the function call returns.

ERROR CODE:

UNKNOWN (0).

PERMISSION_DENIED (1) if the user clicks that “Don’t Share” button or otherwise denies you access to their location.

POSITION_UNAVAILABLE (2) if the network is down or the positioning satellites can’t be contacted.

TIMEOUT (3) if the network is up but it takes too long to calculate the user’s position.

 accuracy: integer (default=1000001) (optional)

GPS accuracy in meters.

 options: (optional):

HTML5 Geolocation options.

   enableHighAccuracy: boolean (default=true)

The enableHighAccuracy property is exactly what it sounds like. If true, and the device can support it, and the user consents to sharing their exact location, then the device will try to provide it. Both iPhones and Android phones have separate permissions for low- and high-accuracy positioning, so it is possible that enableHighAccuracy: true will fail, but calling with enableHighAccuracy: false would succeed.

   timeout: integer (default=20000)

The timeout property is the number of milliseconds your web application is willing to wait for a position. This timer doesn’t start counting down until after the user gives permission to even try to calculate their position. You’re not timing the user; you’re timing the network.

   maximumAge: integer (default=2000)

The maximumAge property allows the device to answer immediately with a cached position.

 marker: object (optional):

A marker object. Since a marker has a point parameter it will be discarded and your current GPS location used instead.

 vectorCircle: object (optional):

A vector circle object.

 

Example:

map.showMyLocation(

{ showOnStart: true, setView: true, errorFunction: function errorResult(e) { alert(e); }

});