leaflet-html 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- var t=function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(t){var a=t.dataset,e=a.center,r=a.zoom,o=L.map(t).setView(JSON.parse(e),parseInt(r));t.querySelectorAll("[data-control-layers]").forEach(function(t){var a={};t.querySelectorAll("[data-tile-layer]").forEach(function(t){var e=t.dataset,r=e.show,n=e.name;a[n]=L.tileLayer(e.urlTemplate,{maxZoom:e.maxZoom,attribution:e.attribution}),null!=r&&a[n].addTo(o)});var e={};t.querySelectorAll("[data-layer-group]").forEach(function(t){var a=t.dataset.name,r=[];new MutationObserver(function(t){var r=e[a];t.forEach(function(t){t.addedNodes.forEach(function(t){var a=L.marker(JSON.parse(t.dataset.latLng));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(function(t){var a=r.getLayer(t.dataset._leafletId);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(function(t){var a=t.dataset.latLng,e=t.dataset.opacity,n={opacity:parseFloat(void 0===e?"1.0":e)};console.log(n);var l=L.marker(JSON.parse(a),n).addTo(o);t.dataset._leafletId=L.stamp(l),new MutationObserver(function(t){t.forEach(function(t){l.setLatLng(JSON.parse(t.target.dataset.latLng))})}).observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(function(t){l.bindPopup(t.dataset.content),new MutationObserver(function(){l.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(l)}),e[a]=L.layerGroup(r)}),L.control.layers(a,e).addTo(o)})})};module.exports=function(){document.addEventListener("DOMContentLoaded",t)};
1
+ var t=void document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(t){var a=t.dataset,e=a.center,r=a.zoom,o=L.map(t).setView(JSON.parse(e),parseInt(r));t.querySelectorAll("[data-control-layers]").forEach(function(t){var a={};t.querySelectorAll("[data-tile-layer]").forEach(function(t){var e=t.dataset,r=e.show,n=e.name;a[n]=L.tileLayer(e.urlTemplate,{maxZoom:e.maxZoom,attribution:e.attribution}),null!=r&&a[n].addTo(o)});var e={};t.querySelectorAll("[data-layer-group]").forEach(function(t){var a=t.dataset.name,r=[];new MutationObserver(function(t){var r=e[a];t.forEach(function(t){t.addedNodes.forEach(function(t){var a=L.marker(JSON.parse(t.dataset.latLng));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(function(t){var a=r.getLayer(t.dataset._leafletId);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(function(t){var a=t.dataset.latLng,e=t.dataset.opacity,n={opacity:parseFloat(void 0===e?"1.0":e)};console.log(n);var l=L.marker(JSON.parse(a),n).addTo(o);t.dataset._leafletId=L.stamp(l),new MutationObserver(function(t){t.forEach(function(t){l.setLatLng(JSON.parse(t.target.dataset.latLng))})}).observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(function(t){l.bindPopup(t.dataset.content),new MutationObserver(function(){l.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(l)}),e[a]=L.layerGroup(r)}),L.control.layers(a,e).addTo(o)})})});module.exports=t;
2
2
  //# sourceMappingURL=leaflet-html.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaflet-html.cjs","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom))\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {}\n \n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } = tileEl.dataset\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map)\n }\n })\n\n const overlayMaps = {}\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset\n const layers = []\n\n const observer = new MutationObserver(function(mutations) {\n const group = overlayMaps[name]\n\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n const { latLng } = node.dataset // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng))\n group.addLayer(layer)\n map.addLayer(layer)\n })\n\n mutation.removedNodes.forEach(node => {\n const { _leafletId } = node.dataset\n const layer = group.getLayer(_leafletId)\n group.removeLayer(layer)\n\n map.removeLayer(layer)\n })\n })\n })\n observer.observe(el, { childList: true })\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset\n const { opacity = \"1.0\" } = el.dataset\n const options = { opacity: parseFloat(opacity) }\n console.log(options)\n const marker = L.marker(JSON.parse(latLng), options).addTo(map)\n el.dataset._leafletId = L.stamp(marker) // Save ID for later\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset\n marker.setLatLng(JSON.parse(latLng))\n })\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-lat-lng\"] })\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset\n marker.bindPopup(content)\n const observer = new MutationObserver(function() {\n marker.getPopup().setContent(el.dataset.content)\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-content\"] })\n })\n\n layers.push(marker)\n })\n\n overlayMaps[name] = L.layerGroup(layers)\n })\n\n L.control.layers(baseMaps, overlayMaps).addTo(map)\n })\n })\n}\n\nconst init = () => {\n document.addEventListener(\"DOMContentLoaded\", render)\n}\n\nexport default init\n"],"names":["render","document","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control","addEventListener"],"mappings":"AAAA,IAAMA,EAAS,WAEbC,SAASC,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EAA0DD,EAAOV,QAAzDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KACjDJ,EAASI,GAAQT,EAAEU,UADMH,EAAXI,YAC4B,CAAEC,QADGL,EAAPK,QACaC,YADfN,EAAXM,cAEf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAE,EAEtBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAASC,GAC7C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAA2B,GAChBA,EAASC,WAAW5B,QAAQ,SAAA6B,GAC1B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAA6B,GAC5B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADZ,IAAAH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAASC,GAC3CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACJ,GACSM,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,kBAG3DjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,iBAC7D,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF,iBAEa,WACXR,SAAS4D,iBAAiB,mBAAoB7D,EAChD"}
1
+ {"version":3,"file":"leaflet-html.cjs","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } =\n tileEl.dataset;\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n console.log(options);\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["init","document","addEventListener","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"AAAA,IA4FMA,OACJC,SAASC,iBAAiB,mBA7Fb,WAEbD,SAASE,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EACED,EAAOV,QADDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KAEjDJ,EAASI,GAAQT,EAAEU,UAFMH,EAAXI,YAE4B,CAAEC,QAFGL,EAAPK,QAEaC,YAFfN,EAAXM,cAGf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAA,EAEpBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAAUC,GAC9C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAC2B,GACjBA,EAASC,WAAW5B,QAAQ,SAAC6B,GAC3B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAC6B,GAC7B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADT,IAAHH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAAUC,GAC9CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACF,GACSM,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,kBAIpBjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,iBAEtB,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF"}
@@ -1,2 +1,2 @@
1
- var t=function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(t){var a=t.dataset,e=a.center,r=a.zoom,o=L.map(t).setView(JSON.parse(e),parseInt(r));t.querySelectorAll("[data-control-layers]").forEach(function(t){var a={};t.querySelectorAll("[data-tile-layer]").forEach(function(t){var e=t.dataset,r=e.show,n=e.name;a[n]=L.tileLayer(e.urlTemplate,{maxZoom:e.maxZoom,attribution:e.attribution}),null!=r&&a[n].addTo(o)});var e={};t.querySelectorAll("[data-layer-group]").forEach(function(t){var a=t.dataset.name,r=[];new MutationObserver(function(t){var r=e[a];t.forEach(function(t){t.addedNodes.forEach(function(t){var a=L.marker(JSON.parse(t.dataset.latLng));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(function(t){var a=r.getLayer(t.dataset._leafletId);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(function(t){var a=t.dataset.latLng,e=t.dataset.opacity,n={opacity:parseFloat(void 0===e?"1.0":e)};console.log(n);var l=L.marker(JSON.parse(a),n).addTo(o);t.dataset._leafletId=L.stamp(l),new MutationObserver(function(t){t.forEach(function(t){l.setLatLng(JSON.parse(t.target.dataset.latLng))})}).observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(function(t){l.bindPopup(t.dataset.content),new MutationObserver(function(){l.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(l)}),e[a]=L.layerGroup(r)}),L.control.layers(a,e).addTo(o)})})},a=function(){document.addEventListener("DOMContentLoaded",t)};export{a as default};
1
+ var t=void document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(t){var a=t.dataset,e=a.center,r=a.zoom,o=L.map(t).setView(JSON.parse(e),parseInt(r));t.querySelectorAll("[data-control-layers]").forEach(function(t){var a={};t.querySelectorAll("[data-tile-layer]").forEach(function(t){var e=t.dataset,r=e.show,n=e.name;a[n]=L.tileLayer(e.urlTemplate,{maxZoom:e.maxZoom,attribution:e.attribution}),null!=r&&a[n].addTo(o)});var e={};t.querySelectorAll("[data-layer-group]").forEach(function(t){var a=t.dataset.name,r=[];new MutationObserver(function(t){var r=e[a];t.forEach(function(t){t.addedNodes.forEach(function(t){var a=L.marker(JSON.parse(t.dataset.latLng));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(function(t){var a=r.getLayer(t.dataset._leafletId);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(function(t){var a=t.dataset.latLng,e=t.dataset.opacity,n={opacity:parseFloat(void 0===e?"1.0":e)};console.log(n);var l=L.marker(JSON.parse(a),n).addTo(o);t.dataset._leafletId=L.stamp(l),new MutationObserver(function(t){t.forEach(function(t){l.setLatLng(JSON.parse(t.target.dataset.latLng))})}).observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(function(t){l.bindPopup(t.dataset.content),new MutationObserver(function(){l.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(l)}),e[a]=L.layerGroup(r)}),L.control.layers(a,e).addTo(o)})})});export{t as default};
2
2
  //# sourceMappingURL=leaflet-html.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaflet-html.esm.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom))\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {}\n \n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } = tileEl.dataset\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map)\n }\n })\n\n const overlayMaps = {}\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset\n const layers = []\n\n const observer = new MutationObserver(function(mutations) {\n const group = overlayMaps[name]\n\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n const { latLng } = node.dataset // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng))\n group.addLayer(layer)\n map.addLayer(layer)\n })\n\n mutation.removedNodes.forEach(node => {\n const { _leafletId } = node.dataset\n const layer = group.getLayer(_leafletId)\n group.removeLayer(layer)\n\n map.removeLayer(layer)\n })\n })\n })\n observer.observe(el, { childList: true })\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset\n const { opacity = \"1.0\" } = el.dataset\n const options = { opacity: parseFloat(opacity) }\n console.log(options)\n const marker = L.marker(JSON.parse(latLng), options).addTo(map)\n el.dataset._leafletId = L.stamp(marker) // Save ID for later\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset\n marker.setLatLng(JSON.parse(latLng))\n })\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-lat-lng\"] })\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset\n marker.bindPopup(content)\n const observer = new MutationObserver(function() {\n marker.getPopup().setContent(el.dataset.content)\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-content\"] })\n })\n\n layers.push(marker)\n })\n\n overlayMaps[name] = L.layerGroup(layers)\n })\n\n L.control.layers(baseMaps, overlayMaps).addTo(map)\n })\n })\n}\n\nconst init = () => {\n document.addEventListener(\"DOMContentLoaded\", render)\n}\n\nexport default init\n"],"names":["render","document","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control","init","addEventListener"],"mappings":"AAAA,IAAMA,EAAS,WAEbC,SAASC,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EAA0DD,EAAOV,QAAzDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KACjDJ,EAASI,GAAQT,EAAEU,UADMH,EAAXI,YAC4B,CAAEC,QADGL,EAAPK,QACaC,YADfN,EAAXM,cAEf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAE,EAEtBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAASC,GAC7C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAA2B,GAChBA,EAASC,WAAW5B,QAAQ,SAAA6B,GAC1B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAA6B,GAC5B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADZ,IAAAH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAASC,GAC3CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACJ,GACSM,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,kBAG3DjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,iBAC7D,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF,EAEMoD,EAAO,WACX5D,SAAS6D,iBAAiB,mBAAoB9D,EAChD"}
1
+ {"version":3,"file":"leaflet-html.esm.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } =\n tileEl.dataset;\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n console.log(options);\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["init","document","addEventListener","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"AAAA,IA4FMA,OACJC,SAASC,iBAAiB,mBA7Fb,WAEbD,SAASE,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EACED,EAAOV,QADDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KAEjDJ,EAASI,GAAQT,EAAEU,UAFMH,EAAXI,YAE4B,CAAEC,QAFGL,EAAPK,QAEaC,YAFfN,EAAXM,cAGf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAA,EAEpBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAAUC,GAC9C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAC2B,GACjBA,EAASC,WAAW5B,QAAQ,SAAC6B,GAC3B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAC6B,GAC7B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADT,IAAHH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAAUC,GAC9CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACF,GACSM,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,kBAIpBjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,iBAEtB,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF"}
@@ -1,2 +1,2 @@
1
- const t=()=>{document.querySelectorAll("[data-leaflet-html]").forEach(t=>{const{center:e,zoom:a}=t.dataset,o=L.map(t).setView(JSON.parse(e),parseInt(a));t.querySelectorAll("[data-control-layers]").forEach(t=>{const e={};t.querySelectorAll("[data-tile-layer]").forEach(t=>{const{show:a,urlTemplate:r,attribution:n,maxZoom:s,name:l}=t.dataset;e[l]=L.tileLayer(r,{maxZoom:s,attribution:n}),null!=a&&e[l].addTo(o)});const a={};t.querySelectorAll("[data-layer-group]").forEach(t=>{const{name:e}=t.dataset,r=[];new MutationObserver(function(t){const r=a[e];t.forEach(t=>{t.addedNodes.forEach(t=>{const{latLng:e}=t.dataset,a=L.marker(JSON.parse(e));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(t=>{const{_leafletId:e}=t.dataset,a=r.getLayer(e);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(t=>{const{latLng:e}=t.dataset,{opacity:a="1.0"}=t.dataset,n={opacity:parseFloat(a)};console.log(n);const s=L.marker(JSON.parse(e),n).addTo(o);t.dataset._leafletId=L.stamp(s);const l=new MutationObserver(function(t){t.forEach(t=>{const{latLng:e}=t.target.dataset;s.setLatLng(JSON.parse(e))})});l.observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(t=>{const{content:e}=t.dataset;s.bindPopup(e),new MutationObserver(function(){s.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(s)}),a[e]=L.layerGroup(r)}),L.control.layers(e,a).addTo(o)})})},e=()=>{document.addEventListener("DOMContentLoaded",t)};export{e as default};
1
+ const t=void document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-leaflet-html]").forEach(t=>{const{center:e,zoom:a}=t.dataset,o=L.map(t).setView(JSON.parse(e),parseInt(a));t.querySelectorAll("[data-control-layers]").forEach(t=>{const e={};t.querySelectorAll("[data-tile-layer]").forEach(t=>{const{show:a,urlTemplate:r,attribution:n,maxZoom:s,name:l}=t.dataset;e[l]=L.tileLayer(r,{maxZoom:s,attribution:n}),null!=a&&e[l].addTo(o)});const a={};t.querySelectorAll("[data-layer-group]").forEach(t=>{const{name:e}=t.dataset,r=[];new MutationObserver(function(t){const r=a[e];t.forEach(t=>{t.addedNodes.forEach(t=>{const{latLng:e}=t.dataset,a=L.marker(JSON.parse(e));r.addLayer(a),o.addLayer(a)}),t.removedNodes.forEach(t=>{const{_leafletId:e}=t.dataset,a=r.getLayer(e);r.removeLayer(a),o.removeLayer(a)})})}).observe(t,{childList:!0}),t.querySelectorAll("[data-marker]").forEach(t=>{const{latLng:e}=t.dataset,{opacity:a="1.0"}=t.dataset,n={opacity:parseFloat(a)};console.log(n);const s=L.marker(JSON.parse(e),n).addTo(o);t.dataset._leafletId=L.stamp(s);const l=new MutationObserver(function(t){t.forEach(t=>{const{latLng:e}=t.target.dataset;s.setLatLng(JSON.parse(e))})});l.observe(t,{attributes:!0,attributeFilter:["data-lat-lng"]}),t.querySelectorAll("[data-popup]").forEach(t=>{const{content:e}=t.dataset;s.bindPopup(e),new MutationObserver(function(){s.getPopup().setContent(t.dataset.content)}).observe(t,{attributes:!0,attributeFilter:["data-content"]})}),r.push(s)}),a[e]=L.layerGroup(r)}),L.control.layers(e,a).addTo(o)})})});export{t as default};
2
2
  //# sourceMappingURL=leaflet-html.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaflet-html.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom))\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {}\n \n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } = tileEl.dataset\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map)\n }\n })\n\n const overlayMaps = {}\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset\n const layers = []\n\n const observer = new MutationObserver(function(mutations) {\n const group = overlayMaps[name]\n\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n const { latLng } = node.dataset // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng))\n group.addLayer(layer)\n map.addLayer(layer)\n })\n\n mutation.removedNodes.forEach(node => {\n const { _leafletId } = node.dataset\n const layer = group.getLayer(_leafletId)\n group.removeLayer(layer)\n\n map.removeLayer(layer)\n })\n })\n })\n observer.observe(el, { childList: true })\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset\n const { opacity = \"1.0\" } = el.dataset\n const options = { opacity: parseFloat(opacity) }\n console.log(options)\n const marker = L.marker(JSON.parse(latLng), options).addTo(map)\n el.dataset._leafletId = L.stamp(marker) // Save ID for later\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset\n marker.setLatLng(JSON.parse(latLng))\n })\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-lat-lng\"] })\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset\n marker.bindPopup(content)\n const observer = new MutationObserver(function() {\n marker.getPopup().setContent(el.dataset.content)\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-content\"] })\n })\n\n layers.push(marker)\n })\n\n overlayMaps[name] = L.layerGroup(layers)\n })\n\n L.control.layers(baseMaps, overlayMaps).addTo(map)\n })\n })\n}\n\nconst init = () => {\n document.addEventListener(\"DOMContentLoaded\", render)\n}\n\nexport default init\n"],"names":["render","document","querySelectorAll","forEach","el","center","zoom","dataset","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","show","urlTemplate","attribution","maxZoom","name","tileLayer","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","latLng","layer","marker","addLayer","removedNodes","_leafletId","getLayer","removeLayer","observe","childList","opacity","options","parseFloat","console","log","stamp","observer","target","setLatLng","attributes","attributeFilter","content","bindPopup","getPopup","setContent","push","layerGroup","control","init","addEventListener"],"mappings":"AAAA,MAAMA,EAASA,KAEbC,SAASC,iBAAiB,uBAAuBC,QAASC,IACxD,MAAMC,OAAEA,EAAMC,KAAEA,GAASF,EAAGG,QACtBC,EAAMC,EAAED,IAAIJ,GAAIM,QAAQC,KAAKC,MAAMP,GAASQ,SAASP,IAG3DF,EAAGF,iBAAiB,yBAAyBC,QAASC,IACpD,MAAMU,EAAW,GAGjBV,EAAGF,iBAAiB,qBAAqBC,QAASY,IAChD,MAAMC,KAAEA,EAAIC,YAAEA,EAAWC,YAAEA,EAAWC,QAAEA,EAAOC,KAAEA,GAASL,EAAOR,QACjEO,EAASM,GAAQX,EAAEY,UAAUJ,EAAa,CAAEE,UAASD,gBACzC,MAARF,GACFF,EAASM,GAAME,MAAMd,EACvB,GAGF,MAAMe,EAAc,CAAE,EAEtBnB,EAAGF,iBAAiB,sBAAsBC,QAASC,IACjD,MAAMgB,KAAEA,GAAShB,EAAGG,QACdiB,EAAS,GAEE,IAAIC,iBAAiB,SAASC,GAC7C,MAAMC,EAAQJ,EAAYH,GAE1BM,EAAUvB,QAAQyB,IAChBA,EAASC,WAAW1B,QAAQ2B,IAC1B,MAAMC,OAAEA,GAAWD,EAAKvB,QAClByB,EAAQvB,EAAEwB,OAAOtB,KAAKC,MAAMmB,IAClCJ,EAAMO,SAASF,GACfxB,EAAI0B,SAASF,EACf,GAEAJ,EAASO,aAAahC,QAAQ2B,IAC5B,MAAMM,WAAEA,GAAeN,EAAKvB,QACtByB,EAAQL,EAAMU,SAASD,GAC7BT,EAAMW,YAAYN,GAElBxB,EAAI8B,YAAYN,EAAK,EAEzB,EACF,GACSO,QAAQnC,EAAI,CAAEoC,WAAW,IAGlCpC,EAAGF,iBAAiB,iBAAiBC,QAASC,IAC5C,MAAM2B,OAAEA,GAAW3B,EAAGG,SAChBkC,QAAEA,EAAU,OAAUrC,EAAGG,QACzBmC,EAAU,CAAED,QAASE,WAAWF,IACtCG,QAAQC,IAAIH,GACZ,MAAMT,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMmB,GAASW,GAASpB,MAAMd,GAC3DJ,EAAGG,QAAQ6B,WAAa3B,EAAEqC,MAAMb,GAEhC,MAAMc,EAAW,IAAItB,iBAAiB,SAASC,GAC3CA,EAAUvB,QAASyB,IACjB,MAAMG,OAAEA,GAAWH,EAASoB,OAAOzC,QACnC0B,EAAOgB,UAAUtC,KAAKC,MAAMmB,GAC9B,EACJ,GACAgB,EAASR,QAAQnC,EAAI,CAAE8C,YAAY,EAAMC,gBAAiB,CAAC,kBAG3D/C,EAAGF,iBAAiB,gBAAgBC,QAASC,IAC3C,MAAMgD,QAAEA,GAAYhD,EAAGG,QACvB0B,EAAOoB,UAAUD,GACA,IAAI3B,iBAAiB,WACpCQ,EAAOqB,WAAWC,WAAWnD,EAAGG,QAAQ6C,QAC1C,GACSb,QAAQnC,EAAI,CAAE8C,YAAY,EAAMC,gBAAiB,CAAC,iBAC7D,GAEA3B,EAAOgC,KAAKvB,EACd,GAEAV,EAAYH,GAAQX,EAAEgD,WAAWjC,EACnC,GAEAf,EAAEiD,QAAQlC,OAAOV,EAAUS,GAAaD,MAAMd,EAChD,EACF,EACF,EAEMmD,EAAOA,KACX1D,SAAS2D,iBAAiB,mBAAoB5D,EAChD"}
1
+ {"version":3,"file":"leaflet-html.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } =\n tileEl.dataset;\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n console.log(options);\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["init","document","addEventListener","render","querySelectorAll","forEach","el","center","zoom","dataset","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","show","urlTemplate","attribution","maxZoom","name","tileLayer","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","latLng","layer","marker","addLayer","removedNodes","_leafletId","getLayer","removeLayer","observe","childList","opacity","options","parseFloat","console","log","stamp","observer","target","setLatLng","attributes","attributeFilter","content","bindPopup","getPopup","setContent","push","layerGroup","control"],"mappings":"AAAA,MA4FMA,OACJC,SAASC,iBAAiB,mBA7FbC,KAEbF,SAASG,iBAAiB,uBAAuBC,QAASC,IACxD,MAAMC,OAAEA,EAAMC,KAAEA,GAASF,EAAGG,QACtBC,EAAMC,EAAED,IAAIJ,GAAIM,QAAQC,KAAKC,MAAMP,GAASQ,SAASP,IAG3DF,EAAGF,iBAAiB,yBAAyBC,QAASC,IACpD,MAAMU,EAAW,CAAA,EAGjBV,EAAGF,iBAAiB,qBAAqBC,QAASY,IAChD,MAAMC,KAAEA,EAAIC,YAAEA,EAAWC,YAAEA,EAAWC,QAAEA,EAAOC,KAAEA,GAC/CL,EAAOR,QACTO,EAASM,GAAQX,EAAEY,UAAUJ,EAAa,CAAEE,UAASD,gBACzC,MAARF,GACFF,EAASM,GAAME,MAAMd,EACvB,GAGF,MAAMe,EAAc,CAAA,EAEpBnB,EAAGF,iBAAiB,sBAAsBC,QAASC,IACjD,MAAMgB,KAAEA,GAAShB,EAAGG,QACdiB,EAAS,GAEE,IAAIC,iBAAiB,SAAUC,GAC9C,MAAMC,EAAQJ,EAAYH,GAE1BM,EAAUvB,QAASyB,IACjBA,EAASC,WAAW1B,QAAS2B,IAC3B,MAAMC,OAAEA,GAAWD,EAAKvB,QAClByB,EAAQvB,EAAEwB,OAAOtB,KAAKC,MAAMmB,IAClCJ,EAAMO,SAASF,GACfxB,EAAI0B,SAASF,EAAK,GAGpBJ,EAASO,aAAahC,QAAS2B,IAC7B,MAAMM,WAAEA,GAAeN,EAAKvB,QACtByB,EAAQL,EAAMU,SAASD,GAC7BT,EAAMW,YAAYN,GAElBxB,EAAI8B,YAAYN,EAClB,IAEJ,GACSO,QAAQnC,EAAI,CAAEoC,WAAW,IAGlCpC,EAAGF,iBAAiB,iBAAiBC,QAASC,IAC5C,MAAM2B,OAAEA,GAAW3B,EAAGG,SAChBkC,QAAEA,EAAU,OAAUrC,EAAGG,QACzBmC,EAAU,CAAED,QAASE,WAAWF,IACtCG,QAAQC,IAAIH,GACZ,MAAMT,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMmB,GAASW,GAASpB,MAAMd,GAC3DJ,EAAGG,QAAQ6B,WAAa3B,EAAEqC,MAAMb,GAEhC,MAAMc,EAAW,IAAItB,iBAAiB,SAAUC,GAC9CA,EAAUvB,QAASyB,IACjB,MAAMG,OAAEA,GAAWH,EAASoB,OAAOzC,QACnC0B,EAAOgB,UAAUtC,KAAKC,MAAMmB,GAAO,EAEvC,GACAgB,EAASR,QAAQnC,EAAI,CACnB8C,YAAY,EACZC,gBAAiB,CAAC,kBAIpB/C,EAAGF,iBAAiB,gBAAgBC,QAASC,IAC3C,MAAMgD,QAAEA,GAAYhD,EAAGG,QACvB0B,EAAOoB,UAAUD,GACA,IAAI3B,iBAAiB,WACpCQ,EAAOqB,WAAWC,WAAWnD,EAAGG,QAAQ6C,QAC1C,GACSb,QAAQnC,EAAI,CACnB8C,YAAY,EACZC,gBAAiB,CAAC,iBACnB,GAGH3B,EAAOgC,KAAKvB,EAAM,GAGpBV,EAAYH,GAAQX,EAAEgD,WAAWjC,EAAM,GAGzCf,EAAEiD,QAAQlC,OAAOV,EAAUS,GAAaD,MAAMd,EAAG,EAErD,EACF"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).leafletHtml=t()}(this,function(){var e=function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(e){var t=e.dataset,a=t.center,o=t.zoom,r=L.map(e).setView(JSON.parse(a),parseInt(o));e.querySelectorAll("[data-control-layers]").forEach(function(e){var t={};e.querySelectorAll("[data-tile-layer]").forEach(function(e){var a=e.dataset,o=a.show,n=a.name;t[n]=L.tileLayer(a.urlTemplate,{maxZoom:a.maxZoom,attribution:a.attribution}),null!=o&&t[n].addTo(r)});var a={};e.querySelectorAll("[data-layer-group]").forEach(function(e){var t=e.dataset.name,o=[];new MutationObserver(function(e){var o=a[t];e.forEach(function(e){e.addedNodes.forEach(function(e){var t=L.marker(JSON.parse(e.dataset.latLng));o.addLayer(t),r.addLayer(t)}),e.removedNodes.forEach(function(e){var t=o.getLayer(e.dataset._leafletId);o.removeLayer(t),r.removeLayer(t)})})}).observe(e,{childList:!0}),e.querySelectorAll("[data-marker]").forEach(function(e){var t=e.dataset.latLng,a=e.dataset.opacity,n={opacity:parseFloat(void 0===a?"1.0":a)};console.log(n);var l=L.marker(JSON.parse(t),n).addTo(r);e.dataset._leafletId=L.stamp(l),new MutationObserver(function(e){e.forEach(function(e){l.setLatLng(JSON.parse(e.target.dataset.latLng))})}).observe(e,{attributes:!0,attributeFilter:["data-lat-lng"]}),e.querySelectorAll("[data-popup]").forEach(function(e){l.bindPopup(e.dataset.content),new MutationObserver(function(){l.getPopup().setContent(e.dataset.content)}).observe(e,{attributes:!0,attributeFilter:["data-content"]})}),o.push(l)}),a[t]=L.layerGroup(o)}),L.control.layers(t,a).addTo(r)})})};return function(){document.addEventListener("DOMContentLoaded",e)}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).leafletHtml=t()}(this,function(){document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("[data-leaflet-html]").forEach(function(e){var t=e.dataset,a=t.center,o=t.zoom,r=L.map(e).setView(JSON.parse(a),parseInt(o));e.querySelectorAll("[data-control-layers]").forEach(function(e){var t={};e.querySelectorAll("[data-tile-layer]").forEach(function(e){var a=e.dataset,o=a.show,n=a.name;t[n]=L.tileLayer(a.urlTemplate,{maxZoom:a.maxZoom,attribution:a.attribution}),null!=o&&t[n].addTo(r)});var a={};e.querySelectorAll("[data-layer-group]").forEach(function(e){var t=e.dataset.name,o=[];new MutationObserver(function(e){var o=a[t];e.forEach(function(e){e.addedNodes.forEach(function(e){var t=L.marker(JSON.parse(e.dataset.latLng));o.addLayer(t),r.addLayer(t)}),e.removedNodes.forEach(function(e){var t=o.getLayer(e.dataset._leafletId);o.removeLayer(t),r.removeLayer(t)})})}).observe(e,{childList:!0}),e.querySelectorAll("[data-marker]").forEach(function(e){var t=e.dataset.latLng,a=e.dataset.opacity,n={opacity:parseFloat(void 0===a?"1.0":a)};console.log(n);var l=L.marker(JSON.parse(t),n).addTo(r);e.dataset._leafletId=L.stamp(l),new MutationObserver(function(e){e.forEach(function(e){l.setLatLng(JSON.parse(e.target.dataset.latLng))})}).observe(e,{attributes:!0,attributeFilter:["data-lat-lng"]}),e.querySelectorAll("[data-popup]").forEach(function(e){l.bindPopup(e.dataset.content),new MutationObserver(function(){l.getPopup().setContent(e.dataset.content)}).observe(e,{attributes:!0,attributeFilter:["data-content"]})}),o.push(l)}),a[t]=L.layerGroup(o)}),L.control.layers(t,a).addTo(r)})})})});
2
2
  //# sourceMappingURL=leaflet-html.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaflet-html.umd.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom))\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {}\n \n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } = tileEl.dataset\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map)\n }\n })\n\n const overlayMaps = {}\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset\n const layers = []\n\n const observer = new MutationObserver(function(mutations) {\n const group = overlayMaps[name]\n\n mutations.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n const { latLng } = node.dataset // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng))\n group.addLayer(layer)\n map.addLayer(layer)\n })\n\n mutation.removedNodes.forEach(node => {\n const { _leafletId } = node.dataset\n const layer = group.getLayer(_leafletId)\n group.removeLayer(layer)\n\n map.removeLayer(layer)\n })\n })\n })\n observer.observe(el, { childList: true })\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset\n const { opacity = \"1.0\" } = el.dataset\n const options = { opacity: parseFloat(opacity) }\n console.log(options)\n const marker = L.marker(JSON.parse(latLng), options).addTo(map)\n el.dataset._leafletId = L.stamp(marker) // Save ID for later\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset\n marker.setLatLng(JSON.parse(latLng))\n })\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-lat-lng\"] })\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset\n marker.bindPopup(content)\n const observer = new MutationObserver(function() {\n marker.getPopup().setContent(el.dataset.content)\n })\n observer.observe(el, { attributes: true, attributeFilter: [\"data-content\"] })\n })\n\n layers.push(marker)\n })\n\n overlayMaps[name] = L.layerGroup(layers)\n })\n\n L.control.layers(baseMaps, overlayMaps).addTo(map)\n })\n })\n}\n\nconst init = () => {\n document.addEventListener(\"DOMContentLoaded\", render)\n}\n\nexport default init\n"],"names":["render","document","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control","addEventListener"],"mappings":"8NAAA,IAAMA,EAAS,WAEbC,SAASC,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EAA0DD,EAAOV,QAAzDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KACjDJ,EAASI,GAAQT,EAAEU,UADMH,EAAXI,YAC4B,CAAEC,QADGL,EAAPK,QACaC,YADfN,EAAXM,cAEf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAE,EAEtBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAASC,GAC7C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAA2B,GAChBA,EAASC,WAAW5B,QAAQ,SAAA6B,GAC1B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAA6B,GAC5B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADZ,IAAAH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAASC,GAC3CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACJ,GACSM,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,kBAG3DjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CAAEgD,YAAY,EAAMC,gBAAiB,CAAC,iBAC7D,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF,SAEa,WACXR,SAAS4D,iBAAiB,mBAAoB7D,EAChD"}
1
+ {"version":3,"file":"leaflet-html.umd.js","sources":["../src/index.js"],"sourcesContent":["const render = () => {\n // Render Leaflet API calls\n document.querySelectorAll(\"[data-leaflet-html]\").forEach((el) => {\n const { center, zoom } = el.dataset;\n const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));\n\n // L.control.layers\n el.querySelectorAll(\"[data-control-layers]\").forEach((el) => {\n const baseMaps = {};\n\n // L.tileLayers\n el.querySelectorAll(\"[data-tile-layer]\").forEach((tileEl) => {\n const { show, urlTemplate, attribution, maxZoom, name } =\n tileEl.dataset;\n baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });\n if (show != null) {\n baseMaps[name].addTo(map);\n }\n });\n\n const overlayMaps = {};\n // L.layerGroup\n el.querySelectorAll(\"[data-layer-group]\").forEach((el) => {\n const { name } = el.dataset;\n const layers = [];\n\n const observer = new MutationObserver(function (mutations) {\n const group = overlayMaps[name];\n\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n const { latLng } = node.dataset; // MutationObserver needed\n const layer = L.marker(JSON.parse(latLng));\n group.addLayer(layer);\n map.addLayer(layer);\n });\n\n mutation.removedNodes.forEach((node) => {\n const { _leafletId } = node.dataset;\n const layer = group.getLayer(_leafletId);\n group.removeLayer(layer);\n\n map.removeLayer(layer);\n });\n });\n });\n observer.observe(el, { childList: true });\n\n // L.marker\n el.querySelectorAll(\"[data-marker]\").forEach((el) => {\n const { latLng } = el.dataset;\n const { opacity = \"1.0\" } = el.dataset;\n const options = { opacity: parseFloat(opacity) };\n console.log(options);\n const marker = L.marker(JSON.parse(latLng), options).addTo(map);\n el.dataset._leafletId = L.stamp(marker); // Save ID for later\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n const { latLng } = mutation.target.dataset;\n marker.setLatLng(JSON.parse(latLng));\n });\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-lat-lng\"],\n });\n\n // marker.bindPopup\n el.querySelectorAll(\"[data-popup]\").forEach((el) => {\n const { content } = el.dataset;\n marker.bindPopup(content);\n const observer = new MutationObserver(function () {\n marker.getPopup().setContent(el.dataset.content);\n });\n observer.observe(el, {\n attributes: true,\n attributeFilter: [\"data-content\"],\n });\n });\n\n layers.push(marker);\n });\n\n overlayMaps[name] = L.layerGroup(layers);\n });\n\n L.control.layers(baseMaps, overlayMaps).addTo(map);\n });\n });\n};\n\nconst init = (() => {\n document.addEventListener(\"DOMContentLoaded\", render);\n})();\n\nexport default init;\n"],"names":["document","addEventListener","querySelectorAll","forEach","el","_el$dataset","dataset","center","zoom","map","L","setView","JSON","parse","parseInt","baseMaps","tileEl","_tileEl$dataset","show","name","tileLayer","urlTemplate","maxZoom","attribution","addTo","overlayMaps","layers","MutationObserver","mutations","group","mutation","addedNodes","node","layer","marker","latLng","addLayer","removedNodes","getLayer","_leafletId","removeLayer","observe","childList","_el$dataset$opacity","opacity","options","parseFloat","console","log","stamp","setLatLng","target","attributes","attributeFilter","bindPopup","content","getPopup","setContent","push","layerGroup","control"],"mappings":"8NA6FEA,SAASC,iBAAiB,mBA7Fb,WAEbD,SAASE,iBAAiB,uBAAuBC,QAAQ,SAACC,GACxD,IAAAC,EAAyBD,EAAGE,QAApBC,EAAMF,EAANE,OAAQC,EAAIH,EAAJG,KACVC,EAAMC,EAAED,IAAIL,GAAIO,QAAQC,KAAKC,MAAMN,GAASO,SAASN,IAG3DJ,EAAGF,iBAAiB,yBAAyBC,QAAQ,SAACC,GACpD,IAAMW,EAAW,GAGjBX,EAAGF,iBAAiB,qBAAqBC,QAAQ,SAACa,GAChD,IAAAC,EACED,EAAOV,QADDY,EAAID,EAAJC,KAAyCC,EAAIF,EAAJE,KAEjDJ,EAASI,GAAQT,EAAEU,UAFMH,EAAXI,YAE4B,CAAEC,QAFGL,EAAPK,QAEaC,YAFfN,EAAXM,cAGf,MAARL,GACFH,EAASI,GAAMK,MAAMf,EAEzB,GAEA,IAAMgB,EAAc,CAAA,EAEpBrB,EAAGF,iBAAiB,sBAAsBC,QAAQ,SAACC,GACjD,IAAQe,EAASf,EAAGE,QAAZa,KACFO,EAAS,GAEE,IAAIC,iBAAiB,SAAUC,GAC9C,IAAMC,EAAQJ,EAAYN,GAE1BS,EAAUzB,QAAQ,SAAC2B,GACjBA,EAASC,WAAW5B,QAAQ,SAAC6B,GAC3B,IACMC,EAAQvB,EAAEwB,OAAOtB,KAAKC,MADTmB,EAAK1B,QAAhB6B,SAERN,EAAMO,SAASH,GACfxB,EAAI2B,SAASH,EACf,GAEAH,EAASO,aAAalC,QAAQ,SAAC6B,GAC7B,IACMC,EAAQJ,EAAMS,SADGN,EAAK1B,QAApBiC,YAERV,EAAMW,YAAYP,GAElBxB,EAAI+B,YAAYP,EAClB,EACF,EACF,GACSQ,QAAQrC,EAAI,CAAEsC,WAAW,IAGlCtC,EAAGF,iBAAiB,iBAAiBC,QAAQ,SAACC,GAC5C,IAAQ+B,EAAW/B,EAAGE,QAAd6B,OACRQ,EAA4BvC,EAAGE,QAAvBsC,QACFC,EAAU,CAAED,QAASE,gBADT,IAAHH,EAAG,MAAKA,IAEvBI,QAAQC,IAAIH,GACZ,IAAMX,EAASxB,EAAEwB,OAAOtB,KAAKC,MAAMsB,GAASU,GAASrB,MAAMf,GAC3DL,EAAGE,QAAQiC,WAAa7B,EAAEuC,MAAMf,GAEf,IAAIP,iBAAiB,SAAUC,GAC9CA,EAAUzB,QAAQ,SAAC2B,GAEjBI,EAAOgB,UAAUtC,KAAKC,MADHiB,EAASqB,OAAO7C,QAA3B6B,QAEV,EACF,GACSM,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,kBAIpBjD,EAAGF,iBAAiB,gBAAgBC,QAAQ,SAACC,GAE3C8B,EAAOoB,UADalD,EAAGE,QAAfiD,SAES,IAAI5B,iBAAiB,WACpCO,EAAOsB,WAAWC,WAAWrD,EAAGE,QAAQiD,QAC1C,GACSd,QAAQrC,EAAI,CACnBgD,YAAY,EACZC,gBAAiB,CAAC,iBAEtB,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF"}
@@ -14,7 +14,10 @@
14
14
  integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
15
15
  crossorigin=""
16
16
  ></script>
17
- <script src="https://www.unpkg.com/leaflet-html@0.1.3/dist/leaflet-html.umd.js"></script>
17
+ <script
18
+ src="https://www.unpkg.com/leaflet-html@0.1.5/dist/leaflet-html.umd.js"
19
+ defer
20
+ ></script>
18
21
  <style>
19
22
  * {
20
23
  margin: 0;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "leaflet-html",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "description": "Leaflet expressed in HTML",
6
6
  "source": "src/index.js",
7
7
  "main": "./dist/leaflet-html.js",
8
+ "umd:main": "./dist/leaflet-html.umd.js",
8
9
  "exports": {
9
10
  "default": "./dist/leaflet-html.js"
10
11
  },
package/src/index.js CHANGED
@@ -1,90 +1,97 @@
1
1
  const render = () => {
2
2
  // Render Leaflet API calls
3
3
  document.querySelectorAll("[data-leaflet-html]").forEach((el) => {
4
- const { center, zoom } = el.dataset
5
- const map = L.map(el).setView(JSON.parse(center), parseInt(zoom))
4
+ const { center, zoom } = el.dataset;
5
+ const map = L.map(el).setView(JSON.parse(center), parseInt(zoom));
6
6
 
7
7
  // L.control.layers
8
8
  el.querySelectorAll("[data-control-layers]").forEach((el) => {
9
- const baseMaps = {}
10
-
9
+ const baseMaps = {};
10
+
11
11
  // L.tileLayers
12
12
  el.querySelectorAll("[data-tile-layer]").forEach((tileEl) => {
13
- const { show, urlTemplate, attribution, maxZoom, name } = tileEl.dataset
13
+ const { show, urlTemplate, attribution, maxZoom, name } =
14
+ tileEl.dataset;
14
15
  baseMaps[name] = L.tileLayer(urlTemplate, { maxZoom, attribution });
15
16
  if (show != null) {
16
- baseMaps[name].addTo(map)
17
+ baseMaps[name].addTo(map);
17
18
  }
18
- })
19
+ });
19
20
 
20
- const overlayMaps = {}
21
+ const overlayMaps = {};
21
22
  // L.layerGroup
22
23
  el.querySelectorAll("[data-layer-group]").forEach((el) => {
23
- const { name } = el.dataset
24
- const layers = []
24
+ const { name } = el.dataset;
25
+ const layers = [];
25
26
 
26
- const observer = new MutationObserver(function(mutations) {
27
- const group = overlayMaps[name]
27
+ const observer = new MutationObserver(function (mutations) {
28
+ const group = overlayMaps[name];
28
29
 
29
- mutations.forEach(mutation => {
30
- mutation.addedNodes.forEach(node => {
31
- const { latLng } = node.dataset // MutationObserver needed
32
- const layer = L.marker(JSON.parse(latLng))
33
- group.addLayer(layer)
34
- map.addLayer(layer)
35
- })
30
+ mutations.forEach((mutation) => {
31
+ mutation.addedNodes.forEach((node) => {
32
+ const { latLng } = node.dataset; // MutationObserver needed
33
+ const layer = L.marker(JSON.parse(latLng));
34
+ group.addLayer(layer);
35
+ map.addLayer(layer);
36
+ });
36
37
 
37
- mutation.removedNodes.forEach(node => {
38
- const { _leafletId } = node.dataset
39
- const layer = group.getLayer(_leafletId)
40
- group.removeLayer(layer)
38
+ mutation.removedNodes.forEach((node) => {
39
+ const { _leafletId } = node.dataset;
40
+ const layer = group.getLayer(_leafletId);
41
+ group.removeLayer(layer);
41
42
 
42
- map.removeLayer(layer)
43
- })
44
- })
45
- })
46
- observer.observe(el, { childList: true })
43
+ map.removeLayer(layer);
44
+ });
45
+ });
46
+ });
47
+ observer.observe(el, { childList: true });
47
48
 
48
49
  // L.marker
49
50
  el.querySelectorAll("[data-marker]").forEach((el) => {
50
- const { latLng } = el.dataset
51
- const { opacity = "1.0" } = el.dataset
52
- const options = { opacity: parseFloat(opacity) }
53
- console.log(options)
54
- const marker = L.marker(JSON.parse(latLng), options).addTo(map)
55
- el.dataset._leafletId = L.stamp(marker) // Save ID for later
51
+ const { latLng } = el.dataset;
52
+ const { opacity = "1.0" } = el.dataset;
53
+ const options = { opacity: parseFloat(opacity) };
54
+ console.log(options);
55
+ const marker = L.marker(JSON.parse(latLng), options).addTo(map);
56
+ el.dataset._leafletId = L.stamp(marker); // Save ID for later
56
57
 
57
- const observer = new MutationObserver(function(mutations) {
58
- mutations.forEach((mutation) => {
59
- const { latLng } = mutation.target.dataset
60
- marker.setLatLng(JSON.parse(latLng))
61
- })
62
- })
63
- observer.observe(el, { attributes: true, attributeFilter: ["data-lat-lng"] })
58
+ const observer = new MutationObserver(function (mutations) {
59
+ mutations.forEach((mutation) => {
60
+ const { latLng } = mutation.target.dataset;
61
+ marker.setLatLng(JSON.parse(latLng));
62
+ });
63
+ });
64
+ observer.observe(el, {
65
+ attributes: true,
66
+ attributeFilter: ["data-lat-lng"],
67
+ });
64
68
 
65
69
  // marker.bindPopup
66
70
  el.querySelectorAll("[data-popup]").forEach((el) => {
67
- const { content } = el.dataset
68
- marker.bindPopup(content)
69
- const observer = new MutationObserver(function() {
70
- marker.getPopup().setContent(el.dataset.content)
71
- })
72
- observer.observe(el, { attributes: true, attributeFilter: ["data-content"] })
73
- })
71
+ const { content } = el.dataset;
72
+ marker.bindPopup(content);
73
+ const observer = new MutationObserver(function () {
74
+ marker.getPopup().setContent(el.dataset.content);
75
+ });
76
+ observer.observe(el, {
77
+ attributes: true,
78
+ attributeFilter: ["data-content"],
79
+ });
80
+ });
74
81
 
75
- layers.push(marker)
76
- })
82
+ layers.push(marker);
83
+ });
77
84
 
78
- overlayMaps[name] = L.layerGroup(layers)
79
- })
85
+ overlayMaps[name] = L.layerGroup(layers);
86
+ });
80
87
 
81
- L.control.layers(baseMaps, overlayMaps).addTo(map)
82
- })
83
- })
84
- }
88
+ L.control.layers(baseMaps, overlayMaps).addTo(map);
89
+ });
90
+ });
91
+ };
85
92
 
86
- const init = () => {
87
- document.addEventListener("DOMContentLoaded", render)
88
- }
93
+ const init = (() => {
94
+ document.addEventListener("DOMContentLoaded", render);
95
+ })();
89
96
 
90
- export default init
97
+ export default init;