Ik probeer meerdere lagen te clusteren in leaflet, maar het lijkt niet te werken. Ik heb 5 rest-eindpunten die ik samen probeer te voegen om te clusteren met behulp van de L.markerClusterGroup(). Dit is wat ik in mijn html heb:<\/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>De punten van de 2 lagen verschijnen, maar ze clusteren niet. Alle hulp wordt gewaardeerd.<\/P>Bedankt<\/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
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.