I want to acquire the user's current position to use it in different functions. Locate widget works perfectly but I am not able to get the latitude and longitude from it. Are there any alternatives to Locate widget?
Omar,
The locate widget has locate event that returns the GeoLocationPostion object that contains position.coords.latitude and longitude.
locateBtn.on('locate', function(pos){
console.info(pos.position.coords.latitude, pos.position.coords.longitude);
});
Thanks, Robert Scheitlin, GISP for the quick response. It WORKS just fine.
Is there is another way to fire the locate function rather than clicking the locate button?
Right now I have a neat menu from where all my functions are triggered. However, when I need the current position I press a button to show the locate button and say "Hey! click this button". A very complicated method.
Can I request the position with my own custom button?
Omar,
Sure just dont add the widget to the view and then just call the locate method:
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#locate
Robert,
All issues have been resolved. Thanks for your support, much appreciated.