mapbox getsource返回对象返回未定义值
我正在调用getsource
方法load> load
事件类似:
map.on('load', () => {
map.addSource("country-boundary-source", {
type: "vector",
url: "mapbox://mapbox.country-boundaries-v1"
});
const source = map.getSource("country-boundary-source");
console.log("Source:", source);
})
在输出中,该对象具有诸如vectorlayers
and code>和vectorLayerIds之类的字段
。但是,当我使用source.vectorlayers
调用这些值时,我会返回给我一个未定义的值。我不太确定为什么会发生这种情况,因为它正在输出。
I am calling the getSource
method inside a load
event like so:
map.on('load', () => {
map.addSource("country-boundary-source", {
type: "vector",
url: "mapbox://mapbox.country-boundaries-v1"
});
const source = map.getSource("country-boundary-source");
console.log("Source:", source);
})
In the output, the object has fields such as vectorLayers
and vectorLayerIds
. However when I call these values using source.vectorLayers
I get an undefined value returned to me. I'm not really sure why this would be happening, since it is being outputted.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论