Complete missing Leaflet default marker bugfix
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
<script lang="ts">
|
||||
import * as L from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import lmiUrl from 'leaflet/dist/images/marker-icon.png';
|
||||
import lmi2Url from 'leaflet/dist/images/marker-icon-2x.png';
|
||||
import lmsUrl from 'leaflet/dist/images/marker-shadow.png';
|
||||
import { onMount, type Snippet } from "svelte";
|
||||
import type { SvelteHTMLElements } from "svelte/elements";
|
||||
|
||||
// Fix bundling bug for leaflet default marker icon on production
|
||||
L.Icon.Default.prototype.options.iconUrl = lmiUrl;
|
||||
L.Icon.Default.prototype.options.iconRetinaUrl = lmi2Url;
|
||||
L.Icon.Default.prototype.options.shadowUrl = lmsUrl;
|
||||
|
||||
type Props = {
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -22,7 +30,7 @@
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
}).addTo(map);
|
||||
const marker = L.marker([x, y], { icon: new L.Icon.Default }).addTo(map);
|
||||
const marker = L.marker([x, y]).addTo(map);
|
||||
if (children !== undefined)
|
||||
marker.bindPopup(popupDiv, { closeOnClick: false }).openPopup();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user