yio-map 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/YioMap.d.ts.map +1 -1
- package/dist/yio-map.iife.js +2 -2
- package/dist/yio-map.js +24 -15
- package/dist/yio-map.umd.cjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ See [CHANGELOG.md](CHANGELOG.md) for breaking changes between versions.
|
|
|
48
48
|
| `enableSelect` | `boolean` | Enable feature selection on click/hover |
|
|
49
49
|
| `editCreate` | `string` | Source layer name to draw new features on |
|
|
50
50
|
| `editModify` | `number[]` | Feature IDs enabled for editing |
|
|
51
|
-
| `geojsonSources` | `object\|string` | GeoJSON data or URL to overlay |
|
|
51
|
+
| `geojsonSources` | `object\|string` | GeoJSON data or URL to overlay, by source id of the content map. A source without a layer in the content map is ignored with a console warning (once per content map). |
|
|
52
52
|
| `sourceLayerVisibility` | `object` | Toggle visibility of source layers |
|
|
53
53
|
| `lang` | `string` | Override UI language (defaults to `<html lang>`, then browser language, then `en`). Supported: `en`, `de` |
|
|
54
54
|
|
package/dist/YioMap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YioMap.d.ts","sourceRoot":"","sources":["../src/YioMap.js"],"names":[],"mappings":"AAsBA;IACE,yCAmCE;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAeE;IAEF,sBAAsB;IACtB,kBADW,OAAO,CACO;
|
|
1
|
+
{"version":3,"file":"YioMap.d.ts","sourceRoot":"","sources":["../src/YioMap.js"],"names":[],"mappings":"AAsBA;IACE,yCAmCE;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAeE;IAEF,sBAAsB;IACtB,kBADW,OAAO,CACO;IAwFvB,iBAAoB;IACpB,aAAa;IACb,kBAAoB;IAYtB;;OAEG;IACH,oBAFa,UAAU,CAItB;IAED;;OAEG;IACH,2BAFa,OAAO,CAAC,UAAU,CAAC,CAI/B;IAED;;OAEG;IACH,oBAFW,KAAK,QAOf;IAHG,wDAAwE;IAS5E,8BAGC;IAPD,yBAEC;IAWD,8BAGC;IAPD,yBAEC;IAOD,gCAGC;IAED,2BAEC;IAMD,iCAGC;IAPD,4BAEC;IAWD,kCAGC;IAPD,6BAEC;IAWD,+BAEC;IAND,0BAEC;IAUD,sCAEC;IAND,iCAEC;IAUD,iCAGC;IAPD,4BAEC;IAkBD,wBAcC;IA4ID,2CAQC;IAkBD,sCAwCC;IAcD;;;OAGG;IACH,eAFW,KAAK,CAAC,MAAM,CAAC,QAIvB;IAmBD,+CAEC;;CACF;2BAniBgD,KAAK;uBAU/B,mBAAmB"}
|
package/dist/yio-map.iife.js
CHANGED
|
@@ -95,7 +95,7 @@ var YioMap=(function(){var e=globalThis,t=e.ShadowRoot&&(e.ShadyCSS===void 0||e.
|
|
|
95
95
|
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="%23dc4b6f" viewBox="0 0 24 24">
|
|
96
96
|
<path fill-rule="evenodd" d="M11.906 1.994a8.002 8.002 0 0 1 8.09 8.421 7.996 7.996 0 0 1-1.297 3.957.996.996 0 0 1-.133.204l-.108.129c-.178.243-.37.477-.573.699l-5.112 6.224a1 1 0 0 1-1.545 0L5.982 15.26l-.002-.002a18.146 18.146 0 0 1-.309-.38l-.133-.163a.999.999 0 0 1-.13-.202 7.995 7.995 0 0 1 6.498-12.518ZM15 9.997a3 3 0 1 1-5.999 0 3 3 0 0 1 5.999 0Z" clip-rule="evenodd" />
|
|
97
97
|
</svg>
|
|
98
|
-
`,anchor:[.5,1]})}),l3=class extends Fo{#e=null;#t=null;#n=null;getEditLayer(){return this.#t}clearModifiedFeatures(){if(this.#a.clear(),!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)!==void 0);e.removeFeatures(t)}clearCreatedFeatures(){if(!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)===void 0);e.removeFeatures(t)}#r;#i=null;#a=new Set;constructor(e){super(),this.#e=e.yioMap}drawInteraction;modifyInteraction;#o(e){this.#e._handleClick(e.originalEvent)}#s=null;#c=!1;#l(){this.drawInteraction=new W4({source:this.#t.getSource(),condition:e=>Jo(e)?this.createEnabled&&!this.#c:!1,type:`Point`,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.drawInteraction),this.drawInteraction.on(`drawend`,e=>{e.feature.set(`mvt:layer`,this.#r)}),this.modifyInteraction=new e3({source:this.#t.getSource(),condition:e=>$o(e)?this.modifyEnabled:!1,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.modifyInteraction)}#u(){this.drawInteraction&&=(this.drawInteraction.setMap(null),null),this.modifyInteraction&&=(this.modifyInteraction.setMap(null),null)}#d=Promise.resolve();setActive(e){return this.getMap()?(this.#d=this.#d.then(()=>this.#f(e)).catch(e=>console.error(`Error toggling edit mode:`,e)),this.#d):Promise.resolve()}async contentChanged(){let e=await this.#e._getContentLayerPromise();this.#t&&e?.getLayers().getArray().includes(this.#t)||(this.getActive()&&await this.setActive(!1),this.#t=null,this.#n=null,this.#a.clear(),await this.setActive(this.createEnabled||this.modifyEnabled))}async#f(e){if(e===!!this.getActive())return;let t=this.getMap();if(t){if(e){let e=await this.#e._getContentLayerPromise();if(!e)return;if(!C4(e,`edits`).length){console.warn(`No edits source found in content layer. Please add a source with key "edits" and at least one layer that uses it.`);let t=e.get(`mapbox-style`);t.sources.edits={type:`geojson`,data:{type:`FeatureCollection`,features:[]}};let n=[];for(let e of t.layers)t.sources[e.source]?.type!==`vector`||e.type!==`circle`&&e.type!==`symbol`||n.push({id:`edits-`+e.id,"source-layer":e[`source-layer`]});n.length||n.push({id:`edits`});for(let t of n)await y4(e,{...t,source:`edits`,type:`circle`,paint:{"circle-radius":5,"circle-color":`#ff0000`,"circle-stroke-width":1}})}this.#t=C4(e,`edits`)[0],this.#n=this.#e._getContentLayer().getLayers().getArray().filter(e=>e instanceof I0).pop(),this.#n&&!this.#s&&(this.#s=this.#n.getStyle(),this.#n.setStyle((e,t)=>{if(!this.#a.has(e.get(`id`)))return this.#s(e,t)})),this.#p||(this.#p=e=>{if(!this.modifyEnabled)return t.getTargetElement().style.cursor=``,this.#c=!1,null;this.#c=!!this.#m(e.pixel),this.#c?t.getTargetElement().classList.add(`cursor-move`):t.getTargetElement().classList.remove(`cursor-move`)},t.on(`pointermove`,this.#p)),this.#l()}else this.#s&&=(this.#n?.setStyle(this.#s),null),this.#p&&=(t.un(`pointermove`,this.#p),null),this.#u();super.setActive(e)}}get createEnabled(){return!!this.#r}async setCreateEnabled(e){this.#r=e||void 0,e||(this.clearCreatedFeatures(),this.#n?.getSource().refresh()),await this.setActive(!!e||!!this.#i),this.drawInteraction&&this.drawInteraction.setMap(e?this.getMap():null),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#i?this.getMap():null)}get modifyEnabled(){return!!this.#i||!!this.#r}async setModifyEnabled(e){e&&e.length===0&&(e=null),e||(this.clearModifiedFeatures(),this.#n?.getSource().refresh()),this.#i=e,await this.setActive(!!e||!!this.#r),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#r?this.getMap():null)}#p=null;#m(e){let t=this.getMap().getFeaturesAtPixel(e,{layerFilter:e=>e===this.#t||e==this.#n}).filter(e=>e.getGeometry().getType()===`Point`&&(this.#t.getSource().hasFeature(e)||this.#i?.includes(e.get(`id`))));return t.length?t[0]:null}handleEvent(e){let t=!0;if(e.type===`pointerdown`){let t=this.#m(e.pixel);if(t&&t instanceof Cd&&this.modifyEnabled){let e=t.get(`id`);this.#a.has(e)||this.#a.add(e),this.#n.changed();let n=Td(t);this.#t.getSource().addFeature(n)}}return t&&this.modifyEnabled&&(t=this.modifyInteraction.handleEvent(e)),t&&this.createEnabled&&(t=this.drawInteraction.handleEvent(e)),t&&e.type===`click`&&this.#o(e),t}},u3=class extends Fo{#e=null;#t=new M0({source:new xv});constructor(e){super(),this.#e=e.yioMap,this.setActive(!1)}setMap(e){let t=this.getMap();t&&t.removeLayer(this.#t),e&&e.addLayer(this.#t),super.setMap(e)}#n(e){let t=this.#t.getSource();t.clear();let n=new dd(new Na(e));n.setStyle(c3),t.addFeature(n),this.#e.dispatchEvent(new CustomEvent(`pin`,{composed:!0,bubbles:!0,detail:{coordinate:ui(e)}}))}#r(e){let t=this.getMap(),n=this.#e._getContentLayer();t.getFeaturesAtPixel(e.pixel,{layerFilter:e=>n.getLayers().getArray().includes(e)}).length===0&&this.#n(e.coordinate)}setActive(e){e||this.#t.getSource().clear(),super.setActive(e)}setPin(e){this.#n(e)}handleEvent(e){return e.type===`singleclick`&&this.#r(e),!0}},d3=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20256%20256'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%3e%3cg%20id='favicon'%3e%3crect%20x='0'%20y='0'%20width='256'%20height='256'%20style='fill:none;'/%3e%3cg%3e%3cpath%20d='M54.77,244.669C59.16,246.864%2071.078,250.001%2083.623,250.001C125.022,250.001%20142.585,223.029%20152.621,191.98L212.21,6L163.284,6L146.662,66.216C140.076,90.051%20135.999,112.005%20133.49,128L132.235,128C130.04,112.946%20123.14,86.288%20116.554,66.216L96.796,6L43.793,6L110.282,182.571C108.713,200.448%2098.677,210.17%2081.742,210.17C73.901,210.17%2067.315,208.288%2062.61,205.779L54.77,244.669Z'%20style='fill:rgb(223,72,110);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,f3={name:`yio-map`,description:`Web component for interactive maps using LitElement and OpenLayers`,license:`MIT`,author:`yio-map`,repository:{type:`git`,url:`https://github.com/yiogmbh/yio-map`},version:`0.15.
|
|
98
|
+
`,anchor:[.5,1]})}),l3=class extends Fo{#e=null;#t=null;#n=null;getEditLayer(){return this.#t}clearModifiedFeatures(){if(this.#a.clear(),!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)!==void 0);e.removeFeatures(t)}clearCreatedFeatures(){if(!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)===void 0);e.removeFeatures(t)}#r;#i=null;#a=new Set;constructor(e){super(),this.#e=e.yioMap}drawInteraction;modifyInteraction;#o(e){this.#e._handleClick(e.originalEvent)}#s=null;#c=!1;#l(){this.drawInteraction=new W4({source:this.#t.getSource(),condition:e=>Jo(e)?this.createEnabled&&!this.#c:!1,type:`Point`,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.drawInteraction),this.drawInteraction.on(`drawend`,e=>{e.feature.set(`mvt:layer`,this.#r)}),this.modifyInteraction=new e3({source:this.#t.getSource(),condition:e=>$o(e)?this.modifyEnabled:!1,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.modifyInteraction)}#u(){this.drawInteraction&&=(this.drawInteraction.setMap(null),null),this.modifyInteraction&&=(this.modifyInteraction.setMap(null),null)}#d=Promise.resolve();setActive(e){return this.getMap()?(this.#d=this.#d.then(()=>this.#f(e)).catch(e=>console.error(`Error toggling edit mode:`,e)),this.#d):Promise.resolve()}async contentChanged(){let e=await this.#e._getContentLayerPromise();this.#t&&e?.getLayers().getArray().includes(this.#t)||(this.getActive()&&await this.setActive(!1),this.#t=null,this.#n=null,this.#a.clear(),await this.setActive(this.createEnabled||this.modifyEnabled))}async#f(e){if(e===!!this.getActive())return;let t=this.getMap();if(t){if(e){let e=await this.#e._getContentLayerPromise();if(!e)return;if(!C4(e,`edits`).length){console.warn(`No edits source found in content layer. Please add a source with key "edits" and at least one layer that uses it.`);let t=e.get(`mapbox-style`);t.sources.edits={type:`geojson`,data:{type:`FeatureCollection`,features:[]}};let n=[];for(let e of t.layers)t.sources[e.source]?.type!==`vector`||e.type!==`circle`&&e.type!==`symbol`||n.push({id:`edits-`+e.id,"source-layer":e[`source-layer`]});n.length||n.push({id:`edits`});for(let t of n)await y4(e,{...t,source:`edits`,type:`circle`,paint:{"circle-radius":5,"circle-color":`#ff0000`,"circle-stroke-width":1}})}this.#t=C4(e,`edits`)[0],this.#n=this.#e._getContentLayer().getLayers().getArray().filter(e=>e instanceof I0).pop(),this.#n&&!this.#s&&(this.#s=this.#n.getStyle(),this.#n.setStyle((e,t)=>{if(!this.#a.has(e.get(`id`)))return this.#s(e,t)})),this.#p||(this.#p=e=>{if(!this.modifyEnabled)return t.getTargetElement().style.cursor=``,this.#c=!1,null;this.#c=!!this.#m(e.pixel),this.#c?t.getTargetElement().classList.add(`cursor-move`):t.getTargetElement().classList.remove(`cursor-move`)},t.on(`pointermove`,this.#p)),this.#l()}else this.#s&&=(this.#n?.setStyle(this.#s),null),this.#p&&=(t.un(`pointermove`,this.#p),null),this.#u();super.setActive(e)}}get createEnabled(){return!!this.#r}async setCreateEnabled(e){this.#r=e||void 0,e||(this.clearCreatedFeatures(),this.#n?.getSource().refresh()),await this.setActive(!!e||!!this.#i),this.drawInteraction&&this.drawInteraction.setMap(e?this.getMap():null),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#i?this.getMap():null)}get modifyEnabled(){return!!this.#i||!!this.#r}async setModifyEnabled(e){e&&e.length===0&&(e=null),e||(this.clearModifiedFeatures(),this.#n?.getSource().refresh()),this.#i=e,await this.setActive(!!e||!!this.#r),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#r?this.getMap():null)}#p=null;#m(e){let t=this.getMap().getFeaturesAtPixel(e,{layerFilter:e=>e===this.#t||e==this.#n}).filter(e=>e.getGeometry().getType()===`Point`&&(this.#t.getSource().hasFeature(e)||this.#i?.includes(e.get(`id`))));return t.length?t[0]:null}handleEvent(e){let t=!0;if(e.type===`pointerdown`){let t=this.#m(e.pixel);if(t&&t instanceof Cd&&this.modifyEnabled){let e=t.get(`id`);this.#a.has(e)||this.#a.add(e),this.#n.changed();let n=Td(t);this.#t.getSource().addFeature(n)}}return t&&this.modifyEnabled&&(t=this.modifyInteraction.handleEvent(e)),t&&this.createEnabled&&(t=this.drawInteraction.handleEvent(e)),t&&e.type===`click`&&this.#o(e),t}},u3=class extends Fo{#e=null;#t=new M0({source:new xv});constructor(e){super(),this.#e=e.yioMap,this.setActive(!1)}setMap(e){let t=this.getMap();t&&t.removeLayer(this.#t),e&&e.addLayer(this.#t),super.setMap(e)}#n(e){let t=this.#t.getSource();t.clear();let n=new dd(new Na(e));n.setStyle(c3),t.addFeature(n),this.#e.dispatchEvent(new CustomEvent(`pin`,{composed:!0,bubbles:!0,detail:{coordinate:ui(e)}}))}#r(e){let t=this.getMap(),n=this.#e._getContentLayer();t.getFeaturesAtPixel(e.pixel,{layerFilter:e=>n.getLayers().getArray().includes(e)}).length===0&&this.#n(e.coordinate)}setActive(e){e||this.#t.getSource().clear(),super.setActive(e)}setPin(e){this.#n(e)}handleEvent(e){return e.type===`singleclick`&&this.#r(e),!0}},d3=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20256%20256'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%3e%3cg%20id='favicon'%3e%3crect%20x='0'%20y='0'%20width='256'%20height='256'%20style='fill:none;'/%3e%3cg%3e%3cpath%20d='M54.77,244.669C59.16,246.864%2071.078,250.001%2083.623,250.001C125.022,250.001%20142.585,223.029%20152.621,191.98L212.21,6L163.284,6L146.662,66.216C140.076,90.051%20135.999,112.005%20133.49,128L132.235,128C130.04,112.946%20123.14,86.288%20116.554,66.216L96.796,6L43.793,6L110.282,182.571C108.713,200.448%2098.677,210.17%2081.742,210.17C73.901,210.17%2067.315,208.288%2062.61,205.779L54.77,244.669Z'%20style='fill:rgb(223,72,110);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,f3={name:`yio-map`,description:`Web component for interactive maps using LitElement and OpenLayers`,license:`MIT`,author:`yio-map`,repository:{type:`git`,url:`https://github.com/yiogmbh/yio-map`},version:`0.15.1`,type:`module`,files:[`dist`],exports:{".":{import:`./dist/yio-map.js`,types:`./dist/index.d.ts`}},scripts:{start:`vite`,build:`vite build && vite -c vite.config-umd.js build && tsc src/index.js --outDir dist --skipLibCheck --allowJS --declaration --declarationMap --emitDeclarationOnly`,prepublishOnly:`npm run build`,lint:`eslint --ext .js,.html . && prettier "**/*.(js|html)" --check --ignore-path .gitignore`,format:`eslint --ext .js,.html . --fix && prettier "**/*.(js|html)" --write --ignore-path .gitignore`,prepare:`husky`,pretest:`tsc --noEmit && npx playwright install chromium-headless-shell`,test:`vitest run --silent`,"test:watch":`npm run pretest && vitest watch`,storybook:`storybook dev -p 6006`,"storybook:build":`storybook build`},dependencies:{lit:`^3.3.3`},peerDependencies:{ol:`^10.11.0`,"ol-mapbox-style":`^13.9.0`},devDependencies:{"@chromatic-com/storybook":`^5.6.0`,"@eslint/js":`^10.0.1`,"@storybook/addon-docs":`10.6.9`,"@storybook/web-components":`^10.6.9`,"@storybook/web-components-vite":`^10.6.9`,"@types/node":`^25.9.12`,"@vitest/browser":`^5.1.2`,"@vitest/browser-playwright":`^5.1.2`,eslint:`^10.15.0`,"eslint-config-flat-gitignore":`^2.4.0`,"eslint-config-prettier":`^10.1.9`,"eslint-plugin-html":`^8.2.1`,"eslint-plugin-storybook":`^10.6.9`,globals:`^17.14.0`,husky:`^9.1.7`,"lint-staged":`^17.6.2`,playwright:`^1.65.1`,prettier:`^3.10.1`,"rollup-plugin-peer-deps-external":`^2.2.4`,storybook:`10.6.9`,typescript:`^5.9.3`,vite:`8.4.0`,vitest:`^5.1.2`},"lint-staged":{"*.js":[`eslint --fix`,`prettier --write`]}};function p3(){let e=document.createElement(`img`);return e.src=d3,e.alt=`yio.at`,e.style.height=`1em`,new ko({label:e,render:m3})}function m3(e){let t=this.element;if(!t||!e.frameState)return;let n=this.collectSourceAttributions_(e.frameState)??[],r=[];r.push(`
|
|
99
99
|
<a href="https://yio.at" target="_blank" rel="noopener">
|
|
100
100
|
<b>yio gmbh</b>
|
|
101
101
|
</a> v${f3.version}
|
|
@@ -229,4 +229,4 @@ var YioMap=(function(){var e=globalThis,t=e.ShadowRoot&&(e.ShadyCSS===void 0||e.
|
|
|
229
229
|
max-width: 300px;
|
|
230
230
|
background-color: transparent;
|
|
231
231
|
}
|
|
232
|
-
`];static properties={center:{type:Array,reflect:!0},zoom:{type:Number,reflect:!0},contentMap:{type:String},editCreate:{type:String},editModify:{type:Array},enablePinning:{type:Boolean},enableSelect:{type:Boolean},enableSearch:{type:Boolean},lang:{type:String},geojsonSources:{type:Object},editFeatures:{attribute:!1},lastClickCoordinate:{type:Array,attribute:!1},userSelect:{attribute:!1},sourceLayerVisibility:{type:Object}};notifyNextChange=!1;#e=null;#t=``;#n=new ws;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=!1;#d=!1;#f=null;#p=null;#
|
|
232
|
+
`];static properties={center:{type:Array,reflect:!0},zoom:{type:Number,reflect:!0},contentMap:{type:String},editCreate:{type:String},editModify:{type:Array},enablePinning:{type:Boolean},enableSelect:{type:Boolean},enableSearch:{type:Boolean},lang:{type:String},geojsonSources:{type:Object},editFeatures:{attribute:!1},lastClickCoordinate:{type:Array,attribute:!1},userSelect:{attribute:!1},sourceLayerVisibility:{type:Object}};notifyNextChange=!1;#e=null;#t=``;#n=new ws;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=!1;#d=!1;#f=null;#p=new Set;#m=null;#h=!1;#g=null;#_=null;constructor(){super(),this.center=[0,0],this.zoom=2,this.userSelect=[],this.#r=new l3({yioMap:this}),this.#i=new k4({yioMap:this}),this.#a=new u3({yioMap:this})}_getContentLayer(){return this.#n}_getContentLayerPromise(){return this.#o}_handleClick(e){e instanceof PointerEvent&&(this.lastClickCoordinate=ui(this.#e.getEventCoordinate(e))),this.dispatchEvent(new PointerEvent(`click`,e))}get contentMap(){return this.#t}set contentMap(e){this.#t=e,this.#v()}get editCreate(){return this.#c}set editCreate(e){this.#c=e,this.#r.setCreateEnabled(e)}set editModify(e){this.#l=e,this.#r.setModifyEnabled(e)}get editModify(){return this.#l}get enableSelect(){return this.#u}set enableSelect(e){this.#u=e,this.#i.setActive(!!this.#u)}get enablePinning(){return this.#d}set enablePinning(e){this.#d=e,this.#a.setActive(!!this.#d)}get geojsonSources(){return this.#f}set geojsonSources(e){this.#f=e}get sourceLayerVisibility(){return this.#m}set sourceLayerVisibility(e){this.#m=e}get enableSearch(){return this.#h}set enableSearch(e){this.#h=e,this.#C()}get lang(){return this.#g}set lang(e){this.#g=e,this.#_&&(this.#_.lang=e)}get editFeatures(){let e=this.#r.getEditLayer()?.getSource()?.getFeatures();return e?new Fd().writeFeaturesObject(e,{dataProjection:`EPSG:4326`,featureProjection:`EPSG:3857`}):null}async#v(){let e=++this.#s;if(await this.#o,e===this.#s){if(this.#n.getLayers().clear(),this.#o=null,this.#p.clear(),this.contentMap){if(this.#o=g4(this.#n,this.contentMap).catch(e=>{console.error(`Error applying content to yiomap:`,e)}),await this.#o,e!==this.#s)return;await this.#b(),await this.#y()}await this.#r.contentChanged()}}async#y(){if(!this.#f)return;let e=await this.#o;if(!e)return;let t=Object.keys(this.#f);await Promise.all(t.map(async t=>{if(!w4(e,t))this.#p.has(t)||(this.#p.add(t),console.warn(`Geojson source '${t}' is not used by any layer of the content map, ignored.`));else try{let n=await x4(e,t,{type:`geojson`,data:this.#f[t]});C4(e,t).forEach(e=>{e.getSource()!==n&&e.setSource(n)})}catch(e){console.error(`Error updating GeoJSON source '${t}':`,e)}}))}async#b(){if(!this.#m)return;let e=await this.#o;if(!e)return;let t=e.get(`mapbox-style`),n=Object.keys(t.layers);try{await Promise.all(n.map(n=>{let r=t.layers[n],i=r[`source-layer`];if(!i||!(i in this.#m))return;let a=this.#m[i]?`visible`:`none`;b4(e,{...r,layout:{...r.layout,visibility:a}})}))}catch(e){console.error(`Error updating source layer visibility:`,e)}}#x(){this.#e=new ld({controls:Mo({attribution:!1})}),this.#e.addControl(p3()),this.#e.addControl(new O4({map:this.#e})),this.#C(),this.#e.addLayer(this.#n),this.#e.addInteraction(this.#i),this.#i.setActive(this.#u),this.#e.addInteraction(this.#a),this.#a.setActive(this.#d),this.#e.addInteraction(this.#r),this.#r.setActive(!!this.editCreate||!!this.editModify);let e=!0;this.#e.on(`moveend`,()=>{if(e){e=!1;return}let t=this.#e.getView();this.notifyNextChange=!0,this.center=ui(t.getCenter()),this.zoom=t.getZoom()})}firstUpdated(e){super.firstUpdated(e),this.#x();let t=this.shadowRoot.querySelector(`.map`);this.shadowRoot.addEventListener(`click`,e=>e.stopPropagation()),this.#e.setTarget(t)}connectedCallback(){super.connectedCallback(),this.#e&&!this.#e.getTarget()&&this.#e.setTarget(this.shadowRoot.querySelector(`.map`))}disconnectedCallback(){super.disconnectedCallback(),this.#e?.setTarget(null)}updated(e){super.updated(e),e.has(`sourceLayerVisibility`)&&!e.has(`contentMap`)&&this.#o&&this.#b(),e.has(`geojsonSources`)&&!e.has(`contentMap`)&&this.#o&&this.#y(),!this.notifyNextChange&&(e.has(`center`)||e.has(`zoom`))&&this.#e.getView().animate({center:li(this.center),zoom:this.zoom,duration:500}),this.notifyNextChange&&(this.notifyNextChange=!1,this.dispatchEvent(new CustomEvent(`change`,{composed:!0,bubbles:!0,detail:{changedProperties:e}})))}#S=e=>{let{coordinates:t}=e.detail,n=ui(t);t&&(this.center=n,this.zoom=18),this.enablePinning&&this.setPin(n)};setPin(e){this.#a.setPin(li(e))}#C(){this.#e&&(this.#h&&!this.#_?(this.#_=new S3({onSelect:this.#S}),this.#g&&(this.#_.lang=this.#g),this.#e.addControl(this.#_)):!this.#h&&this.#_&&(this.#e.removeControl(this.#_),this.#_=null))}render(){return de`<div class="map"></div>`}};return window.customElements.define(`yio-map`,C3),C3})();
|
package/dist/yio-map.js
CHANGED
|
@@ -1209,7 +1209,7 @@ var package_default = {
|
|
|
1209
1209
|
"type": "git",
|
|
1210
1210
|
"url": "https://github.com/yiogmbh/yio-map"
|
|
1211
1211
|
},
|
|
1212
|
-
version: "0.15.
|
|
1212
|
+
version: "0.15.1",
|
|
1213
1213
|
type: "module",
|
|
1214
1214
|
files: ["dist"],
|
|
1215
1215
|
exports: { ".": {
|
|
@@ -1756,6 +1756,10 @@ var YioMap = class extends i {
|
|
|
1756
1756
|
* @type {Object|string} GeoJSON data or URL to overlay on the map
|
|
1757
1757
|
*/
|
|
1758
1758
|
#geojsonSources = null;
|
|
1759
|
+
/**
|
|
1760
|
+
* @type {Set<string>} keys of `geojsonSources` without a layer in the content map, warned about once per content map
|
|
1761
|
+
*/
|
|
1762
|
+
#missingGeojsonSources = /* @__PURE__ */ new Set();
|
|
1759
1763
|
#sourceLayerVisibility = null;
|
|
1760
1764
|
/**
|
|
1761
1765
|
* @type {boolean} whether search is enabled
|
|
@@ -1872,6 +1876,7 @@ var YioMap = class extends i {
|
|
|
1872
1876
|
if (version !== this.#contentMapVersion) return;
|
|
1873
1877
|
this.#contentLayer.getLayers().clear();
|
|
1874
1878
|
this.#contentLayerPromise = null;
|
|
1879
|
+
this.#missingGeojsonSources.clear();
|
|
1875
1880
|
if (this.contentMap) {
|
|
1876
1881
|
this.#contentLayerPromise = apply(this.#contentLayer, this.contentMap).catch((error) => {
|
|
1877
1882
|
console.error("Error applying content to yiomap:", error);
|
|
@@ -1888,22 +1893,26 @@ var YioMap = class extends i {
|
|
|
1888
1893
|
const layer = await this.#contentLayerPromise;
|
|
1889
1894
|
if (!layer) return;
|
|
1890
1895
|
const sources = Object.keys(this.#geojsonSources);
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
+
await Promise.all(sources.map(async (source) => {
|
|
1897
|
+
if (!getSource(layer, source)) {
|
|
1898
|
+
if (!this.#missingGeojsonSources.has(source)) {
|
|
1899
|
+
this.#missingGeojsonSources.add(source);
|
|
1900
|
+
console.warn(`Geojson source '${source}' is not used by any layer of the content map, ignored.`);
|
|
1901
|
+
}
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
try {
|
|
1905
|
+
const newSource = await updateMapboxSource(layer, source, {
|
|
1896
1906
|
type: "geojson",
|
|
1897
|
-
data
|
|
1898
|
-
}).then((newSource) => {
|
|
1899
|
-
getLayers(layer, source).forEach((sourceLayer) => {
|
|
1900
|
-
if (sourceLayer.getSource() !== newSource) sourceLayer.setSource(newSource);
|
|
1901
|
-
});
|
|
1907
|
+
data: this.#geojsonSources[source]
|
|
1902
1908
|
});
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1909
|
+
getLayers(layer, source).forEach((sourceLayer) => {
|
|
1910
|
+
if (sourceLayer.getSource() !== newSource) sourceLayer.setSource(newSource);
|
|
1911
|
+
});
|
|
1912
|
+
} catch (error) {
|
|
1913
|
+
console.error(`Error updating GeoJSON source '${source}':`, error);
|
|
1914
|
+
}
|
|
1915
|
+
}));
|
|
1907
1916
|
}
|
|
1908
1917
|
async #updateSourceLayerVisibility() {
|
|
1909
1918
|
if (!this.#sourceLayerVisibility) return;
|
package/dist/yio-map.umd.cjs
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="%23dc4b6f" viewBox="0 0 24 24">
|
|
96
96
|
<path fill-rule="evenodd" d="M11.906 1.994a8.002 8.002 0 0 1 8.09 8.421 7.996 7.996 0 0 1-1.297 3.957.996.996 0 0 1-.133.204l-.108.129c-.178.243-.37.477-.573.699l-5.112 6.224a1 1 0 0 1-1.545 0L5.982 15.26l-.002-.002a18.146 18.146 0 0 1-.309-.38l-.133-.163a.999.999 0 0 1-.13-.202 7.995 7.995 0 0 1 6.498-12.518ZM15 9.997a3 3 0 1 1-5.999 0 3 3 0 0 1 5.999 0Z" clip-rule="evenodd" />
|
|
97
97
|
</svg>
|
|
98
|
-
`,anchor:[.5,1]})}),l3=class extends Fo{#e=null;#t=null;#n=null;getEditLayer(){return this.#t}clearModifiedFeatures(){if(this.#a.clear(),!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)!==void 0);e.removeFeatures(t)}clearCreatedFeatures(){if(!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)===void 0);e.removeFeatures(t)}#r;#i=null;#a=new Set;constructor(e){super(),this.#e=e.yioMap}drawInteraction;modifyInteraction;#o(e){this.#e._handleClick(e.originalEvent)}#s=null;#c=!1;#l(){this.drawInteraction=new W4({source:this.#t.getSource(),condition:e=>Jo(e)?this.createEnabled&&!this.#c:!1,type:`Point`,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.drawInteraction),this.drawInteraction.on(`drawend`,e=>{e.feature.set(`mvt:layer`,this.#r)}),this.modifyInteraction=new e3({source:this.#t.getSource(),condition:e=>$o(e)?this.modifyEnabled:!1,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.modifyInteraction)}#u(){this.drawInteraction&&=(this.drawInteraction.setMap(null),null),this.modifyInteraction&&=(this.modifyInteraction.setMap(null),null)}#d=Promise.resolve();setActive(e){return this.getMap()?(this.#d=this.#d.then(()=>this.#f(e)).catch(e=>console.error(`Error toggling edit mode:`,e)),this.#d):Promise.resolve()}async contentChanged(){let e=await this.#e._getContentLayerPromise();this.#t&&e?.getLayers().getArray().includes(this.#t)||(this.getActive()&&await this.setActive(!1),this.#t=null,this.#n=null,this.#a.clear(),await this.setActive(this.createEnabled||this.modifyEnabled))}async#f(e){if(e===!!this.getActive())return;let t=this.getMap();if(t){if(e){let e=await this.#e._getContentLayerPromise();if(!e)return;if(!C4(e,`edits`).length){console.warn(`No edits source found in content layer. Please add a source with key "edits" and at least one layer that uses it.`);let t=e.get(`mapbox-style`);t.sources.edits={type:`geojson`,data:{type:`FeatureCollection`,features:[]}};let n=[];for(let e of t.layers)t.sources[e.source]?.type!==`vector`||e.type!==`circle`&&e.type!==`symbol`||n.push({id:`edits-`+e.id,"source-layer":e[`source-layer`]});n.length||n.push({id:`edits`});for(let t of n)await y4(e,{...t,source:`edits`,type:`circle`,paint:{"circle-radius":5,"circle-color":`#ff0000`,"circle-stroke-width":1}})}this.#t=C4(e,`edits`)[0],this.#n=this.#e._getContentLayer().getLayers().getArray().filter(e=>e instanceof I0).pop(),this.#n&&!this.#s&&(this.#s=this.#n.getStyle(),this.#n.setStyle((e,t)=>{if(!this.#a.has(e.get(`id`)))return this.#s(e,t)})),this.#p||(this.#p=e=>{if(!this.modifyEnabled)return t.getTargetElement().style.cursor=``,this.#c=!1,null;this.#c=!!this.#m(e.pixel),this.#c?t.getTargetElement().classList.add(`cursor-move`):t.getTargetElement().classList.remove(`cursor-move`)},t.on(`pointermove`,this.#p)),this.#l()}else this.#s&&=(this.#n?.setStyle(this.#s),null),this.#p&&=(t.un(`pointermove`,this.#p),null),this.#u();super.setActive(e)}}get createEnabled(){return!!this.#r}async setCreateEnabled(e){this.#r=e||void 0,e||(this.clearCreatedFeatures(),this.#n?.getSource().refresh()),await this.setActive(!!e||!!this.#i),this.drawInteraction&&this.drawInteraction.setMap(e?this.getMap():null),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#i?this.getMap():null)}get modifyEnabled(){return!!this.#i||!!this.#r}async setModifyEnabled(e){e&&e.length===0&&(e=null),e||(this.clearModifiedFeatures(),this.#n?.getSource().refresh()),this.#i=e,await this.setActive(!!e||!!this.#r),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#r?this.getMap():null)}#p=null;#m(e){let t=this.getMap().getFeaturesAtPixel(e,{layerFilter:e=>e===this.#t||e==this.#n}).filter(e=>e.getGeometry().getType()===`Point`&&(this.#t.getSource().hasFeature(e)||this.#i?.includes(e.get(`id`))));return t.length?t[0]:null}handleEvent(e){let t=!0;if(e.type===`pointerdown`){let t=this.#m(e.pixel);if(t&&t instanceof Cd&&this.modifyEnabled){let e=t.get(`id`);this.#a.has(e)||this.#a.add(e),this.#n.changed();let n=Td(t);this.#t.getSource().addFeature(n)}}return t&&this.modifyEnabled&&(t=this.modifyInteraction.handleEvent(e)),t&&this.createEnabled&&(t=this.drawInteraction.handleEvent(e)),t&&e.type===`click`&&this.#o(e),t}},u3=class extends Fo{#e=null;#t=new M0({source:new xv});constructor(e){super(),this.#e=e.yioMap,this.setActive(!1)}setMap(e){let t=this.getMap();t&&t.removeLayer(this.#t),e&&e.addLayer(this.#t),super.setMap(e)}#n(e){let t=this.#t.getSource();t.clear();let n=new dd(new Na(e));n.setStyle(c3),t.addFeature(n),this.#e.dispatchEvent(new CustomEvent(`pin`,{composed:!0,bubbles:!0,detail:{coordinate:ui(e)}}))}#r(e){let t=this.getMap(),n=this.#e._getContentLayer();t.getFeaturesAtPixel(e.pixel,{layerFilter:e=>n.getLayers().getArray().includes(e)}).length===0&&this.#n(e.coordinate)}setActive(e){e||this.#t.getSource().clear(),super.setActive(e)}setPin(e){this.#n(e)}handleEvent(e){return e.type===`singleclick`&&this.#r(e),!0}},d3=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20256%20256'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%3e%3cg%20id='favicon'%3e%3crect%20x='0'%20y='0'%20width='256'%20height='256'%20style='fill:none;'/%3e%3cg%3e%3cpath%20d='M54.77,244.669C59.16,246.864%2071.078,250.001%2083.623,250.001C125.022,250.001%20142.585,223.029%20152.621,191.98L212.21,6L163.284,6L146.662,66.216C140.076,90.051%20135.999,112.005%20133.49,128L132.235,128C130.04,112.946%20123.14,86.288%20116.554,66.216L96.796,6L43.793,6L110.282,182.571C108.713,200.448%2098.677,210.17%2081.742,210.17C73.901,210.17%2067.315,208.288%2062.61,205.779L54.77,244.669Z'%20style='fill:rgb(223,72,110);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,f3={name:`yio-map`,description:`Web component for interactive maps using LitElement and OpenLayers`,license:`MIT`,author:`yio-map`,repository:{type:`git`,url:`https://github.com/yiogmbh/yio-map`},version:`0.15.
|
|
98
|
+
`,anchor:[.5,1]})}),l3=class extends Fo{#e=null;#t=null;#n=null;getEditLayer(){return this.#t}clearModifiedFeatures(){if(this.#a.clear(),!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)!==void 0);e.removeFeatures(t)}clearCreatedFeatures(){if(!this.#t)return;let e=this.#t.getSource(),t=e.getFeatures().filter(e=>e.get(`id`)===void 0);e.removeFeatures(t)}#r;#i=null;#a=new Set;constructor(e){super(),this.#e=e.yioMap}drawInteraction;modifyInteraction;#o(e){this.#e._handleClick(e.originalEvent)}#s=null;#c=!1;#l(){this.drawInteraction=new W4({source:this.#t.getSource(),condition:e=>Jo(e)?this.createEnabled&&!this.#c:!1,type:`Point`,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.drawInteraction),this.drawInteraction.on(`drawend`,e=>{e.feature.set(`mvt:layer`,this.#r)}),this.modifyInteraction=new e3({source:this.#t.getSource(),condition:e=>$o(e)?this.modifyEnabled:!1,style:()=>this.#c?null:s3}),this.getMap().addInteraction(this.modifyInteraction)}#u(){this.drawInteraction&&=(this.drawInteraction.setMap(null),null),this.modifyInteraction&&=(this.modifyInteraction.setMap(null),null)}#d=Promise.resolve();setActive(e){return this.getMap()?(this.#d=this.#d.then(()=>this.#f(e)).catch(e=>console.error(`Error toggling edit mode:`,e)),this.#d):Promise.resolve()}async contentChanged(){let e=await this.#e._getContentLayerPromise();this.#t&&e?.getLayers().getArray().includes(this.#t)||(this.getActive()&&await this.setActive(!1),this.#t=null,this.#n=null,this.#a.clear(),await this.setActive(this.createEnabled||this.modifyEnabled))}async#f(e){if(e===!!this.getActive())return;let t=this.getMap();if(t){if(e){let e=await this.#e._getContentLayerPromise();if(!e)return;if(!C4(e,`edits`).length){console.warn(`No edits source found in content layer. Please add a source with key "edits" and at least one layer that uses it.`);let t=e.get(`mapbox-style`);t.sources.edits={type:`geojson`,data:{type:`FeatureCollection`,features:[]}};let n=[];for(let e of t.layers)t.sources[e.source]?.type!==`vector`||e.type!==`circle`&&e.type!==`symbol`||n.push({id:`edits-`+e.id,"source-layer":e[`source-layer`]});n.length||n.push({id:`edits`});for(let t of n)await y4(e,{...t,source:`edits`,type:`circle`,paint:{"circle-radius":5,"circle-color":`#ff0000`,"circle-stroke-width":1}})}this.#t=C4(e,`edits`)[0],this.#n=this.#e._getContentLayer().getLayers().getArray().filter(e=>e instanceof I0).pop(),this.#n&&!this.#s&&(this.#s=this.#n.getStyle(),this.#n.setStyle((e,t)=>{if(!this.#a.has(e.get(`id`)))return this.#s(e,t)})),this.#p||(this.#p=e=>{if(!this.modifyEnabled)return t.getTargetElement().style.cursor=``,this.#c=!1,null;this.#c=!!this.#m(e.pixel),this.#c?t.getTargetElement().classList.add(`cursor-move`):t.getTargetElement().classList.remove(`cursor-move`)},t.on(`pointermove`,this.#p)),this.#l()}else this.#s&&=(this.#n?.setStyle(this.#s),null),this.#p&&=(t.un(`pointermove`,this.#p),null),this.#u();super.setActive(e)}}get createEnabled(){return!!this.#r}async setCreateEnabled(e){this.#r=e||void 0,e||(this.clearCreatedFeatures(),this.#n?.getSource().refresh()),await this.setActive(!!e||!!this.#i),this.drawInteraction&&this.drawInteraction.setMap(e?this.getMap():null),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#i?this.getMap():null)}get modifyEnabled(){return!!this.#i||!!this.#r}async setModifyEnabled(e){e&&e.length===0&&(e=null),e||(this.clearModifiedFeatures(),this.#n?.getSource().refresh()),this.#i=e,await this.setActive(!!e||!!this.#r),this.modifyInteraction&&this.modifyInteraction.setMap(e||this.#r?this.getMap():null)}#p=null;#m(e){let t=this.getMap().getFeaturesAtPixel(e,{layerFilter:e=>e===this.#t||e==this.#n}).filter(e=>e.getGeometry().getType()===`Point`&&(this.#t.getSource().hasFeature(e)||this.#i?.includes(e.get(`id`))));return t.length?t[0]:null}handleEvent(e){let t=!0;if(e.type===`pointerdown`){let t=this.#m(e.pixel);if(t&&t instanceof Cd&&this.modifyEnabled){let e=t.get(`id`);this.#a.has(e)||this.#a.add(e),this.#n.changed();let n=Td(t);this.#t.getSource().addFeature(n)}}return t&&this.modifyEnabled&&(t=this.modifyInteraction.handleEvent(e)),t&&this.createEnabled&&(t=this.drawInteraction.handleEvent(e)),t&&e.type===`click`&&this.#o(e),t}},u3=class extends Fo{#e=null;#t=new M0({source:new xv});constructor(e){super(),this.#e=e.yioMap,this.setActive(!1)}setMap(e){let t=this.getMap();t&&t.removeLayer(this.#t),e&&e.addLayer(this.#t),super.setMap(e)}#n(e){let t=this.#t.getSource();t.clear();let n=new dd(new Na(e));n.setStyle(c3),t.addFeature(n),this.#e.dispatchEvent(new CustomEvent(`pin`,{composed:!0,bubbles:!0,detail:{coordinate:ui(e)}}))}#r(e){let t=this.getMap(),n=this.#e._getContentLayer();t.getFeaturesAtPixel(e.pixel,{layerFilter:e=>n.getLayers().getArray().includes(e)}).length===0&&this.#n(e.coordinate)}setActive(e){e||this.#t.getSource().clear(),super.setActive(e)}setPin(e){this.#n(e)}handleEvent(e){return e.type===`singleclick`&&this.#r(e),!0}},d3=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20width='100%25'%20height='100%25'%20viewBox='0%200%20256%20256'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xml:space='preserve'%20xmlns:serif='http://www.serif.com/'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;'%3e%3cg%3e%3cg%20id='favicon'%3e%3crect%20x='0'%20y='0'%20width='256'%20height='256'%20style='fill:none;'/%3e%3cg%3e%3cpath%20d='M54.77,244.669C59.16,246.864%2071.078,250.001%2083.623,250.001C125.022,250.001%20142.585,223.029%20152.621,191.98L212.21,6L163.284,6L146.662,66.216C140.076,90.051%20135.999,112.005%20133.49,128L132.235,128C130.04,112.946%20123.14,86.288%20116.554,66.216L96.796,6L43.793,6L110.282,182.571C108.713,200.448%2098.677,210.17%2081.742,210.17C73.901,210.17%2067.315,208.288%2062.61,205.779L54.77,244.669Z'%20style='fill:rgb(223,72,110);fill-rule:nonzero;'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,f3={name:`yio-map`,description:`Web component for interactive maps using LitElement and OpenLayers`,license:`MIT`,author:`yio-map`,repository:{type:`git`,url:`https://github.com/yiogmbh/yio-map`},version:`0.15.1`,type:`module`,files:[`dist`],exports:{".":{import:`./dist/yio-map.js`,types:`./dist/index.d.ts`}},scripts:{start:`vite`,build:`vite build && vite -c vite.config-umd.js build && tsc src/index.js --outDir dist --skipLibCheck --allowJS --declaration --declarationMap --emitDeclarationOnly`,prepublishOnly:`npm run build`,lint:`eslint --ext .js,.html . && prettier "**/*.(js|html)" --check --ignore-path .gitignore`,format:`eslint --ext .js,.html . --fix && prettier "**/*.(js|html)" --write --ignore-path .gitignore`,prepare:`husky`,pretest:`tsc --noEmit && npx playwright install chromium-headless-shell`,test:`vitest run --silent`,"test:watch":`npm run pretest && vitest watch`,storybook:`storybook dev -p 6006`,"storybook:build":`storybook build`},dependencies:{lit:`^3.3.3`},peerDependencies:{ol:`^10.11.0`,"ol-mapbox-style":`^13.9.0`},devDependencies:{"@chromatic-com/storybook":`^5.6.0`,"@eslint/js":`^10.0.1`,"@storybook/addon-docs":`10.6.9`,"@storybook/web-components":`^10.6.9`,"@storybook/web-components-vite":`^10.6.9`,"@types/node":`^25.9.12`,"@vitest/browser":`^5.1.2`,"@vitest/browser-playwright":`^5.1.2`,eslint:`^10.15.0`,"eslint-config-flat-gitignore":`^2.4.0`,"eslint-config-prettier":`^10.1.9`,"eslint-plugin-html":`^8.2.1`,"eslint-plugin-storybook":`^10.6.9`,globals:`^17.14.0`,husky:`^9.1.7`,"lint-staged":`^17.6.2`,playwright:`^1.65.1`,prettier:`^3.10.1`,"rollup-plugin-peer-deps-external":`^2.2.4`,storybook:`10.6.9`,typescript:`^5.9.3`,vite:`8.4.0`,vitest:`^5.1.2`},"lint-staged":{"*.js":[`eslint --fix`,`prettier --write`]}};function p3(){let e=document.createElement(`img`);return e.src=d3,e.alt=`yio.at`,e.style.height=`1em`,new ko({label:e,render:m3})}function m3(e){let t=this.element;if(!t||!e.frameState)return;let n=this.collectSourceAttributions_(e.frameState)??[],r=[];r.push(`
|
|
99
99
|
<a href="https://yio.at" target="_blank" rel="noopener">
|
|
100
100
|
<b>yio gmbh</b>
|
|
101
101
|
</a> v${f3.version}
|
|
@@ -229,4 +229,4 @@
|
|
|
229
229
|
max-width: 300px;
|
|
230
230
|
background-color: transparent;
|
|
231
231
|
}
|
|
232
|
-
`];static properties={center:{type:Array,reflect:!0},zoom:{type:Number,reflect:!0},contentMap:{type:String},editCreate:{type:String},editModify:{type:Array},enablePinning:{type:Boolean},enableSelect:{type:Boolean},enableSearch:{type:Boolean},lang:{type:String},geojsonSources:{type:Object},editFeatures:{attribute:!1},lastClickCoordinate:{type:Array,attribute:!1},userSelect:{attribute:!1},sourceLayerVisibility:{type:Object}};notifyNextChange=!1;#e=null;#t=``;#n=new ws;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=!1;#d=!1;#f=null;#p=null;#
|
|
232
|
+
`];static properties={center:{type:Array,reflect:!0},zoom:{type:Number,reflect:!0},contentMap:{type:String},editCreate:{type:String},editModify:{type:Array},enablePinning:{type:Boolean},enableSelect:{type:Boolean},enableSearch:{type:Boolean},lang:{type:String},geojsonSources:{type:Object},editFeatures:{attribute:!1},lastClickCoordinate:{type:Array,attribute:!1},userSelect:{attribute:!1},sourceLayerVisibility:{type:Object}};notifyNextChange=!1;#e=null;#t=``;#n=new ws;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=!1;#d=!1;#f=null;#p=new Set;#m=null;#h=!1;#g=null;#_=null;constructor(){super(),this.center=[0,0],this.zoom=2,this.userSelect=[],this.#r=new l3({yioMap:this}),this.#i=new k4({yioMap:this}),this.#a=new u3({yioMap:this})}_getContentLayer(){return this.#n}_getContentLayerPromise(){return this.#o}_handleClick(e){e instanceof PointerEvent&&(this.lastClickCoordinate=ui(this.#e.getEventCoordinate(e))),this.dispatchEvent(new PointerEvent(`click`,e))}get contentMap(){return this.#t}set contentMap(e){this.#t=e,this.#v()}get editCreate(){return this.#c}set editCreate(e){this.#c=e,this.#r.setCreateEnabled(e)}set editModify(e){this.#l=e,this.#r.setModifyEnabled(e)}get editModify(){return this.#l}get enableSelect(){return this.#u}set enableSelect(e){this.#u=e,this.#i.setActive(!!this.#u)}get enablePinning(){return this.#d}set enablePinning(e){this.#d=e,this.#a.setActive(!!this.#d)}get geojsonSources(){return this.#f}set geojsonSources(e){this.#f=e}get sourceLayerVisibility(){return this.#m}set sourceLayerVisibility(e){this.#m=e}get enableSearch(){return this.#h}set enableSearch(e){this.#h=e,this.#C()}get lang(){return this.#g}set lang(e){this.#g=e,this.#_&&(this.#_.lang=e)}get editFeatures(){let e=this.#r.getEditLayer()?.getSource()?.getFeatures();return e?new Fd().writeFeaturesObject(e,{dataProjection:`EPSG:4326`,featureProjection:`EPSG:3857`}):null}async#v(){let e=++this.#s;if(await this.#o,e===this.#s){if(this.#n.getLayers().clear(),this.#o=null,this.#p.clear(),this.contentMap){if(this.#o=g4(this.#n,this.contentMap).catch(e=>{console.error(`Error applying content to yiomap:`,e)}),await this.#o,e!==this.#s)return;await this.#b(),await this.#y()}await this.#r.contentChanged()}}async#y(){if(!this.#f)return;let e=await this.#o;if(!e)return;let t=Object.keys(this.#f);await Promise.all(t.map(async t=>{if(!w4(e,t))this.#p.has(t)||(this.#p.add(t),console.warn(`Geojson source '${t}' is not used by any layer of the content map, ignored.`));else try{let n=await x4(e,t,{type:`geojson`,data:this.#f[t]});C4(e,t).forEach(e=>{e.getSource()!==n&&e.setSource(n)})}catch(e){console.error(`Error updating GeoJSON source '${t}':`,e)}}))}async#b(){if(!this.#m)return;let e=await this.#o;if(!e)return;let t=e.get(`mapbox-style`),n=Object.keys(t.layers);try{await Promise.all(n.map(n=>{let r=t.layers[n],i=r[`source-layer`];if(!i||!(i in this.#m))return;let a=this.#m[i]?`visible`:`none`;b4(e,{...r,layout:{...r.layout,visibility:a}})}))}catch(e){console.error(`Error updating source layer visibility:`,e)}}#x(){this.#e=new ld({controls:Mo({attribution:!1})}),this.#e.addControl(p3()),this.#e.addControl(new O4({map:this.#e})),this.#C(),this.#e.addLayer(this.#n),this.#e.addInteraction(this.#i),this.#i.setActive(this.#u),this.#e.addInteraction(this.#a),this.#a.setActive(this.#d),this.#e.addInteraction(this.#r),this.#r.setActive(!!this.editCreate||!!this.editModify);let e=!0;this.#e.on(`moveend`,()=>{if(e){e=!1;return}let t=this.#e.getView();this.notifyNextChange=!0,this.center=ui(t.getCenter()),this.zoom=t.getZoom()})}firstUpdated(e){super.firstUpdated(e),this.#x();let t=this.shadowRoot.querySelector(`.map`);this.shadowRoot.addEventListener(`click`,e=>e.stopPropagation()),this.#e.setTarget(t)}connectedCallback(){super.connectedCallback(),this.#e&&!this.#e.getTarget()&&this.#e.setTarget(this.shadowRoot.querySelector(`.map`))}disconnectedCallback(){super.disconnectedCallback(),this.#e?.setTarget(null)}updated(e){super.updated(e),e.has(`sourceLayerVisibility`)&&!e.has(`contentMap`)&&this.#o&&this.#b(),e.has(`geojsonSources`)&&!e.has(`contentMap`)&&this.#o&&this.#y(),!this.notifyNextChange&&(e.has(`center`)||e.has(`zoom`))&&this.#e.getView().animate({center:li(this.center),zoom:this.zoom,duration:500}),this.notifyNextChange&&(this.notifyNextChange=!1,this.dispatchEvent(new CustomEvent(`change`,{composed:!0,bubbles:!0,detail:{changedProperties:e}})))}#S=e=>{let{coordinates:t}=e.detail,n=ui(t);t&&(this.center=n,this.zoom=18),this.enablePinning&&this.setPin(n)};setPin(e){this.#a.setPin(li(e))}#C(){this.#e&&(this.#h&&!this.#_?(this.#_=new S3({onSelect:this.#S}),this.#g&&(this.#_.lang=this.#g),this.#e.addControl(this.#_)):!this.#h&&this.#_&&(this.#e.removeControl(this.#_),this.#_=null))}render(){return de`<div class="map"></div>`}};return window.customElements.define(`yio-map`,C3),C3});
|