leaflet-html 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/.github/workflows/npm-publish.yml +27 -27
  2. package/.prettierignore +2 -0
  3. package/.prettierrc +1 -0
  4. package/README.md +2 -2
  5. package/dist/leaflet-html.cjs +1 -1
  6. package/dist/leaflet-html.cjs.map +1 -1
  7. package/dist/leaflet-html.js +1 -1
  8. package/dist/leaflet-html.js.map +1 -1
  9. package/dist/leaflet-html.modern.js +2 -0
  10. package/dist/leaflet-html.modern.js.map +1 -0
  11. package/dist/leaflet-html.umd.js +1 -1
  12. package/dist/leaflet-html.umd.js.map +1 -1
  13. package/docs/content/_index.md +7 -2
  14. package/docs/content/articles/_index.md +5 -0
  15. package/docs/content/articles/basic.md +115 -0
  16. package/docs/content/articles/icons.md +35 -0
  17. package/docs/content/articles/style.md +14 -0
  18. package/docs/public/icons/leaf-green.png +0 -0
  19. package/docs/public/icons/leaf-orange.png +0 -0
  20. package/docs/public/icons/leaf-red.png +0 -0
  21. package/docs/public/icons/leaf-shadow.png +0 -0
  22. package/docs/static/icons/leaf-green.png +0 -0
  23. package/docs/static/icons/leaf-orange.png +0 -0
  24. package/docs/static/icons/leaf-red.png +0 -0
  25. package/docs/static/icons/leaf-shadow.png +0 -0
  26. package/docs/templates/article-page.html +8 -0
  27. package/docs/templates/article.html +12 -0
  28. package/docs/templates/base.html +66 -0
  29. package/docs/templates/index.html +5 -56
  30. package/example/geojson/index.html +7 -0
  31. package/example/index.html +7 -0
  32. package/example/overlays/index.html +7 -0
  33. package/package.json +12 -9
  34. package/src/events.js +3 -3
  35. package/src/index.js +19 -18
  36. package/src/l-base-layers.js +6 -7
  37. package/src/l-control-layers.js +17 -17
  38. package/src/l-geojson.js +13 -11
  39. package/src/l-icon.js +124 -0
  40. package/src/l-image-overlay.js +22 -20
  41. package/src/l-lat-lng-bounds.js +7 -7
  42. package/src/l-layer-group.js +15 -15
  43. package/src/l-map.js +17 -17
  44. package/src/l-marker.js +67 -18
  45. package/src/l-overlay-layers.js +6 -6
  46. package/src/l-popup.js +8 -10
  47. package/src/l-tile-layer.js +13 -10
  48. package/src/l-video-overlay.js +17 -16
  49. package/vite.config.js +7 -0
  50. package/dist/leaflet-html.esm.js +0 -2
  51. package/dist/leaflet-html.esm.js.map +0 -1
