Select to view content in your preferred language

Wrong coordinates showing up on map

1256
3
Jump to solution
01-02-2018 12:16 PM
MansiShah
Occasional Contributor

I am having trouble getting the correct lat/long coordinates to show up on my map. I have coordinates showing up but they do not reset when they hit 180 or -180. It keeps going on onto 190..191..etc and -182...-190...etc. I keep getting a "Uncaught TypeError: Cannot read property 'clone' of undefined at Object.f. webMercatorToGeographic... Here is code I'm using:

// Create a Map, add the basemapMap to the Map:
var map = new Map({
basemap: basemapMap,
center: [0, 0],
slider: false,
layers: []
});

// Add the Map to the MapView:
var view = new MapView({
....
});
view.on("pointer-move", function(evt){
var coordinates = webMercatorUtils.webMercatorToGeographic(evt.mapPoint);
dom.byId("info").innerHTML = coordinates.x.toFixed(5) + ", " + coordinates.y.toFixed(5);
});
1 Solution

Accepted Solutions
3 Replies
RobertScheitlin__GISP
MVP Emeritus
MansiShah
Occasional Contributor

Thank you so much. That worked. I added a point.normalize() underneath the var point = view.toMap(mpx, mpy) and the coordinates are correctly displaying now. Thank you so much. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.