Get LongLat of Point

2007
3
Jump to solution
12-08-2014 11:47 AM
ChristianGruber
New Contributor

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

0 Kudos
1 Solution

Accepted Solutions
HeikoHeijenga
Esri Contributor

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/

View solution in original post

3 Replies
SteveCole
Frequent Contributor

Yes- you'll need to add the webMercatorUtils into your project and use those methods.

0 Kudos
ChristianGruber
New Contributor

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.

0 Kudos
HeikoHeijenga
Esri Contributor

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/