AnsweredAssumed Answered

Converting lat long to spatial reference

Question asked by ingenue3911 on Dec 13, 2016
Latest reply on Dec 15, 2016 by ingenue3911

I'm trying to project some lat long coordinates into another spatial reference. No errors are thrown, but I printing the result to the console gives "undefined". Anyone see where I'm going wrong?

 

var lat = window.myMap.extent.getCenter().getLatitude().toFixed(2);
var long = window.myMap.extent.getCenter().getLongitude().toFixed(2);

var latLong = "Latitude : " + lat + " - Longitude : " + long;

var X;
var Y;

var rgpfSixSudSR = new SpatialReference ({
wkid : 3297
});
var geometryService = new GeometryService("http://ourserver/arcgis/rest/services/Utilities/Geometry/GeometryServer");
var inputPoint = new Point(lat, long, rgpfSixSudSR);
var prjParams = new ProjectParameters ();
prjParams.geometries = [inputPoint];
prjParams.outSR = rgpfSixSudSR;

geometryService.project(prjParams, function (outputpoint) {
console.log('Conversion completed');
X = outputpoint[0].x;
Y = outputpoint[0].y;
});

var center = "X : " + X + " - Y : " + Y;

console.log(latLong);
console.log(center);

Outcomes