question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
AndrewEastwoodcommented, Mar 30, 2020

if it’s fixed … then why it’s not merged yet ?

2reactions
qlerebourscommented, Aug 25, 2019

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

GeoJSONLayer | ArcGIS Maps SDK for JavaScript 4.25
GeoJSONLayer is created by setting its url property to point to geojson feed or to a blob ... The Error object returned if...
Read more >
Solved: Editor widget doesnt work with GeoJSONLayer in 4.2...
I'm not able to get the Editor widget to work with a GeoJSONLayer in the 4.22 version, but in the 4.21 version with...
Read more >
Setting layers from GeoJSON property - GIS Stack Exchange
While trying to build a JSFiddle minimal example that shows an error I came to a working solution and could not find an...
Read more >
Trouble binding events/popups to existing leaflet geojson layer
Basically, when you have processed a GeoJSON, its feature properties are gone. There are two ways to proceed. // create empty GeoJSON layer...
Read more >
GeoJSONLayer | ArcGIS API for JavaScript 4.18
Fires when an error emits during the creation of a LayerView after a layer has been added to the map. Properties: view View....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found