Polygon wkid convert with gsvc.project

531
1
04-24-2013 06:36 AM
KarlRanna
New Contributor
I'm trying to convert polygon from wkid 3301 to wkid 4326. I've been using this code snippet for converting points, but I'm not sure how I would accomplish this to create a polygon object. I'm not even sure if gsvc.project() is the best solution. Any suggestions would be appreciated.

dojo.require("esri.tasks.geometry");
var outSR = new esri.SpatialReference({ wkid: 4326 });
mapHandler.gsvc.project([ geometry ], outSR, function(projectedPoints) {
    pt = projectedPoints[0];
});
0 Kudos
1 Reply
KarlRanna
New Contributor
In case anyone is interested... I ended up solving this with the following code:

mapHandler.gsvc.project([ geometry ], outSR, function(projectedPoints) {
    var polygonJSON = {"rings": projectedPoints[0].rings, "spatialReference": {"wkid": projectedPoints[0].spatialReference.wkid}};
    var polygon = new esri.geometry.Polygon(polygonJSON);
});
0 Kudos