leaflet-html 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- var t=require("leaflet");function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e}var n=/*#__PURE__*/e(t);function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(r())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var a=new(t.bind.apply(t,i));return n&&o(a,n.prototype),a}(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)},l(t)}var s="map:addTo",u="popup:add",c=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(s,function(t){t.detail.type="base"})},e}(/*#__PURE__*/l(HTMLElement)),p=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=t.control.layers({},{});this.addEventListener(s,function(t){var n=t.detail,r=n.type,i=n.name,a=n.layer;"overlay"===r?e.addOverlay(a,i):"base"===r&&e.addBaseLayer(a,i),t.preventDefault()});var n=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{layer:e}});this.dispatchEvent(n)},n}(/*#__PURE__*/l(HTMLElement)),d=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=t.layerGroup(),r=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{layer:n,name:e}});this.dispatchEvent(r),this.addEventListener(s,function(t){t.stopPropagation(),n.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var e=t.getAttribute("leaflet-id");if(null!==e){var r=n.getLayer(parseInt(e));void 0!==r&&n.removeLayer(r)}}})})}).observe(this,{childList:!0})},n}(/*#__PURE__*/l(HTMLElement)),f=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=this.getAttribute("url-template");if(null!==n){var r={},i="attribution";this.hasAttribute(i)&&(r[i]=this.getAttribute(i)),this.layer=t.tileLayer(n,r);var a=new CustomEvent(s,{detail:{name:e,layer:this.layer},bubbles:!0});this.dispatchEvent(a)}},n}(/*#__PURE__*/l(HTMLElement)),h=/*#__PURE__*/function(t){function e(){var n;return(n=t.call(this)||this).map=null,n.addEventListener("map:bounds",function(t){var e=t.detail;null!==n.map&&n.map[e.method](e.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof e){var n=t.target;t.removedNodes.forEach(function(t){t instanceof f&&null!==n.map&&null!==t.layer&&n.map.removeLayer(t.layer)})}})}).observe(n,{childList:!0}),n}return i(e,t),e.prototype.connectedCallback=function(){var t=this;this.map=n.map(this);var e=this.getAttribute("center"),r=this.getAttribute("zoom");null!==e&&null!==r&&this.map.setView(JSON.parse(e),parseInt(r)),this.addEventListener(s,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){null!==t.map&&t.map.removeLayer(e.detail.layer)})},e}(/*#__PURE__*/l(HTMLElement)),b=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e.addEventListener("icon:add",function(t){t.stopPropagation(),e.layer.setIcon(t.detail.icon)}),e}i(e,t);var r=e.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=n.marker(e,{opacity:r}),this.hasAttribute("icon")){var i=n.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(i)}this.setAttribute("leaflet-id",n.stamp(this.layer)),this.addEventListener(u,function(e){t.layer.bindPopup(e.detail.content)});var a=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(a)},r.attributeChangedCallback=function(t,e,r){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(r)),"opacity"===t&&this.layer.setOpacity(parseFloat(r)),"icon"===t&&this.layer.setIcon(n.icon(JSON.parse(r))))},e}(/*#__PURE__*/l(HTMLElement));b.observedAttributes=["lat-lng","opacity","icon"];var y=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(s,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/l(HTMLElement)),v=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/l(HTMLElement)),m=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.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)},e}(/*#__PURE__*/l(HTMLElement));m.observedAttributes=["bounds"];var E=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}i(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this.getAttribute("url");if(null!==e){var n=this.getAttribute("bounds");if(null!==n){var r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=t.imageOverlay(e,JSON.parse(n),r),this.dispatchEvent(new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},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__*/l(HTMLElement));E.observedAttributes=["url","bounds","opacity"];var g=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=JSON.parse(this.getAttribute("url")),n=JSON.parse(this.getAttribute("bounds")),r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},i=t.videoOverlay(e,n,r);this.dispatchEvent(new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{layer:i}}))},n}(/*#__PURE__*/l(HTMLElement)),O=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("geojson");if(null!==e){var n=t.geoJSON(JSON.parse(e));this.dispatchEvent(new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:{layer:n}}))}},n}(/*#__PURE__*/l(HTMLElement)),L=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},A=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).icon=null,e}return i(e,t),e.prototype.connectedCallback=function(){var t=this,e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=t.getAttribute(n))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=JSON.parse(t.getAttribute(n)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=n.icon(e);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},e}(/*#__PURE__*/l(HTMLElement)),C=(customElements.define("l-map",h),customElements.define("l-control-layers",p),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",y),customElements.define("l-layer-group",d),customElements.define("l-tile-layer",f),customElements.define("l-marker",b),customElements.define("l-popup",v),customElements.define("l-lat-lng-bounds",m),customElements.define("l-image-overlay",E),customElements.define("l-video-overlay",g),customElements.define("l-geojson",O),void customElements.define("l-icon",A));module.exports=C;
1
+ var t=require("leaflet");function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e}var n=/*#__PURE__*/e(t);function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(r())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,e);var i=new(t.bind.apply(t,a));return n&&o(i,n.prototype),i}(t,arguments,i(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)},l(t)}var u="map:addTo",s="popup:add",c=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return a(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="base"})},e}(/*#__PURE__*/l(HTMLElement)),p=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return a(n,e),n.prototype.connectedCallback=function(){var e=t.control.layers({},{});this.addEventListener(u,function(t){var n=t.detail,r=n.type,a=n.name,i=n.layer;"overlay"===r?e.addOverlay(i,a):"base"===r&&e.addBaseLayer(i,a),t.preventDefault()});var n=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:e}});this.dispatchEvent(n)},n}(/*#__PURE__*/l(HTMLElement)),f=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return a(e,t),e}(/*#__PURE__*/l(HTMLElement)),h=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return a(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=t.layerGroup();this.layer=n;var r=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:n,name:e}});this.dispatchEvent(r),this.addEventListener(u,function(t){t.stopPropagation(),n.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var e=t.getAttribute("leaflet-id");if(null!==e){var r=n.getLayer(parseInt(e));void 0!==r&&n.removeLayer(r)}}})})}).observe(this,{childList:!0})},n}(f),d=/*#__PURE__*/function(t){function e(){var n;return(n=t.call(this)||this).map=null,n.addEventListener("map:bounds",function(t){var e=t.detail;null!==n.map&&n.map[e.method](e.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof e){var n=t.target;t.removedNodes.forEach(function(t){t instanceof f&&null!==n.map&&null!==t.layer&&n.map.removeLayer(t.layer)})}})}).observe(n,{childList:!0}),n}return a(e,t),e.prototype.connectedCallback=function(){var t=this;this.map=n.map(this);var e=this.getAttribute("center"),r=this.getAttribute("zoom");null!==e&&null!==r&&this.map.setView(JSON.parse(e),parseInt(r)),this.addEventListener(u,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){null!==t.map&&t.map.removeLayer(e.detail.layer)})},e}(/*#__PURE__*/l(HTMLElement)),b=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e.addEventListener("icon:add",function(t){t.stopPropagation(),e.layer.setIcon(t.detail.icon)}),e}a(e,t);var r=e.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=n.marker(e,{opacity:r}),this.hasAttribute("icon")){var a=n.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(a)}this.setAttribute("leaflet-id",n.stamp(this.layer)),this.addEventListener(s,function(e){t.layer.bindPopup(e.detail.content)});var i=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(i)},r.attributeChangedCallback=function(t,e,r){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(r)),"opacity"===t&&this.layer.setOpacity(parseFloat(r)),"icon"===t&&this.layer.setIcon(n.icon(JSON.parse(r))))},e}(f);b.observedAttributes=["lat-lng","opacity","icon"];var y=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return a(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/l(HTMLElement)),v=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return a(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/l(HTMLElement)),m=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return a(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=this.getAttribute("url-template");if(null!==n){var r={},a="attribution";this.hasAttribute(a)&&(r[a]=this.getAttribute(a)),this.layer=t.tileLayer(n,r);var i=new CustomEvent(u,{detail:{name:e,layer:this.layer},bubbles:!0});this.dispatchEvent(i)}},n}(f),E=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return a(e,t),e.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)},e}(/*#__PURE__*/l(HTMLElement));E.observedAttributes=["bounds"];var g=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}a(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this.getAttribute("url");if(null!==e){var n=this.getAttribute("bounds");if(null!==n){var r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=t.imageOverlay(e,JSON.parse(n),r),this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},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}(f);g.observedAttributes=["url","bounds","opacity"];var O=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return a(n,e),n.prototype.connectedCallback=function(){var e=JSON.parse(this.getAttribute("url")),n=JSON.parse(this.getAttribute("bounds")),r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},a=t.videoOverlay(e,n,r);this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:a}}))},n}(f),A=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return a(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("geojson");if(null!==e){var n=t.geoJSON(JSON.parse(e));this.dispatchEvent(new CustomEvent(u,{bubbles:!0,cancelable:!0,detail:{layer:n}}))}},n}(/*#__PURE__*/l(HTMLElement)),L=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},C=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).icon=null,e}return a(e,t),e.prototype.connectedCallback=function(){var t=this,e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=t.getAttribute(n))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=JSON.parse(t.getAttribute(n)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=n.icon(e);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},e}(/*#__PURE__*/l(HTMLElement)),w=(customElements.define("l-map",d),customElements.define("l-control-layers",p),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",y),customElements.define("l-layer-group",h),customElements.define("l-tile-layer",m),customElements.define("l-marker",b),customElements.define("l-popup",v),customElements.define("l-lat-lng-bounds",E),customElements.define("l-image-overlay",g),customElements.define("l-video-overlay",O),customElements.define("l-geojson",A),void customElements.define("l-icon",C));module.exports=w;
2
2
  //# sourceMappingURL=leaflet-html.cjs.map
@@ -1 +1 @@
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-tile-layer.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { 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 = 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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LTileLayer from \"./l-tile-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LTileLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { 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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { 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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","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","parseInt","removeLayer","observe","childList","LTileLayer","_this","urlTemplate","options","key","hasAttribute","tileLayer","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","init","customElements","define"],"mappings":"m/CAAaA,EAAW,YACXC,EAAW,YCElBC,eAAWC,SAAAA,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,CATcC,cASdS,EATuBC,cCEpBC,eAAc,SAAAX,GAClB,SAAAW,IAAc,OACZX,EAAAC,K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KtB,CACnB,CA+CC+D,OA/CA1G,EAAA0G,EAAA7G,GAAA6G,EAAAzG,UAEDC,kBAAA,WAAoB,IAAAqD,EAClBxD,KAAM8C,EAAU,CAAA,EAGL,CACT,WACA,kBACA,aACA,oBACA,cAEGb,QAAQ,SAACc,GACRS,EAAKR,aAAaD,KACpBD,EAAQwD,EAAUvD,IAAQS,EAAK9B,aAAaqB,GAEhD,GAGa,CACX,cACA,YACA,gBACA,cACA,iBACA,gBAEKd,QAAQ,SAACc,GACVS,EAAKR,aAAaD,KACpBD,EAAQwD,EAAUvD,IAAQc,KAAKC,MAAMN,EAAK9B,aAAaqB,IAE3D,GAEI/C,KAAKgD,aAAa,kBACpBF,EAAQ8D,YAAoD,SAAtC5G,KAAK0B,aAAa,iBAE1C1B,KAAKkE,KAAOT,EAAES,KAAKpB,GAEnB,IAAM1B,EAAQ,IAAIC,YAAY,WAAY,CACxCC,YAAY,EACZC,SAAS,EACTjB,OAAQ,CACN4D,KAAMlE,KAAKkE,QAGflE,KAAKwB,cAAcJ,EACrB,EAACuF,CAAA,eAAApG,EAnDiBC,cCUdqG,GAEJC,eAAeC,OAAO,QAAS7D,GAC/B4D,eAAeC,OAAO,mBAAoBtG,GAC1CqG,eAAeC,OAAO,gBAAiBlH,GACvCiH,eAAeC,OAAO,mBAAoB7B,GAC1C4B,eAAeC,OAAO,gBAAiBtF,GACvCqF,eAAeC,OAAO,eAAgBpE,GACtCmE,eAAeC,OAAO,WAAY/C,GAClC8C,eAAeC,OAAO,UAAW5B,GACjC2B,eAAeC,OAAO,mBAAoB3B,GAC1C0B,eAAeC,OAAO,kBAAmBzB,GACzCwB,eAAeC,OAAO,kBAAmBjB,GACzCgB,eAAeC,OAAO,YAAaZ,QACnCW,eAAeC,OAAO,SAAUJ"}
1
+ {"version":3,"file":"leaflet-html.cjs","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer.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/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","class LLayer extends HTMLElement {\n constructor() {\n super()\n this.layer = null\n }\n}\n\nexport default LLayer\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LLayerGroup extends LLayer {\n constructor() {\n super();\n this.layer = null;\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const group = layerGroup();\n this.layer = group;\n\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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LMarker extends LLayer {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LTileLayer extends LLayer {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LImageOverlay extends LLayer {\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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LVideoOverlay extends LLayer {\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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayer","_this","LLayerGroup","_LLayer","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","parseInt","removeLayer","observe","childList","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","hasAttribute","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","options","key","tileLayer","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","init","customElements","define"],"mappings":"m/CAAaA,EAAW,YACXC,EAAW,YCElBC,e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,OAAO,gBAAiBpH,GACvCmH,eAAeC,OAAO,mBAAoBlC,GAC1CiC,eAAeC,OAAO,gBAAiBtF,GACvCqF,eAAeC,OAAO,eAAgBhC,GACtC+B,eAAeC,OAAO,WAAYrD,GAClCoD,eAAeC,OAAO,UAAWjC,GACjCgC,eAAeC,OAAO,mBAAoB3B,GAC1C0B,eAAeC,OAAO,kBAAmBzB,GACzCwB,eAAeC,OAAO,kBAAmBjB,GACzCgB,eAAeC,OAAO,YAAaZ,QACnCW,eAAeC,OAAO,SAAUJ"}
@@ -1,2 +1,2 @@
1
- import*as t from"leaflet";import{control as e,layerGroup as n,tileLayer as r,imageOverlay as i,videoOverlay as o,geoJSON as a}from"leaflet";function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&u(i,n.prototype),i}(t,arguments,s(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},d(t)}var p="map:addTo",h="popup:add",f=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){this.addEventListener(p,function(t){t.detail.type="base"})},e}(/*#__PURE__*/d(HTMLElement)),b=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return c(n,t),n.prototype.connectedCallback=function(){var t=e.layers({},{});this.addEventListener(p,function(e){var n=e.detail,r=n.type,i=n.name,o=n.layer;"overlay"===r?t.addOverlay(o,i):"base"===r&&t.addBaseLayer(o,i),e.preventDefault()});var n=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(n)},n}(/*#__PURE__*/d(HTMLElement)),m=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=n(),r=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(r),this.addEventListener(p,function(t){t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var n=t.getAttribute("leaflet-id");if(null!==n){var r=e.getLayer(parseInt(n));void 0!==r&&e.removeLayer(r)}}})})}).observe(this,{childList:!0})},e}(/*#__PURE__*/d(HTMLElement)),v=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=this.getAttribute("url-template");if(null!==e){var n={},i="attribution";this.hasAttribute(i)&&(n[i]=this.getAttribute(i)),this.layer=r(e,n);var o=new CustomEvent(p,{detail:{name:t,layer:this.layer},bubbles:!0});this.dispatchEvent(o)}},e}(/*#__PURE__*/d(HTMLElement)),y=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).map=null,t.addEventListener("map:bounds",function(e){var n=e.detail;null!==t.map&&t.map[n.method](n.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof n){var e=t.target;t.removedNodes.forEach(function(t){t instanceof v&&null!==e.map&&null!==t.layer&&e.map.removeLayer(t.layer)})}})}).observe(t,{childList:!0}),t}return c(n,e),n.prototype.connectedCallback=function(){var e=this;this.map=t.map(this);var n=this.getAttribute("center"),r=this.getAttribute("zoom");null!==n&&null!==r&&this.map.setView(JSON.parse(n),parseInt(r)),this.addEventListener(p,function(t){t.detail.layer.addTo(e.map)}),this.addEventListener("layer:remove",function(t){null!==e.map&&e.map.removeLayer(t.detail.layer)})},n}(/*#__PURE__*/d(HTMLElement)),E=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t.addEventListener("icon:add",function(e){e.stopPropagation(),t.layer.setIcon(e.detail.icon)}),t}c(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this,n=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=t.marker(n,{opacity:r}),this.hasAttribute("icon")){var i=t.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(i)}this.setAttribute("leaflet-id",t.stamp(this.layer)),this.addEventListener(h,function(t){e.layer.bindPopup(t.detail.content)});var o=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(o)},r.attributeChangedCallback=function(e,n,r){null!==this.layer&&("lat-lng"===e&&this.layer.setLatLng(JSON.parse(r)),"opacity"===e&&this.layer.setOpacity(parseFloat(r)),"icon"===e&&this.layer.setIcon(t.icon(JSON.parse(r))))},n}(/*#__PURE__*/d(HTMLElement));if(E.observedAttributes=["lat-lng","opacity","icon"],import.meta.vitest){var g=import.meta.vitest,A=g.it,w=g.expect;(0,g.beforeAll)(function(){customElements.define("l-marker",E)}),A("default icon",function(){var e=document.createElement("l-marker");document.body.appendChild(e);var n=e.layer.getIcon(),r=new t.Icon.Default;w(n).toEqual(r)}),A("adds an icon",function(){var e=document.createElement("l-marker");e.setAttribute("icon",JSON.stringify({iconUrl:"foo.png"})),document.body.appendChild(e);var n=e.layer.getIcon(),r=t.icon({iconUrl:"foo.png"});w(n).toEqual(r)}),A("changes an icon",function(){var e=document.createElement("l-marker");document.body.appendChild(e),e.setAttribute("icon",JSON.stringify({iconUrl:"bar.png"}));var n=e.layer.getIcon(),r=t.icon({iconUrl:"bar.png"});w(n).toEqual(r)})}var C=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){this.addEventListener(p,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/d(HTMLElement)),O=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(h,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/d(HTMLElement)),L=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.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)},e}(/*#__PURE__*/d(HTMLElement));L.observedAttributes=["bounds"];var S=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}c(e,t);var n=e.prototype;return n.connectedCallback=function(){var t=this.getAttribute("url");if(null!==t){var e=this.getAttribute("bounds");if(null!==e){var n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=i(t,JSON.parse(e),n),this.dispatchEvent(new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},n.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)))},e}(/*#__PURE__*/d(HTMLElement));S.observedAttributes=["url","bounds","opacity"];var k=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.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=o(t,e,n);this.dispatchEvent(new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:r}}))},e}(/*#__PURE__*/d(HTMLElement)),M=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("geojson");if(null!==t){var e=a(JSON.parse(t));this.dispatchEvent(new CustomEvent(p,{bubbles:!0,cancelable:!0,detail:{layer:e}}))}},e}(/*#__PURE__*/d(HTMLElement)),N=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},T=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).icon=null,t}return c(n,e),n.prototype.connectedCallback=function(){var e=this,n={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(t){e.hasAttribute(t)&&(n[N(t)]=e.getAttribute(t))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(t){e.hasAttribute(t)&&(n[N(t)]=JSON.parse(e.getAttribute(t)))}),this.hasAttribute("cross-origin")&&(n.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=t.icon(n);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},n}(/*#__PURE__*/d(HTMLElement));if(import.meta.vitest){var H=import.meta.vitest,J=H.it,P=H.expect;(0,H.beforeAll)(function(){customElements.define("l-icon",T)}),J("default",function(){var e=document.createElement("l-icon");document.body.appendChild(e);var n=e.icon,r=t.icon();P(n).toEqual(r)}),J("emits icon:add event",function(){try{var e=document.createElement("l-icon"),n=new Promise(function(t){e.addEventListener("icon:add",function(e){t(e.detail.icon)})});return document.body.appendChild(e),Promise.resolve(n).then(function(e){var n=t.icon();P(e).toEqual(n)})}catch(t){return Promise.reject(t)}}),J("options",function(){var e=document.createElement("l-icon");e.setAttribute("icon-url","url.png"),e.setAttribute("icon-retina-url","retina.png"),e.setAttribute("icon-size","[0, 0]"),e.setAttribute("icon-anchor","[0, 0]"),e.setAttribute("popup-anchor","[0, 0]"),e.setAttribute("tooltip-anchor","[0, 0]"),e.setAttribute("shadow-url","urlShadow.png"),e.setAttribute("shadow-retina-url","retinaShadow.png"),e.setAttribute("shadow-size","[0, 0]"),e.setAttribute("shadow-anchor","[0, 0]"),e.setAttribute("class-name","foo"),e.setAttribute("cross-origin","true"),document.body.appendChild(e);var n=e.icon,r=t.icon({iconUrl:"url.png",iconRetinaUrl:"retina.png",iconSize:[0,0],iconAnchor:[0,0],popupAnchor:[0,0],tooltipAnchor:[0,0],shadowUrl:"urlShadow.png",shadowRetinaUrl:"retinaShadow.png",shadowSize:[0,0],shadowAnchor:[0,0],className:"foo",crossOrigin:!0});P(n).toEqual(r)})}var j=(customElements.define("l-map",y),customElements.define("l-control-layers",b),customElements.define("l-base-layers",f),customElements.define("l-overlay-layers",C),customElements.define("l-layer-group",m),customElements.define("l-tile-layer",v),customElements.define("l-marker",E),customElements.define("l-popup",O),customElements.define("l-lat-lng-bounds",L),customElements.define("l-image-overlay",S),customElements.define("l-video-overlay",k),customElements.define("l-geojson",M),void customElements.define("l-icon",T));export{j as default};
1
+ import*as t from"leaflet";import{control as e,layerGroup as n,tileLayer as r,imageOverlay as i,videoOverlay as o,geoJSON as a}from"leaflet";function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(l=function(){return!!t})()}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,s(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&s(i,n.prototype),i}(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,t)},d(t)}var p="map:addTo",h="popup:add",f=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){this.addEventListener(p,function(t){t.detail.type="base"})},e}(/*#__PURE__*/d(HTMLElement)),b=/*#__PURE__*/function(t){function n(){return t.call(this)||this}return c(n,t),n.prototype.connectedCallback=function(){var t=e.layers({},{});this.addEventListener(p,function(e){var n=e.detail,r=n.type,i=n.name,o=n.layer;"overlay"===r?t.addOverlay(o,i):"base"===r&&t.addBaseLayer(o,i),e.preventDefault()});var n=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(n)},n}(/*#__PURE__*/d(HTMLElement)),m=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return c(e,t),e}(/*#__PURE__*/d(HTMLElement)),v=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=n();this.layer=e;var r=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(r),this.addEventListener(p,function(t){t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var n=t.getAttribute("leaflet-id");if(null!==n){var r=e.getLayer(parseInt(n));void 0!==r&&e.removeLayer(r)}}})})}).observe(this,{childList:!0})},e}(m),y=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).map=null,t.addEventListener("map:bounds",function(e){var n=e.detail;null!==t.map&&t.map[n.method](n.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof n){var e=t.target;t.removedNodes.forEach(function(t){t instanceof m&&null!==e.map&&null!==t.layer&&e.map.removeLayer(t.layer)})}})}).observe(t,{childList:!0}),t}return c(n,e),n.prototype.connectedCallback=function(){var e=this;this.map=t.map(this);var n=this.getAttribute("center"),r=this.getAttribute("zoom");null!==n&&null!==r&&this.map.setView(JSON.parse(n),parseInt(r)),this.addEventListener(p,function(t){t.detail.layer.addTo(e.map)}),this.addEventListener("layer:remove",function(t){null!==e.map&&e.map.removeLayer(t.detail.layer)})},n}(/*#__PURE__*/d(HTMLElement)),E=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t.addEventListener("icon:add",function(e){e.stopPropagation(),t.layer.setIcon(e.detail.icon)}),t}c(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this,n=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=t.marker(n,{opacity:r}),this.hasAttribute("icon")){var i=t.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(i)}this.setAttribute("leaflet-id",t.stamp(this.layer)),this.addEventListener(h,function(t){e.layer.bindPopup(t.detail.content)});var o=new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(o)},r.attributeChangedCallback=function(e,n,r){null!==this.layer&&("lat-lng"===e&&this.layer.setLatLng(JSON.parse(r)),"opacity"===e&&this.layer.setOpacity(parseFloat(r)),"icon"===e&&this.layer.setIcon(t.icon(JSON.parse(r))))},n}(m);if(E.observedAttributes=["lat-lng","opacity","icon"],import.meta.vitest){var g=import.meta.vitest,A=g.it,w=g.expect;(0,g.beforeAll)(function(){customElements.define("l-marker",E)}),A("default icon",function(){var e=document.createElement("l-marker");document.body.appendChild(e);var n=e.layer.getIcon(),r=new t.Icon.Default;w(n).toEqual(r)}),A("adds an icon",function(){var e=document.createElement("l-marker");e.setAttribute("icon",JSON.stringify({iconUrl:"foo.png"})),document.body.appendChild(e);var n=e.layer.getIcon(),r=t.icon({iconUrl:"foo.png"});w(n).toEqual(r)}),A("changes an icon",function(){var e=document.createElement("l-marker");document.body.appendChild(e),e.setAttribute("icon",JSON.stringify({iconUrl:"bar.png"}));var n=e.layer.getIcon(),r=t.icon({iconUrl:"bar.png"});w(n).toEqual(r)})}var C=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){this.addEventListener(p,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/d(HTMLElement)),O=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(h,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/d(HTMLElement)),L=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("name"),e=this.getAttribute("url-template");if(null!==e){var n={},i="attribution";this.hasAttribute(i)&&(n[i]=this.getAttribute(i)),this.layer=r(e,n);var o=new CustomEvent(p,{detail:{name:t,layer:this.layer},bubbles:!0});this.dispatchEvent(o)}},e}(m),S=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.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)},e}(/*#__PURE__*/d(HTMLElement));S.observedAttributes=["bounds"];var k=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}c(e,t);var n=e.prototype;return n.connectedCallback=function(){var t=this.getAttribute("url");if(null!==t){var e=this.getAttribute("bounds");if(null!==e){var n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=i(t,JSON.parse(e),n),this.dispatchEvent(new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},n.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)))},e}(m);k.observedAttributes=["url","bounds","opacity"];var N=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.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=o(t,e,n);this.dispatchEvent(new CustomEvent(p,{cancelable:!0,bubbles:!0,detail:{layer:r}}))},e}(m),J=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return c(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("geojson");if(null!==t){var e=a(JSON.parse(t));this.dispatchEvent(new CustomEvent(p,{bubbles:!0,cancelable:!0,detail:{layer:e}}))}},e}(/*#__PURE__*/d(HTMLElement)),M=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},T=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).icon=null,t}return c(n,e),n.prototype.connectedCallback=function(){var e=this,n={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(t){e.hasAttribute(t)&&(n[M(t)]=e.getAttribute(t))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(t){e.hasAttribute(t)&&(n[M(t)]=JSON.parse(e.getAttribute(t)))}),this.hasAttribute("cross-origin")&&(n.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=t.icon(n);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},n}(/*#__PURE__*/d(HTMLElement));if(import.meta.vitest){var P=import.meta.vitest,j=P.it,H=P.expect;(0,P.beforeAll)(function(){customElements.define("l-icon",T)}),j("default",function(){var e=document.createElement("l-icon");document.body.appendChild(e);var n=e.icon,r=t.icon();H(n).toEqual(r)}),j("emits icon:add event",function(){try{var e=document.createElement("l-icon"),n=new Promise(function(t){e.addEventListener("icon:add",function(e){t(e.detail.icon)})});return document.body.appendChild(e),Promise.resolve(n).then(function(e){var n=t.icon();H(e).toEqual(n)})}catch(t){return Promise.reject(t)}}),j("options",function(){var e=document.createElement("l-icon");e.setAttribute("icon-url","url.png"),e.setAttribute("icon-retina-url","retina.png"),e.setAttribute("icon-size","[0, 0]"),e.setAttribute("icon-anchor","[0, 0]"),e.setAttribute("popup-anchor","[0, 0]"),e.setAttribute("tooltip-anchor","[0, 0]"),e.setAttribute("shadow-url","urlShadow.png"),e.setAttribute("shadow-retina-url","retinaShadow.png"),e.setAttribute("shadow-size","[0, 0]"),e.setAttribute("shadow-anchor","[0, 0]"),e.setAttribute("class-name","foo"),e.setAttribute("cross-origin","true"),document.body.appendChild(e);var n=e.icon,r=t.icon({iconUrl:"url.png",iconRetinaUrl:"retina.png",iconSize:[0,0],iconAnchor:[0,0],popupAnchor:[0,0],tooltipAnchor:[0,0],shadowUrl:"urlShadow.png",shadowRetinaUrl:"retinaShadow.png",shadowSize:[0,0],shadowAnchor:[0,0],className:"foo",crossOrigin:!0});H(n).toEqual(r)})}var I=(customElements.define("l-map",y),customElements.define("l-control-layers",b),customElements.define("l-base-layers",f),customElements.define("l-overlay-layers",C),customElements.define("l-layer-group",v),customElements.define("l-tile-layer",L),customElements.define("l-marker",E),customElements.define("l-popup",O),customElements.define("l-lat-lng-bounds",S),customElements.define("l-image-overlay",k),customElements.define("l-video-overlay",N),customElements.define("l-geojson",J),void customElements.define("l-icon",T));export{I as default};
2
2
  //# sourceMappingURL=leaflet-html.js.map
@@ -1 +1 @@
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-tile-layer.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { 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 = 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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LTileLayer from \"./l-tile-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LTileLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { 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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { 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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","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","parseInt","removeLayer","observe","childList","LTileLayer","_this","urlTemplate","options","key","hasAttribute","tileLayer","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","vitest","_import$meta$vitest","it","expect","beforeAll","customElements","define","document","createElement","body","appendChild","actual","getIcon","expected","Icon","Default","toEqual","stringify","iconUrl","LOverlayLayers","LPopup","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","promise","Promise","resolve","then","e","reject","iconRetinaUrl","iconSize","iconAnchor","popupAnchor","tooltipAnchor","shadowUrl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,eAAeC,OAAO,kBAAmBiB,GACzClB,eAAeC,OAAO,kBAAmByB,GACzC1B,eAAeC,OAAO,YAAa8B,QACnC/B,eAAeC,OAAO,SAAUsC"}
1
+ {"version":3,"file":"leaflet-html.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer.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/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","class LLayer extends HTMLElement {\n constructor() {\n super()\n this.layer = null\n }\n}\n\nexport default LLayer\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LLayerGroup extends LLayer {\n constructor() {\n super();\n this.layer = null;\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const group = layerGroup();\n this.layer = group;\n\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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LMarker extends LLayer {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LTileLayer extends LLayer {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LImageOverlay extends LLayer {\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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LVideoOverlay extends LLayer {\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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayer","_this","LLayerGroup","_LLayer","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","parseInt","removeLayer","observe","childList","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","hasAttribute","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","vitest","_import$meta$vitest","it","expect","beforeAll","customElements","define","document","createElement","body","appendChild","actual","getIcon","expected","Icon","Default","toEqual","stringify","iconUrl","LOverlayLayers","LPopup","LTileLayer","urlTemplate","options","key","tileLayer","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","promise","Promise","resolve","then","e","reject","iconRetinaUrl","iconSize","iconAnchor","popupAnchor","tooltipAnchor","shadowUrl","shadowRetinaUrl","shadowSize","shadowAnchor","className","init"],"mappings":"g0CAAaA,EAAW,YACXC,EAAW,YCElBC,eAAWC,SAAAA,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,CATcC,cASdS,EATuBC,cCEpBC,eAAc,SAAAX,GAClB,SAAAW,IAAc,OACZX,EAAAC,KAAMC,WACR,CA2BC,OA3BAC,EAAAQ,EAAAX,GAAAW,EAAAP,UAEDC,kBAAA,WAEE,IAGMO,EAAgBC,EAAQC,OAHjB,CAAA,EAEG,CAAE,GAGlBZ,KAAKI,iBAAiBT,EAAU,SAACU,GAC/B,IAAAQ,EAA8BR,EAAGC,OAAzBQ,EAAID,EAAJC,KAAMC,EAAIF,EAAJE,KAAMC,EAAKH,EAALG,MACP,YAATF,EACFJ,EAAcO,WAAWD,EAAOD,GACd,SAATD,GACTJ,EAAcQ,aAAaF,EAAOD,GAEpCV,EAAGc,gBACL,GAEA,IAAMC,EAAQ,IAAIC,YAAY1B,EAAU,CACtC2B,YAAY,EACZC,SAAS,EACTjB,OAAQ,CACNU,MAAON,KAGXV,KAAKwB,cAAcJ,EACrB,EAACX,CAAA,CA9BiB,cA8B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,EAAG,GACdC,WAAY,CAAC,EAAG,GAChBC,YAAa,CAAC,EAAG,GACjBC,cAAe,CAAC,EAAG,GACnBC,UAAW,gBACXC,gBAAiB,mBACjBC,WAAY,CAAC,EAAG,GAChBC,aAAc,CAAC,EAAG,GAClBC,UAAW,MACXhB,aAAa,IAEf/C,EAAOQ,GAAQK,QAAQH,EACzB,EACF,CC1GM,IAAAsD,GAEJ9D,eAAeC,OAAO,QAASvC,GAC/BsC,eAAeC,OAAO,mBAAoB5E,GAC1C2E,eAAeC,OAAO,gBAAiBxF,GACvCuF,eAAeC,OAAO,mBAAoBa,GAC1Cd,eAAeC,OAAO,gBAAiB1D,GACvCyD,eAAeC,OAAO,eAAgBe,GACtChB,eAAeC,OAAO,WAAYzB,GAClCwB,eAAeC,OAAO,UAAWc,GACjCf,eAAeC,OAAO,mBAAoBoB,GAC1CrB,eAAeC,OAAO,kBAAmBsB,GACzCvB,eAAeC,OAAO,kBAAmB8B,GACzC/B,eAAeC,OAAO,YAAamC,QACnCpC,eAAeC,OAAO,SAAU2C"}
@@ -1,2 +1,2 @@
1
- import*as t from"leaflet";import{control as e,layerGroup as n,tileLayer as s,imageOverlay as a,videoOverlay as o,geoJSON as i}from"leaflet";const l="map:addTo",r="popup:add";class c extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(l,t=>{t.detail.type="base"})}}class u extends HTMLElement{constructor(){super()}connectedCallback(){const t=e.layers({},{});this.addEventListener(l,e=>{const{type:n,name:s,layer:a}=e.detail;"overlay"===n?t.addOverlay(a,s):"base"===n&&t.addBaseLayer(a,s),e.preventDefault()});const n=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(n)}}class d extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("name"),e=n(),s=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(s),this.addEventListener(l,t=>{t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(t=>{t.removedNodes.forEach(t=>{if(t instanceof HTMLElement){const n=t.getAttribute("leaflet-id");if(null!==n){const t=e.getLayer(parseInt(n));void 0!==t&&e.removeLayer(t)}}})})}).observe(this,{childList:!0})}}class h extends HTMLElement{constructor(){super(),this.layer=null}connectedCallback(){const t=this.getAttribute("name"),e=this.getAttribute("url-template");if(null===e)return;const n={},a="attribution";this.hasAttribute(a)&&(n[a]=this.getAttribute(a)),this.layer=s(e,n);const o=new CustomEvent(l,{detail:{name:t,layer:this.layer},bubbles:!0});this.dispatchEvent(o)}}class p extends HTMLElement{constructor(){super(),this.map=null,this.addEventListener("map:bounds",t=>{const{bounds:e,method:n}=t.detail;null!==this.map&&this.map[n](e)}),new MutationObserver(function(t){t.forEach(t=>{if(t.target instanceof p){const e=t.target;t.removedNodes.forEach(t=>{t instanceof h&&null!==e.map&&null!==t.layer&&e.map.removeLayer(t.layer)})}})}).observe(this,{childList:!0})}connectedCallback(){this.map=t.map(this);const e=this.getAttribute("center"),n=this.getAttribute("zoom");null!==e&&null!==n&&this.map.setView(JSON.parse(e),parseInt(n)),this.addEventListener(l,t=>{t.detail.layer.addTo(this.map)}),this.addEventListener("layer:remove",t=>{null!==this.map&&this.map.removeLayer(t.detail.layer)})}}class b extends HTMLElement{constructor(){super(),this.layer=null,this.addEventListener("icon:add",t=>{t.stopPropagation(),this.layer.setIcon(t.detail.icon)})}connectedCallback(){const e=JSON.parse(this.getAttribute("lat-lng")),n=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=t.marker(e,{opacity:n}),this.hasAttribute("icon")){const e=t.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(e)}this.setAttribute("leaflet-id",t.stamp(this.layer)),this.addEventListener(r,t=>{const{content:e}=t.detail;this.layer.bindPopup(e)});const s=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(s)}attributeChangedCallback(e,n,s){null!==this.layer&&("lat-lng"===e&&this.layer.setLatLng(JSON.parse(s)),"opacity"===e&&this.layer.setOpacity(parseFloat(s)),"icon"===e&&this.layer.setIcon(t.icon(JSON.parse(s))))}}if(b.observedAttributes=["lat-lng","opacity","icon"],import.meta.vitest){const{it:e,expect:n,beforeAll:s}=import.meta.vitest;s(()=>{customElements.define("l-marker",b)}),e("default icon",()=>{const e=document.createElement("l-marker");document.body.appendChild(e);let s=e.layer.getIcon(),a=new t.Icon.Default;n(s).toEqual(a)}),e("adds an icon",()=>{const e=document.createElement("l-marker");e.setAttribute("icon",JSON.stringify({iconUrl:"foo.png"})),document.body.appendChild(e);let s=e.layer.getIcon(),a=t.icon({iconUrl:"foo.png"});n(s).toEqual(a)}),e("changes an icon",()=>{const e=document.createElement("l-marker");document.body.appendChild(e),e.setAttribute("icon",JSON.stringify({iconUrl:"bar.png"}));let s=e.layer.getIcon(),a=t.icon({iconUrl:"bar.png"});n(s).toEqual(a)})}class m extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(l,t=>{t.detail.type="overlay"})}}class y extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("content"),e=new CustomEvent(r,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)}}class E extends HTMLElement{constructor(){super()}attributeChangedCallback(t,e,n){const s=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(n),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(s)}}E.observedAttributes=["bounds"];class g extends HTMLElement{constructor(){super(),this.layer=null}connectedCallback(){const t=this.getAttribute("url");if(null===t)return void console.warn("attribute 'url' not set");let e=this.getAttribute("bounds");if(null===e)return void console.warn("attribute 'bounds' not set");const n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=a(t,JSON.parse(e),n),this.dispatchEvent(new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}attributeChangedCallback(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)))}}g.observedAttributes=["url","bounds","opacity"];class v extends HTMLElement{constructor(){super()}connectedCallback(){const 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},s=o(t,e,n);this.dispatchEvent(new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:s}}))}}class f extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("geojson");if(null!==t){const e=i(JSON.parse(t));this.dispatchEvent(new CustomEvent(l,{bubbles:!0,cancelable:!0,detail:{layer:e}}))}}}const A=t=>t.replace(/-./g,t=>t[1].toUpperCase());class C extends HTMLElement{constructor(){super(),this.icon=null}connectedCallback(){const e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(t=>{this.hasAttribute(t)&&(e[A(t)]=this.getAttribute(t))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(t=>{this.hasAttribute(t)&&(e[A(t)]=JSON.parse(this.getAttribute(t)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=t.icon(e);const n=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(n)}}if(import.meta.vitest){const{it:e,expect:n,beforeAll:s}=import.meta.vitest;s(()=>{customElements.define("l-icon",C)}),e("default",()=>{const e=document.createElement("l-icon");document.body.appendChild(e);let s=e.icon,a=t.icon();n(s).toEqual(a)}),e("emits icon:add event",async()=>{const e=document.createElement("l-icon");let s=new Promise(t=>{e.addEventListener("icon:add",e=>{t(e.detail.icon)})});document.body.appendChild(e);let a=await s,o=t.icon();n(a).toEqual(o)}),e("options",()=>{const e=document.createElement("l-icon");e.setAttribute("icon-url","url.png"),e.setAttribute("icon-retina-url","retina.png"),e.setAttribute("icon-size","[0, 0]"),e.setAttribute("icon-anchor","[0, 0]"),e.setAttribute("popup-anchor","[0, 0]"),e.setAttribute("tooltip-anchor","[0, 0]"),e.setAttribute("shadow-url","urlShadow.png"),e.setAttribute("shadow-retina-url","retinaShadow.png"),e.setAttribute("shadow-size","[0, 0]"),e.setAttribute("shadow-anchor","[0, 0]"),e.setAttribute("class-name","foo"),e.setAttribute("cross-origin","true"),document.body.appendChild(e);let s=e.icon,a=t.icon({iconUrl:"url.png",iconRetinaUrl:"retina.png",iconSize:[0,0],iconAnchor:[0,0],popupAnchor:[0,0],tooltipAnchor:[0,0],shadowUrl:"urlShadow.png",shadowRetinaUrl:"retinaShadow.png",shadowSize:[0,0],shadowAnchor:[0,0],className:"foo",crossOrigin:!0});n(s).toEqual(a)})}const w=(customElements.define("l-map",p),customElements.define("l-control-layers",u),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",m),customElements.define("l-layer-group",d),customElements.define("l-tile-layer",h),customElements.define("l-marker",b),customElements.define("l-popup",y),customElements.define("l-lat-lng-bounds",E),customElements.define("l-image-overlay",g),customElements.define("l-video-overlay",v),customElements.define("l-geojson",f),void customElements.define("l-icon",C));export{w as default};
1
+ import*as t from"leaflet";import{control as e,layerGroup as n,tileLayer as s,imageOverlay as a,videoOverlay as o,geoJSON as i}from"leaflet";const l="map:addTo",r="popup:add";class c extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(l,t=>{t.detail.type="base"})}}class u extends HTMLElement{constructor(){super()}connectedCallback(){const t=e.layers({},{});this.addEventListener(l,e=>{const{type:n,name:s,layer:a}=e.detail;"overlay"===n?t.addOverlay(a,s):"base"===n&&t.addBaseLayer(a,s),e.preventDefault()});const n=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:t}});this.dispatchEvent(n)}}class d extends HTMLElement{constructor(){super(),this.layer=null}}class h extends HTMLElement{constructor(){super(),this.map=null,this.addEventListener("map:bounds",t=>{const{bounds:e,method:n}=t.detail;null!==this.map&&this.map[n](e)}),new MutationObserver(function(t){t.forEach(t=>{if(t.target instanceof h){const e=t.target;t.removedNodes.forEach(t=>{t instanceof d&&null!==e.map&&null!==t.layer&&e.map.removeLayer(t.layer)})}})}).observe(this,{childList:!0})}connectedCallback(){this.map=t.map(this);const e=this.getAttribute("center"),n=this.getAttribute("zoom");null!==e&&null!==n&&this.map.setView(JSON.parse(e),parseInt(n)),this.addEventListener(l,t=>{t.detail.layer.addTo(this.map)}),this.addEventListener("layer:remove",t=>{null!==this.map&&this.map.removeLayer(t.detail.layer)})}}class p extends d{constructor(){super(),this.layer=null,this.addEventListener("icon:add",t=>{t.stopPropagation(),this.layer.setIcon(t.detail.icon)})}connectedCallback(){const e=JSON.parse(this.getAttribute("lat-lng")),n=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=t.marker(e,{opacity:n}),this.hasAttribute("icon")){const e=t.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(e)}this.setAttribute("leaflet-id",t.stamp(this.layer)),this.addEventListener(r,t=>{const{content:e}=t.detail;this.layer.bindPopup(e)});const s=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(s)}attributeChangedCallback(e,n,s){null!==this.layer&&("lat-lng"===e&&this.layer.setLatLng(JSON.parse(s)),"opacity"===e&&this.layer.setOpacity(parseFloat(s)),"icon"===e&&this.layer.setIcon(t.icon(JSON.parse(s))))}}if(p.observedAttributes=["lat-lng","opacity","icon"],import.meta.vitest){const{it:e,expect:n,beforeAll:s}=import.meta.vitest;s(()=>{customElements.define("l-marker",p)}),e("default icon",()=>{const e=document.createElement("l-marker");document.body.appendChild(e);let s=e.layer.getIcon(),a=new t.Icon.Default;n(s).toEqual(a)}),e("adds an icon",()=>{const e=document.createElement("l-marker");e.setAttribute("icon",JSON.stringify({iconUrl:"foo.png"})),document.body.appendChild(e);let s=e.layer.getIcon(),a=t.icon({iconUrl:"foo.png"});n(s).toEqual(a)}),e("changes an icon",()=>{const e=document.createElement("l-marker");document.body.appendChild(e),e.setAttribute("icon",JSON.stringify({iconUrl:"bar.png"}));let s=e.layer.getIcon(),a=t.icon({iconUrl:"bar.png"});n(s).toEqual(a)})}class b extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener(l,t=>{t.detail.type="overlay"})}}class m extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("content"),e=new CustomEvent(r,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)}}class y extends HTMLElement{constructor(){super()}attributeChangedCallback(t,e,n){const s=new CustomEvent("map:bounds",{bubbles:!0,detail:{bounds:JSON.parse(n),method:this.getAttribute("method")||"fitBounds"}});this.dispatchEvent(s)}}y.observedAttributes=["bounds"];class E extends d{constructor(){super(),this.layer=null}connectedCallback(){const t=this.getAttribute("url");if(null===t)return void console.warn("attribute 'url' not set");let e=this.getAttribute("bounds");if(null===e)return void console.warn("attribute 'bounds' not set");const n={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=a(t,JSON.parse(e),n),this.dispatchEvent(new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}attributeChangedCallback(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)))}}E.observedAttributes=["url","bounds","opacity"];class g extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("geojson");if(null!==t){const e=i(JSON.parse(t));this.dispatchEvent(new CustomEvent(l,{bubbles:!0,cancelable:!0,detail:{layer:e}}))}}}const v=t=>t.replace(/-./g,t=>t[1].toUpperCase());class f extends HTMLElement{constructor(){super(),this.icon=null}connectedCallback(){const e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(t=>{this.hasAttribute(t)&&(e[v(t)]=this.getAttribute(t))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(t=>{this.hasAttribute(t)&&(e[v(t)]=JSON.parse(this.getAttribute(t)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=t.icon(e);const n=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(n)}}if(import.meta.vitest){const{it:e,expect:n,beforeAll:s}=import.meta.vitest;s(()=>{customElements.define("l-icon",f)}),e("default",()=>{const e=document.createElement("l-icon");document.body.appendChild(e);let s=e.icon,a=t.icon();n(s).toEqual(a)}),e("emits icon:add event",async()=>{const e=document.createElement("l-icon");let s=new Promise(t=>{e.addEventListener("icon:add",e=>{t(e.detail.icon)})});document.body.appendChild(e);let a=await s,o=t.icon();n(a).toEqual(o)}),e("options",()=>{const e=document.createElement("l-icon");e.setAttribute("icon-url","url.png"),e.setAttribute("icon-retina-url","retina.png"),e.setAttribute("icon-size","[0, 0]"),e.setAttribute("icon-anchor","[0, 0]"),e.setAttribute("popup-anchor","[0, 0]"),e.setAttribute("tooltip-anchor","[0, 0]"),e.setAttribute("shadow-url","urlShadow.png"),e.setAttribute("shadow-retina-url","retinaShadow.png"),e.setAttribute("shadow-size","[0, 0]"),e.setAttribute("shadow-anchor","[0, 0]"),e.setAttribute("class-name","foo"),e.setAttribute("cross-origin","true"),document.body.appendChild(e);let s=e.icon,a=t.icon({iconUrl:"url.png",iconRetinaUrl:"retina.png",iconSize:[0,0],iconAnchor:[0,0],popupAnchor:[0,0],tooltipAnchor:[0,0],shadowUrl:"urlShadow.png",shadowRetinaUrl:"retinaShadow.png",shadowSize:[0,0],shadowAnchor:[0,0],className:"foo",crossOrigin:!0});n(s).toEqual(a)})}const A=(customElements.define("l-map",h),customElements.define("l-control-layers",u),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",b),customElements.define("l-layer-group",class extends d{constructor(){super(),this.layer=null}connectedCallback(){const t=this.getAttribute("name"),e=n();this.layer=e;const s=new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:e,name:t}});this.dispatchEvent(s),this.addEventListener(l,t=>{t.stopPropagation(),e.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(t=>{t.removedNodes.forEach(t=>{if(t instanceof HTMLElement){const n=t.getAttribute("leaflet-id");if(null!==n){const t=e.getLayer(parseInt(n));void 0!==t&&e.removeLayer(t)}}})})}).observe(this,{childList:!0})}}),customElements.define("l-tile-layer",class extends d{constructor(){super(),this.layer=null}connectedCallback(){const t=this.getAttribute("name"),e=this.getAttribute("url-template");if(null===e)return;const n={},a="attribution";this.hasAttribute(a)&&(n[a]=this.getAttribute(a)),this.layer=s(e,n);const o=new CustomEvent(l,{detail:{name:t,layer:this.layer},bubbles:!0});this.dispatchEvent(o)}}),customElements.define("l-marker",p),customElements.define("l-popup",m),customElements.define("l-lat-lng-bounds",y),customElements.define("l-image-overlay",E),customElements.define("l-video-overlay",class extends d{constructor(){super()}connectedCallback(){const 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},s=o(t,e,n);this.dispatchEvent(new CustomEvent(l,{cancelable:!0,bubbles:!0,detail:{layer:s}}))}}),customElements.define("l-geojson",g),void customElements.define("l-icon",f));export{A as default};
2
2
  //# sourceMappingURL=leaflet-html.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaflet-html.modern.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer-group.js","../src/l-tile-layer.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { 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 = 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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LTileLayer from \"./l-tile-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LTileLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { 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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { 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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","HTMLElement","constructor","super","connectedCallback","this","addEventListener","ev","detail","LControlLayers","controlLayers","control","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","parseInt","removeLayer","observe","childList","LTileLayer","urlTemplate","options","key","hasAttribute","tileLayer","LMap","map","bounds","method","target","el","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","latLng","opacity","parseFloat","marker","setAttribute","stamp","content","bindPopup","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","vitest","it","expect","beforeAll","customElements","define","document","createElement","body","appendChild","actual","getIcon","expected","Icon","Default","toEqual","stringify","iconUrl","LOverlayLayers","LPopup","LLatLngBounds","_name","LImageOverlay","url","console","warn","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","async","promise","Promise","resolve","iconRetinaUrl","iconSize","iconAnchor","popupAnchor","tooltipAnchor","shadowUrl","shadowRetinaUrl","shadowSize","shadowAnchor","className","init"],"mappings":"kJAAaA,EAAW,YACXC,EAAW,YCExB,MAAMC,UAAoBC,YACxBC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACEC,KAAKC,iBAAiBR,EAAWS,IAC/BA,EAAGC,OAAa,KAAI,MACtB,EACF,ECPF,MAAMC,UAAuBR,YAC3BC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GAEE,MAGMM,EAAgBC,EAAQC,OAHjB,CAAE,EAEC,CAAA,GAGhBP,KAAKC,iBAAiBR,EAAWS,IAC/B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O,WAAYtB,GAClCqB,eAAeC,OAAO,UAAWc,GACjCf,eAAeC,OAAO,mBAAoBe,GAC1ChB,eAAeC,OAAO,kBAAmBiB,GACzClB,eAAeC,OAAO,kBAAmByB,GACzC1B,eAAeC,OAAO,YAAa8B,QACnC/B,eAAeC,OAAO,SAAUsC"}
1
+ {"version":3,"file":"leaflet-html.modern.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-geojson.js","../src/l-icon.js","../src/index.js","../src/l-layer-group.js","../src/l-tile-layer.js","../src/l-video-overlay.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","class LLayer extends HTMLElement {\n constructor() {\n super()\n this.layer = null\n }\n}\n\nexport default LLayer\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LMarker extends LLayer {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LImageOverlay extends LLayer {\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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LLayerGroup extends LLayer {\n constructor() {\n super();\n this.layer = null;\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const group = layerGroup();\n this.layer = group;\n\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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LTileLayer extends LLayer {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LVideoOverlay extends LLayer {\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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","HTMLElement","constructor","super","connectedCallback","this","addEventListener","ev","detail","LControlLayers","controlLayers","control","layers","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayer","LMap","map","bounds","method","MutationObserver","mutations","forEach","mutation","target","el","removedNodes","node","removeLayer","observe","childList","L","center","getAttribute","zoom","setView","JSON","parse","parseInt","addTo","LMarker","stopPropagation","setIcon","icon","latLng","opacity","parseFloat","marker","hasAttribute","setAttribute","stamp","content","bindPopup","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","vitest","it","expect","beforeAll","customElements","define","document","createElement","body","appendChild","actual","getIcon","expected","Icon","Default","toEqual","stringify","iconUrl","LOverlayLayers","LPopup","LLatLngBounds","_name","LImageOverlay","url","console","warn","options","alt","imageOverlay","setUrl","setBounds","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","key","crossOrigin","async","promise","Promise","resolve","iconRetinaUrl","iconSize","iconAnchor","popupAnchor","tooltipAnchor","shadowUrl","shadowRetinaUrl","shadowSize","shadowAnchor","className","init","group","layerGroup","addLayer","leafletId","getLayer","urlTemplate","tileLayer","autoplay","muted","playsInline","videoOverlay"],"mappings":"kJAAaA,EAAW,YACXC,EAAW,YCExB,MAAMC,UAAoBC,YACxBC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACEC,KAAKC,iBAAiBR,EAAWS,IAC/BA,EAAGC,OAAa,KAAI,MACtB,EACF,ECPF,MAAMC,UAAuBR,YAC3BC,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GAEE,MAGMM,EAAgBC,EAAQC,OAHjB,CAAE,EAEC,CAAA,GAGhBP,KAAKC,iBAAiBR,EAAWS,IAC/B,MAAMM,KAAEA,EAAIC,KAAEA,EAAIC,MAAEA,GAAUR,EAAGC,OACpB,YAATK,EACFH,EAAcM,WAAWD,EAAOD,GACd,SAATD,GACTH,EAAcO,aAAaF,EAAOD,GAEpCP,EAAGW,gBAAc,GAGnB,MAAMC,EAAQ,IAAIC,YAAYtB,EAAU,CACtCuB,YAAY,EACZC,SAAS,EACTd,OAAQ,CACNO,MAAOL,KAGXL,KAAKkB,cAAcJ,EACrB,ECnCF,MAAMK,UAAevB,YACnBC,WAAAA,GACEC,QACAE,KAAKU,MAAQ,IACf,ECCF,MAAMU,UAAaxB,YACjBC,WAAAA,GACEC,QAEAE,KAAKqB,IAAM,KACXrB,KAAKC,iBAAiB,aAAeC,IACnC,MAAMoB,OAAEA,EAAMC,OAAEA,GAAWrB,EAAGC,OACb,OAAbH,KAAKqB,KACPrB,KAAKqB,IAAIE,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AX,iBAAAA,GACE,MAAMU,EAAOT,KAAKqC,aAAa,QACzBwF,EAAc7H,KAAKqC,aAAa,gBACtC,GAAoB,OAAhBwF,EACF,OAEF,MAAMpC,EAAU,CAAA,EACVc,EAAM,cACRvG,KAAKoD,aAAamD,KACpBd,EAAQc,GAAOvG,KAAKqC,aAAakE,IAEnCvG,KAAKU,MAAQoH,EAAUD,EAAapC,GACpC,MAAM3E,EAAQ,IAAIC,YAAYtB,EAAU,CACtCU,OAAQ,CAAEM,OAAMC,MAAOV,KAAKU,OAC5BO,SAAS,IAEXjB,KAAKkB,cAAcJ,EACrB,IFLAqD,eAAeC,OAAO,WAAYxB,GAClCuB,eAAeC,OAAO,UAAWc,GACjCf,eAAeC,OAAO,mBAAoBe,GAC1ChB,eAAeC,OAAO,kBAAmBiB,GACzClB,eAAeC,OAAO,kBGtBxB,cAA4BjD,EAC1BtB,WAAAA,GACEC,OACF,CAEAC,iBAAAA,GACE,MAAMuF,EAAM9C,KAAKC,MAAMzC,KAAKqC,aAAa,QACnCf,EAASkB,KAAKC,MAAMzC,KAAKqC,aAAa,WACtCoD,EAAU,CACdxC,QAASC,WAAWlD,KAAKqC,aAAa,YAAc,OACpDqD,IAAK1F,KAAKqC,aAAa,QAAU,GACjC0F,UAAU,EACVC,OAAO,EACPC,aAAa,GAETvH,EAAQwH,EAAa5C,EAAKhE,EAAQmE,GACxCzF,KAAKkB,cACH,IAAIH,YAAYtB,EAAU,CACxBuB,YAAY,EACZC,SAAS,EACTd,OAAQ,CACNO,WAIR,IHFAyD,eAAeC,OAAO,YAAa0B,QACnC3B,eAAeC,OAAO,SAAUkC"}
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],e):(t||self).leafletHtml=e(t.leaflet)}(this,function(t){function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e}var n=/*#__PURE__*/e(t);function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(r())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var a=new(t.bind.apply(t,i));return n&&o(a,n.prototype),a}(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)},l(t)}var u="map:addTo",s="popup:add",c=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="base"})},e}(/*#__PURE__*/l(HTMLElement)),p=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=t.control.layers({},{});this.addEventListener(u,function(t){var n=t.detail,r=n.type,i=n.name,a=n.layer;"overlay"===r?e.addOverlay(a,i):"base"===r&&e.addBaseLayer(a,i),t.preventDefault()});var n=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:e}});this.dispatchEvent(n)},n}(/*#__PURE__*/l(HTMLElement)),f=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=t.layerGroup(),r=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:n,name:e}});this.dispatchEvent(r),this.addEventListener(u,function(t){t.stopPropagation(),n.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var e=t.getAttribute("leaflet-id");if(null!==e){var r=n.getLayer(parseInt(e));void 0!==r&&n.removeLayer(r)}}})})}).observe(this,{childList:!0})},n}(/*#__PURE__*/l(HTMLElement)),d=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=this.getAttribute("url-template");if(null!==n){var r={},i="attribution";this.hasAttribute(i)&&(r[i]=this.getAttribute(i)),this.layer=t.tileLayer(n,r);var a=new CustomEvent(u,{detail:{name:e,layer:this.layer},bubbles:!0});this.dispatchEvent(a)}},n}(/*#__PURE__*/l(HTMLElement)),h=/*#__PURE__*/function(t){function e(){var n;return(n=t.call(this)||this).map=null,n.addEventListener("map:bounds",function(t){var e=t.detail;null!==n.map&&n.map[e.method](e.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof e){var n=t.target;t.removedNodes.forEach(function(t){t instanceof d&&null!==n.map&&null!==t.layer&&n.map.removeLayer(t.layer)})}})}).observe(n,{childList:!0}),n}return i(e,t),e.prototype.connectedCallback=function(){var t=this;this.map=n.map(this);var e=this.getAttribute("center"),r=this.getAttribute("zoom");null!==e&&null!==r&&this.map.setView(JSON.parse(e),parseInt(r)),this.addEventListener(u,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){null!==t.map&&t.map.removeLayer(e.detail.layer)})},e}(/*#__PURE__*/l(HTMLElement)),b=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e.addEventListener("icon:add",function(t){t.stopPropagation(),e.layer.setIcon(t.detail.icon)}),e}i(e,t);var r=e.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=n.marker(e,{opacity:r}),this.hasAttribute("icon")){var i=n.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(i)}this.setAttribute("leaflet-id",n.stamp(this.layer)),this.addEventListener(s,function(e){t.layer.bindPopup(e.detail.content)});var a=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(a)},r.attributeChangedCallback=function(t,e,r){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(r)),"opacity"===t&&this.layer.setOpacity(parseFloat(r)),"icon"===t&&this.layer.setIcon(n.icon(JSON.parse(r))))},e}(/*#__PURE__*/l(HTMLElement));b.observedAttributes=["lat-lng","opacity","icon"];var y=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/l(HTMLElement)),v=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/l(HTMLElement)),m=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.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)},e}(/*#__PURE__*/l(HTMLElement));m.observedAttributes=["bounds"];var E=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}i(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this.getAttribute("url");if(null!==e){var n=this.getAttribute("bounds");if(null!==n){var r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=t.imageOverlay(e,JSON.parse(n),r),this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},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__*/l(HTMLElement));E.observedAttributes=["url","bounds","opacity"];var g=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=JSON.parse(this.getAttribute("url")),n=JSON.parse(this.getAttribute("bounds")),r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},i=t.videoOverlay(e,n,r);this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:i}}))},n}(/*#__PURE__*/l(HTMLElement)),O=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("geojson");if(null!==e){var n=t.geoJSON(JSON.parse(e));this.dispatchEvent(new CustomEvent(u,{bubbles:!0,cancelable:!0,detail:{layer:n}}))}},n}(/*#__PURE__*/l(HTMLElement)),L=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},A=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).icon=null,e}return i(e,t),e.prototype.connectedCallback=function(){var t=this,e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=t.getAttribute(n))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=JSON.parse(t.getAttribute(n)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=n.icon(e);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},e}(/*#__PURE__*/l(HTMLElement));return customElements.define("l-map",h),customElements.define("l-control-layers",p),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",y),customElements.define("l-layer-group",f),customElements.define("l-tile-layer",d),customElements.define("l-marker",b),customElements.define("l-popup",v),customElements.define("l-lat-lng-bounds",m),customElements.define("l-image-overlay",E),customElements.define("l-video-overlay",g),customElements.define("l-geojson",O),void customElements.define("l-icon",A)});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],e):(t||self).leafletHtml=e(t.leaflet)}(this,function(t){function e(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e}var n=/*#__PURE__*/e(t);function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(r())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,e);var a=new(t.bind.apply(t,i));return n&&o(a,n.prototype),a}(t,arguments,a(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)},l(t)}var u="map:addTo",s="popup:add",c=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="base"})},e}(/*#__PURE__*/l(HTMLElement)),f=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=t.control.layers({},{});this.addEventListener(u,function(t){var n=t.detail,r=n.type,i=n.name,a=n.layer;"overlay"===r?e.addOverlay(a,i):"base"===r&&e.addBaseLayer(a,i),t.preventDefault()});var n=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:e}});this.dispatchEvent(n)},n}(/*#__PURE__*/l(HTMLElement)),p=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e}return i(e,t),e}(/*#__PURE__*/l(HTMLElement)),d=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=t.layerGroup();this.layer=n;var r=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:n,name:e}});this.dispatchEvent(r),this.addEventListener(u,function(t){t.stopPropagation(),n.addLayer(t.detail.layer)}),new MutationObserver(function(t){t.forEach(function(t){t.removedNodes.forEach(function(t){if(t instanceof HTMLElement){var e=t.getAttribute("leaflet-id");if(null!==e){var r=n.getLayer(parseInt(e));void 0!==r&&n.removeLayer(r)}}})})}).observe(this,{childList:!0})},n}(p),h=/*#__PURE__*/function(t){function e(){var n;return(n=t.call(this)||this).map=null,n.addEventListener("map:bounds",function(t){var e=t.detail;null!==n.map&&n.map[e.method](e.bounds)}),new MutationObserver(function(t){t.forEach(function(t){if(t.target instanceof e){var n=t.target;t.removedNodes.forEach(function(t){t instanceof p&&null!==n.map&&null!==t.layer&&n.map.removeLayer(t.layer)})}})}).observe(n,{childList:!0}),n}return i(e,t),e.prototype.connectedCallback=function(){var t=this;this.map=n.map(this);var e=this.getAttribute("center"),r=this.getAttribute("zoom");null!==e&&null!==r&&this.map.setView(JSON.parse(e),parseInt(r)),this.addEventListener(u,function(e){e.detail.layer.addTo(t.map)}),this.addEventListener("layer:remove",function(e){null!==t.map&&t.map.removeLayer(e.detail.layer)})},e}(/*#__PURE__*/l(HTMLElement)),b=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).layer=null,e.addEventListener("icon:add",function(t){t.stopPropagation(),e.layer.setIcon(t.detail.icon)}),e}i(e,t);var r=e.prototype;return r.connectedCallback=function(){var t=this,e=JSON.parse(this.getAttribute("lat-lng")),r=parseFloat(this.getAttribute("opacity")||"1.0");if(this.layer=n.marker(e,{opacity:r}),this.hasAttribute("icon")){var i=n.icon(JSON.parse(this.getAttribute("icon")));this.layer.setIcon(i)}this.setAttribute("leaflet-id",n.stamp(this.layer)),this.addEventListener(s,function(e){t.layer.bindPopup(e.detail.content)});var a=new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}});this.dispatchEvent(a)},r.attributeChangedCallback=function(t,e,r){null!==this.layer&&("lat-lng"===t&&this.layer.setLatLng(JSON.parse(r)),"opacity"===t&&this.layer.setOpacity(parseFloat(r)),"icon"===t&&this.layer.setIcon(n.icon(JSON.parse(r))))},e}(p);b.observedAttributes=["lat-lng","opacity","icon"];var y=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){this.addEventListener(u,function(t){t.detail.type="overlay"})},e}(/*#__PURE__*/l(HTMLElement)),v=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.prototype.connectedCallback=function(){var t=this.getAttribute("content"),e=new CustomEvent(s,{cancelable:!0,bubbles:!0,detail:{content:t}});this.dispatchEvent(e)},e}(/*#__PURE__*/l(HTMLElement)),m=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("name"),n=this.getAttribute("url-template");if(null!==n){var r={},i="attribution";this.hasAttribute(i)&&(r[i]=this.getAttribute(i)),this.layer=t.tileLayer(n,r);var a=new CustomEvent(u,{detail:{name:e,layer:this.layer},bubbles:!0});this.dispatchEvent(a)}},n}(p),E=/*#__PURE__*/function(t){function e(){return t.call(this)||this}return i(e,t),e.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)},e}(/*#__PURE__*/l(HTMLElement));E.observedAttributes=["bounds"];var g=/*#__PURE__*/function(e){function n(){var t;return(t=e.call(this)||this).layer=null,t}i(n,e);var r=n.prototype;return r.connectedCallback=function(){var e=this.getAttribute("url");if(null!==e){var n=this.getAttribute("bounds");if(null!==n){var r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||""};this.layer=t.imageOverlay(e,JSON.parse(n),r),this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:this.layer}}))}else console.warn("attribute 'bounds' not set")}else console.warn("attribute 'url' not set")},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}(p);g.observedAttributes=["url","bounds","opacity"];var O=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=JSON.parse(this.getAttribute("url")),n=JSON.parse(this.getAttribute("bounds")),r={opacity:parseFloat(this.getAttribute("opacity")||"1.0"),alt:this.getAttribute("alt")||"",autoplay:!0,muted:!0,playsInline:!0},i=t.videoOverlay(e,n,r);this.dispatchEvent(new CustomEvent(u,{cancelable:!0,bubbles:!0,detail:{layer:i}}))},n}(p),A=/*#__PURE__*/function(e){function n(){return e.call(this)||this}return i(n,e),n.prototype.connectedCallback=function(){var e=this.getAttribute("geojson");if(null!==e){var n=t.geoJSON(JSON.parse(e));this.dispatchEvent(new CustomEvent(u,{bubbles:!0,cancelable:!0,detail:{layer:n}}))}},n}(/*#__PURE__*/l(HTMLElement)),L=function(t){return t.replace(/-./g,function(t){return t[1].toUpperCase()})},C=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this).icon=null,e}return i(e,t),e.prototype.connectedCallback=function(){var t=this,e={};["icon-url","icon-retina-url","shadow-url","shadow-retina-url","class-name"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=t.getAttribute(n))}),["icon-anchor","icon-size","shadow-anchor","shadow-size","tooltip-anchor","popup-anchor"].forEach(function(n){t.hasAttribute(n)&&(e[L(n)]=JSON.parse(t.getAttribute(n)))}),this.hasAttribute("cross-origin")&&(e.crossOrigin="true"===this.getAttribute("cross-origin")),this.icon=n.icon(e);var r=new CustomEvent("icon:add",{cancelable:!0,bubbles:!0,detail:{icon:this.icon}});this.dispatchEvent(r)},e}(/*#__PURE__*/l(HTMLElement));return customElements.define("l-map",h),customElements.define("l-control-layers",f),customElements.define("l-base-layers",c),customElements.define("l-overlay-layers",y),customElements.define("l-layer-group",d),customElements.define("l-tile-layer",m),customElements.define("l-marker",b),customElements.define("l-popup",v),customElements.define("l-lat-lng-bounds",E),customElements.define("l-image-overlay",g),customElements.define("l-video-overlay",O),customElements.define("l-geojson",A),void customElements.define("l-icon",C)});
2
2
  //# sourceMappingURL=leaflet-html.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"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-tile-layer.js","../src/l-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { 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 = 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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LTileLayer from \"./l-tile-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LTileLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { 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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { 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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","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","parseInt","removeLayer","observe","childList","LTileLayer","_this","urlTemplate","options","key","hasAttribute","tileLayer","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","customElements","define"],"mappings":"guDAAaA,EAAW,YACXC,EAAW,YCElBC,eAAWC,SAAAA,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,CATcC,cASdS,EATuBC,cCEpBC,eAAc,SAAAX,GAClB,SAAAW,IAAc,OACZX,EAAAC,KAAMC,WACR,CA2BC,OA3BAC,EAAAQ,EAAAX,GAAAW,EAAAP,UAEDC,kBAAA,WAEE,IAG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AoB,IAAAqD,EAClBxD,KAAM8C,EAAU,CAAA,EAGL,CACT,WACA,kBACA,aACA,oBACA,cAEGb,QAAQ,SAACc,GACRS,EAAKR,aAAaD,KACpBD,EAAQwD,EAAUvD,IAAQS,EAAK9B,aAAaqB,GAEhD,GAGa,CACX,cACA,YACA,gBACA,cACA,iBACA,gBAEKd,QAAQ,SAACc,GACVS,EAAKR,aAAaD,KACpBD,EAAQwD,EAAUvD,IAAQc,KAAKC,MAAMN,EAAK9B,aAAaqB,IAE3D,GAEI/C,KAAKgD,aAAa,kBACpBF,EAAQ8D,YAAoD,SAAtC5G,KAAK0B,aAAa,iBAE1C1B,KAAKkE,KAAOT,EAAES,KAAKpB,GAEnB,IAAM1B,EAAQ,IAAIC,YAAY,WAAY,CACxCC,YAAY,EACZC,SAAS,EACTjB,OAAQ,CACN4D,KAAMlE,KAAKkE,QAGflE,KAAKwB,cAAcJ,EACrB,EAACuF,CAAA,eAAApG,EAnDiBC,qBCYlBqG,eAAeC,OAAO,QAAS5D,GAC/B2D,eAAeC,OAAO,mBAAoBrG,GAC1CoG,eAAeC,OAAO,gBAAiBjH,GACvCgH,eAAeC,OAAO,mBAAoB5B,GAC1C2B,eAAeC,OAAO,gBAAiBrF,GACvCoF,eAAeC,OAAO,eAAgBnE,GACtCkE,eAAeC,OAAO,WAAY9C,GAClC6C,eAAeC,OAAO,UAAW3B,GACjC0B,eAAeC,OAAO,mBAAoB1B,GAC1CyB,eAAeC,OAAO,kBAAmBxB,GACzCuB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,YAAaX,QACnCU,eAAeC,OAAO,SAAUH"}
