leaflet-html 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +62 -35
- package/dist/leaflet-html.cjs +1 -1
- package/dist/leaflet-html.cjs.map +1 -1
- package/dist/leaflet-html.esm.js +1 -1
- package/dist/leaflet-html.esm.js.map +1 -1
- package/dist/leaflet-html.js +1 -1
- package/dist/leaflet-html.js.map +1 -1
- package/dist/leaflet-html.umd.js +1 -1
- package/dist/leaflet-html.umd.js.map +1 -1
- package/docs/content/_index.md +60 -62
- package/docs/templates/index.html +23 -19
- package/example/geojson/index.html +42 -0
- package/example/index.html +58 -50
- package/example/overlays/index.html +34 -35
- package/package.json +2 -2
- package/src/events.js +3 -0
- package/src/index.js +25 -184
- package/src/l-base-layers.js +16 -0
- package/src/l-control-layers.js +34 -0
- package/src/l-geojson.js +20 -0
- package/src/l-image-overlay.js +41 -0
- package/src/l-lat-lng-bounds.js +20 -0
- package/src/l-layer-group.js +39 -0
- package/src/l-map.js +33 -0
- package/src/l-marker.js +45 -0
- package/src/l-overlay-layers.js +15 -0
- package/src/l-popup.js +23 -0
- package/src/l-tile-layer.js +19 -0
- package/src/l-video-overlay.js +30 -0
package/README.md
CHANGED
@@ -8,6 +8,34 @@ Fine grained reactive frameworks such as [Solid JS](https://solidjs.com) or [Van
|
|
8
8
|
|
9
9
|
RESTful frameworks, like [HTMX](Https://htmx.org), that serve HTML over the wire are perfect choices for server rendered content.
|
10
10
|
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Include both Leaflet and Leaflet HTML in script tags in the head of the document.
|
14
|
+
|
15
|
+
```html
|
16
|
+
<link
|
17
|
+
rel="stylesheet"
|
18
|
+
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
19
|
+
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
20
|
+
crossorigin=""
|
21
|
+
/>
|
22
|
+
<script
|
23
|
+
src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
24
|
+
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
25
|
+
crossorigin=""
|
26
|
+
></script>
|
27
|
+
<script src="https://unpkg.com/leaflet-html@latest/leaflet-html.umd.js"></script>
|
28
|
+
```
|
29
|
+
|
30
|
+
And remember to style the various map container elements with enough size to be visible.
|
31
|
+
|
32
|
+
```css
|
33
|
+
l-map {
|
34
|
+
display: block;
|
35
|
+
block-size: 100vh;
|
36
|
+
}
|
37
|
+
```
|
38
|
+
|
11
39
|
## Example
|
12
40
|
|
13
41
|
The HTML in `example/index.html` is a simple demonstration of the API.
|
@@ -16,41 +44,40 @@ The HTML in `example/index.html` is a simple demonstration of the API.
|
|
16
44
|
|
17
45
|
```html
|
18
46
|
<!-- Note: Leaflet JS/CSS must be included in <head> and [data-leaflet-html] styled to an appropriate size. -->
|
19
|
-
<
|
20
|
-
<
|
21
|
-
<
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
></
|
28
|
-
<
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</div>
|
47
|
+
<l-map center="[39.61, -105.02]" zoom="10">
|
48
|
+
<l-control-layers>
|
49
|
+
<l-base-layers>
|
50
|
+
<l-tile-layer
|
51
|
+
name="OpenStreetMap"
|
52
|
+
url-template="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
53
|
+
attribution='© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
54
|
+
max-zoom="12"
|
55
|
+
></l-tile-layer>
|
56
|
+
<l-tile-layer
|
57
|
+
name="Toner"
|
58
|
+
url-template="https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}{r}.png"
|
59
|
+
attribution=''
|
60
|
+
max-zoom="12"
|
61
|
+
></l-tile-layer>
|
62
|
+
</l-base-layers>
|
63
|
+
<l-overlay-layers>
|
64
|
+
<l-layer-group name="Cities">
|
65
|
+
<l-marker lat-lng="[39.61, -105.02]">
|
66
|
+
<l-popup content="This is Littleton, CO."></l-popup>
|
67
|
+
</l-marker>
|
68
|
+
<l-marker lat-lng="[39.74, -104.99]">
|
69
|
+
<l-popup content="This is Denver, CO."></l-popup>
|
70
|
+
</l-marker>
|
71
|
+
<l-marker lat-lng="[39.73, -104.8]">
|
72
|
+
<l-popup content="This is Aurora, CO."></l-popup>
|
73
|
+
</l-marker>
|
74
|
+
<l-marker lat-lng="[39.77, -105.23]">
|
75
|
+
<l-popup content="This is Golden, CO."></l-popup>
|
76
|
+
</l-marker>
|
77
|
+
</l-layer-group>
|
78
|
+
</l-overlay-layers>
|
79
|
+
</l-control-layers>
|
80
|
+
</l-map>
|
54
81
|
```
|
55
82
|
|
56
83
|
## Build
|
package/dist/leaflet-html.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var
|
1
|
+
function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(t=function(){return!!e})()}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function a(e){var i="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(e))return i.get(e);i.set(e,a)}function a(){return function(e,n,a){if(t())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var o=new(e.bind.apply(e,i));return a&&r(o,a.prototype),o}(e,arguments,n(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,e)},a(e)}var i="map:addTo",o="popup:add",l=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="base"})},n}(/*#__PURE__*/a(HTMLElement)),u=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.control.layers({},{});this.addEventListener(i,function(e){var n=e.detail,r=n.type,a=n.name,i=n.layer;"overlay"===r?t.addOverlay(i,a):"base"===r&&t.addBaseLayer(i,a),e.preventDefault()});var e=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),s=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=L.layerGroup(),n=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(n),this.addEventListener(i,function(t){t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){var n=t.getAttribute("leaflet-id"),r=e.getLayer(n);e.removeLayer(r)})})}).observe(this,{childList:!0})},n}(/*#__PURE__*/a(HTMLElement)),c=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).map=null,e.addEventListener("map:bounds",function(t){var n=t.detail;e.map[n.method](n.bounds)}),e}return e(n,t),n.prototype.connectedCallback=function(){var t=this;this.map=L.map(this);var e=this.getAttribute("center"),n=this.getAttribute("zoom");null!==e&&null!==n&&this.map.setView(JSON.parse(e),parseInt(n)),this.addEventListener(i,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){t.map.remove(e.detail.layer)})},n}(/*#__PURE__*/a(HTMLElement)),p=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),n=parseFloat(this.getAttribute("opacity")||"1.0");this.layer=L.marker(e,{opacity:n}),this.setAttribute("leaflet-id",L.stamp(this.layer)),this.addEventListener(o,function(e){t.layer.bindPopup(e.detail.content)});var r=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(r)},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(n)),"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));p.observedAttributes=["lat-lng","opacity"];var d=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="overlay"})},n}(/*#__PURE__*/a(HTMLElement)),b=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(o,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),h=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=this.getAttribute("url-template"),n=this.getAttribute("attribution"),r=L.tileLayer(e,{attribution:n}),a=new CustomEvent(i,{detail:{name:t,layer:r},bubbles:!0});this.dispatchEvent(a)},n}(/*#__PURE__*/a(HTMLElement)),f=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.attributeChangedCallback=function(t,e,n){var r=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(n),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(r)},n}(/*#__PURE__*/a(HTMLElement));f.observedAttributes=["bounds"];var y=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this.getAttribute("url"),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=L.imageOverlay(t,e,n),this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("url"===t?this.layer.setUrl(n):"bounds"===t?this.layer.setBounds(JSON.parse(n)):"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));y.observedAttributes=["url","bounds","opacity"];var v=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=JSON.parse(this.getAttribute("url")),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},r=L.videoOverlay(t,e,n);this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:r}}))},n}(/*#__PURE__*/a(HTMLElement)),m=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.geoJSON(JSON.parse(this.getAttribute("geojson")));this.dispatchEvent(new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:{layer:t}}))},n}(/*#__PURE__*/a(HTMLElement)),E=(customElements.define("l-map",c),customElements.define("l-control-layers",u),customElements.define("l-base-layers",l),customElements.define("l-overlay-layers",d),customElements.define("l-layer-group",s),customElements.define("l-tile-layer",h),customElements.define("l-marker",p),customElements.define("l-popup",b),customElements.define("l-lat-lng-bounds",f),customElements.define("l-image-overlay",y),customElements.define("l-video-overlay",v),void customElements.define("l-geojson",m));module.exports=E;
|
2
2
|
//# sourceMappingURL=leaflet-html.cjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"leaflet-html.cjs","sources":["../src/index.js"],"sourcesContent":["// @ts-check\n\n// Helpers\nconst selector = (noun) => `[data-${noun}]`;\n\n/**\n * Parse L.tileLayer args from element attributes\n */\nconst parseTileLayer = (el) => {\n const { urlTemplate } = el.dataset;\n const {\n attribution = null,\n maxZoom = \"18\",\n minZoom = \"0\",\n subdomains = \"abc\",\n } = el.dataset;\n const options = { attribution, maxZoom, minZoom, subdomains };\n return [urlTemplate, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseImageOverlay = (el) => {\n let { url, bounds } = el.dataset;\n bounds = JSON.parse(bounds);\n const { opacity } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n return [url, bounds, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseVideoOverlay = (el) => {\n let { url, bounds } = el.dataset;\n url = JSON.parse(url);\n bounds = JSON.parse(bounds);\n const {\n opacity,\n errorOverlayUrl,\n autoplay = true,\n muted = true,\n playsInline = true,\n } = el.dataset;\n const options = {\n opacity: parseFloat(opacity),\n errorOverlayUrl,\n autoplay,\n muted,\n playsInline,\n };\n return [url, bounds, options];\n};\n\n/**\n * @param {HTMLElement} el\n */\nconst parseLatLngBounds = (el) => {\n let { bounds } = el.dataset;\n if (typeof bounds === \"undefined\") {\n throw Error(\"data-bounds not specified\")\n }\n return [JSON.parse(bounds)];\n}\n\nconst render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(selector(\"leaflet-html\")).forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.latLngBounds\n el.querySelectorAll(selector(\"lat-lng-bounds\")).forEach((el) => {\n const bounds = L.latLngBounds(...parseLatLngBounds(el))\n // TODO: encapsulate this design pattern\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n let [bounds] = parseLatLngBounds(mutation.target)\n map.flyToBounds(bounds); // TODO: Use HTML attrs for fly/fit bounds\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-bounds\"],\n });\n map.fitBounds(bounds)\n })\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n L.tileLayer(...parseTileLayer(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"image-overlay\")).forEach((el) => {\n L.imageOverlay(...parseImageOverlay(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"video-overlay\")).forEach((el) => {\n L.videoOverlay(...parseVideoOverlay(el)).addTo(map);\n });\n\n // L.control.layers\n el.querySelectorAll(selector(\"control-layers\")).forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n const { name, show } = el.dataset;\n baseMaps[name] = L.tileLayer(...parseTileLayer(el));\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(selector(\"layer-group\")).forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(selector(\"marker\")).forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(selector(\"popup\")).forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["selector","noun","parseTileLayer","el","_el$dataset","dataset","_el$dataset$attributi","attribution","_el$dataset$maxZoom","maxZoom","_el$dataset$minZoom","minZoom","_el$dataset$subdomain","subdomains","urlTemplate","parseLatLngBounds","bounds","Error","JSON","parse","init","document","addEventListener","querySelectorAll","forEach","_el$dataset5","center","zoom","map","L","setView","parseInt","_L","latLngBounds","apply","MutationObserver","mutations","mutation","_parseLatLngBounds","target","flyToBounds","observe","attributes","attributeFilter","fitBounds","_L2","tileLayer","addTo","_L3","imageOverlay","_el$dataset2","url","opacity","parseFloat","parseImageOverlay","_L4","videoOverlay","_el$dataset3","_el$dataset4","errorOverlayUrl","_el$dataset4$autoplay","autoplay","_el$dataset4$muted","muted","_el$dataset4$playsInl","playsInline","parseVideoOverlay","baseMaps","_L5","_el$dataset6","name","show","overlayMaps","layers","group","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","childList","_el$dataset$opacity","options","stamp","setLatLng","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"AAGA,IAAMA,EAAW,SAACC,GAAkBA,MAAAA,SAAAA,OAK9BC,EAAiB,SAACC,GACtB,IACAC,EAKID,EAAGE,QAAOC,EAAAF,EAJZG,YAAkBC,EAAAJ,EAClBK,QAAcC,EA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,iBAEtB,GAEA8B,EAAOqB,KAAKhB,EACd,GAEAN,EAAYF,GAAQzC,EAAEkE,WAAWtB,EACnC,GAEA5C,EAAEmE,QAAQvB,OAAON,EAAUK,GAAazB,MAAMnB,EAChD,EACF,EACF"}
|
1
|
+
{"version":3,"file":"leaflet-html.cjs","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer-group.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-tile-layer.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\"\nexport const popupAdd = \"popup:add\"\nexport const layerRemove = \"layer:remove\"\n","import { mapAddTo } from \"./events.js\"\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\"\n })\n }\n}\n\nexport default LBaseLayers\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const base = {}\n const overlay = {}\n const control = L.control.layers(base, overlay)\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail\n if (type === \"overlay\") {\n control.addOverlay(layer, name)\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name)\n }\n ev.preventDefault()\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LControlLayers\n","import { mapAddTo } from \"./events.js\"\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const group = L.layerGroup()\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name\n }\n })\n this.dispatchEvent(event)\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation()\n group.addLayer(ev.detail.layer)\n })\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true })\n }\n}\n\nexport default LLayerGroup\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\"\n\nclass LMap extends HTMLElement {\n constructor() {\n super()\n\n this.map = null\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail\n this.map[method](bounds)\n })\n }\n\n connectedCallback() {\n this.map = L.map(this)\n const center = this.getAttribute(\"center\")\n const zoom = this.getAttribute(\"zoom\")\n if ((center !== null) && (zoom !== null)) {\n this.map.setView(JSON.parse(center), parseInt(zoom))\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer\n layer.addTo(this.map)\n })\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer)\n })\n }\n}\n\nexport default LMap\n","import { mapAddTo, popupAdd } from \"./events.js\"; \n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const latLng = JSON.parse(this.getAttribute(\"lat-lng\"))\n const opacity = parseFloat(this.getAttribute(\"opacity\") || \"1.0\")\n this.layer = L.marker(latLng, { opacity });\n this.setAttribute(\"leaflet-id\", L.stamp(this.layer))\n\n this.addEventListener(popupAdd, (ev) => {\n const { content } = ev.detail\n this.layer.bindPopup(content)\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n })\n this.dispatchEvent(event)\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"lat-lng\") {\n this.layer.setLatLng(JSON.parse(newValue))\n }\n if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\n\nexport default LMarker\n","import { mapAddTo } from \"./events.js\"\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\"\n })\n }\n}\n\nexport default LOverlayLayers\n","import { popupAdd } from \"./events.js\"\n\nclass LPopup extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\")\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content\n }\n })\n this.dispatchEvent(event)\n }\n}\n\n\nexport default LPopup\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const urlTemplate = this.getAttribute(\"url-template\")\n const attribution = this.getAttribute(\"attribution\")\n const options = { attribution }\n const layer = L.tileLayer(urlTemplate, options)\n const event = new CustomEvent(mapAddTo, { detail: { name, layer }, bubbles: true})\n this.dispatchEvent(event)\n }\n}\n\nexport default LTileLayer\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"]\n\n constructor() {\n super()\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\"\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LLatLngBounds\n","import { mapAddTo } from \"./events.js\"\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\")\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\"\n }\n this.layer = L.imageOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n }))\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"url\") {\n this.layer.setUrl(newValue)\n } else if (name === \"bounds\") {\n this.layer.setBounds(JSON.parse(newValue))\n } else if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\nexport default LImageOverlay\n","import { mapAddTo } from \"./events.js\"\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"))\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true\n }\n const layer = L.videoOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LVideoOverlay\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")))\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LGeoJSON\n","// @ts-check\nimport LBaseLayers from \"./l-base-layers.js\";\nimport LControlLayers from \"./l-control-layers.js\"; \nimport LLayerGroup from \"./l-layer-group.js\"; \nimport LMap from \"./l-map.js\"; \nimport LMarker from \"./l-marker.js\"; \nimport LOverlayLayers from \"./l-overlay-layers.js\";\nimport LPopup from \"./l-popup.js\"; \nimport LTileLayer from \"./l-tile-layer.js\";\nimport LLatLngBounds from \"./l-lat-lng-bounds.js\";\nimport LImageOverlay from \"./l-image-overlay.js\";\nimport LVideoOverlay from \"./l-video-overlay.js\";\nimport LGeoJSON from \"./l-geojson.js\";\n\n\nconst init = (() => {\n // Custom elements (order of definition is important)\n customElements.define(\"l-map\", LMap)\n customElements.define(\"l-control-layers\", LControlLayers)\n customElements.define(\"l-base-layers\", LBaseLayers)\n customElements.define(\"l-overlay-layers\", LOverlayLayers)\n customElements.define(\"l-layer-group\", LLayerGroup)\n customElements.define(\"l-tile-layer\", LTileLayer)\n customElements.define(\"l-marker\", LMarker)\n customElements.define(\"l-popup\", LPopup)\n customElements.define(\"l-lat-lng-bounds\", LLatLngBounds)\n customElements.define(\"l-image-overlay\", LImageOverlay)\n customElements.define(\"l-video-overlay\", LVideoOverlay)\n customElements.define(\"l-geojson\", LGeoJSON)\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","control","L","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","_this","map","method","bounds","_this2","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","init","customElements","define"],"mappings":"orCAAaA,EAAW,YACXC,EAAW,YCClBC,eAAW,SAAAC,GACf,SAAAD,IAAc,OACZC,EAAAC,KAAAC,OAAO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,kBAAA,WACE,IAAMa,EAAQL,EAAEkF,QAAQ1C,KAAKC,MAAMpD,KAAK0B,aAAa,aACrD1B,KAAKwB,cAAc,IAAIH,YAAY1B,EAAU,CAC3C4B,SAAS,EACTD,YAAY,EACZhB,OAAQ,CACNU,MAAAA,KAGN,EAAC4E,CAAA,CAdW,cAcXrF,EAdoBC,cCajBsF,GAEJC,eAAeC,OAAO,QAAStD,GAC/BqD,eAAeC,OAAO,mBAAoBvF,GAC1CsF,eAAeC,OAAO,gBAAiBnG,GACvCkG,eAAeC,OAAO,mBAAoBxB,GAC1CuB,eAAeC,OAAO,gBAAiBvE,GACvCsE,eAAeC,OAAO,eAAgBtB,GACtCqB,eAAeC,OAAO,WAAYxC,GAClCuC,eAAeC,OAAO,UAAWvB,GACjCsB,eAAeC,OAAO,mBAAoBlB,GAC1CiB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,kBAAmBT,QACzCQ,eAAeC,OAAO,YAAaJ"}
|
package/dist/leaflet-html.esm.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var
|
1
|
+
function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(t=function(){return!!e})()}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function a(e){var i="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(e))return i.get(e);i.set(e,a)}function a(){return function(e,n,a){if(t())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var o=new(e.bind.apply(e,i));return a&&r(o,a.prototype),o}(e,arguments,n(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,e)},a(e)}var i="map:addTo",o="popup:add",l=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="base"})},n}(/*#__PURE__*/a(HTMLElement)),u=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.control.layers({},{});this.addEventListener(i,function(e){var n=e.detail,r=n.type,a=n.name,i=n.layer;"overlay"===r?t.addOverlay(i,a):"base"===r&&t.addBaseLayer(i,a),e.preventDefault()});var e=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),s=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=L.layerGroup(),n=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(n),this.addEventListener(i,function(t){t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){var n=t.getAttribute("leaflet-id"),r=e.getLayer(n);e.removeLayer(r)})})}).observe(this,{childList:!0})},n}(/*#__PURE__*/a(HTMLElement)),c=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).map=null,e.addEventListener("map:bounds",function(t){var n=t.detail;e.map[n.method](n.bounds)}),e}return e(n,t),n.prototype.connectedCallback=function(){var t=this;this.map=L.map(this);var e=this.getAttribute("center"),n=this.getAttribute("zoom");null!==e&&null!==n&&this.map.setView(JSON.parse(e),parseInt(n)),this.addEventListener(i,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){t.map.remove(e.detail.layer)})},n}(/*#__PURE__*/a(HTMLElement)),p=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),n=parseFloat(this.getAttribute("opacity")||"1.0");this.layer=L.marker(e,{opacity:n}),this.setAttribute("leaflet-id",L.stamp(this.layer)),this.addEventListener(o,function(e){t.layer.bindPopup(e.detail.content)});var r=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(r)},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(n)),"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));p.observedAttributes=["lat-lng","opacity"];var d=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="overlay"})},n}(/*#__PURE__*/a(HTMLElement)),b=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(o,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),f=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=this.getAttribute("url-template"),n=this.getAttribute("attribution"),r=L.tileLayer(e,{attribution:n}),a=new CustomEvent(i,{detail:{name:t,layer:r},bubbles:!0});this.dispatchEvent(a)},n}(/*#__PURE__*/a(HTMLElement)),h=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.attributeChangedCallback=function(t,e,n){var r=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(n),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(r)},n}(/*#__PURE__*/a(HTMLElement));h.observedAttributes=["bounds"];var y=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this.getAttribute("url"),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=L.imageOverlay(t,e,n),this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("url"===t?this.layer.setUrl(n):"bounds"===t?this.layer.setBounds(JSON.parse(n)):"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));y.observedAttributes=["url","bounds","opacity"];var v=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=JSON.parse(this.getAttribute("url")),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},r=L.videoOverlay(t,e,n);this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:r}}))},n}(/*#__PURE__*/a(HTMLElement)),m=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.geoJSON(JSON.parse(this.getAttribute("geojson")));this.dispatchEvent(new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:{layer:t}}))},n}(/*#__PURE__*/a(HTMLElement)),E=(customElements.define("l-map",c),customElements.define("l-control-layers",u),customElements.define("l-base-layers",l),customElements.define("l-overlay-layers",d),customElements.define("l-layer-group",s),customElements.define("l-tile-layer",f),customElements.define("l-marker",p),customElements.define("l-popup",b),customElements.define("l-lat-lng-bounds",h),customElements.define("l-image-overlay",y),customElements.define("l-video-overlay",v),void customElements.define("l-geojson",m));export{E as default};
|
2
2
|
//# sourceMappingURL=leaflet-html.esm.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"leaflet-html.esm.js","sources":["../src/index.js"],"sourcesContent":["// @ts-check\n\n// Helpers\nconst selector = (noun) => `[data-${noun}]`;\n\n/**\n * Parse L.tileLayer args from element attributes\n */\nconst parseTileLayer = (el) => {\n const { urlTemplate } = el.dataset;\n const {\n attribution = null,\n maxZoom = \"18\",\n minZoom = \"0\",\n subdomains = \"abc\",\n } = el.dataset;\n const options = { attribution, maxZoom, minZoom, subdomains };\n return [urlTemplate, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseImageOverlay = (el) => {\n let { url, bounds } = el.dataset;\n bounds = JSON.parse(bounds);\n const { opacity } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n return [url, bounds, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseVideoOverlay = (el) => {\n let { url, bounds } = el.dataset;\n url = JSON.parse(url);\n bounds = JSON.parse(bounds);\n const {\n opacity,\n errorOverlayUrl,\n autoplay = true,\n muted = true,\n playsInline = true,\n } = el.dataset;\n const options = {\n opacity: parseFloat(opacity),\n errorOverlayUrl,\n autoplay,\n muted,\n playsInline,\n };\n return [url, bounds, options];\n};\n\n/**\n * @param {HTMLElement} el\n */\nconst parseLatLngBounds = (el) => {\n let { bounds } = el.dataset;\n if (typeof bounds === \"undefined\") {\n throw Error(\"data-bounds not specified\")\n }\n return [JSON.parse(bounds)];\n}\n\nconst render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(selector(\"leaflet-html\")).forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.latLngBounds\n el.querySelectorAll(selector(\"lat-lng-bounds\")).forEach((el) => {\n const bounds = L.latLngBounds(...parseLatLngBounds(el))\n // TODO: encapsulate this design pattern\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n let [bounds] = parseLatLngBounds(mutation.target)\n map.flyToBounds(bounds); // TODO: Use HTML attrs for fly/fit bounds\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-bounds\"],\n });\n map.fitBounds(bounds)\n })\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n L.tileLayer(...parseTileLayer(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"image-overlay\")).forEach((el) => {\n L.imageOverlay(...parseImageOverlay(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"video-overlay\")).forEach((el) => {\n L.videoOverlay(...parseVideoOverlay(el)).addTo(map);\n });\n\n // L.control.layers\n el.querySelectorAll(selector(\"control-layers\")).forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n const { name, show } = el.dataset;\n baseMaps[name] = L.tileLayer(...parseTileLayer(el));\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(selector(\"layer-group\")).forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(selector(\"marker\")).forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(selector(\"popup\")).forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["selector","noun","parseTileLayer","el","_el$dataset","dataset","_el$dataset$attributi","attribution","_el$dataset$maxZoom","maxZoom","_el$dataset$minZoom","minZoom","_el$dataset$subdomain","subdomains","urlTemplate","parseLatLngBounds","bounds","Error","JSON","parse","init","document","addEventListener","querySelectorAll","forEach","_el$dataset5","center","zoom","map","L","setView","parseInt","_L","latLngBounds","apply","MutationObserver","mutations","mutation","_parseLatLngBounds","target","flyToBounds","observe","attributes","attributeFilter","fitBounds","_L2","tileLayer","addTo","_L3","imageOverlay","_el$dataset2","url","opacity","parseFloat","parseImageOverlay","_L4","videoOverlay","_el$dataset3","_el$dataset4","errorOverlayUrl","_el$dataset4$autoplay","autoplay","_el$dataset4$muted","muted","_el$dataset4$playsInl","playsInline","parseVideoOverlay","baseMaps","_L5","_el$dataset6","name","show","overlayMaps","layers","group","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","childList","_el$dataset$opacity","options","stamp","setLatLng","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"AAGA,IAAMA,EAAW,SAACC,GAAkBA,MAAAA,SAAAA,OAK9BC,EAAiB,SAACC,GACtB,IACAC,EAKID,EAAGE,QAAOC,EAAAF,EAJZG,YAAkBC,EAAAJ,EAClBK,QAAcC,EAAAN,EACdO,QAAaC,EAAAR,EACbS,WAGF,MA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GAEAN,EAAYF,GAAQzC,EAAEkE,WAAWtB,EACnC,GAEA5C,EAAEmE,QAAQvB,OAAON,EAAUK,GAAazB,MAAMnB,EAChD,EACF,EACF"}
|
1
|
+
{"version":3,"file":"leaflet-html.esm.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer-group.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-tile-layer.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\"\nexport const popupAdd = \"popup:add\"\nexport const layerRemove = \"layer:remove\"\n","import { mapAddTo } from \"./events.js\"\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\"\n })\n }\n}\n\nexport default LBaseLayers\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const base = {}\n const overlay = {}\n const control = L.control.layers(base, overlay)\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail\n if (type === \"overlay\") {\n control.addOverlay(layer, name)\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name)\n }\n ev.preventDefault()\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LControlLayers\n","import { mapAddTo } from \"./events.js\"\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const group = L.layerGroup()\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name\n }\n })\n this.dispatchEvent(event)\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation()\n group.addLayer(ev.detail.layer)\n })\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true })\n }\n}\n\nexport default LLayerGroup\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\"\n\nclass LMap extends HTMLElement {\n constructor() {\n super()\n\n this.map = null\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail\n this.map[method](bounds)\n })\n }\n\n connectedCallback() {\n this.map = L.map(this)\n const center = this.getAttribute(\"center\")\n const zoom = this.getAttribute(\"zoom\")\n if ((center !== null) && (zoom !== null)) {\n this.map.setView(JSON.parse(center), parseInt(zoom))\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer\n layer.addTo(this.map)\n })\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer)\n })\n }\n}\n\nexport default LMap\n","import { mapAddTo, popupAdd } from \"./events.js\"; \n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const latLng = JSON.parse(this.getAttribute(\"lat-lng\"))\n const opacity = parseFloat(this.getAttribute(\"opacity\") || \"1.0\")\n this.layer = L.marker(latLng, { opacity });\n this.setAttribute(\"leaflet-id\", L.stamp(this.layer))\n\n this.addEventListener(popupAdd, (ev) => {\n const { content } = ev.detail\n this.layer.bindPopup(content)\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n })\n this.dispatchEvent(event)\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"lat-lng\") {\n this.layer.setLatLng(JSON.parse(newValue))\n }\n if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\n\nexport default LMarker\n","import { mapAddTo } from \"./events.js\"\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\"\n })\n }\n}\n\nexport default LOverlayLayers\n","import { popupAdd } from \"./events.js\"\n\nclass LPopup extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\")\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content\n }\n })\n this.dispatchEvent(event)\n }\n}\n\n\nexport default LPopup\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const urlTemplate = this.getAttribute(\"url-template\")\n const attribution = this.getAttribute(\"attribution\")\n const options = { attribution }\n const layer = L.tileLayer(urlTemplate, options)\n const event = new CustomEvent(mapAddTo, { detail: { name, layer }, bubbles: true})\n this.dispatchEvent(event)\n }\n}\n\nexport default LTileLayer\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"]\n\n constructor() {\n super()\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\"\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LLatLngBounds\n","import { mapAddTo } from \"./events.js\"\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\")\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\"\n }\n this.layer = L.imageOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n }))\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"url\") {\n this.layer.setUrl(newValue)\n } else if (name === \"bounds\") {\n this.layer.setBounds(JSON.parse(newValue))\n } else if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\nexport default LImageOverlay\n","import { mapAddTo } from \"./events.js\"\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"))\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true\n }\n const layer = L.videoOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LVideoOverlay\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")))\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LGeoJSON\n","// @ts-check\nimport LBaseLayers from \"./l-base-layers.js\";\nimport LControlLayers from \"./l-control-layers.js\"; \nimport LLayerGroup from \"./l-layer-group.js\"; \nimport LMap from \"./l-map.js\"; \nimport LMarker from \"./l-marker.js\"; \nimport LOverlayLayers from \"./l-overlay-layers.js\";\nimport LPopup from \"./l-popup.js\"; \nimport LTileLayer from \"./l-tile-layer.js\";\nimport LLatLngBounds from \"./l-lat-lng-bounds.js\";\nimport LImageOverlay from \"./l-image-overlay.js\";\nimport LVideoOverlay from \"./l-video-overlay.js\";\nimport LGeoJSON from \"./l-geojson.js\";\n\n\nconst init = (() => {\n // Custom elements (order of definition is important)\n customElements.define(\"l-map\", LMap)\n customElements.define(\"l-control-layers\", LControlLayers)\n customElements.define(\"l-base-layers\", LBaseLayers)\n customElements.define(\"l-overlay-layers\", LOverlayLayers)\n customElements.define(\"l-layer-group\", LLayerGroup)\n customElements.define(\"l-tile-layer\", LTileLayer)\n customElements.define(\"l-marker\", LMarker)\n customElements.define(\"l-popup\", LPopup)\n customElements.define(\"l-lat-lng-bounds\", LLatLngBounds)\n customElements.define(\"l-image-overlay\", LImageOverlay)\n customElements.define(\"l-video-overlay\", LVideoOverlay)\n customElements.define(\"l-geojson\", LGeoJSON)\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","control","L","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","_this","map","method","bounds","_this2","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","init","customElements","define"],"mappings":"orCAAaA,EAAW,YACXC,EAAW,YCClBC,eAAW,SAAAC,GACf,SAAAD,IAAc,OACZC,EAAAC,KAAAC,OAAOA,IACT,CAMC,OANAC,EAAAJ,EAAAC,GAA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AQ1C,KAAKC,MAAMpD,KAAK0B,aAAa,aACrD1B,KAAKwB,cAAc,IAAIH,YAAY1B,EAAU,CAC3C4B,SAAS,EACTD,YAAY,EACZhB,OAAQ,CACNU,MAAAA,KAGN,EAAC4E,CAAA,CAdW,cAcXrF,EAdoBC,cCajBsF,GAEJC,eAAeC,OAAO,QAAStD,GAC/BqD,eAAeC,OAAO,mBAAoBvF,GAC1CsF,eAAeC,OAAO,gBAAiBnG,GACvCkG,eAAeC,OAAO,mBAAoBxB,GAC1CuB,eAAeC,OAAO,gBAAiBvE,GACvCsE,eAAeC,OAAO,eAAgBtB,GACtCqB,eAAeC,OAAO,WAAYxC,GAClCuC,eAAeC,OAAO,UAAWvB,GACjCsB,eAAeC,OAAO,mBAAoBlB,GAC1CiB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,kBAAmBT,QACzCQ,eAAeC,OAAO,YAAaJ"}
|
package/dist/leaflet-html.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
const t=t
|
1
|
+
const t="map:addTo",e="popup:add";class s extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(t,t=>{t.detail.type="base"})}}class a extends HTMLElement{constructor(){super()}connectedCallback(){const e=L.control.layers({},{});this.addEventListener(t,t=>{const{type:s,name:a,layer:l}=t.detail;"overlay"===s?e.addOverlay(l,a):"base"===s&&e.addBaseLayer(l,a),t.preventDefault()});const s=new CustomEvent(t,{cancelable:!0,bubbles:!0,detail:{layer:e}});this.dispatchEvent(s)}}class l extends HTMLElement{constructor(){super()}connectedCallback(){const e=this.getAttribute("name"),s=L.layerGroup(),a=new CustomEvent(t,{cancelable:!0,bubbles:!0,detail:{layer:s,name:e}});this.dispatchEvent(a),this.addEventListener(t,t=>{t.stopPropagation(),s.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(t=>{t.removedNodes.forEach(t=>{const e=t.getAttribute("leaflet-id"),a=s.getLayer(e);s.removeLayer(a)})})}).observe(this,{childList:!0})}}class n extends HTMLElement{constructor(){super(),this.map=null,this.addEventListener("map:bounds",t=>{const{bounds:e,method:s}=t.detail;this.map[s](e)})}connectedCallback(){this.map=L.map(this);const e=this.getAttribute("center"),s=this.getAttribute("zoom");null!==e&&null!==s&&this.map.setView(JSON.parse(e),parseInt(s)),this.addEventListener(t,t=>{t.detail.layer.addTo(this.map)}),this.addEventListener("layer:remove",t=>{this.map.remove(t.detail.layer)})}}class i extends HTMLElement{constructor(){super(),this.layer=null}connectedCallback(){const s=JSON.parse(this.getAttribute("lat-lng")),a=parseFloat(this.getAttribute("opacity")||"1.0");this.layer=L.marker(s,{opacity:a}),this.setAttribute("leaflet-id",L.stamp(this.layer)),this.addEventListener(e,t=>{const{content:e}=t.detail;this.layer.bindPopup(e)});const l=new CustomEvent(t,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(l)}attributeChangedCallback(t,e,s){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(s)),"opacity"===t&&this.layer.setOpacity(parseFloat(s)))}}i.observedAttributes=["lat-lng","opacity"];class r extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(t,t=>{t.detail.type="overlay"})}}class o extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("content"),s=new CustomEvent(e,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(s)}}class c extends HTMLElement{constructor(){super()}connectedCallback(){const e=this.getAttribute("name"),s=this.getAttribute("url-template"),a=this.getAttribute("attribution"),l=L.tileLayer(s,{attribution:a}),n=new CustomEvent(t,{detail:{name:e,layer:l},bubbles:!0});this.dispatchEvent(n)}}class d extends HTMLElement{constructor(){super()}attributeChangedCallback(t,e,s){const a=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(s),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(a)}}d.observedAttributes=["bounds"];class u extends HTMLElement{constructor(){super(),this.layer=null}connectedCallback(){const e=this.getAttribute("url"),s=JSON.parse(this.getAttribute("bounds")),a={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=L.imageOverlay(e,s,a),this.dispatchEvent(new CustomEvent(t,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}attributeChangedCallback(t,e,s){null!==this.layer&&("url"===t?this.layer.setUrl(s):"bounds"===t?this.layer.setBounds(JSON.parse(s)):"opacity"===t&&this.layer.setOpacity(parseFloat(s)))}}u.observedAttributes=["url","bounds","opacity"];class b extends HTMLElement{constructor(){super()}connectedCallback(){const e=JSON.parse(this.getAttribute("url")),s=JSON.parse(this.getAttribute("bounds")),a={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},l=L.videoOverlay(e,s,a);this.dispatchEvent(new CustomEvent(t,{cancelable:!0,bubbles:!0,detail:{layer:l}}))}}class p extends HTMLElement{constructor(){super()}connectedCallback(){const e=L.geoJSON(JSON.parse(this.getAttribute("geojson")));this.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:{layer:e}}))}}const h=(customElements.define("l-map",n),customElements.define("l-control-layers",a),customElements.define("l-base-layers",s),customElements.define("l-overlay-layers",r),customElements.define("l-layer-group",l),customElements.define("l-tile-layer",c),customElements.define("l-marker",i),customElements.define("l-popup",o),customElements.define("l-lat-lng-bounds",d),customElements.define("l-image-overlay",u),customElements.define("l-video-overlay",b),void customElements.define("l-geojson",p));export{h as default};
|
2
2
|
//# sourceMappingURL=leaflet-html.js.map
|
package/dist/leaflet-html.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"leaflet-html.js","sources":["../src/index.js"],"sourcesContent":["// @ts-check\n\n// Helpers\nconst selector = (noun) => `[data-${noun}]`;\n\n/**\n * Parse L.tileLayer args from element attributes\n */\nconst parseTileLayer = (el) => {\n const { urlTemplate } = el.dataset;\n const {\n attribution = null,\n maxZoom = \"18\",\n minZoom = \"0\",\n subdomains = \"abc\",\n } = el.dataset;\n const options = { attribution, maxZoom, minZoom, subdomains };\n return [urlTemplate, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseImageOverlay = (el) => {\n let { url, bounds } = el.dataset;\n bounds = JSON.parse(bounds);\n const { opacity } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n return [url, bounds, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseVideoOverlay = (el) => {\n let { url, bounds } = el.dataset;\n url = JSON.parse(url);\n bounds = JSON.parse(bounds);\n const {\n opacity,\n errorOverlayUrl,\n autoplay = true,\n muted = true,\n playsInline = true,\n } = el.dataset;\n const options = {\n opacity: parseFloat(opacity),\n errorOverlayUrl,\n autoplay,\n muted,\n playsInline,\n };\n return [url, bounds, options];\n};\n\n/**\n * @param {HTMLElement} el\n */\nconst parseLatLngBounds = (el) => {\n let { bounds } = el.dataset;\n if (typeof bounds === \"undefined\") {\n throw Error(\"data-bounds not specified\")\n }\n return [JSON.parse(bounds)];\n}\n\nconst render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(selector(\"leaflet-html\")).forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.latLngBounds\n el.querySelectorAll(selector(\"lat-lng-bounds\")).forEach((el) => {\n const bounds = L.latLngBounds(...parseLatLngBounds(el))\n // TODO: encapsulate this design pattern\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n let [bounds] = parseLatLngBounds(mutation.target)\n map.flyToBounds(bounds); // TODO: Use HTML attrs for fly/fit bounds\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-bounds\"],\n });\n map.fitBounds(bounds)\n })\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n L.tileLayer(...parseTileLayer(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"image-overlay\")).forEach((el) => {\n L.imageOverlay(...parseImageOverlay(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"video-overlay\")).forEach((el) => {\n L.videoOverlay(...parseVideoOverlay(el)).addTo(map);\n });\n\n // L.control.layers\n el.querySelectorAll(selector(\"control-layers\")).forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n const { name, show } = el.dataset;\n baseMaps[name] = L.tileLayer(...parseTileLayer(el));\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(selector(\"layer-group\")).forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(selector(\"marker\")).forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(selector(\"popup\")).forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["selector","noun","parseTileLayer","el","urlTemplate","dataset","attribution","maxZoom","minZoom","subdomains","parseLatLngBounds","bounds","Error","JSON","parse","init","document","addEventListener","render","querySelectorAll","forEach","center","zoom","map","L","setView","parseInt","latLngBounds","observer","MutationObserver","mutations","mutation","target","flyToBounds","observe","attributes","attributeFilter","fitBounds","tileLayer","addTo","imageOverlay","url","opacity","parseFloat","parseImageOverlay","videoOverlay","errorOverlayUrl","autoplay","muted","playsInline","parseVideoOverlay","baseMaps","name","show","overlayMaps","layers","group","addedNodes","node","latLng","layer","marker","addLayer","removedNodes","_leafletId","getLayer","removeLayer","childList","options","stamp","setLatLng","content","bindPopup","getPopup","setContent","push","layerGroup","control"],"mappings":"AAGA,MAAMA,EAAYC,GAAU,SAAQA,KAK9BC,EAAkBC,IACtB,MAAMC,YAAEA,GAAgBD,EAAGE,SACrBC,YACJA,EAAc,KAAIC,QAClBA,EAAU,KAAIC,QACdA,EAAU,IAAGC,WACbA,EAAa,OACXN,EAAGE,QAEP,MAAO,CAACD,EADQ,CAAEE,cAAaC,UAASC,UAASC,cACrB,EAyCxBC,EAAqBP,IACzB,IAAIQ,OAAEA,GAAWR,EAAGE,QACpB,QAAsB,IAAXM,EACT,MAAMC,MAAM,6BAEd,MAAO,CAACC,KAAKC,MAAMH,GAAO,EA2HtBI,OACJC,SAASC,iBAAiB,mBAzHbC,KAEbF,SAASG,iBAAiBnB,EAAS,iBAAiBoB,QAASjB,IAC3D,MAAMkB,OAAEA,EAAMC,KAAEA,GAASnB,EAAGE,QACtBkB,EAAMC,EAAED,IAAIpB,GAAIsB,QAAQZ,KAAKC,MAAMO,GAASK,SAASJ,IAG3DnB,EAAGg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EAAI,CACnBgC,YAAY,EACZC,gBAAiB,CAAC,kBAIpBjC,EAAGgB,iBAAiBnB,EAAS,UAAUoB,QAASjB,IAC9C,MAAMoE,QAAEA,GAAYpE,EAAGE,QACvBwD,EAAOW,UAAUD,GACA,IAAI1C,iBAAiB,WACpCgC,EAAOY,WAAWC,WAAWvE,EAAGE,QAAQkE,QAC1C,GACSrC,QAAQ/B,EAAI,CACnBgC,YAAY,EACZC,gBAAiB,CAAC,iBACnB,GAGHmB,EAAOoB,KAAKd,EACd,GAEAP,EAAYF,GAAQ5B,EAAEoD,WAAWrB,EACnC,GAEA/B,EAAEqD,QAAQtB,OAAOJ,EAAUG,GAAaf,MAAMhB,EAChD,EACF,EACF"}
|
1
|
+
{"version":3,"file":"leaflet-html.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer-group.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-tile-layer.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\"\nexport const popupAdd = \"popup:add\"\nexport const layerRemove = \"layer:remove\"\n","import { mapAddTo } from \"./events.js\"\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\"\n })\n }\n}\n\nexport default LBaseLayers\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const base = {}\n const overlay = {}\n const control = L.control.layers(base, overlay)\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail\n if (type === \"overlay\") {\n control.addOverlay(layer, name)\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name)\n }\n ev.preventDefault()\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LControlLayers\n","import { mapAddTo } from \"./events.js\"\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const group = L.layerGroup()\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name\n }\n })\n this.dispatchEvent(event)\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation()\n group.addLayer(ev.detail.layer)\n })\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true })\n }\n}\n\nexport default LLayerGroup\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\"\n\nclass LMap extends HTMLElement {\n constructor() {\n super()\n\n this.map = null\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail\n this.map[method](bounds)\n })\n }\n\n connectedCallback() {\n this.map = L.map(this)\n const center = this.getAttribute(\"center\")\n const zoom = this.getAttribute(\"zoom\")\n if ((center !== null) && (zoom !== null)) {\n this.map.setView(JSON.parse(center), parseInt(zoom))\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer\n layer.addTo(this.map)\n })\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer)\n })\n }\n}\n\nexport default LMap\n","import { mapAddTo, popupAdd } from \"./events.js\"; \n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const latLng = JSON.parse(this.getAttribute(\"lat-lng\"))\n const opacity = parseFloat(this.getAttribute(\"opacity\") || \"1.0\")\n this.layer = L.marker(latLng, { opacity });\n this.setAttribute(\"leaflet-id\", L.stamp(this.layer))\n\n this.addEventListener(popupAdd, (ev) => {\n const { content } = ev.detail\n this.layer.bindPopup(content)\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n })\n this.dispatchEvent(event)\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"lat-lng\") {\n this.layer.setLatLng(JSON.parse(newValue))\n }\n if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\n\nexport default LMarker\n","import { mapAddTo } from \"./events.js\"\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\"\n })\n }\n}\n\nexport default LOverlayLayers\n","import { popupAdd } from \"./events.js\"\n\nclass LPopup extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\")\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content\n }\n })\n this.dispatchEvent(event)\n }\n}\n\n\nexport default LPopup\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const urlTemplate = this.getAttribute(\"url-template\")\n const attribution = this.getAttribute(\"attribution\")\n const options = { attribution }\n const layer = L.tileLayer(urlTemplate, options)\n const event = new CustomEvent(mapAddTo, { detail: { name, layer }, bubbles: true})\n this.dispatchEvent(event)\n }\n}\n\nexport default LTileLayer\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"]\n\n constructor() {\n super()\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\"\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LLatLngBounds\n","import { mapAddTo } from \"./events.js\"\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\")\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\"\n }\n this.layer = L.imageOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n }))\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"url\") {\n this.layer.setUrl(newValue)\n } else if (name === \"bounds\") {\n this.layer.setBounds(JSON.parse(newValue))\n } else if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\nexport default LImageOverlay\n","import { mapAddTo } from \"./events.js\"\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"))\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true\n }\n const layer = L.videoOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LVideoOverlay\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")))\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LGeoJSON\n","// @ts-check\nimport LBaseLayers from \"./l-base-layers.js\";\nimport LControlLayers from \"./l-control-layers.js\"; \nimport LLayerGroup from \"./l-layer-group.js\"; \nimport LMap from \"./l-map.js\"; \nimport LMarker from \"./l-marker.js\"; \nimport LOverlayLayers from \"./l-overlay-layers.js\";\nimport LPopup from \"./l-popup.js\"; \nimport LTileLayer from \"./l-tile-layer.js\";\nimport LLatLngBounds from \"./l-lat-lng-bounds.js\";\nimport LImageOverlay from \"./l-image-overlay.js\";\nimport LVideoOverlay from \"./l-video-overlay.js\";\nimport LGeoJSON from \"./l-geojson.js\";\n\n\nconst init = (() => {\n // Custom elements (order of definition is important)\n customElements.define(\"l-map\", LMap)\n customElements.define(\"l-control-layers\", LControlLayers)\n customElements.define(\"l-base-layers\", LBaseLayers)\n customElements.define(\"l-overlay-layers\", LOverlayLayers)\n customElements.define(\"l-layer-group\", LLayerGroup)\n customElements.define(\"l-tile-layer\", LTileLayer)\n customElements.define(\"l-marker\", LMarker)\n customElements.define(\"l-popup\", LPopup)\n customElements.define(\"l-lat-lng-bounds\", LLatLngBounds)\n customElements.define(\"l-image-overlay\", LImageOverlay)\n customElements.define(\"l-video-overlay\", LVideoOverlay)\n customElements.define(\"l-geojson\", LGeoJSON)\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","HTMLElement","constructor","super","connectedCallback","this","addEventListener","ev","detail","LControlLayers","control","L","layers","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","map","bounds","method","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","latLng","opacity","parseFloat","marker","setAttribute","stamp","content","bindPopup","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","init","customElements","define"],"mappings":"MAAaA,EAAW,YACXC,EAAW,YCCxB,MAAMC,UAAoBC,YACxBC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACEC,KAAKC,iBAAiBR,EAAWS,IAC/BA,EAAGC,OAAa,KAAI,MACtB,EACF,ECTF,MAAMC,UAAuBR,YAC3BC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACE,MAEMM,EAAUC,EAAED,QAAQE,OAFb,CAAE,EACC,CAAA,GAGhBP,KAAKC,iBAAiBR,EAAWS,IAC/B,MAAMM,KAAEA,EAAIC,KAAEA,EAAIC,MAAEA,GAAUR,EAAGC,OACpB,YAATK,EACFH,EAAQM,WAAWD,EAAOD,GACR,SAATD,GACTH,EAAQO,aAAaF,EAAOD,GAE9BP,EAAGW,gBACL,GAEA,MAAMC,EAAQ,IAAIC,YAAYtB,EAAU,CACtCuB,YAAY,EACZC,SAAS,EACTd,OAAQ,CACNO,MAAOL,KAGXL,KAAKkB,cAAcJ,EACrB,EC5BF,MAAMK,UAAoBvB,YACxBC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACE,MAAMU,EAAOT,KAAKoB,aAAa,QACzBC,EAAQf,EAAEgB,aACVR,EAAQ,IAAIC,YAAYtB,EAAU,CACtCuB,YAAY,EACZC,SAAS,EACTd,OAAQ,CACNO,MAAOW,EACPZ,UAGJT,KAAKkB,cAAcJ,GAEnBd,KAAKC,iBAAiBR,EAAWS,IAC/BA,EAAGqB,kBACHF,EAAMG,SAAStB,EAAGC,OAAOO,MAC3B,GAEiB,IAAIe,iBAAiB,SAASC,GAC7CA,EAAUC,QAASC,IACjBA,EAASC,aAAaF,QAASG,IAC7B,MAAMC,EAAYD,EAAKV,aAAa,cAC9BV,EAAQW,EAAMW,SAASD,GAC7BV,EAAMY,YAA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,ECDI,MAAA2E,GAEJC,eAAeC,OAAO,QAASnD,GAC/BkD,eAAeC,OAAO,mBAAoBnF,GAC1CkF,eAAeC,OAAO,gBAAiB5F,GACvC2F,eAAeC,OAAO,mBAAoBxB,GAC1CuB,eAAeC,OAAO,gBAAiBpE,GACvCmE,eAAeC,OAAO,eAAgBtB,GACtCqB,eAAeC,OAAO,WAAYvC,GAClCsC,eAAeC,OAAO,UAAWvB,GACjCsB,eAAeC,OAAO,mBAAoBlB,GAC1CiB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,kBAAmBT,QACzCQ,eAAeC,OAAO,YAAaJ"}
|
package/dist/leaflet-html.umd.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).leafletHtml=e()}(this,function(){function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(t=function(){return!!e})()}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function a(e){var i="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(e))return i.get(e);i.set(e,a)}function a(){return function(e,n,a){if(t())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var o=new(e.bind.apply(e,i));return a&&r(o,a.prototype),o}(e,arguments,n(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,e)},a(e)}var i="map:addTo",o="popup:add",l=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="base"})},n}(/*#__PURE__*/a(HTMLElement)),u=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.control.layers({},{});this.addEventListener(i,function(e){var n=e.detail,r=n.type,a=n.name,i=n.layer;"overlay"===r?t.addOverlay(i,a):"base"===r&&t.addBaseLayer(i,a),e.preventDefault()});var e=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),s=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=L.layerGroup(),n=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(n),this.addEventListener(i,function(t){t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){var n=t.getAttribute("leaflet-id"),r=e.getLayer(n);e.removeLayer(r)})})}).observe(this,{childList:!0})},n}(/*#__PURE__*/a(HTMLElement)),c=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).map=null,e.addEventListener("map:bounds",function(t){var n=t.detail;e.map[n.method](n.bounds)}),e}return e(n,t),n.prototype.connectedCallback=function(){var t=this;this.map=L.map(this);var e=this.getAttribute("center"),n=this.getAttribute("zoom");null!==e&&null!==n&&this.map.setView(JSON.parse(e),parseInt(n)),this.addEventListener(i,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){t.map.remove(e.detail.layer)})},n}(/*#__PURE__*/a(HTMLElement)),p=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),n=parseFloat(this.getAttribute("opacity")||"1.0");this.layer=L.marker(e,{opacity:n}),this.setAttribute("leaflet-id",L.stamp(this.layer)),this.addEventListener(o,function(e){t.layer.bindPopup(e.detail.content)});var r=new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(r)},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(n)),"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));p.observedAttributes=["lat-lng","opacity"];var d=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){this.addEventListener(i,function(t){t.detail.type="overlay"})},n}(/*#__PURE__*/a(HTMLElement)),f=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(o,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},n}(/*#__PURE__*/a(HTMLElement)),b=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=this.getAttribute("url-template"),n=this.getAttribute("attribution"),r=L.tileLayer(e,{attribution:n}),a=new CustomEvent(i,{detail:{name:t,layer:r},bubbles:!0});this.dispatchEvent(a)},n}(/*#__PURE__*/a(HTMLElement)),h=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.attributeChangedCallback=function(t,e,n){var r=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(n),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(r)},n}(/*#__PURE__*/a(HTMLElement));h.observedAttributes=["bounds"];var y=/*#__PURE__*/function(t){function n(){var e;return(e=t.call(this)||this).layer=null,e}e(n,t);var r=n.prototype;return r.connectedCallback=function(){var t=this.getAttribute("url"),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=L.imageOverlay(t,e,n),this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))},r.attributeChangedCallback=function(t,e,n){null!==this.layer&&("url"===t?this.layer.setUrl(n):"bounds"===t?this.layer.setBounds(JSON.parse(n)):"opacity"===t&&this.layer.setOpacity(parseFloat(n)))},n}(/*#__PURE__*/a(HTMLElement));y.observedAttributes=["url","bounds","opacity"];var m=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=JSON.parse(this.getAttribute("url")),e=JSON.parse(this.getAttribute("bounds")),n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},r=L.videoOverlay(t,e,n);this.dispatchEvent(new CustomEvent(i,{cancelable:!0,bubbles:!0,detail:{layer:r}}))},n}(/*#__PURE__*/a(HTMLElement)),v=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.connectedCallback=function(){var t=L.geoJSON(JSON.parse(this.getAttribute("geojson")));this.dispatchEvent(new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:{layer:t}}))},n}(/*#__PURE__*/a(HTMLElement));return customElements.define("l-map",c),customElements.define("l-control-layers",u),customElements.define("l-base-layers",l),customElements.define("l-overlay-layers",d),customElements.define("l-layer-group",s),customElements.define("l-tile-layer",b),customElements.define("l-marker",p),customElements.define("l-popup",f),customElements.define("l-lat-lng-bounds",h),customElements.define("l-image-overlay",y),customElements.define("l-video-overlay",m),void customElements.define("l-geojson",v)});
|
2
2
|
//# sourceMappingURL=leaflet-html.umd.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"leaflet-html.umd.js","sources":["../src/index.js"],"sourcesContent":["// @ts-check\n\n// Helpers\nconst selector = (noun) => `[data-${noun}]`;\n\n/**\n * Parse L.tileLayer args from element attributes\n */\nconst parseTileLayer = (el) => {\n const { urlTemplate } = el.dataset;\n const {\n attribution = null,\n maxZoom = \"18\",\n minZoom = \"0\",\n subdomains = \"abc\",\n } = el.dataset;\n const options = { attribution, maxZoom, minZoom, subdomains };\n return [urlTemplate, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseImageOverlay = (el) => {\n let { url, bounds } = el.dataset;\n bounds = JSON.parse(bounds);\n const { opacity } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n return [url, bounds, options];\n};\n\n/**\n * Parse L.imageOverlay args from element attributes\n */\nconst parseVideoOverlay = (el) => {\n let { url, bounds } = el.dataset;\n url = JSON.parse(url);\n bounds = JSON.parse(bounds);\n const {\n opacity,\n errorOverlayUrl,\n autoplay = true,\n muted = true,\n playsInline = true,\n } = el.dataset;\n const options = {\n opacity: parseFloat(opacity),\n errorOverlayUrl,\n autoplay,\n muted,\n playsInline,\n };\n return [url, bounds, options];\n};\n\n/**\n * @param {HTMLElement} el\n */\nconst parseLatLngBounds = (el) => {\n let { bounds } = el.dataset;\n if (typeof bounds === \"undefined\") {\n throw Error(\"data-bounds not specified\")\n }\n return [JSON.parse(bounds)];\n}\n\nconst render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(selector(\"leaflet-html\")).forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.latLngBounds\n el.querySelectorAll(selector(\"lat-lng-bounds\")).forEach((el) => {\n const bounds = L.latLngBounds(...parseLatLngBounds(el))\n // TODO: encapsulate this design pattern\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n let [bounds] = parseLatLngBounds(mutation.target)\n map.flyToBounds(bounds); // TODO: Use HTML attrs for fly/fit bounds\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-bounds\"],\n });\n map.fitBounds(bounds)\n })\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n L.tileLayer(...parseTileLayer(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"image-overlay\")).forEach((el) => {\n L.imageOverlay(...parseImageOverlay(el)).addTo(map);\n });\n\n el.querySelectorAll(selector(\"video-overlay\")).forEach((el) => {\n L.videoOverlay(...parseVideoOverlay(el)).addTo(map);\n });\n\n // L.control.layers\n el.querySelectorAll(selector(\"control-layers\")).forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(selector(\"tile-layer\")).forEach((el) => {\n const { name, show } = el.dataset;\n baseMaps[name] = L.tileLayer(...parseTileLayer(el));\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(selector(\"layer-group\")).forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(selector(\"marker\")).forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(selector(\"popup\")).forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["selector","noun","parseTileLayer","el","_el$dataset","dataset","_el$dataset$attributi","attribution","_el$dataset$maxZoom","maxZoom","_el$dataset$minZoom","minZoom","_el$dataset$subdomain","subdomains","urlTemplate","parseLatLngBounds","bounds","Error","JSON","parse","document","addEventListener","querySelectorAll","forEach","_el$dataset5","center","zoom","map","L","setView","parseInt","_L","latLngBounds","apply","MutationObserver","mutations","mutation","_parseLatLngBounds","target","flyToBounds","observe","attributes","attributeFilter","fitBounds","_L2","tileLayer","addTo","_L3","imageOverlay","_el$dataset2","url","opacity","parseFloat","parseImageOverlay","_L4","videoOverlay","_el$dataset3","_el$dataset4","errorOverlayUrl","_el$dataset4$autoplay","autoplay","_el$dataset4$muted","muted","_el$dataset4$playsInl","playsInline","parseVideoOverlay","baseMaps","_L5","_el$dataset6","name","show","overlayMaps","layers","group","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","childList","_el$dataset$opacity","options","stamp","setLatLng","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"8NAGA,IAAMA,EAAW,SAACC,GAAkBA,MAAAA,SAAAA,OAK9BC,EAAiB,SAACC,GACtB,IACAC,EAKID,EAAGE,QAAOC,EAAAF,EAJZG,YAAkBC,EAAAJ,EAClBK,QAAcC,EAAAN,EACdO,QAAaC,EAAAR,EACbS,WAGF,MAAO,CARiBV,EAAGE,QAAnBS,YAOQ,CAAEP,iBALL,IAAAD,EAAG,KAAIA,EAKWG,aAJnB,IAAHD,EAAG,KAAIA,EAIwBG,aAH/B,IAAAD,E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"file":"leaflet-html.umd.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer-group.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-tile-layer.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\"\nexport const popupAdd = \"popup:add\"\nexport const layerRemove = \"layer:remove\"\n","import { mapAddTo } from \"./events.js\"\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\"\n })\n }\n}\n\nexport default LBaseLayers\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const base = {}\n const overlay = {}\n const control = L.control.layers(base, overlay)\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail\n if (type === \"overlay\") {\n control.addOverlay(layer, name)\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name)\n }\n ev.preventDefault()\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LControlLayers\n","import { mapAddTo } from \"./events.js\"\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const group = L.layerGroup()\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name\n }\n })\n this.dispatchEvent(event)\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation()\n group.addLayer(ev.detail.layer)\n })\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true })\n }\n}\n\nexport default LLayerGroup\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\"\n\nclass LMap extends HTMLElement {\n constructor() {\n super()\n\n this.map = null\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail\n this.map[method](bounds)\n })\n }\n\n connectedCallback() {\n this.map = L.map(this)\n const center = this.getAttribute(\"center\")\n const zoom = this.getAttribute(\"zoom\")\n if ((center !== null) && (zoom !== null)) {\n this.map.setView(JSON.parse(center), parseInt(zoom))\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer\n layer.addTo(this.map)\n })\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer)\n })\n }\n}\n\nexport default LMap\n","import { mapAddTo, popupAdd } from \"./events.js\"; \n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const latLng = JSON.parse(this.getAttribute(\"lat-lng\"))\n const opacity = parseFloat(this.getAttribute(\"opacity\") || \"1.0\")\n this.layer = L.marker(latLng, { opacity });\n this.setAttribute(\"leaflet-id\", L.stamp(this.layer))\n\n this.addEventListener(popupAdd, (ev) => {\n const { content } = ev.detail\n this.layer.bindPopup(content)\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n })\n this.dispatchEvent(event)\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"lat-lng\") {\n this.layer.setLatLng(JSON.parse(newValue))\n }\n if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\n\nexport default LMarker\n","import { mapAddTo } from \"./events.js\"\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\"\n })\n }\n}\n\nexport default LOverlayLayers\n","import { popupAdd } from \"./events.js\"\n\nclass LPopup extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\")\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content\n }\n })\n this.dispatchEvent(event)\n }\n}\n\n\nexport default LPopup\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const urlTemplate = this.getAttribute(\"url-template\")\n const attribution = this.getAttribute(\"attribution\")\n const options = { attribution }\n const layer = L.tileLayer(urlTemplate, options)\n const event = new CustomEvent(mapAddTo, { detail: { name, layer }, bubbles: true})\n this.dispatchEvent(event)\n }\n}\n\nexport default LTileLayer\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"]\n\n constructor() {\n super()\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\"\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LLatLngBounds\n","import { mapAddTo } from \"./events.js\"\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\")\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\"\n }\n this.layer = L.imageOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n }))\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"url\") {\n this.layer.setUrl(newValue)\n } else if (name === \"bounds\") {\n this.layer.setBounds(JSON.parse(newValue))\n } else if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\nexport default LImageOverlay\n","import { mapAddTo } from \"./events.js\"\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"))\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true\n }\n const layer = L.videoOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LVideoOverlay\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")))\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LGeoJSON\n","// @ts-check\nimport LBaseLayers from \"./l-base-layers.js\";\nimport LControlLayers from \"./l-control-layers.js\"; \nimport LLayerGroup from \"./l-layer-group.js\"; \nimport LMap from \"./l-map.js\"; \nimport LMarker from \"./l-marker.js\"; \nimport LOverlayLayers from \"./l-overlay-layers.js\";\nimport LPopup from \"./l-popup.js\"; \nimport LTileLayer from \"./l-tile-layer.js\";\nimport LLatLngBounds from \"./l-lat-lng-bounds.js\";\nimport LImageOverlay from \"./l-image-overlay.js\";\nimport LVideoOverlay from \"./l-video-overlay.js\";\nimport LGeoJSON from \"./l-geojson.js\";\n\n\nconst init = (() => {\n // Custom elements (order of definition is important)\n customElements.define(\"l-map\", LMap)\n customElements.define(\"l-control-layers\", LControlLayers)\n customElements.define(\"l-base-layers\", LBaseLayers)\n customElements.define(\"l-overlay-layers\", LOverlayLayers)\n customElements.define(\"l-layer-group\", LLayerGroup)\n customElements.define(\"l-tile-layer\", LTileLayer)\n customElements.define(\"l-marker\", LMarker)\n customElements.define(\"l-popup\", LPopup)\n customElements.define(\"l-lat-lng-bounds\", LLatLngBounds)\n customElements.define(\"l-image-overlay\", LImageOverlay)\n customElements.define(\"l-video-overlay\", LVideoOverlay)\n customElements.define(\"l-geojson\", LGeoJSON)\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","control","L","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","_this","map","method","bounds","_this2","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","customElements","define"],"mappings":"k5CAAaA,EAAW,YACXC,EAAW,YCClBC,eAAW,SAAAC,GACf,SAAAD,IAAc,OACZC,EAAAC,KAAAC,OAAOA,IACT,CAMC,OANAC,EAAAJ,EAAAC,GAAAD,EAAAK,UAEDC,kBAAA,WACEH,KAAKI,iBAAiBT,EAAU,SAACU,GAC/BA,EAAGC,OAAa,KAAI,MACtB,EACF,EAACT,CAAA,CATc,cASdU,EATuBC,cCApBC,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