Hi,
I'm using ESRI JavaScript API and would like to know how I can transform a Point object (given X,Y and SpatialReference) to Longitude and Latitude? I already tried to create a new Point object and called getLatitude() / getLongitude() but it doesn't work.
Example data: X=154814.29750000034, Y=258542.16709999926, SpatialReference=31254
Any suggestions?
Thanks in advance,
Christian
Solved! Go to Solution.
Your data is not in a webmercator projection so you can't use webMercatorUtils. Instead you need to use the Geometry service to do the projection: geometryservice-amd | API Reference | ArcGIS API for JavaScript
See working sample here http://jsfiddle.net/Heiko/01examzx/
Yes- you'll need to add the webMercatorUtils into your project and use those methods.
I tried
require(["esri/geometry/webMercatorUtils"], function (webMercatorUtils) {
var normalizedVal = webMercatorUtils.xyToLngLat(154814.29750000034, 258542.16709999926);
console.log(normalizedVal);
var value = webMercatorUtils.xyToLngLat(154814.29750000034, 258542.16709999926, true);
console.log(value);
});
but none of them returned correct values.
Your data is not in a webmercator projection so you can't use webMercatorUtils. Instead you need to use the Geometry service to do the projection: geometryservice-amd | API Reference | ArcGIS API for JavaScript
See working sample here http://jsfiddle.net/Heiko/01examzx/