Locate Button and Map Projection

1066
6
Jump to solution
02-07-2014 01:44 AM
MartinSirkovsky
Occasional Contributor
I am trying to place a locate button widget on my map. My map is in UTM29 projection and it seems that locate button only work withgeographical coordinates. When I set an ESRI map to background map, it works.

I have a script which can convert the input coordinates to WGS84, but I am not able to find out how to pass the converted coordinates to the locate button. Is there any way how to get locate button to work with different projection (coordinate system)?

Thanks
Martin
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor
in this case it sounds like Martin isn't talking about the measurement widget, but rather the 'locate' widget, but the guiding principle is much the same.

geolocation in html5 always returns wgs84 lat/long coordinates for user positions.  our JavaScript API includes clientside utility methods for converting between wgs84 and web mercator (because of their widespread use) so it is possible using the out of the box widget to display the user's location on a web mercator basemap.

if you need to convert wgs84 coordinates into another projection, you would either have to write your own clientside conversion utility or rely on an ArcGIS Server geometry service to do the heavy lifting for you.  because the locate widget does not allow you to inject coordinates that you reprojected using a custom utility or geometry service, my best suggestion is digging into the source of the widget yourself if you'd like to repurpose its logic.

View solution in original post

0 Kudos
6 Replies
BryanLynn
New Contributor III
The measurement tools only work with one coordinate system.  Here are two threads with lots of responses on the issue.  IMHO it seems kinda crazy for a variety of reasons but that is just me.

http://forums.arcgis.com/threads/101878-Measurement-Dijit-show-wrong-distance-on-mouse-move

http://forums.arcgis.com/threads/65517-Modifications-to-the-Measurement-Widget?p=362797#post362797

Basically, what you have to do is get the results - convert them to your coordinate system then modify the results pane to show the desired results.  However, my code to show the correct results is no longer working since I changed API versions.

Hope that helps.
0 Kudos
JohnGravois
Frequent Contributor
in this case it sounds like Martin isn't talking about the measurement widget, but rather the 'locate' widget, but the guiding principle is much the same.

geolocation in html5 always returns wgs84 lat/long coordinates for user positions.  our JavaScript API includes clientside utility methods for converting between wgs84 and web mercator (because of their widespread use) so it is possible using the out of the box widget to display the user's location on a web mercator basemap.

if you need to convert wgs84 coordinates into another projection, you would either have to write your own clientside conversion utility or rely on an ArcGIS Server geometry service to do the heavy lifting for you.  because the locate widget does not allow you to inject coordinates that you reprojected using a custom utility or geometry service, my best suggestion is digging into the source of the widget yourself if you'd like to repurpose its logic.
0 Kudos
MartinSirkovsky
Occasional Contributor
Thank you for the answer. This just confirms my conclusion. I have created a function which converts the coordinates, and hoped that I could pass them to the geolocate widget. Unfortunatelly, this is not possible. Maybe a good idea for a new feature in the future.
0 Kudos
JohnGravois
Frequent Contributor
Martin,

it looks like there are already plans for this to be included in a future release.

https://github.com/driskull/arcgis-d...Button.js#L286
0 Kudos
EricPanorel
New Contributor

Would like to "vote" for this feature too.

0 Kudos
JonathanUihlein
Esri Regular Contributor

Hi Eric,


Seeing as this thread is six months old, what feature are you talking about?

0 Kudos