1
+ {"version":3,"file":"leaflet-html.umd.js","sources":["../src/events.js","../src/l-base-layers.js","../src/l-control-layers.js","../src/l-layer.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/l-icon.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\";\nexport const popupAdd = \"popup:add\";\nexport const layerRemove = \"layer:remove\";\n","// @ts-check\nimport { 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","// @ts-check\n/** @typedef {import(\"leaflet\").Layer} Layer */\nimport { control } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n /** @type {{ [key: string]: Layer }} */\n const base = {};\n /** @type {{ [key: string]: Layer }} */\n const overlay = {};\n const controlLayers = control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n controlLayers.addOverlay(layer, name);\n } else if (type === \"base\") {\n controlLayers.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: controlLayers,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","class LLayer extends HTMLElement {\n constructor() {\n super()\n this.layer = null\n }\n}\n\nexport default LLayer\n","// @ts-check\nimport { layerGroup } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LLayerGroup extends LLayer {\n constructor() {\n super();\n this.layer = null;\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const group = layerGroup();\n this.layer = group;\n\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 if (node instanceof HTMLElement) {\n const leafletId = node.getAttribute(\"leaflet-id\");\n if (leafletId !== null) {\n const layer = group.getLayer(parseInt(leafletId));\n if (typeof layer !== \"undefined\") {\n group.removeLayer(layer);\n }\n }\n }\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport * as L from \"leaflet\";\nimport { layerRemove, mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.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 if (this.map !== null) {\n this.map[method](bounds);\n }\n });\n\n // Observe removed l-tile-layers\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n if (mutation.target instanceof LMap) {\n const el = mutation.target\n mutation.removedNodes.forEach((node) => {\n if (node instanceof LLayer) {\n if ((el.map !== null) && (node.layer !== null)) {\n el.map.removeLayer(node.layer)\n }\n }\n })\n }\n })\n })\n observer.observe(this, { childList: true })\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 if (this.map !== null) {\n this.map.removeLayer(ev.detail.layer);\n }\n });\n }\n}\n\nexport default LMap;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\nimport { mapAddTo, popupAdd } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LMarker extends LLayer {\n static observedAttributes = [\"lat-lng\", \"opacity\", \"icon\"];\n\n constructor() {\n super();\n this.layer = null;\n this.addEventListener(\"icon:add\", (ev) => {\n ev.stopPropagation();\n this.layer.setIcon(ev.detail.icon);\n });\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 if (this.hasAttribute(\"icon\")) {\n const icon = L.icon(JSON.parse(this.getAttribute(\"icon\")));\n this.layer.setIcon(icon);\n }\n\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 if (name === \"icon\") {\n this.layer.setIcon(L.icon(JSON.parse(newValue)));\n }\n }\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-marker\", LMarker);\n });\n\n it(\"default icon\", () => {\n const el = document.createElement(\"l-marker\");\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = new L.Icon.Default();\n expect(actual).toEqual(expected);\n });\n\n it(\"adds an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute before appendChild\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"foo.png\" }));\n document.body.appendChild(el);\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"foo.png\" });\n expect(actual).toEqual(expected);\n });\n\n it(\"changes an icon\", () => {\n const el = document.createElement(\"l-marker\");\n // Set attribute after appendChild\n document.body.appendChild(el);\n el.setAttribute(\"icon\", JSON.stringify({ iconUrl: \"bar.png\" }));\n let actual = el.layer.getIcon();\n let expected = L.icon({ iconUrl: \"bar.png\" });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LMarker;\n","// @ts-check\nimport { 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","// @ts-check\nimport { 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\nexport default LPopup;\n","// @ts-check\nimport { tileLayer } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LTileLayer extends LLayer {\n constructor() {\n super();\n this.layer = null\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n if (urlTemplate === null) {\n return;\n }\n const options = {};\n const key = \"attribution\";\n if (this.hasAttribute(key)) {\n options[key] = this.getAttribute(key);\n }\n this.layer = tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer: this.layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","// @ts-check\nclass 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","// @ts-check\nimport { imageOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LImageOverlay extends LLayer {\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 if (url === null) {\n console.warn(\"attribute 'url' not set\");\n return;\n }\n let bounds = this.getAttribute(\"bounds\");\n if (bounds === null) {\n console.warn(\"attribute 'bounds' not set\");\n return;\n }\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = imageOverlay(url, JSON.parse(bounds), options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer,\n },\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","// @ts-check\nimport { videoOverlay } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\nimport LLayer from \"./l-layer.js\";\n\nclass LVideoOverlay extends LLayer {\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 = videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","// @ts-check\nimport { geoJSON } from \"leaflet\";\nimport { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const value = this.getAttribute(\"geojson\");\n if (value !== null) {\n const layer = geoJSON(JSON.parse(value));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\n },\n }),\n );\n }\n }\n}\n\nexport default LGeoJSON;\n","// @vitest-environment happy-dom\nimport * as L from \"leaflet\";\n\nconst camelCase = (kebab) => kebab.replace(/-./g, (x) => x[1].toUpperCase());\n\nclass LIcon extends HTMLElement {\n constructor() {\n super();\n this.icon = null;\n }\n\n connectedCallback() {\n const options = {};\n\n // Strings\n let keys = [\n \"icon-url\",\n \"icon-retina-url\",\n \"shadow-url\",\n \"shadow-retina-url\",\n \"class-name\",\n ];\n keys.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = this.getAttribute(key);\n }\n });\n\n // Points\n let points = [\n \"icon-anchor\",\n \"icon-size\",\n \"shadow-anchor\",\n \"shadow-size\",\n \"tooltip-anchor\",\n \"popup-anchor\",\n ];\n points.forEach((key) => {\n if (this.hasAttribute(key)) {\n options[camelCase(key)] = JSON.parse(this.getAttribute(key));\n }\n });\n\n if (this.hasAttribute(\"cross-origin\")) {\n options.crossOrigin = this.getAttribute(\"cross-origin\") === \"true\";\n }\n this.icon = L.icon(options);\n\n const event = new CustomEvent(\"icon:add\", {\n cancelable: true,\n bubbles: true,\n detail: {\n icon: this.icon,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nif (import.meta.vitest) {\n const { it, expect, beforeAll } = import.meta.vitest;\n\n beforeAll(() => {\n customElements.define(\"l-icon\", LIcon);\n });\n\n it(\"default\", () => {\n const el = document.createElement(\"l-icon\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"emits icon:add event\", async () => {\n const el = document.createElement(\"l-icon\");\n let promise = new Promise((resolve) => {\n el.addEventListener(\"icon:add\", (ev) => {\n resolve(ev.detail.icon);\n });\n });\n document.body.appendChild(el);\n let actual = await promise;\n let expected = L.icon();\n expect(actual).toEqual(expected);\n });\n\n it(\"options\", () => {\n const el = document.createElement(\"l-icon\");\n el.setAttribute(\"icon-url\", \"url.png\");\n el.setAttribute(\"icon-retina-url\", \"retina.png\");\n el.setAttribute(\"icon-size\", \"[0, 0]\");\n el.setAttribute(\"icon-anchor\", \"[0, 0]\");\n el.setAttribute(\"popup-anchor\", \"[0, 0]\");\n el.setAttribute(\"tooltip-anchor\", \"[0, 0]\");\n el.setAttribute(\"shadow-url\", \"urlShadow.png\");\n el.setAttribute(\"shadow-retina-url\", \"retinaShadow.png\");\n el.setAttribute(\"shadow-size\", \"[0, 0]\");\n el.setAttribute(\"shadow-anchor\", \"[0, 0]\");\n el.setAttribute(\"class-name\", \"foo\");\n el.setAttribute(\"cross-origin\", \"true\");\n document.body.appendChild(el);\n\n let actual = el.icon;\n let expected = L.icon({\n iconUrl: \"url.png\",\n iconRetinaUrl: \"retina.png\",\n iconSize: [0, 0],\n iconAnchor: [0, 0],\n popupAnchor: [0, 0],\n tooltipAnchor: [0, 0],\n shadowUrl: \"urlShadow.png\",\n shadowRetinaUrl: \"retinaShadow.png\",\n shadowSize: [0, 0],\n shadowAnchor: [0, 0],\n className: \"foo\",\n crossOrigin: true,\n });\n expect(actual).toEqual(expected);\n });\n}\n\nexport default LIcon;\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\";\nimport LIcon from \"./l-icon.js\";\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 customElements.define(\"l-icon\", LIcon);\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","controlLayers","control","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayer","_this","LLayerGroup","_LLayer","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","parseInt","removeLayer","observe","childList","LMap","map","method","bounds","target","el","_this2","L","center","zoom","setView","JSON","parse","addTo","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","hasAttribute","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","options","key","tileLayer","LLatLngBounds","_name","LImageOverlay","url","alt","imageOverlay","console","warn","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","value","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","crossOrigin","customElements","define"],"mappings":"guDAAaA,EAAW,YACXC,EAAW,YCElBC,eAAWC,SAAAA,GACf,SAAAD,IAAc,OACZC,EAAAC,KAAAC,OAAOA,IACT,CAMC,OANAC,EAAAJ,EAAAC,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AeC,OAAO,eAAgB/B,GACtC8B,eAAeC,OAAO,WAAYpD,GAClCmD,eAAeC,OAAO,UAAWhC,GACjC+B,eAAeC,OAAO,mBAAoB1B,GAC1CyB,eAAeC,OAAO,kBAAmBxB,GACzCuB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,YAAaX,QACnCU,eAAeC,OAAO,SAAUH"}
@@ -24,12 +24,14 @@ The principles that govern HTMX development also hold for Leaflet-HTML.
24
24
  A button that requests HTML to replace part of the document should update the map.
