Open gangxuexue opened 4 years ago
hello @gangxuexue 我是來自iOS频道的佈道助手,看到你問到這個問題,试着先帮你解答下。 你可以嘗試用一下方法來獲取feature elements
// Change the cursor style as a UI indicator.
map.getCanvas().style.cursor = 'pointer';
var feat = features[0]
//LOOKUP THE HOVERED CLUSTER FEATURES UNDERLYING DATA POINTS
var cluster_id = features[0].properties.cluster_id;
var all_features = cluster.getLeaves(cluster_id, Math.floor(map.getZoom()), limit = Infinity);
//DISPLAY THE HOVERED FEATURES IN THE POPUP
var features_to_display = []
all_features.forEach(function(f) {
features_to_display.push(f.properties["Primary ID"])
})
// Populate the popup and set its coordinates
// based on the feature found.
搜索到一個相關的issue 關於features in cluster,里面有一个哥们回复的一个demo你可以参考下 https://github.com/mapbox/mapbox-gl-js/issues/3318#issuecomment-331566101
他的这个Get features under a cluster应该是token过期了, 建议你根据现在有的cluster demo 然后参考我上面的那段代码就应该能access到features
希望对你有所帮助
问题:如题,mapbox的聚合demo是用三层layer合起来的,如果我添加点击事件,点击聚合点,如何获取其中的组成的聚合点其中各个要素信息? 我要知道其中7个要素信息,如果过滤出来