Comments (5)
deck.gl uses map.getLayer(id)
to determine if a layer already exists in the stack. Starting 3.5.2, this method is returning undefined
for a layer that is already added.
Here is a minimal reproduction:
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
accessToken: MAPBOX_TOKEN
});
const layer = {
id: 'my-layer',
type: 'custom',
onAdd() {
console.log(`Layer ${this.id} is added`);
},
onRemove() {
console.log(`Layer ${this.id} is removed`);
},
render() {}
}
map.on('styledata', () => {
if (map.getLayer(layer.id)) {
// already added
} else {
map.addLayer(layer);
}
});
Log:
Layer my-layer is added
evented.ts:172
Error: Layer with id "my-layer" already exists on this map
at Da.addLayer (style.ts:2118:38)
at Map.addLayer (map.ts:2813:20)
at Map.<anonymous> (app.js:38:9)
at Map.fire (evented.ts:150:26)
at Map.<anonymous> (map.ts:768:18)
at Map.fire (evented.ts:150:26)
at Da.fire (evented.ts:166:24)
at style.ts:1202:18
at h2 (load_sprite.ts:55:13)
at load_sprite.ts:37:27
from mapbox-gl-js.
@moong23, could you please make a standalone reproduction of this? I.e., using only GL JS?
from mapbox-gl-js.
@stepankuzmin well haven't tried to use GL JS only, but i'll try my best 😃
from mapbox-gl-js.
thx @Pessimistress
from mapbox-gl-js.
Thanks, @Pessimistress. This is a bug.
from mapbox-gl-js.
Related Issues (20)
- Intersection doesn't seem to work consistently HOT 1
- Problems displaying overlapping portions of two fill-extrusion layers of the same height and different colors
- Map `idle` event not firing since 3.4 release HOT 2
- Dynamic hillshade with terrain doesn't update lighting smoothly HOT 3
- Retain Globe Curvature at higher zoom levels and/or when camera tilted
- Layer with id "jsx-layer-0" already exists on this map HOT 2
- `map.setTerrain` makes vector tiles disappear
- updateData throws exception when called on source with dynamic=true and cluster=true HOT 2
- Custom Layer has incorrect hierarchy in terrain or globe projection HOT 2
- API reference page crash when viewing method of `Map` HOT 5
- [3.5.2] setConfigProperty rerender HOT 2
- "mapLayer.layout.get()" is no longer a function HOT 1
- map.setConfigProperty('basemap', 'show3dObjects', false) in standard style doesn't work anymore in 3.6.0 HOT 2
- querySourceFeatures returns features outside the viewbox HOT 2
- setTerrain does not allow null, when it should
- Map Jumps on setFreeCameraOptions if altitude changes from above ~10k to below
- Improve Marker performance HOT 1
- Ability to cancel request in `requestTransform` for overzooming purposes
- mapbox.eventData.uuid and mapbox.eventData cookies are not documented
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-gl-js.