我有一个geojson.MultiPoint
我正在Mapbox地图中显示:
let geojson = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {"type": "MultiPoint", "coordinates": [[1, 2], [3, 4], [...]]},
"properties": {"status": "status"}
}]
}
然后我添加了一个geojson源和一个圆圈层:
map.addSource("gps-points", {
type: "geojson",
data: geojson,
});
map.addLayer({
id: "gps-points",
type: "circle",
source: "gps-points",
paint: {
"circle-radius": 3,
"circle-color": "#1f77b4",
}
});
我现在要做的是获取点击处理程序中点击的点的索引,如:
map.on("click", "gps-points", function(e) {
// get the index of this point in the coordinates array
});
我知道我可以使用Point
代替MultiPoint
轻松完成此操作,但我必须可视化大量的点,Point
不具备可扩展性。是否可以使用MultiPoint
在Mapbox GL JS中执行此操作?