Estou tentando agrupar múltiplas camadas no leaflet, mas parece que não está funcionando. Tenho 5 endpoints REST que estou tentando juntar para agrupar usando o L.markerClusterGroup(). Isto é o que tenho no meu html:<\/P>
<\/P>
<script> var map = L.map('map').setView([50.6805, -120.3421], 12);<\/P>
L.esri.basemapLayer('Streets').addTo(map); var markers = L.markerClusterGroup(); var ArtsCultureEducation = L.esri.featureLayer({ url: '<\/SPAN>http:\/\/geoprodsvr.kamloops.ca\/arcgis3\/rest\/services\/Website\/CityFacilities_LL\/MapServer\/0<\/A>',<\/SPAN> }); var PublicSafteySite = L.esri.featureLayer({ url: '<\/SPAN>http:\/\/geoprodsvr.kamloops.ca\/arcgis3\/rest\/services\/Website\/CityFacilities_LL\/MapServer\/1<\/A>',<\/SPAN> });<\/P> <\/P> markers.addLayer(PublicSafteySite); markers.addLayer(ArtsCultureEducation); map.addLayer(markers);<\/script><\/P> <\/P>Os pontos das 2 camadas aparecem, mas eles não se agrupam. Qualquer ajuda será apreciada.<\/P>Obrigado<\/P>Darryl<\/P>
when Leaflet.markerCluster.addLayer() is called, an attempt is made immediately to check whether a single lat/long can be extracted and clustered:
<SPAN class="comment token">// if its not possible to dig out a single lat/lon from the layer,</SPAN> <SPAN class="comment token">// abort clustering</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="operator token">!</SPAN>layer<SPAN class="punctuation token">.</SPAN>getLatLng<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>_nonPointGroup<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addLayer</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">fire</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'layeradd'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> layer<SPAN class="punctuation token">:</SPAN> layer <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">this</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>
so you have several problems...
1. L.esri.featureLayer doesn't fetch any features at all until after it is added to the map and even then has to make asynchronous web requests to ask for features that intersect the area being drawn
2. even when these features are retrieved, they can't be pulled out of L.esri.featureLayer via the .getLatLng() method that plugin uses (above).
in the ArcGIS world, we tend to think of layers as entire collections of features with the same geometry type in a map. In Leaflet, a layer often refers to a single geometry (marker, polyline or polygon)
unfortunately, i don't have any helpful advice for conveniently managing and clustering data coming from several different services. it would take some work.
Thanks John
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.