Complete missing Leaflet default marker bugfix
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as L from 'leaflet';
|
import * as L from 'leaflet';
|
||||||
import 'leaflet/dist/leaflet.css';
|
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 { onMount, type Snippet } from "svelte";
|
||||||
import type { SvelteHTMLElements } from "svelte/elements";
|
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 = {
|
type Props = {
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
@@ -22,7 +30,7 @@
|
|||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
}).addTo(map);
|
}).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)
|
if (children !== undefined)
|
||||||
marker.bindPopup(popupDiv, { closeOnClick: false }).openPopup();
|
marker.bindPopup(popupDiv, { closeOnClick: false }).openPopup();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user