kyanuk1

Converting State Plane to Lat/Lng project problem

Discussion created by kyanuk1 on May 30, 2013
Latest reply on May 30, 2013 by kyanuk1
Hello,

I am trying to take a map extent coordinates (in State Plane), and convert them to pairs of Lat/Long coordinates.  I am getting a 'wkid is null or undefined' error during the geometry service project function.

My code:

function getCoords {
    var topLeft = toLatLng(map.extent.xmin, map.extent.ymax);
    var topRight = toLatLng(map.extent.xmax, map.extent.ymax);
    var bottomRight = toLatLng(map.extent.xmax, map.extent.ymin);
    var bottomLeft = toLatLng(map.extent.xmin, map.extent.ymin);

    [...]
}

function toLatLng(x,y) {
    var pt = new esri.geometry.Point(x, y, map.SpatialReference);
    var symbol = new esri.symbol.SimpleMarkerSymbol();
    var graphic = new esri.Graphic(pt, symbol);
    var outSR = new esri.SpatialReference({ wkid: 4326 });

    try{
        geometrySvc.project([graphic], outSR,  // this is where it fails
        function (features) {
            pt = features[0].geometry;
        });
    } catch (e) { alert(e.message); }

    var retv = pt.x + "," + pt.y + ",0";
    return (retv);
}



Any advice is much appreciated

Outcomes