Wrong coordinates showing up on map

370
3
Jump to solution
01-02-2018 12:16 PM
MansiShah
New Contributor III

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);
});
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor
3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor
MansiShah
New Contributor III

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 Esteemed Contributor

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