GeoJSONLayer layerOptions Prop error
See original GitHub issue@types/mapbox-gl": "0.45.0"
mapbox-gl": "0.46.0"
react-mapbox-gl": "3.8.0"
Hello. I have discovered a bug related to passing a layerOptions prop to the GeoJSONLayer component, specifically when setting the id
prop of the layerOptions object.
In geojson-layer.ts
, within the createLayer function, we see that map.addLayer
is called when creating each internal layer for the GeoJSONLayer (symbol layer, line layer, etc.).
In particular, by spreading the layerOptions object, the ID for the layer being created is overwritten with the ID of the layerOptions object. This causes the error error: Error: Layer with id <id> already exists on this map
, since multiple layers are being added to the map with the same ID.
The layerOptions prop is typed as Layer
from MapboxGL, which requires an id
prop. This does not seem appropriate.
This also caused my symbol mouse handlers to not work, and this may be the cause of previous issues https://github.com/alex3165/react-mapbox-gl/issues/483.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
Top GitHub Comments
if it’s fixed … then why it’s not merged yet ?
@dm261395 , this is fixed in my PR, if needed you can use npm patch package to patch the lib while this is not merged.
I will also comment #652 that will be fixed with this PR to show the working code