Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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];
});
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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);
});
share|improve this answer
    
Welcome to the site, and thanks for posting the solution. You should mark this answer as accepted, so that future readers will quickly now what worked. Thanks. –  user3461 Apr 25 '13 at 11:53
    
The system says I can accept my answer tomorrow. –  ObviousCat Apr 25 '13 at 13:32
1  
Great, thanks for following up and keeping the site's Q&A format working well. –  user3461 Apr 25 '13 at 13:35
    
You should be able create straight from the JSON. var polygon = new esri.geometry.Polygon(projectPoints[0]); –  awesomo Apr 26 '13 at 16:48
    
Thanks for clearing that up. –  ObviousCat Apr 26 '13 at 21:25
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.