I'm trying to insert x, and y coordinates manually through input text, and center the map and zoom it to that point. I have this code:
var x = $("#x").val();
var y = $("#y").val();
var point=new esri.geometry.Point(x, y, map.spatialReference);
map.centerAndZoom(point,6);
When executing this code, it gives me a blank page. What's wrong? I also tried this code:
map.graphics.clear();
var xMin, yMin, xMax, yMax;
var mp = new esri.geometry.Point;
mp.x = $("#x").val();
mp.y = $("#y").val();
mp.spatialReference = map.spatialReference;
var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CROSS, 30, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1), new dojo.Color([0,255,0,0.25]));
var graphic = new esri.Graphic(mp, symbol);
xMin = mp.x-1000;
yMin = mp.y-1000;
xMax = mp.x+1000;
yMax = mp.y+1000;
var newExtent = new esri.geometry.Extent();
newExtent.xmin = xMin;
newExtent.ymin = yMin;
newExtent.xmax = xMax;
newExtent.ymax = yMax;
newExtent.spatialReference = map.spatialReference;
map.setExtent(newExtent);
map.graphics.add(graphic);
Also does not work. Any help??