data-urls in L.Icon.Default
See original GitHub issue- I’ve looked at the documentation to make sure the behavior is documented and expected
- I’m sure this is a Leaflet code issue, not an issue with my own code nor with the framework I’m using (Cordova, Ionic, Angular, React…)
- I’ve searched through the issues to make sure it’s not yet reported
Steps to reproduce
Steps to reproduce the behavior:
var myIcon = L.Icon.Default.extend({options: {
iconUrl: 'data:image/png;base64,iVBORw...'
}});
Expected behavior There is nothing special in data url, so I expect this code to work flawlessly.
Current behavior Unfortunately there is path-guessing magic in code (#4605) which fails to deal with data-url.
Environment
- Leaflet version: 1.4.0
- Browser (with version): Google Chrome Version 71.0.3578.98 (Official Build) (32-bit)
- OS/Platform (with version): Windows 8.1 (32-bit)
Additional context Current workaround:
L.Icon.Default.imagePath = ' ';
But better to improve magic to take into account data-urls here: https://github.com/Leaflet/Leaflet/blob/61ef1776ac3c7afc5dec5ce4dfab8986ff9f5376/src/layer/marker/Icon.Default.js#L45-L59
Minimal example reproducing the issue
I haven’t got simple example, but will make if it will be necessary.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Alter Leaflet L.Icon.Default - GIS Stack Exchange
Let me quote the Leaflet documentation: In order to change the default icon, just change the properties of L.Icon.Default.prototype.options ...
Read more >How to use the leaflet.icon function in leaflet - Snyk
To help you get started, we've selected a few leaflet.icon examples, based on popular ways ... delete L.Icon.Default.prototype._getIconUrl; L.Icon.Default.
Read more >How to change the default icon pin on leaflet directive?
In order to change the default icon, just change the properties of L.Icon.Default.prototype.options (which is a set of Icon options ).
Read more >Data URIs | CSS-Tricks
(It's equally correct to say “Data URL”, which I think I prefer.) ... This is very useful for small images, e.g. icons, for...
Read more >embed graphics inline with data uri scheme
The resulting image is a folder icon (cropped screenshot):. folder icon. CSS and Inline Images. Embedded in XHTML files, data URL images are ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ghybs I originally tried all the suggestions on that thread but couldn’t comment because the thread was locked. With my code verbatim to the code snippet suggested:
The icon url strings are being mutated after being passed to the options objects. The only solution I didn’t try was the leaflet-defaulticon-compatibility third-party library and was exploring other possible solutions first.
Edit: Just went back and loaded the leaflet-defaulticon-compatibility library and it works. (Thanks for that link.) I would make a PR to update the readme to suggest this solution so others like me don’t have to hunt through github issues but it seems odd to have the readme link to an unofficial repo to wrap their own library’s css to fix the styling.
Hi @jaythomas,
The situation you describe is duplicate of #4968.