Select to view content in your preferred language

Multipolgons

3516
12
04-19-2010 05:55 AM
AmyRamsdell
Occasional Contributor
Looking for suggestions on working with Multipolygons and their extents and projecting their coordinates.

I have a graphics layer that I build from a service JSON return.  Right now the only way that I know how to use the
WebMercatorUtil to convert from WGS to webmercator is point by point because it doesn't work with polys with multiple rings. Does this sound correct or is there another approach?

Also once all the polys are returned I want to zoom to that extent of the graphics layer however the GraphicUtil.getGraphicsExtent doesn't work on this type of poly as well.

By the way, I miss the old Search in the forums. For that matter, the whole thing is getting more difficult to navigate through.  Gotta use the new icons though.
Tags (2)
0 Kudos
12 Replies
AmyRamsdell
Occasional Contributor
Sorry I am an idiot in this new forum structure! How do you get the code inserted? It looks like I have an extra array object in hierarchy for the multipolygon vs the polygon.  I have the flex builder pictures in the attached document.  Here is my code

for (var i:int = 0; i < polyArray.length; i++ )
       {        
        var ring:Array = [];
         pointArray = polyArray[0];
for (var j:int = 0; j < pointArray.length; j++ )
{
                   lon = Number(pointArray[0]);
                   lat = Number(pointArray[1]);
    var point:MapPoint = new MapPoint(lon,lat);
    WebMercatorUtil.geographicToWebMercator(point,true);
    ring.push(point);
}
poly.addRing([ring]);
       }
0 Kudos
AmyRamsdell
Occasional Contributor
OH my. I am so sorry to waste your time when it was just bad code, but you helped me out tremendously

poly.addRing([ring]);

should be poly.addRing(ring);


Thank you!!!!
0 Kudos
MehulChoksey
Esri Contributor
couple of things i noticed
-You should be able to project entire polygon to WebMercator. You need not be projecting each point of the polygon by looping through it.
-Try NOT to use "true" in the second parameter in WebMercatorUtil.geographicToWebMercator(point,true);
0 Kudos