Select to view content in your preferred language

Clip overlapping polygon area from an underlying polygon

3576
1
05-27-2013 10:21 PM
TomasN
by
Emerging Contributor
Hello,

I have two polygons which create in code below:

polygon11849185221 = new esri.geometry.Polygon(new esri.SpatialReference({wkid: map.spatialReference})); polygon11849185221 .addRing([[490998.3934, 6118739.2932],[491048.9492, 6118690.8986],[491083.825, 6118656.3184],[491095.9428, 18650.7028]);
var symbol11849185221 = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2),new dojo.Color([255,255,0,0.25]));
polygonGraphic11849185221 = new esri.Graphic(polygon11849185221 , symbol11849185221 , { keeper: true });
var polyLayer11849185221 = new esri.layers.GraphicsLayer({ id: " poly11849185221 " });
map.addLayer(polyLayer11849185221 );
polyLayer11849185221 .add(polygonGraphic11849185221);

Is it posible to get comman coordinates (area coordinates) of two polygons? Thanks for your help 🙂
0 Kudos
1 Reply
VinayBansal
Frequent Contributor
Hello,

I have two polygons which create in code below:

polygon11849185221 = new esri.geometry.Polygon(new esri.SpatialReference({wkid: map.spatialReference})); polygon11849185221 .addRing([[490998.3934, 6118739.2932],[491048.9492, 6118690.8986],[491083.825, 6118656.3184],[491095.9428, 18650.7028]);
var symbol11849185221 = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2),new dojo.Color([255,255,0,0.25]));
polygonGraphic11849185221 = new esri.Graphic(polygon11849185221 , symbol11849185221 , { keeper: true });
var polyLayer11849185221 = new esri.layers.GraphicsLayer({ id: " poly11849185221 " });
map.addLayer(polyLayer11849185221 );
polyLayer11849185221 .add(polygonGraphic11849185221);

Is it posible to get comman coordinates (area coordinates) of two polygons? Thanks for your help 🙂


I am not seeing 2 polygons in your code....
But anyways......
There is no direct method in ArcGIS Javascript API for finding common coordinates.
You can use contains method in esri.geometry.Polygon to find the point in polygon
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/polygon.html
Loop for all the points of 1 polygon to find in other polygon.

Or

You can make use of geometry service method. But this is bit tricky. You need to find the difference of 2 polygons using geometry service and when you get the points array that are not common between 2 polygons. Then loop all the rings of any of the polygon and get the points that don't exists in difference points to get the common points.

http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/

Go to geometry service -> Difference
0 Kudos