【发布时间】:2021-06-17 08:31:34
【问题描述】:
在一个 mapbox 项目上工作。我创建了一个自定义图层,并希望更新该图层的绘制属性。我试过的方法不起作用。以下是详细信息:
我创建的层:
map.addLayer({
id: 'points-circle',
source: 'points',
type: 'circle',
paint: {
'circle-radius': pointSize*.6,
'circle-color': {type: 'identity', property: 'color'},
}
})
稍后,我尝试更新circle-radius 属性,如下所示:
map.setPaintProperty('points-circle','circle-radius', pointSize*.6)
失败并出现错误:Error: The layer 'points-circle' does not exist in the map's style and cannot be styled. 如何更新自定义添加层的圆半径?
【问题讨论】:
-
map和this._map一样吗?
-
@AndrewHarvey 我更新了问题以消除这种混乱。
-
@astrojams1 给我们看一个最小的例子。作为一个选项 - 在 jsfiddle 上。
-
如果您收到消息
Error: The layer 'points-circle' does not exist in the map's style and cannot be styled.,那么在addLayer步骤中出现了问题。你需要先解决这个问题。
标签: mapbox mapbox-gl-js