简体   繁体   English

即使放大,mapbox-gl 聚类点也位于同一位置

[英]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).我正在使用 mapbox-gl JS 并将我的一些位于同一位置(重叠)的源点聚类。

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?如果聚集的点仍在设置的 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/请参阅此处的文档示例: https : //docs.mapbox.com/mapbox-gl-js/example/cluster/

I am using a different layer filter filter={['==', 'cluster', true]}我正在使用不同的图层过滤器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.编辑示例以显示问题(取自上述示例的代码) https://jsfiddle.net/8z9p6cfu/13/放大到 6 点集群,在设置级别,即使仍有 6 个点相同,非集群层也将接管地点。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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