mflawton

Project function fails - Cannot read property 'spatialReference' of undefined

Discussion created by mflawton on Mar 6, 2013
Latest reply on Mar 6, 2013 by mflawton
This has been giving me fits. Why doesn't this work?

function showCoordinatesNew(evt) {
 var mp = esri.geometry.webMercatorToGeographic(evt.mapPoint);
 console.log(mp.x+","+mp.y); //<-- returns correct geographic coordinates
 console.log(mp.spatialReference.wkid); //<-- returns wkid 4326
 var params = new esri.tasks.ProjectParameters();
 params.geometries = mp;
 //setting output Spatial Reference to Nevada State Plane West Zone NAD83
 params.outSR = new esri.SpatialReference({wkid: 102709});
 //execute project function, callback will be picked up by onProjectComplete
 gsvc.project(params); //<-- fails with Uncaught TypeError: Cannot read property 'spatialReference' of undefined
}
       
function onProjectComplete(geometries) {
 //project function never gets this far.
 var mp = geometries[0];
 console.log("Returned Coordinates: " + mp.x + "," + mp.y);
 convertSP(mp.x,mp.y);
}

function onError(message) {
 alert(message);
}


Here is the full error:

Uncaught TypeError: Cannot read property 'spatialReference' of undefined serverapi.arcgisonline.com:34
dojo.declare.toJson serverapi.arcgisonline.com:34
dojo.declare.project serverapi.arcgisonline.com:34
showCoordinatesNew QuickMap32.js:192
_4ff.(anonymous function)._504 serverapi.arcgisonline.com:15
_599._fire serverapi.arcgisonline.com:34
_599._onMouseMoveHandler serverapi.arcgisonline.com:34
(anonymous function)

Outcomes