Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jeff-hager-dev/975444435e34f7595535ba3db45d3f2a to your computer and use it in GitHub Desktop.

Select an option

Save jeff-hager-dev/975444435e34f7595535ba3db45d3f2a to your computer and use it in GitHub Desktop.
[Spiderifying Clustered Layers in Mapbox-GL: Spidering the data on the map ] #geospark-blog-post
// LEG_LIMIT is a constant we used to enforce how many legs are allowed. If exceeded we zoom the layer in one zoom level.
if (enforceLegLimit && features.length > LEG_LIMIT) {
var currentZoom = map.getZoom();
map.flyTo({center: options.location, zoom: currentZoom + 1});
return;
}
spiderifier = new MapboxglSpiderifier(map, {
markerWidth: 40,
markerHeight: 40,
onClick: function (event, spiderLeg) {
var offset = MapboxglSpiderifier.popupOffsetForSpiderLeg(spiderLeg);
event.stopPropagation();
var content = createPopupContent(spiderLeg.feature.properties);
var popup = new mapboxgl.Popup({
closeOnClick: false,
offset: options.offset
})
.setHTML(content);
spiderleg.mapboxMarker.setPopup(currentPopup);
currentPopup.addTo(map);
}
});
spiderifier.spiderfy(event.lngLat, features);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment