-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Default marker icon doesn't load (because of race condition?) #7202
Comments
I was hitting a similar issue when I was doing a bit of svelte-leaflet last week, so one way of working around this would be polling for the Leaflet CSS to be loaded, and delay the map's Another approach would be to (finally) succumb to embedding the default icons as I don't like either way. 😕 |
What if instead of loading css you add style with JS? |
Based on my experience with svelte-leaflet, Say I wanted to have my build system grab the Leaflet CSS as a JS string, so my code could create a An approach like #4586, and having each Leaflet module/class add its own CSS could work, but that would involve hard-coding the CSS inside each Leaflet JS modules (or making a mess of the rollup-based build system so a bunch of ESM modules is created as output). |
But that's slightly another problem. You've open the issue about vanilla Leaflet, haven't you? With all that bundlers things get too unpredictable, so may be we should use some different approach, not css.
|
Yes, the problem is reproducible with vanilla leaflet under the right browser/network conditions, as long as the browser decides to finish loading So far I've had luck reproducing it using any plunkr demo (e.g. https://plnkr.co/edit/PkoIbkLQfcONE5VI ), with Firefox 77 and Firefox 78 in two different Linux boxes. Using a non-plunkr simpler page (e.g. loading a local checkout of https://github.com/Leaflet/Leaflet/blob/master/debug/map/markers.html over
So the plunkr use case would try to use |
Oh my oh my. https://developer.mozilla.org/es/docs/Web/API/Document/currentScript We can pull the Why didn't we discover this earlier?! Oh wait, that's the |
Well, Leaflet could find its own location in this way: <link id="leaflet-css" type="text/css" rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> document.querySelector('link#leaflet-css').href This will work as long as linking convention is obeyed. But combing this with current method (incl. possibility to override |
I... like this. And after reading https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#attribute-substrings , I think it could be done by checking if the last characters of the document.querySelector('link[href$="leaflet.css"]').href ...since we only have |
Something like this 411e6ea (Haven't seen two recent PRs yet) |
Lately I've been hitting a heisenbug regarding the dreaded autodetection of the path for
L.Icon.Default
(see #7092, #6496, and others).In order to reproduce:
L.Marker
One out of every 20 times, I get something like
Refreshing the page (with the Leaflet JS/CSS code cached) will make the default marker appear (with the right L.Icon.Default URL):
I'm able to reproduce this in a fairly consistent manner using Firefox 77 (on Debian), private mode, network console open, cache disabled.
The text was updated successfully, but these errors were encountered: