Created
June 4, 2018 20:02
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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