From 4b81189c87990e7e3c78c0aed0dfa3629834ac2e Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 1 May 2021 19:35:18 +0200 Subject: [PATCH] fixing leaflet icon path --- angular.json | 4 ++-- src/frontend/app/app.module.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index 84cbe131..92c83c57 100644 --- a/angular.json +++ b/angular.json @@ -63,7 +63,7 @@ { "glob": "**/*", "input": "node_modules/leaflet/dist/images/", - "output": "./" + "output": "./assets/" } ], "styles": [ @@ -155,7 +155,7 @@ { "glob": "**/*", "input": "node_modules/leaflet/dist/images/", - "output": "./" + "output": "./assets/" } ] } diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index baac199f..3ddc50ea 100644 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -99,6 +99,7 @@ import {GallerySearchFieldComponent} from './ui/gallery/search/search-field/sear import {AppRoutingModule} from './app.routing'; import {CookieService} from 'ngx-cookie-service'; import {LeafletMarkerClusterModule} from '@asymmetrik/ngx-leaflet-markercluster'; +import {icon, Marker} from 'leaflet'; @Injectable() @@ -127,6 +128,23 @@ export class CustomUrlSerializer implements UrlSerializer { } } +// Fixes Leaflet icon path issue: +// https://stackoverflow.com/questions/41144319/leaflet-marker-not-found-production-env +const iconRetinaUrl = 'assets/marker-icon-2x.png'; +const iconUrl = 'assets/marker-icon.png'; +const shadowUrl = 'assets/marker-shadow.png'; +const iconDefault = icon({ + iconRetinaUrl, + iconUrl, + shadowUrl, + iconSize: [25, 41], + iconAnchor: [12, 41], + popupAnchor: [1, -34], + tooltipAnchor: [16, -28], + shadowSize: [41, 41] +}); +Marker.prototype.options.icon = iconDefault; + @NgModule({ imports: [