The location tracking capability of this plugin uses the app's CreateLocator method.
In order to create a location tracking feature on your map, call the CreateLocator method of the map object like this:
callback |
Function Required. The function to be called once the position is acquired passing the position object. |
rate |
Number Optional. The time interval in seconds in getting location. Default is 10 s. |
Return: Locator object
Starting version 1.10, the locator object will not start unless you call the Start method to start the real time tracking.
app.LoadPlugin("MapView"); var marker; function OnStart() { lay = app.CreateLayout("Linear", "VCenter, FillXY"); var apiKey = "AIzaSyD2eHntKEmh272p3ac6YjWPbPkwo3m2mck"; map = app.CreateMapView(apiKey, 0.9, 0.5, 37.775, -122.434, 13); map.SetOnReady(MapOnReady); lay.AddChild(map); app.AddLayout(lay); } function MapOnReady() { locator = map.CreateLocator(OnLocation, 5); locator.Start() } function OnLocation(pos) { if(!marker) marker = map.CreateMarker(pos.latitude, pos.longitude); else marker.SetPosition(pos.latitude, pos.longitude); }