私はesriのfeature serviceとersi-leafletライブラリを使って地図を表示しています。 以下のコードスニペットは表示に使用されています。<\/P>
国々を<\/P>
featureURL = "<\/SPAN>http:\/\/dev.xyz.org\/arcgis\/rest\/services\/MEP\/noRelate_tester\/FeatureServer\/0<\/A>"<\/SPAN><\/SPAN><\/P>var countries = L.esri.featureLayer(featureURL,<\/SPAN><\/P>{<\/SPAN><\/P> style: getStyle,<\/SPAN><\/SPAN><\/P> onEachFeature: onEachFeature<\/SPAN><\/SPAN><\/P>}).addTo(map);<\/SPAN><\/SPAN><\/P> <\/P>現時点では、すべての国が表示されています。<\/P> <\/P>特定のフィルターまたはクエリを満たす国だけを表示(またはハイライト)したいです。<\/P>例えば、type = SDGというフィルター/クエリを満たす国だけを表示したいです。<\/P> <\/P>esri-leafletライブラリのドキュメントと例を確認しましたが、queryメソッドの使い方が全くわかりません。<\/P> <\/P>上記のようにフィルター/クエリを使う方法を示す例を教えていただけませんか?<\/P> <\/P>ありがとうございます<\/P>Chris<\/P>
instead of fetching all the features from the service and filtering on the client, it's a better to only ask ArcGIS Online/Server for the features you want (using the where constructor option).
Querying features | Esri Leaflet
The query method has examples on Esri Leaflet.
Example 1: https://esri.github.io/esri-leaflet/examples/querying-feature-layers-1.html
Example 2: https://esri.github.io/esri-leaflet/examples/querying-feature-layers-2.html
From Esri Leaflet Issues, I found a problem similar to yours.
Since you pass a GeoJSON feature you have access to attributes, like the "filter" attribute.
<SPAN class="keyword token">function</SPAN> <SPAN class="token function">filter</SPAN><SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> feature<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>type <SPAN class="operator token">===</SPAN> <SPAN class="string token">"SDG"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">var</SPAN> countries <SPAN class="operator token">=</SPAN> L<SPAN class="punctuation token">.</SPAN>esri<SPAN class="punctuation token">.</SPAN><SPAN class="token function">featureLayer</SPAN><SPAN class="punctuation token">(</SPAN>featureURL<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">{</SPAN> filter<SPAN class="punctuation token">:</SPAN> filter<SPAN class="punctuation token">,</SPAN> style<SPAN class="punctuation token">:</SPAN> getStyle<SPAN class="punctuation token">,</SPAN> onEachFeature<SPAN class="punctuation token">:</SPAN> onEachFeature <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">addTo</SPAN><SPAN class="punctuation token">(</SPAN>map<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></SPAN><SPAN></SPAN></SPAN>
Issue #214: https://github.com/Esri/esri-leaflet/issues/214
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.