From ce22a2ee74f22f36c44b0be0355ed2fadcb53b27 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 29 Dec 2023 15:07:27 +0100 Subject: [PATCH] Only load Leaflet once, as module --- umap/static/umap/js/modules/vendors.js | 143 ++++++++++++++++++++++++- umap/static/umap/test/index.html | 89 ++++++++------- umap/templates/umap/js.html | 94 ++++++++-------- 3 files changed, 231 insertions(+), 95 deletions(-) diff --git a/umap/static/umap/js/modules/vendors.js b/umap/static/umap/js/modules/vendors.js index 1bf5fa64..85ab07e1 100644 --- a/umap/static/umap/js/modules/vendors.js +++ b/umap/static/umap/js/modules/vendors.js @@ -1,7 +1,144 @@ -import { Util } from '../../vendors/leaflet/leaflet-src.esm.js' +import { + bind, + Bounds, + Browser, + Canvas, + Circle, + Class, + Control, + control, + DivIcon, + DomEvent, + DomUtil, + Draggable, + Evented, + extend, + FeatureGroup, + featureGroup, + GeoJSON, + Handler, + Icon, + LatLng, + latLng, + LatLngBounds, + latLngBounds, + Layer, + LayerGroup, + LineUtil, + Map, + map, + Marker, + Mixin, + Path, + Point, + point, + Polygon, + Polyline, + polyline, + Popup, + Projection, + Rectangle, + rectangle, + setOptions, + stamp, + svg, + TileLayer, + Util, +} from '../../vendors/leaflet/leaflet-src.esm.js' // expose the modules to the window.vendors global scope -window.vendors = { +window.L = { + bind, + Bounds, + Browser, + Canvas, + Circle, + Class, + Control, + control, + DivIcon, + DomEvent, + DomUtil, + Draggable, + Evented, + extend, + FeatureGroup, + featureGroup, + GeoJSON, + Handler, + Icon, + LatLng, + latLng, + LatLngBounds, + latLngBounds, + Layer, + LayerGroup, + LineUtil, + Map, + map, + Marker, + Mixin, + Path, + Point, + point, + Polygon, + Polyline, + polyline, + Popup, + Projection, + Rectangle, + rectangle, + setOptions, + stamp, + svg, + TileLayer, + Util, +} + +export { + bind, + Bounds, + Browser, + Canvas, + Circle, + Class, + Control, + control, + DivIcon, + DomEvent, + DomUtil, + Draggable, + Evented, + extend, + FeatureGroup, + featureGroup, + GeoJSON, + Handler, + Icon, + LatLng, + latLng, + LatLngBounds, + latLngBounds, + Layer, + LayerGroup, + LineUtil, + Map, + map, + Marker, + Mixin, + Path, + Point, + point, + Polygon, + Polyline, + polyline, + Popup, + Projection, + Rectangle, + rectangle, + setOptions, + stamp, + svg, + TileLayer, Util, } -export { Util } diff --git a/umap/static/umap/test/index.html b/umap/static/umap/test/index.html index f0b0e487..f77b0e74 100644 --- a/umap/static/umap/test/index.html +++ b/umap/static/umap/test/index.html @@ -3,51 +3,50 @@ Umap front Tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/umap/templates/umap/js.html b/umap/templates/umap/js.html index 414f145b..45e3198a 100644 --- a/umap/templates/umap/js.html +++ b/umap/templates/umap/js.html @@ -1,52 +1,52 @@ {% load compress %} {% compress js %} - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + {% endcompress %} -{% if locale %}{% endif %} +{% if locale %}{% endif %} {% compress js %} - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + {% endcompress %}