this.goto = function () { var coordinates = prompt("Enter coordinates: ", "502982,221818").split(","); if (coordinates.length != 2) { return; } var point = new esri.geometry.Point({ "x": coordinates[0], "y": coordinates[1], " spatialReference": { " wkid": 27700} }); self.map.centerAt(point); self.map.setLevel(10); }
Solved! Go to Solution.
var coordinates = prompt("Enter coordinates: ", "502982,221818").split(","); var mapControl = Symology.MapMgr.getControl('984604c6-0bd2-4ba5-a990-aa9d6675d1ed'); mapControl.map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], mapControl.map.spatialReference));
var point = new esri.geometry.Point({ "x": parseInt(coordinates[0]), "y": parseInt(coordinates[1]), " spatialReference": { " wkid": 27700} });
The x and y properties of the object passed to the point constructor need to be numbers. Try converting to numbers with parseInt:var point = new esri.geometry.Point({ "x": parseInt(coordinates[0]), "y": parseInt(coordinates[1]), " spatialReference": { " wkid": 27700} });
var point = new esri.geometry.Point(parseInt(coordinates[0]), parseInt(coordinates[1]), new esri.SpatialReference({ wkid: 27700 }));
var coordinates = prompt("Enter coordinates: ", "-13600000,4545000").split(",");
map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], map.spatialReference));
map.centerAt(new esri.geometry.Point({ "x": coordinates[0], "y": coordinates[1], "spatialReference": map.spatialReference}));
var coordinates = prompt("Enter coordinates: ", "502982,221818").split(","); var mapControl = Symology.MapMgr.getControl('984604c6-0bd2-4ba5-a990-aa9d6675d1ed'); mapControl.map.centerAt(new esri.geometry.Point(coordinates[0], coordinates[1], mapControl.map.spatialReference));
i think this is do to javascript being asynchronous. centerat fires (but does not complete), so when setlevel fires the map center is still the old one.
centerat then completes, and then setlevel does. So the final command is setlevel using the original center. Hence it looks like centerat never fired
have you tried the centerAndZoom method?
http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/map.htm#centerAndZoom