25
25
 
26
26
  ```html
27
+ <!-- Initial map -->
27
28
  <l-map center="[55,-5]" zoom="4">
28
29
  <l-tile-layer
29
30
  url-template="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
30
31
  ></l-tile-layer>
31
32
  </l-map>
32
33
 
34
+ <!-- Tiles -->
33
35
  <button hx-get="/tile-osm.html" hx-target="l-tile-layer" hx-swap="outerHTML">
34
36
  OSM
35
37
  </button>
@@ -39,6 +41,14 @@ A button that requests HTML to replace part of the document should update the ma
39
41
  <button hx-get="/tile-esri.html" hx-target="l-tile-layer" hx-swap="outerHTML">
40
42
  ESRI
41
43
  </button>
44
+
45
+ <!-- Marker -->
46
+ <button hx-get="/marker.html" hx-target="l-map" hx-swap="beforeend">
47
+ Add marker
48
+ </button>
49
+ <button hx-get="/marker.html" hx-target="l-marker" hx-swap="delete">
50
+ Delete marker
51
+ </button>
42
52
  ```
43
53
 
44
54
  <l-map center="[55,-5]" zoom="4">
@@ -56,6 +66,12 @@ A button that requests HTML to replace part of the document should update the ma
56
66
  <button hx-get={{ url(path='htmx/tile-esri.html') }} hx-target="l-tile-layer" hx-swap="outerHTML">
