简体   繁体   中英

mapbox-gl cluster points at same location even when zoomed in

I'm using mapbox-gl JS and am clustering some of my source points that are located in same location (overlapping).

Does anyone know of a way to have the cluster layout persist at all scales if the points clustered are still within the set clusterRadius? I have tried changing the zoom options with no success. If you zoom into the clustered points at a certain level the cluster layer will stop displaying even though the points are overlaying each other and are still within set radius.

I can do work arounds like offset points, just curious if this is expected behavior. See doc example here: https://docs.mapbox.com/mapbox-gl-js/example/cluster/

I am using a different layer filter filter={['==', 'cluster', true]}

Edited example to show issue (code taken from above example) https://jsfiddle.net/8z9p6cfu/13/ Zoom into the 6 points cluster and at set level the non cluster layer will take over even though there are still 6 points at same location.

data:

"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": "ak16994521", "mag": 2.3, "time": 1507425650893, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [-118.497, 34.299667, 0.0 ] } },
{ "type": "Feature", "properties": { "id": "ak16994519", "mag": 1.7, "time": 1507425289659, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -118.497, 34.299667, 105.5 ] } },
{ "type": "Feature", "properties": { "id": "ak16994517", "mag": 1.6, "time": 1507424832518, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [-118.497, 34.299667, 0.0 ] } },
{ "type": "Feature", "properties": { "id": "ci38021336", "mag": 1.42, "time": 1507423898710, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -118.497, 34.299667, 7.64 ] } },
{ "type": "Feature", "properties": { "id": "us2000b2nn", "mag": 4.2, "time": 1507422626990, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -118.497, 34.299667, 46.41 ] } },
{ "type": "Feature", "properties": { "id": "ak16994510", "mag": 1.6, "time": 1507422449194, "felt": null, "tsunami": 0 }, "geometry": { "type": "Point", "coordinates": [ -118.497, 34.299667, 0.0 ] } }
]
}

有关此问题在 mapbox 代码中发生的位置和可能的解决方案,请参阅 mapbox 问题评论: https : //github.com/mapbox/mapbox-gl-js/issues/6454

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM