I've to project geometry point
Point(1657272, 6100874) with NZTM, WKID: 2193
But, point is shown near Austria, not on NewZealand maps. I've converted above coordinates to geographic, still its not giving correct results. Following is my code:
var mp = esri.geometry.webMercatorToGeographic(new esri.geometry.Point(1657272, 6100874, new esri.SpatialReference({ wkid: 2193 })));
map = new Map("mapDiv", center: [mp.x,mp.y], zoom: 5, basemap: "streets" });
on(map, "load", addGraphic);
function addGraphic() { map.graphics.add(new esri.Graphic(mp, new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255, 0, 0, 0.5])) ) ) }
Please tell me what's wrong with above code and why it's not projecting point on correct area.
EDITED CODE
var map, gsvc;
require([ "esri/map", "esri/graphic", "esri/symbols/SimpleMarkerSymbol", "esri/tasks/GeometryService", "esri/tasks/ProjectParameters", "esri/SpatialReference", "esri/InfoTemplate", "dojo/dom", "dojo/on", "dojo/domReady!" ], function( Map, Graphic, SimpleMarkerSymbol, GeometryService, ProjectParameters, SpatialReference, InfoTemplate, dom, on ) {
map = new Map("map", { basemap: "streets", center: [174.605369, -37.120276], zoom: 5 }); gsvc = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); on(map, "load", projectToLatLong); function projectToLatLong() { map.graphics.clear();
m_mapPoint = [];
m_mapPoint[0] = new esri.geometry.Point(1657272, 6100874, new esri.SpatialReference({ wkid: 2193 }));
var outSR = new SpatialReference(3857);
var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2), new Color([0, 0, 0, 0])
)
var graphic = new Graphic(m_mapPoint, symbol);
map.graphics.add(graphic);
var params = new esri.tasks.ProjectParameters();
// add array of points
params.geometries = m_mapPoint;
// Output Spatial Reference in lat/long (wkid 3857 )
params.outSR = outSR;
gsvc.project(params);
}
});
</script>
Please check updated code. Still point is not projecting.