HI
How to query graphiclayer with polygon ?
Thank you.
Chengyi,
Well then you need to do exactly what I mentioned then.
<SPAN class="token function">require</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"esri/geometry/geometryEngine"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>geometryEngine<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> view<SPAN class="punctuation token">.</SPAN>graphics<SPAN class="punctuation token">.</SPAN><SPAN class="token function">forEach</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>gra<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN><SPAN class="punctuation token">(</SPAN>geometryEngine<SPAN class="punctuation token">.</SPAN><SPAN class="token function">intersects</SPAN><SPAN class="punctuation token">(</SPAN>gra<SPAN class="punctuation token">,</SPAN> userDrawnGraphic<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">/* now do something */</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Scheitlin
year,this is I needed. thankyou verymuch.
Thank you very much !
Let me explain. Many ploygon are drawn on the graphic when the map is initialized,then I want to draw a new ploygon to search the old ploygon with 4.5 arcgis api for javascript . How to do?
To query a graphics layer you have to loop through the layers graphics and perform your operation on each graphic.
You can use GeometryEngine methods like intersects:
https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.geometryengine-amd.html#intersects
Or if the geometry you want to check is a point geometry, to check if it is inside a polygon then you can use Polygon.contains
https://developers.arcgis.com/javascript/3/jsapi/polygon-amd.html#contains
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.