From 2d111438c2e60dcb3754fad8f9a374c830f42eda 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 | 84 +++++++-------- umap/templates/umap/js.html | 88 +++++++-------- 3 files changed, 226 insertions(+), 89 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 23ba7096..07100785 100644 --- a/umap/static/umap/test/index.html +++ b/umap/static/umap/test/index.html @@ -3,48 +3,48 @@ Umap front Tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/umap/templates/umap/js.html b/umap/templates/umap/js.html index a7e0baf6..82b5c733 100644 --- a/umap/templates/umap/js.html +++ b/umap/templates/umap/js.html @@ -1,49 +1,49 @@ {% load compress %} {% compress js %} - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + {% endcompress %} -{% if locale %}{% endif %} +{% if locale %}{% endif %} {% compress js %} - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + {% endcompress %}