leaflet-html 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/leaflet-html.cjs +1 -1
- package/dist/leaflet-html.cjs.map +1 -1
- package/dist/leaflet-html.esm.js +1 -1
- package/dist/leaflet-html.esm.js.map +1 -1
- package/dist/leaflet-html.js +1 -1
- package/dist/leaflet-html.js.map +1 -1
- package/dist/leaflet-html.umd.js +1 -1
- package/dist/leaflet-html.umd.js.map +1 -1
- package/example/index.html +1 -1
- package/package.json +1 -1
package/dist/leaflet-html.cjs
CHANGED
@@ -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=
|
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
|
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,GACF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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"}
|
package/dist/leaflet-html.esm.js
CHANGED
@@ -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)})})}
|
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
|
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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CAAC,iBAEtB,GAEA3B,EAAOgC,KAAKxB,EACd,GAEAT,EAAYN,GAAQT,EAAEiD,WAAWjC,EACnC,GAEAhB,EAAEkD,QAAQlC,OAAOX,EAAUU,GAAaD,MAAMf,EAChD,EACF,EACF"}
|
package/dist/leaflet-html.js
CHANGED
@@ -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)})})}
|
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
|
package/dist/leaflet-html.js.map
CHANGED
@@ -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
|
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,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AAKvB,EAAM,GAGpBV,EAAYH,GAAQX,EAAEgD,WAAWjC,EAAM,GAGzCf,EAAEiD,QAAQlC,OAAOV,EAAUS,GAAaD,MAAMd,EAAG,EAErD,EACF"}
|
package/dist/leaflet-html.umd.js
CHANGED
@@ -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(){
|
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
|
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,yBAAy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