Working on a mapbox project. I have created a custom layer, and am looking to update a paint property of that layer. Methods I've tried don't work. Here are the details:
The layer I create:
map.addLayer({
id: 'points-circle',
source: 'points',
type: 'circle',
paint: {
'circle-radius': pointSize*.6,
'circle-color': {type: 'identity', property: 'color'},
}
})
Later, I try to update the circle-radius
property, like so:
map.setPaintProperty('points-circle','circle-radius', pointSize*.6)
This fails with the error: Error: The layer 'points-circle' does not exist in the map's style and cannot be styled.
How do I update my circle-radius of my custom added layer?
You may need to wait for the map idle
event to fire to know that the layer is ready to be styled. See https://docs.mapbox.com/mapbox-gl-js/api/map/#map.event:idle .
Would be nice if map.addLayer
returned a promise that resolved when the layer was able to be styled...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.