57
67
  ESRI
58
68
  </button>
69
+ <button hx-get={{ url(path='htmx/marker.html') }} hx-target="l-map" hx-swap="beforeend">
70
+ Add marker
71
+ </button>
72
+ <button hx-get={{ url(path='htmx/marker.html')}} hx-target="l-marker" hx-swap="delete">
73
+ Delete marker
74
+ </button>
59
75
 
60
76
  The above approach works by triggering the change handlers in the `<l-tile-layer>` custom element.
61
77
  The additional HTML tags generated by Leaflet are also inside the `<l-map>` tag.
@@ -65,3 +81,4 @@ All Leaflet-HTML tags, e.g. `<l-marker>`, `<l-icon>`, etc. can be swapped howeve
65
81
  It is just the contents of `<l-map>` that needs careful consideration.
66
82
 
67
83
  A more elegant mechanism in the future will make it clear which part of the document is controlled by Leaflet.
84
+
@@ -0,0 +1,3 @@
1
+ <l-marker lat-lng="[55,-5]">
2
+ <l-popup content="I'm from the server"></l-popup>
3
+ </l-marker>
@@ -1,3 +1,8 @@
1
+ {% if config.base_url == "https://andrewgryan.github.io/leaflet-html" %}
2
+ {% set js_url = "https://unpkg.com/leaflet-html@latest/dist/leaflet-html.js" %}
3
+ {% else %}
4
+ {% set js_url = "/leaflet-html.js" %}
5
+ {% endif %}
1
6
  <!DOCTYPE html>
