-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VectorTileLayer not working with vite project #22
Comments
Thank you for reporting this issue (and doing a well-written writeup). I am able to reproduce this by spinning up an This is extremely odd. I have no had this issue when using parcel or webpack. Let me do some digging and see if I can come up with anything as to why using this library with vite creates this issue. Have you tried using the "vanilla" version of a VectorTileLayer with Vite? Does that work? If that causes the same problem, it helps debug whether the issue in is this wrapper library, or upstream somewhere. |
sigh so this problem is very strange indeed. Looking into it, the author of leaflet answered another person with the same here: Cannot read property '_leaflet_id' of undefined:
Digging into the leaflet src code, when the map.removeLayer event fires, if the IMO this is a small area where the leaflet src code could probably be improved. I don't personally understand why
This will overwrite the Map.removeLayer method to not call This is a hacky workaround, but it does work. I am trying to brainstorm why leaflet code would ever get to running Map.removeLayer on something that is undefined, in this case only. There is something under the hood of react-leaflet with If you are familiar with these things, I'm open to suggestion on what could be going wrong or how to fix it, but for now, at least you have a monkeypatch solution. |
Another thought React 18 renders everything twice when using Completely separately from the other solution I posted, removing StrictMode solves the problem for me as well. Perhaps this is not a |
Thanks! removing the strictmode worked (and the previous solution too). I did notice when i ran the preview of (npm run build) by vite, the app ran without errors with the VectorTile line in the code, but the layer was still not added to the map. And running on build preview removes that behavior relating to strict mode... |
I have an app created with vite. Installed this library and I'm trying to use a vector tile to display in the map. I have tried the url used for the example for this library and even from the esri documentation here for vector tiles. Even created another repo where it's just the base template that vite installs (react-javascript)
and it's giving me this main error
Uncaught TypeError: Cannot use 'in' operator to search for '_leaflet_id' in undefined
Things I tried:
help would be apprecitated.
The text was updated successfully, but these errors were encountered: