Select to view content in your preferred language

Convert x,y from a specific projection to lat lon

1169
2
Jump to solution
03-23-2023 09:52 AM
ADITYAKUMAR1
Occasional Contributor III

Hi,

I have a geocoding service which is in Spatial Reference: 102642  (2226)  VCSWkid(115702)  LatestVCSWkid(115702).  On doing the search, I get the data as 

Point:
X: 6482724.46755938
Y: 1722670.7755127912

But when I try to plot it on the map it goes to some random location and at the same time if I try xyToLngLat(x, y)  it's again moving to some random location. Any idea how to resolve it.

I am using ArcGIS JavaScript 4.

Thanks

Aditya Kumar

 

0 Kudos
1 Solution

Accepted Solutions
BjornSvensson
Esri Regular Contributor

The webMercatorUtils.xyToLngLat() method "Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees).".  If your data is in 102642 (which isn't Web Mercator) or you don't want it in latlong decimal degrees, then you'll have to use another method. But ...

Is that an ArcGIS Geocoding Service?  If so, it can do the projection for you, no need to do it yourself client-side.

Also, the MapView should automatically project your graphics even if they're in a different spatial reference. No need to do it yourself.  See e.g. https://developers.arcgis.com/javascript/latest/sample-code/client-projection/

If this above doesn't help, maybe you can share a codepen or something similar with the minimum code to reproduce the issue you're seeing?

View solution in original post

0 Kudos
2 Replies
BjornSvensson
Esri Regular Contributor

The webMercatorUtils.xyToLngLat() method "Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees).".  If your data is in 102642 (which isn't Web Mercator) or you don't want it in latlong decimal degrees, then you'll have to use another method. But ...

Is that an ArcGIS Geocoding Service?  If so, it can do the projection for you, no need to do it yourself client-side.

Also, the MapView should automatically project your graphics even if they're in a different spatial reference. No need to do it yourself.  See e.g. https://developers.arcgis.com/javascript/latest/sample-code/client-projection/

If this above doesn't help, maybe you can share a codepen or something similar with the minimum code to reproduce the issue you're seeing?

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

@BjornSvensson Thanks for writing. Yes, its a geocoding service and it's properly sitting on the map. The problem is coming while I am trying to do a cluster. During that time it's taking the x,y received from the geocoding service and moves the cluster near the equator.

0 Kudos