To enable high accuracy specify it as a geolocation option when creating the button. For details on how the geolocation options work view the Geolocation API Specification. var locateButton = new esri.dijit.LocateButton({ map: map, geolocationOptions:{ enableHighAccuracy: true } },"locateDiv");Setting enableHighAccuracy to true tells the browser to try and find the most accurate location. So if a device GPS is available it would theoretically use that. You can't switch the locate button to using watch position so if you'd like to use that option you'll need to write your own code to do so.
The locate button uses the getCurrentPosition function of the Geolocation api. getCurrentPosition tries to get the location answer for you as quickly as possible and in some cases this means that it will return IP location or wifi instead of the device gps. You can try setting the enableHighAccuracy geolocation option to true. If this doesn't work you'll want to create your own button that uses the geolocation api with the watchPostion function. watchPosition will provide an updated location if the device moves or if more accurate information becomes available.
dojo.require("esri.dijit.LocateButton");
//add locate button var locateButton = new esri.dijit.LocateButton({ map: map },"locateDiv"); locateButton.startup();
<!--Floating window contains the time slider--> <div id="timeFloater" style='display:none;'></div> <div id="locateDiv"></div>
#locateDiv{ position: absolute; top:120px; left:20px; z-index: 30; }
You're welcome, sorry it was't more help.I was under the impression that HighAccuracy = true used the device GPS, I forget where I read that however. I'm also trying to do the same thing with a web editing app and the LocateButton I found at https://developers.arcgis.com/en/javascript/jssamples/widget_locate.html but I'm having trouble getting my code to work with the locate button.
Hi Richard,Try this thread. It explains it pretty well.http://forums.arcgis.com/threads/48343-Geolocate-API
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.