@@ -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-map.js","../src/l-marker.js","../src/l-overlay-layers.js","../src/l-popup.js","../src/l-tile-layer.js","../src/l-lat-lng-bounds.js","../src/l-image-overlay.js","../src/l-video-overlay.js","../src/l-geojson.js","../src/index.js"],"sourcesContent":["export const mapAddTo = \"map:addTo\"\nexport const popupAdd = \"popup:add\"\nexport const layerRemove = \"layer:remove\"\n","import { mapAddTo } from \"./events.js\"\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\"\n })\n }\n}\n\nexport default LBaseLayers\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const base = {}\n const overlay = {}\n const control = L.control.layers(base, overlay)\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail\n if (type === \"overlay\") {\n control.addOverlay(layer, name)\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name)\n }\n ev.preventDefault()\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LControlLayers\n","import { mapAddTo } from \"./events.js\"\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const group = L.layerGroup()\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name\n }\n })\n this.dispatchEvent(event)\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation()\n group.addLayer(ev.detail.layer)\n })\n\n const observer = new MutationObserver(function(mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true })\n }\n}\n\nexport default LLayerGroup\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\"\n\nclass LMap extends HTMLElement {\n constructor() {\n super()\n\n this.map = null\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail\n this.map[method](bounds)\n })\n }\n\n connectedCallback() {\n this.map = L.map(this)\n const center = this.getAttribute(\"center\")\n const zoom = this.getAttribute(\"zoom\")\n if ((center !== null) && (zoom !== null)) {\n this.map.setView(JSON.parse(center), parseInt(zoom))\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer\n layer.addTo(this.map)\n })\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer)\n })\n }\n}\n\nexport default LMap\n","import { mapAddTo, popupAdd } from \"./events.js\"; \n\nclass LMarker extends HTMLElement {\n static observedAttributes = [\"lat-lng\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const latLng = JSON.parse(this.getAttribute(\"lat-lng\"))\n const opacity = parseFloat(this.getAttribute(\"opacity\") || \"1.0\")\n this.layer = L.marker(latLng, { opacity });\n this.setAttribute(\"leaflet-id\", L.stamp(this.layer))\n\n this.addEventListener(popupAdd, (ev) => {\n const { content } = ev.detail\n this.layer.bindPopup(content)\n })\n \n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n })\n this.dispatchEvent(event)\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"lat-lng\") {\n this.layer.setLatLng(JSON.parse(newValue))\n }\n if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\n\nexport default LMarker\n","import { mapAddTo } from \"./events.js\"\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super()\n }\n \n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\"\n })\n }\n}\n\nexport default LOverlayLayers\n","import { popupAdd } from \"./events.js\"\n\nclass LPopup extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\")\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content\n }\n })\n this.dispatchEvent(event)\n }\n}\n\n\nexport default LPopup\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\")\n const urlTemplate = this.getAttribute(\"url-template\")\n const attribution = this.getAttribute(\"attribution\")\n const options = { attribution }\n const layer = L.tileLayer(urlTemplate, options)\n const event = new CustomEvent(mapAddTo, { detail: { name, layer }, bubbles: true})\n this.dispatchEvent(event)\n }\n}\n\nexport default LTileLayer\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"]\n\n constructor() {\n super()\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\"\n }\n })\n this.dispatchEvent(event)\n }\n}\n\nexport default LLatLngBounds\n","import { mapAddTo } from \"./events.js\"\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"]\n\n constructor() {\n super()\n this.layer = null\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\")\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\"\n }\n this.layer = L.imageOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: this.layer\n }\n }))\n }\n\n attributeChangedCallback(name, _oldValue, newValue) {\n if (this.layer !== null) {\n if (name === \"url\") {\n this.layer.setUrl(newValue)\n } else if (name === \"bounds\") {\n this.layer.setBounds(JSON.parse(newValue))\n } else if (name === \"opacity\") {\n this.layer.setOpacity(parseFloat(newValue))\n }\n }\n }\n}\n\nexport default LImageOverlay\n","import { mapAddTo } from \"./events.js\"\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"))\n const bounds = JSON.parse(this.getAttribute(\"bounds\"))\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true\n }\n const layer = L.videoOverlay(url, bounds, options)\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LVideoOverlay\n\n","import { mapAddTo } from \"./events.js\"\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super()\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")))\n this.dispatchEvent(new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer\n }\n }))\n }\n}\n\nexport default LGeoJSON\n","// @ts-check\nimport LBaseLayers from \"./l-base-layers.js\";\nimport LControlLayers from \"./l-control-layers.js\"; \nimport LLayerGroup from \"./l-layer-group.js\"; \nimport LMap from \"./l-map.js\"; \nimport LMarker from \"./l-marker.js\"; \nimport LOverlayLayers from \"./l-overlay-layers.js\";\nimport LPopup from \"./l-popup.js\"; \nimport LTileLayer from \"./l-tile-layer.js\";\nimport LLatLngBounds from \"./l-lat-lng-bounds.js\";\nimport LImageOverlay from \"./l-image-overlay.js\";\nimport LVideoOverlay from \"./l-video-overlay.js\";\nimport LGeoJSON from \"./l-geojson.js\";\n\n\nconst init = (() => {\n // Custom elements (order of definition is important)\n customElements.define(\"l-map\", LMap)\n customElements.define(\"l-control-layers\", LControlLayers)\n customElements.define(\"l-base-layers\", LBaseLayers)\n customElements.define(\"l-overlay-layers\", LOverlayLayers)\n customElements.define(\"l-layer-group\", LLayerGroup)\n customElements.define(\"l-tile-layer\", LTileLayer)\n customElements.define(\"l-marker\", LMarker)\n customElements.define(\"l-popup\", LPopup)\n customElements.define(\"l-lat-lng-bounds\", LLatLngBounds)\n customElements.define(\"l-image-overlay\", LImageOverlay)\n customElements.define(\"l-video-overlay\", LVideoOverlay)\n customElements.define(\"l-geojson\", LGeoJSON)\n})();\n\nexport default init;\n"],"names":["mapAddTo","popupAdd","LBaseLayers","_HTMLElement","call","this","_inheritsLoose","prototype","connectedCallback","addEventListener","ev","detail","_wrapNativeSuper","HTMLElement","LControlLayers","control","L","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","_this","map","method","bounds","_this2","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","_proto","latLng","opacity","parseFloat","marker","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","customElements","define"],"mappings":"k5CAAaA,EAAW,YACXC,EAAW,YCClBC,eAAW,SAAAC,GACf,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AAA2F,EAAA9F,GAAA8F,EAAA1F,UAEDC,kBAAA,WACE,IAAMa,EAAQL,EAAEkF,QAAQ1C,KAAKC,MAAMpD,KAAK0B,aAAa,aACrD1B,KAAKwB,cAAc,IAAIH,YAAY1B,EAAU,CAC3C4B,SAAS,EACTD,YAAY,EACZhB,OAAQ,CACNU,MAAAA,KAGN,EAAC4E,CAAA,CAdW,cAcXrF,EAdoBC,qBCerBsF,eAAeC,OAAO,QAASrD,GAC/BoD,eAAeC,OAAO,mBAAoBtF,GAC1CqF,eAAeC,OAAO,gBAAiBlG,GACvCiG,eAAeC,OAAO,mBAAoBvB,GAC1CsB,eAAeC,OAAO,gBAAiBtE,GACvCqE,eAAeC,OAAO,eAAgBrB,GACtCoB,eAAeC,OAAO,WAAYvC,GAClCsC,eAAeC,OAAO,UAAWtB,GACjCqB,eAAeC,OAAO,mBAAoBjB,GAC1CgB,eAAeC,OAAO,kBAAmBf,GACzCc,eAAeC,OAAO,kBAAmBR,QACzCO,eAAeC,OAAO,YAAaH"}
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-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","import { mapAddTo } from \"./events.js\";\n\nclass LBaseLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"base\";\n });\n }\n}\n\nexport default LBaseLayers;\n","import { mapAddTo } from \"./events.js\";\n\nclass LControlLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const base = {};\n const overlay = {};\n const control = L.control.layers(base, overlay);\n\n this.addEventListener(mapAddTo, (ev) => {\n const { type, name, layer } = ev.detail;\n if (type === \"overlay\") {\n control.addOverlay(layer, name);\n } else if (type === \"base\") {\n control.addBaseLayer(layer, name);\n }\n ev.preventDefault();\n });\n\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: control,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LControlLayers;\n","import { mapAddTo } from \"./events.js\";\n\nclass LLayerGroup extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const group = L.layerGroup();\n const event = new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer: group,\n name,\n },\n });\n this.dispatchEvent(event);\n\n this.addEventListener(mapAddTo, (ev) => {\n ev.stopPropagation();\n group.addLayer(ev.detail.layer);\n });\n\n const observer = new MutationObserver(function (mutations) {\n mutations.forEach((mutation) => {\n mutation.removedNodes.forEach((node) => {\n const leafletId = node.getAttribute(\"leaflet-id\");\n const layer = group.getLayer(leafletId);\n group.removeLayer(layer);\n });\n });\n });\n observer.observe(this, { childList: true });\n }\n}\n\nexport default LLayerGroup;\n","// @ts-check\nimport { layerRemove, mapAddTo } from \"./events.js\";\n\nclass LMap extends HTMLElement {\n constructor() {\n super();\n\n this.map = null;\n this.addEventListener(\"map:bounds\", (ev) => {\n const { bounds, method } = ev.detail;\n this.map[method](bounds);\n });\n }\n\n connectedCallback() {\n this.map = L.map(this);\n const center = this.getAttribute(\"center\");\n const zoom = this.getAttribute(\"zoom\");\n if (center !== null && zoom !== null) {\n this.map.setView(JSON.parse(center), parseInt(zoom));\n }\n this.addEventListener(mapAddTo, (ev) => {\n const layer = ev.detail.layer;\n layer.addTo(this.map);\n });\n\n this.addEventListener(layerRemove, (ev) => {\n this.map.remove(ev.detail.layer);\n });\n }\n}\n\nexport default LMap;\n","// @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","import { mapAddTo } from \"./events.js\";\n\nclass LOverlayLayers extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n this.addEventListener(mapAddTo, (ev) => {\n ev.detail[\"type\"] = \"overlay\";\n });\n }\n}\n\nexport default LOverlayLayers;\n","import { popupAdd } from \"./events.js\";\n\nclass LPopup extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const content = this.getAttribute(\"content\");\n const event = new CustomEvent(popupAdd, {\n cancelable: true,\n bubbles: true,\n detail: {\n content,\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LPopup;\n","import { mapAddTo } from \"./events.js\";\n\nclass LTileLayer extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const name = this.getAttribute(\"name\");\n const urlTemplate = this.getAttribute(\"url-template\");\n const attribution = this.getAttribute(\"attribution\");\n const options = { attribution };\n const layer = L.tileLayer(urlTemplate, options);\n const event = new CustomEvent(mapAddTo, {\n detail: { name, layer },\n bubbles: true,\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LTileLayer;\n","class LLatLngBounds extends HTMLElement {\n static observedAttributes = [\"bounds\"];\n\n constructor() {\n super();\n }\n\n attributeChangedCallback(_name, _oldValue, newValue) {\n const event = new CustomEvent(\"map:bounds\", {\n bubbles: true,\n detail: {\n bounds: JSON.parse(newValue),\n method: this.getAttribute(\"method\") || \"fitBounds\",\n },\n });\n this.dispatchEvent(event);\n }\n}\n\nexport default LLatLngBounds;\n","import { mapAddTo } from \"./events.js\";\n\nclass LImageOverlay extends HTMLElement {\n static observedAttributes = [\"url\", \"bounds\", \"opacity\"];\n\n constructor() {\n super();\n this.layer = null;\n }\n\n connectedCallback() {\n const url = this.getAttribute(\"url\");\n const bounds = JSON.parse(this.getAttribute(\"bounds\"));\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n };\n this.layer = L.imageOverlay(url, bounds, options);\n this.dispatchEvent(\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","import { mapAddTo } from \"./events.js\";\n\nclass LVideoOverlay extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const url = JSON.parse(this.getAttribute(\"url\"));\n const bounds = JSON.parse(this.getAttribute(\"bounds\"));\n const options = {\n opacity: parseFloat(this.getAttribute(\"opacity\") || \"1.0\"),\n alt: this.getAttribute(\"alt\") || \"\",\n autoplay: true,\n muted: true,\n playsInline: true,\n };\n const layer = L.videoOverlay(url, bounds, options);\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n cancelable: true,\n bubbles: true,\n detail: {\n layer,\n },\n }),\n );\n }\n}\n\nexport default LVideoOverlay;\n","import { mapAddTo } from \"./events.js\";\n\nclass LGeoJSON extends HTMLElement {\n constructor() {\n super();\n }\n\n connectedCallback() {\n const layer = L.geoJSON(JSON.parse(this.getAttribute(\"geojson\")));\n this.dispatchEvent(\n new CustomEvent(mapAddTo, {\n bubbles: true,\n cancelable: true,\n detail: {\n layer,\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","control","L","layers","_ev$detail","type","name","layer","addOverlay","addBaseLayer","preventDefault","event","CustomEvent","cancelable","bubbles","dispatchEvent","LLayerGroup","getAttribute","group","layerGroup","stopPropagation","addLayer","MutationObserver","mutations","forEach","mutation","removedNodes","node","leafletId","getLayer","removeLayer","observe","childList","LMap","_this","map","method","bounds","_this2","center","zoom","setView","JSON","parse","parseInt","addTo","remove","LMarker","setIcon","icon","_proto","latLng","opacity","parseFloat","marker","hasAttribute","setAttribute","stamp","bindPopup","content","attributeChangedCallback","_oldValue","newValue","setLatLng","setOpacity","observedAttributes","LOverlayLayers","LPopup","LTileLayer","urlTemplate","attribution","tileLayer","LLatLngBounds","_name","LImageOverlay","url","options","alt","imageOverlay","setUrl","setBounds","LVideoOverlay","autoplay","muted","playsInline","videoOverlay","LGeoJSON","geoJSON","camelCase","kebab","replace","x","toUpperCase","LIcon","key","crossOrigin","customElements","define"],"mappings":"guDAAaA,EAAW,YACXC,EAAW,YCClBC,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,cCApBC,wBAAcX,GAClB,SAAAW,WACEX,EAAAC,KAAAC,OACFA,IAAA,CAyBC,OAzBAC,EAAAQ,EAAAX,GAAAW,EAAAP,UAEDC,kBAAA,WACE,IAEMO,EAAUC,EAAED,QAAQE,O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OAAO,eAAgB7B,GACtC4B,eAAeC,OAAO,WAAYlD,GAClCiD,eAAeC,OAAO,UAAW9B,GACjC6B,eAAeC,OAAO,mBAAoBzB,GAC1CwB,eAAeC,OAAO,kBAAmBvB,GACzCsB,eAAeC,OAAO,kBAAmBhB,GACzCe,eAAeC,OAAO,YAAaX,QACnCU,eAAeC,OAAO,SAAUJ"}
@@ -5,6 +5,11 @@
5
5
  [LeafletJS](https://leafletjs.com/) is a library geared towards map based visualisations.
6
6
  Leaflet HTML expresses that JavaScript API in HTML.
7
7
 
8
+ ## How-to guides
9
+
10
+ [Articles](@/articles/_index.md) have been written to make adopting Leaflet HTML simpler.
11
+ These articles follow the Leaflet tutorials closely and add a few `leaflet-html` specific
12
+ tips and tricks.
8
13
 
9
14
  ## Design principles
10
15
 
@@ -47,9 +52,9 @@ The following is a live running example of Leaflet HTML.
47
52
  </l-control-layers>
48
53
  </l-map>
49
54
 
55
+ The above application is represented in HTML using the following syntax.
50
56
 
51
57
  ```html
52
- <!-- Example -->
53
58
  <l-map center="[39.61, -105.02]" zoom="10">
54
59
  <l-control-layers>
55
60
  <l-base-layers>
@@ -59,7 +64,6 @@ The following is a live running example of Leaflet HTML.
59
64
  attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>'
60
65
  max-zoom="20"
61
66
  subdomains="abcd"
62
- show
63
67
  ></l-tile-layer>
64
68
  </l-base-layers>
65
69
  <l-overlay-layers>
@@ -82,3 +86,4 @@ The following is a live running example of Leaflet HTML.
82
86
  </l-map>
83
87
  ```
84
88
 
89
+ The above example is a taste of the syntax and capabilities of wrapping Leaflet in HTML tags.
@@ -0,0 +1,5 @@
1
+ +++
2
+ title = "Leaflet HTML articles"
3
+ template = "article.html"
4
+ page_template = "article-page.html"
5
+ +++
@@ -0,0 +1,115 @@
1
+ +++
2
+ title = "Basic usage"
3
+ +++
4
+
5
+ The minimal `leaflet-html` app is a basemap centered and zoomed on a location.
6
+
7
+ ```html
8
+ <l-map center="[53, 0]" zoom="4">
9
+ <l-tile-layer
10
+ url-template="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
11
+ ></l-tile-layer>
12
+ </l-map>
13
+ ```
14
+
15
+ <l-map center="[53, 0]" zoom="4">
16
+ <l-tile-layer
17
+ url-template="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
18
+ ></l-tile-layer>
19
+ </l-map>
20
+
21
+ To add the above widget to a HTML document both JS and CSS tags need to be included in the `<head>` of the page.
22
+
23
+ ## Assets
24
+
25
+ Basic HTML recommended settings, e.g. `charset`, `lang`, and `viewport` to help with cross device support.
26
+ Can be placed in the `<head>` tag, along with CSS and JS assets.
27
+
28
+ ```html
29
+ <head lang="en">
30
+ <meta charset="utf-8" />
31
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
32
+ </head>
33
+ ```
34
+
35
+ ### Leaflet
36
+
37
+ Leaflet is an external dependency of `leaflet-html`, as such,
38
+ the standard Leaflet assets should be included.
39
+
40
+ ```html
41
+ <head>
42
+ ...
43
+ <link
44
+ rel="stylesheet"
45
+ href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
46
+ integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
47
+ crossorigin=""
48
+ />
49
+ <script
50
+ src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
51
+ integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
52
+ crossorigin=""
53
+ ></script>
54
+ ...
55
+ </head>
56
+ ```
57
+
58
+ ### Leaflet-HTML
59
+
60
+ Leaflet-HTML is available via **npm** and **unpkg**.
61
+ To get started quickly, use the CDN version available on **unpkg**.
62
+
63
+ ```html
64
+ <script type="importmap">
65
+ {
66
+ "imports": {
67
+ "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
68
+ }
69
+ }
70
+ </script>
71
+ ```
72
+
73
+ ```html
74
+ <script
75
+ type="module"
76
+ src="https://unpkg.com/leaflet-html@latest/dist/leaflet-html.js"
77
+ ></script>
78
+ ```
79
+
80
+ The `@latest` keyword should keep your site up to date during development.
81
+
82
+ ## Minimal style
83
+
84
+ By default Custom elements are `display: inline`,
85
+ meaning they are unaffected by `height`.
86
+ Add the following ruleset to your stylesheet to enable map size.
87
+
88
+ ```css
89
+ l-map {
90
+ display: block;
91
+ }
92
+ ```
93
+
94
+ It's not always necessary to set `block` directly on an `l-map` tag.
95
+ For example, a parent with `display: grid`, will size the `l-map` tag appropriately.
96
+
97
+ ### Z-index
98
+
99
+ Leaflet has fairly strong `z-index` settings that are not easy to override.
100
+ The easiest way to get around them is to start a new stacking context using `isolation: isolate`.
101
+
102
+ ### Sensible defaults
103
+
104
+ Without knowing anything specific about your application the following settings should be a good starting place.
105
+
106
+ ```css
107
+ l-map {
108
+ display: block;
109
+ block-size: 40ch;
110
+ isolation: isolate;
111
+ z-index: 1;
112
+ }
113
+ ```
114
+
115
+ This allows overlaying your own UI elements and gives full control over size and position of each map on the page.
@@ -0,0 +1,35 @@
1
+ +++
2
+ title = "Custom icons"
3
+ +++
4
+
5
+ There are two ways to add an icon to a marker.
6
+ One is to specify a `icon` attribute containing a JSON string of `L.Icon` options.
7
+
8
+ ```html
9
+ <l-marker
10
+ lat-lng="[51.5, -0.09]"
11
+ icon='{"iconUrl": "icons/leaf-green.png"}'
12
+ ></l-marker>
13
+ ```
14
+
15
+ The other way is to create a separate HTML tag to configure the icon.
16
+ This is a more HTML centered approach.
17
+ The above JSON approach may be suitable in cases where the icon data is available in a data structure.
18
+
19
+ ```html
20
+ <l-marker lat-lng="[51.5, -0.09]">
21
+ <l-icon icon-url="icons/leaf-green.png"></l-icon>
22
+ </l-marker>
23
+ ```
24
+
25
+ Both are supported, choose whichever is most convenient.
26
+
27
+ <l-map center="[51.5, -0.09]" zoom="12">
28
+ <l-tile-layer
29
+ url-template="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
30
+ ></l-tile-layer>
31
+ <l-marker
32
+ lat-lng="[51.5, -0.09]"
33
+ icon='{"iconUrl": "icons/leaf-green.png"}'
34
+ ></l-marker>
35
+ </l-map>
@@ -0,0 +1,14 @@
1
+ +++
2
+ title = "Styling leaflet objects"
3
+ +++
4
+
5
+ ## Naming convention
6
+ Leaflet styles objects using the `style` keyword option.
7
+ Leaflet HTML, on the other hand, needs to support inline style and leaflet style.
8
+ Therefore, the keyword `l-style` is used to style the underlying leaflet objects.
9
+
10
+ ## Example
11
+
12
+ ```html
13
+ <l-marker l-style='{"color": "hotpink"}'></l-marker>
14
+ ```
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,8 @@
1
+ {% extends "base.html" %}
2
+
3
+ {% block content %}
4
+ <main>
5
+ <h1>{{ page.title }}</h1>
6
+ {{ page.content | safe }}
7
+ </main>
8
+ {% endblock %}
@@ -0,0 +1,12 @@
1
+ {% extends "base.html" %}
2
+
3
+ {% block content %}
4
+ <main>
5
+ <h1>{{section.title}}</h1>
6
+ <ul>
7
+ {% for page in section.pages %}
8
+ <li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
9
+ {% endfor %}
10
+ </ul>
11
+ </main>
12
+ {% endblock content %}
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head lang="en">
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <style>
7
+
8
+ l-map {
9
+ display: block;
10
+ block-size: 40ch;
11
+ isolation: isolate;
12
+ z-index: 1;
13
+ }
14
+
15
+ body {
16
+ font-family: system-ui;
17
+ line-height: 1.6;
18
+ }
19
+
20
+ h1, h2, h3 {
21
+ font-weight: 100;
22
+ }
23
+
24
+ pre {
25
+ padding-inline: 0.75rem;
26
+ padding-block: 0.5rem;
27
+ border-radius: 0.2rem;
28
+ overflow-x: auto;
29
+ }
30
+
31
+ main {
32
+ inline-size: min(90%, 80ch);
33
+ margin-inline: auto;
34
+ }
35
+ </style>
36
+ <link
37
+ rel="stylesheet"
38
+ href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
39
+ integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
40
+ crossorigin=""
41
+ />
42
+ <script
43
+ src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
44
+ integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
45
+ crossorigin=""
46
+ ></script>
47
+ <script type="importmap">
48
+ {
49
+ "imports": {
50
+ "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
51
+ }
52
+ }
53
+ </script>
54
+ <script
55
+ type="module"
56
+ src="https://unpkg.com/leaflet-html@latest/dist/leaflet-html.js"
57
+ ></script>
58
+ </head>
59
+ <body>
60
+ <nav>
61
+ <a href="{{ get_url(path='@/_index.md') }}">Home</a>
62
+ <a href="{{ get_url(path='@/articles/_index.md') }}">Articles</a>
63
+ </nav>
64
+ {% block content %}{% endblock %}
65
+ </body>
66
+ </html>
@@ -1,57 +1,6 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head lang="en">
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <style>
7
-
8
- l-map {
9
- display: block;
10
- block-size: 40ch;
11
- isolation: isolate;
12
- z-index: 1;
13
- }
14
-
15
- body {
16
- font-family: system-ui;
17
- line-height: 1.6;
18
- }
19
-
20
- h1, h2 {
21
- font-weight: 100;
22
- }
23
-
24
- pre {
25
- padding-inline: 0.75rem;
26
- padding-block: 0.5rem;
27
- border-radius: 0.2rem;
28
- overflow-x: scroll;
29
- }
30
-
31
- .wrapper {
32
- inline-size: min(90%, 80ch);
33
- margin-inline: auto;
34
- }
35
- </style>
36
- <link
37
- rel="stylesheet"
38
- href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
39
- integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
40
- crossorigin=""
41
- />
42
- <script
43
- src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
44
- integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
45
- crossorigin=""
46
- ></script>
47
- <script
48
- type="module"
49
- src="https://unpkg.com/leaflet-html@latest/dist/leaflet-html.js"
50
- ></script>
51
- </head>
52
- <body>
53
- <div class="wrapper">
1
+ {% extends "base.html" %}
2
+ {% block content %}
3
+ <main>
54
4
  {{ section.content | safe }}
55
- </div>
56
- </body>
57
- </html>
5
+ </main>
6
+ {% endblock %}
@@ -15,6 +15,13 @@
15
15
  integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
16
16
  crossorigin=""
17
17
  ></script>
18
+ <script type="importmap">
19
+ {
20
+ "imports": {
21
+ "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
22
+ }
23
+ }
24
+ </script>
18
25
  <script type="module" src="/src/index.js"></script>
19
26
  <style>
20
27
  * {
@@ -14,6 +14,13 @@
14
14
  integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
15
15
  crossorigin=""
16
16
  ></script>
17
+ <script type="importmap">
18
+ {
19
+ "imports": {
20
+ "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
21
+ }
22
+ }
23
+ </script>
17
24
  <script
18
25
  src="/src/index.js"
19
26
  type="module"
@@ -15,6 +15,13 @@
15
15
  integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
16
16
  crossorigin=""
17
17
  ></script>
18
+ <script type="importmap">
19
+ {
20
+ "imports": {
21
+ "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
22
+ }
23
+ }
24
+ </script>
18
25
  <script type="module" src="/src/index.js"></script>
19
26
  <style>
20
27
  * {
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "leaflet-html",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "description": "Leaflet expressed in HTML",
6
6
  "source": "src/index.js",
7
- "main": "./dist/leaflet-html.js",
8
- "umd:main": "./dist/leaflet-html.umd.js",
9
- "exports": {
10
- "module": "./dist/leaflet-html.js"
11
- },
12
- "module": "./dist/leaflet-html.esm.js",
7
+ "main": "./dist/leaflet-html.cjs",
8
+ "module": "./dist/leaflet-html.js",
13
9
  "author": "andrewgryan",
14
10
  "repository": {
15
11
  "type": "git",
@@ -18,9 +14,16 @@
18
14
  "license": "MIT",
19
15
  "scripts": {
20
16
  "build": "microbundle",
21
- "watch": "microbundle watch"
17
+ "watch": "microbundle watch",
18
+ "test": "vitest"
22
19
  },
23
20
  "devDependencies": {
24
- "microbundle": "^0.15.1"
21
+ "happy-dom": "^14.10.1",
22
+ "microbundle": "^0.15.1",
23
+ "prettier": "3.2.5",
24
+ "vitest": "^1.6.0"
25
+ },
26
+ "dependencies": {
27
+ "leaflet": "^1.9.4"
25
28
  }
26
29
  }
package/src/events.js CHANGED
@@ -1,3 +1,3 @@
1
- export const mapAddTo = "map:addTo"
2
- export const popupAdd = "popup:add"
3
- export const layerRemove = "layer:remove"
1
+ export const mapAddTo = "map:addTo";
2
+ export const popupAdd = "popup:add";
3
+ export const layerRemove = "layer:remove";
package/src/index.js CHANGED
@@ -1,32 +1,33 @@
1
1
  // @ts-check
2
2
  import LBaseLayers from "./l-base-layers.js";
3
- import LControlLayers from "./l-control-layers.js";
4
- import LLayerGroup from "./l-layer-group.js";
5
- import LMap from "./l-map.js";
6
- import LMarker from "./l-marker.js";
3
+ import LControlLayers from "./l-control-layers.js";
4
+ import LLayerGroup from "./l-layer-group.js";
5
+ import LMap from "./l-map.js";
6
+ import LMarker from "./l-marker.js";
7
7
  import LOverlayLayers from "./l-overlay-layers.js";
8
- import LPopup from "./l-popup.js";
8
+ import LPopup from "./l-popup.js";
9
9
  import LTileLayer from "./l-tile-layer.js";
10
10
  import LLatLngBounds from "./l-lat-lng-bounds.js";
11
11
  import LImageOverlay from "./l-image-overlay.js";
12
12
  import LVideoOverlay from "./l-video-overlay.js";
13
13
  import LGeoJSON from "./l-geojson.js";
14
-
14
+ import LIcon from "./l-icon.js";
15
15
 
16
16
  const init = (() => {
17
17
  // Custom elements (order of definition is important)
18
- customElements.define("l-map", LMap)
19
- customElements.define("l-control-layers", LControlLayers)
20
- customElements.define("l-base-layers", LBaseLayers)
21
- customElements.define("l-overlay-layers", LOverlayLayers)
22
- customElements.define("l-layer-group", LLayerGroup)
23
- customElements.define("l-tile-layer", LTileLayer)
24
- customElements.define("l-marker", LMarker)
25
- customElements.define("l-popup", LPopup)
26
- customElements.define("l-lat-lng-bounds", LLatLngBounds)
27
- customElements.define("l-image-overlay", LImageOverlay)
28
- customElements.define("l-video-overlay", LVideoOverlay)
29
- customElements.define("l-geojson", LGeoJSON)
18
+ customElements.define("l-map", LMap);
19
+ customElements.define("l-control-layers", LControlLayers);
20
+ customElements.define("l-base-layers", LBaseLayers);
21
+ customElements.define("l-overlay-layers", LOverlayLayers);
22
+ customElements.define("l-layer-group", LLayerGroup);
23
+ customElements.define("l-tile-layer", LTileLayer);
24
+ customElements.define("l-marker", LMarker);
25
+ customElements.define("l-popup", LPopup);
26
+ customElements.define("l-lat-lng-bounds", LLatLngBounds);
27
+ customElements.define("l-image-overlay", LImageOverlay);
28
+ customElements.define("l-video-overlay", LVideoOverlay);
29
+ customElements.define("l-geojson", LGeoJSON);
30
+ customElements.define("l-icon", LIcon);
30
31
  })();
31
32
 
32
33
  export default init;
@@ -1,16 +1,15 @@
1
- import { mapAddTo } from "./events.js"
1
+ import { mapAddTo } from "./events.js";
2
2
 
3
3
  class LBaseLayers extends HTMLElement {
4
4
  constructor() {
5
- super()
5
+ super();
6
6
  }
7
-
7
+
8
8
  connectedCallback() {
9
9
  this.addEventListener(mapAddTo, (ev) => {
10
- ev.detail["type"] = "base"
11
- })
10
+ ev.detail["type"] = "base";
11
+ });
12
12
  }
13
13
  }
14
14
 
15
- export default LBaseLayers
16
-
15
+ export default LBaseLayers;