2
7
  <html>
3
8
  <head lang="en">
@@ -17,7 +22,7 @@
17
22
  {
18
23
  "imports": {
19
24
  "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
20
- "leaflet-html": "https://unpkg.com/leaflet-html@latest/dist/leaflet-html.js"
25
+ "leaflet-html": "{{ js_url | safe }}"
21
26
  }
22
27
  }
23
28
  </script>
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "leaflet-html",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "description": "Leaflet expressed in HTML",
6
+ "keywords": [
7
+ "leaflet",
8
+ "hda",
9
+ "html",
10
+ "hypermedia",
11
+ "maps"
12
+ ],
6
13
  "source": "src/index.js",
7
14
  "main": "./dist/leaflet-html.cjs",
8
15
  "module": "./dist/leaflet-html.js",
@@ -14,7 +21,7 @@
14
21
  "license": "MIT",
15
22
  "scripts": {
16
23
  "build": "microbundle",
17
- "watch": "microbundle watch",
24
+ "watch": "microbundle watch -o ./docs/static --format esm",
18
25
  "test": "vitest"
19
26
  },
20
27
  "devDependencies": {
@@ -1,8 +1,9 @@
1
1
  // @ts-check
2
2
  import { imageOverlay } from "leaflet";
3
3
  import { mapAddTo } from "./events.js";
4
+ import LLayer from "./l-layer.js";
4
5
 
5
- class LImageOverlay extends HTMLElement {
6
+ class LImageOverlay extends LLayer {
6
7
  static observedAttributes = ["url", "bounds", "opacity"];
7
8
 
8
9
  constructor() {
@@ -1,15 +1,19 @@
1
1
  // @ts-check
2
2
  import { layerGroup } from "leaflet";
3
3
  import { mapAddTo } from "./events.js";
4
+ import LLayer from "./l-layer.js";
4
5
 
5
- class LLayerGroup extends HTMLElement {
6
+ class LLayerGroup extends LLayer {
6
7
  constructor() {
7
8
  super();
9
+ this.layer = null;
8
10
  }
9
11
 
10
12
  connectedCallback() {
11
13
  const name = this.getAttribute("name");
12
14
  const group = layerGroup();
15
+ this.layer = group;
16
+
13
17
  const event = new CustomEvent(mapAddTo, {
14
18
  cancelable: true,
15
19
  bubbles: true,
package/src/l-layer.js ADDED
@@ -0,0 +1,8 @@
1
+ class LLayer extends HTMLElement {
2
+ constructor() {
3
+ super()
4
+ this.layer = null
5
+ }
6
+ }
7
+
8
+ export default LLayer
package/src/l-map.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
  import * as L from "leaflet";
3
3
  import { layerRemove, mapAddTo } from "./events.js";
4
- import LTileLayer from "./l-tile-layer.js";
4
+ import LLayer from "./l-layer.js";
5
5
 
6
6
  class LMap extends HTMLElement {
7
7
  constructor() {
@@ -21,7 +21,7 @@ class LMap extends HTMLElement {
21
21
  if (mutation.target instanceof LMap) {
22
22
  const el = mutation.target
23
23
  mutation.removedNodes.forEach((node) => {
24
- if (node instanceof LTileLayer) {
24
+ if (node instanceof LLayer) {
25
25
  if ((el.map !== null) && (node.layer !== null)) {
26
26
  el.map.removeLayer(node.layer)
27
27
  }
package/src/l-marker.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // @vitest-environment happy-dom
2
2
  import * as L from "leaflet";
3
3
  import { mapAddTo, popupAdd } from "./events.js";
4
+ import LLayer from "./l-layer.js";
4
5
 
5
- class LMarker extends HTMLElement {
6
+ class LMarker extends LLayer {
6
7
  static observedAttributes = ["lat-lng", "opacity", "icon"];
7
8
 
8
9
  constructor() {
@@ -1,8 +1,9 @@
1
1
  // @ts-check
2
2
  import { tileLayer } from "leaflet";
3
3
  import { mapAddTo } from "./events.js";
4
+ import LLayer from "./l-layer.js";
4
5
 
5
- class LTileLayer extends HTMLElement {
6
+ class LTileLayer extends LLayer {
6
7
  constructor() {
7
8
  super();
8
9
  this.layer = null
@@ -1,8 +1,9 @@
1
1
  // @ts-check
2
2
  import { videoOverlay } from "leaflet";
3
3
  import { mapAddTo } from "./events.js";
4
+ import LLayer from "./l-layer.js";
4
5
 
5
- class LVideoOverlay extends HTMLElement {
6
+ class LVideoOverlay extends LLayer {
6
7
  constructor() {
7
8
  super();
8
9
  }