Closed fudom closed 1 month ago
Workaround:
angular.json
Add the following object to the assets array.
{
"glob": "**/*",
"input": "node_modules/leaflet/dist/images/",
"output": "./media"
}
Note: This may overwrite other files. For example, if leaflet/dist/images contains something you already have in media from another source. Because Angular adds not unique ID in this case. You could copy the images to assets in a unique folder and change the default paths.
{
"glob": "**/*",
"input": "node_modules/leaflet/dist/images/",
"output": "./assets/leaflet"
}
delete (Leaflet.Icon.Default.prototype as any)._getIconUrl;
Leaflet.Icon.Default.mergeOptions({
iconRetinaUrl: 'assets/leaflet/marker-icon-2x.png',
iconUrl: 'assets/leaflet/marker-icon.png',
shadowUrl: 'assets/leaflet/marker-shadow.png',
});
(not tested)
I wonder why other png files from leaflet are copied automatically into media like layers-2x-TBM42ERR.png
. (The ID behind is added by Angular). Also marker-icon-2V3QKKVC.png
is copied into media. What is different for the other marker pngs (404 above)?
Hi, and thanks for taking the time to open a bug report in Leaflet.
However, in this repository we only handle bugs in "vanilla" Leaflet. This means that we do not handle bugs which are specific to frameworks such as:
Please understand that we only have the time and energy to test Leaflet in plain web browsers.
Please try to either reproduce the bug without using any frameworks, or submit a bug to the appropriate repo.
Checklist
Steps to reproduce
Following is tested in Angular.
Run
ng serve
.Result:
Marker is shown as broken image link.
The URLs in the css file are correct. Not sure where the media path comes from. Ok, the marker is an
img
element. So the css image url is not used. I wonder why img instead.Expected behavior
The images should be loaded from
images/
of the package.Current behavior
Trying to load the images from the root
media/
.Environment