mirror of
https://github.com/zebrajr/ollama-webui.git
synced 2025-12-06 12:19:46 +01:00
Merge pull request #17503 from ShirasawaSama/patch-13
feat: Dynamically load leaflet to improve first-screen loading speed (-454KB)
This commit is contained in:
commit
867fcc4d95
|
|
@ -1,6 +1,4 @@
|
||||||
<script>
|
<script>
|
||||||
import L from 'leaflet';
|
|
||||||
import 'leaflet/dist/leaflet.css';
|
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
|
|
||||||
let map;
|
let map;
|
||||||
|
|
@ -13,6 +11,28 @@
|
||||||
|
|
||||||
let markerGroupLayer = null;
|
let markerGroupLayer = null;
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const [{ default: L }] = await Promise.all([
|
||||||
|
import('leaflet'),
|
||||||
|
import('leaflet/dist/leaflet.css')
|
||||||
|
]);
|
||||||
|
|
||||||
|
map = L.map(mapElement).setView(setViewLocation ? setViewLocation : [51.505, -0.09], 10);
|
||||||
|
|
||||||
|
if (setViewLocation) {
|
||||||
|
points = [
|
||||||
|
{
|
||||||
|
coords: setViewLocation,
|
||||||
|
content: `Lat: ${setViewLocation[0]}, Lng: ${setViewLocation[1]}`
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution:
|
||||||
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
const setMarkers = (points) => {
|
const setMarkers = (points) => {
|
||||||
if (map) {
|
if (map) {
|
||||||
if (markerGroupLayer) {
|
if (markerGroupLayer) {
|
||||||
|
|
@ -36,23 +56,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
map = L.map(mapElement).setView(setViewLocation ? setViewLocation : [51.505, -0.09], 10);
|
|
||||||
|
|
||||||
if (setViewLocation) {
|
|
||||||
points = [
|
|
||||||
{
|
|
||||||
coords: setViewLocation,
|
|
||||||
content: `Lat: ${setViewLocation[0]}, Lng: ${setViewLocation[1]}`
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
||||||
attribution:
|
|
||||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
setMarkers(points);
|
setMarkers(points);
|
||||||
|
|
||||||
map.on('click', (e) => {
|
map.on('click', (e) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user