【发布时间】:2018-11-15 05:41:50
【问题描述】:
我想在页面加载后使用 queryRenderedFeatures 来填充列表,但它似乎在加载图层之前一直触发。我在下面的控制台中收到错误消息:
The layer 'Points' does not exist in the map's style and cannot be queried for features.
特征加载后如何查询图层?我尝试按照这些答案中的建议进行操作,但它一直返回空
JavaScript that executes after page load
call a function after complete page load
这就是我现在拥有的
map.on('load', function() {
map.addLayer({
'id': 'Points',
'type': 'circle',
'source': 'Points-45d56v',
'source-layer': 'Points-45d56v',
'layout': {
'visibility': 'visible',
},
'paint': {
'circle-radius': 6,
'circle-color': 'red'
}
});
});
$(document).ready(function(){
var features = map.queryRenderedFeatures({layers:['Points']});
console.log(features);
});
【问题讨论】:
标签: javascript mapbox mapbox-gl-js