J'essaie de regrouper plusieurs couches dans leaflet, mais cela ne semble pas fonctionner. J'ai 5 points de terminaison rest que j'essaie de rassembler pour les regrouper en utilisant L.markerClusterGroup(). Voici ce que j'ai dans mon 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>Les points des 2 couches apparaissent, mais ils ne se regroupent pas. Toute aide serait appréciée.<\/P>Merci<\/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
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.