@eox/drawtools 0.14.1 → 0.14.2

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.
@@ -6812,10 +6812,10 @@ const Zs = `
6812
6812
  n.draw.setActive(!1), n.selectionEvents.removeSelectionEvent(), n.currentlyDrawing = !1;
6813
6813
  else if (n.continuous)
6814
6814
  if (!n.layerId)
6815
- n.drawLayer.getSource().clear(!0), n.drawnFeatures = [];
6815
+ n.drawLayer.getSource().clear(), n.drawnFeatures = [];
6816
6816
  else {
6817
6817
  const i = n.drawLayer.getSource().getFeatures().at(-1);
6818
- n.drawLayer.getSource().clear(!0), n.drawLayer.getSource().addFeature(i), n.drawnFeatures = [i];
6818
+ n.drawLayer.getSource().clear(), n.drawLayer.getSource().addFeature(i), n.drawnFeatures = [i];
6819
6819
  }
6820
6820
  })(), n.requestUpdate();
6821
6821
  }, Ks = (n) => {
@@ -178,7 +178,7 @@
178
178
  color: white;
179
179
  content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ctitle%3Econtent-copy%3C/title%3E%3Cpath d='M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z' fill='white' /%3E%3C/svg%3E")
180
180
  }
181
- `,qs=n=>{(()=>{if(n.emitDrawnFeatures(),!n.multipleFeatures)n.draw.setActive(!1),n.selectionEvents.removeSelectionEvent(),n.currentlyDrawing=!1;else if(n.continuous)if(!n.layerId)n.drawLayer.getSource().clear(!0),n.drawnFeatures=[];else{const i=n.drawLayer.getSource().getFeatures().at(-1);n.drawLayer.getSource().clear(!0),n.drawLayer.getSource().addFeature(i),n.drawnFeatures=[i]}})(),n.requestUpdate()},Zs=n=>{const t=()=>{n.drawLayer.set("isDrawingEnabled",!0),n.draw.setActive(!0),n.selectionEvents.addSelectionEvent()},e=()=>{n.currentlyDrawing=!0,n.requestUpdate()};t(),e()},Ds=n=>{let t;return typeof n=="string"?t=document.querySelector(n):t=n,t},ln=(n,t)=>{var s,o,a,l,h;const i=Ds(n.for),r=i.map;return n.drawLayer=i.addOrUpdateLayer({zIndex:100,type:"Vector",properties:{id:"drawLayer",layerControlHide:!0,isDrawingEnabled:!1,multipleFeatures:t},source:{type:"Vector"},style:(s=n.featureStyles)==null?void 0:s.layer,interactions:[{type:"draw",options:{active:!1,id:"drawInteraction",type:n.type,modify:n.allowModify,stopClick:!0,style:(o=n.featureStyles)==null?void 0:o.layer}},{type:"select",options:{id:"SelectLayerHoverInteraction",condition:"pointermove",style:((a=n.featureStyles)==null?void 0:a.hover)||{"fill-color":"rgba(51, 153, 204,0.5)","stroke-color":"#3399CC","stroke-width":2.5},tooltip:!1}},{type:"select",options:{id:"SelectLayerClickInteraction",condition:"click",panIn:!0,style:((l=n.featureStyles)==null?void 0:l.click)||{"fill-color":"rgba(51, 153, 204,0.5)","stroke-color":"#3399CC","stroke-width":2.5}}}]}),n.draw=i.interactions.drawInteraction,n.modify=i.interactions.drawInteractionmodify,je(n,i,n.layerId),(h=n.modify)==null||h.on("modifyend",()=>n.onModifyEnd()),i.addEventListener("addfeatures",()=>qs(n)),{EoxMap:i,OlMap:r}},Ks=n=>{const t=()=>{n.drawnFeatures=[],n.draw.setActive(!1),n.selectionEvents.removeSelectionEvent(),n.drawLayer.getSource().clear(),n.geoJSON=null},e=()=>{n.emitDrawnFeatures(),n.currentlyDrawing=!1,n.requestUpdate()};t(),e()},Qs=(n,t)=>{setTimeout(()=>{const i=n.drawLayer.getSource().getFeatures(),r=n.eoxMap.projection||"EPSG:3857",s=n.projection;n.drawnFeatures=s?i.map(a=>{a=a.clone();const l=a.getGeometry().transform(r,s);return a.setGeometry(l),a}):i;let o;switch(n.format){case"geojson":o=Is(n.drawnFeatures);break;case"wkt":o=Js(n.drawnFeatures);break;case"feature":o=n.drawnFeatures;break;default:o=n.drawnFeatures;break}n.updateGeoJSON(),n.requestUpdate(),t(o)},0)},to=n=>{const t=r=>{(r==null?void 0:r.detail.id)!=="SelectLayerClickInteraction"||!r.detail.feature||(n.drawLayer.getSource().addFeature(r.detail.feature),n.eoxMap.dispatchEvent(new CustomEvent("addfeatures",{detail:r.detail})))};return{addSelectionEvent:()=>{n.layerId&&(n.eoxMap.selectInteractions.SelectLayerHoverInteraction.setActive(!0),n.eoxMap.addEventListener("select",t))},removeSelectionEvent:()=>{var s;const r=(s=n.eoxMap.selectInteractions)==null?void 0:s.SelectLayerHoverInteraction;r&&(r.selectedFids=[],r.setActive(!1)),n.eoxMap.removeEventListener("select",t)}}},je=(n,t,e)=>{var a,l;if(!e||!t)return;const i=JSON.parse(JSON.stringify(t.getLayerById(e).get("_jsonDefinition")))||null;if(!i){console.error(`Layer with id ${e} not found`);return}const r={type:"select",active:!1,options:{id:"SelectLayerHoverInteraction",condition:"pointermove",active:!1,style:((a=n.featureStyles)==null?void 0:a.hover)||{"fill-color":"rgba(0, 0, 0,0.0)","stroke-color":"#3399CC","stroke-width":2.5}}},s={type:"select",options:{id:"SelectLayerClickInteraction",condition:"click",multi:n.multipleFeatures,modify:n.allowModify,active:!1,style:((l=n.featureStyles)==null?void 0:l.click)||{"fill-color":"rgba(0, 0, 0,0.0)","stroke-color":"rgba(0, 0, 0,0.0)"}}};i.interactions=[r,s],t.addOrUpdateLayer(i);const o=n.draw;n.draw=t.selectInteractions.SelectLayerClickInteraction,o.setActive(!1),t.selectInteractions.SelectLayerClickInteraction.setActive(!1),t.selectInteractions.SelectLayerHoverInteraction.setActive(!1)},eo=(n,t,e,i)=>{if(t){if(e){i&&e!==i&&hn(n,t),je(n,t,e);return}if(!e&&i){hn(n,t);return}}};function hn(n,t){t&&(n.discardDrawing(),n.selectionEvents.removeSelectionEvent(),n.draw=t.interactions.drawInteraction,t.selectInteractions.SelectLayerClickInteraction.remove(),t.selectInteractions.SelectLayerHoverInteraction.remove())}const io=':root,:host { --spacing: 1rem; --block-spacing-vertical: calc(var(--spacing) * 2); --block-spacing-horizontal: var(--spacing); --background-color: var(--eox-background-color, transparent); --color: var(--eox-color, #2c3d49); --h-color: var(--eox-h-color, var(--color)); --hover-transparency: var(--eox-hover-transparency, 20%); --bg-hover-transparency: var(--eox-bg-hover-transparency, 40%); --btn-hover-transparency: var(--eox-btn-hover-transparency, 80%); --primary-color: var(--eox-primary-color, #004170); --primary-color-hover: color-mix( in srgb, var(--primary-color) var(--hover-transparency), transparent ); --primary-bg-color-hover: color-mix( in srgb, var(--primary-color) var(--bg-hover-transparency), transparent ); --primary-btn-color-hover: color-mix( in srgb, var(--primary-color) var(--btn-hover-transparency), transparent ); --secondary-color: var(--eox-secondary-color, #c6d4df); --secondary-color-hover: color-mix( in srgb, var(--secondary-color) var(--hover-transparency), transparent ); --secondary-bg-color-hover: color-mix( in srgb, var(--secondary-color) var(--bg-hover-transparency), transparent ); --secondary-btn-color-hover: color-mix( in srgb, var(--secondary-color) var(--btn-hover-transparency), transparent ); --success: var(--eox-success, #26cc0f); --warning: var(--eox-warning, #f18e32); --error: var(--eox-error, #ff5252); --header-font-family: var(--eox-header-font-family, "Roboto", sans-serif); --body-font-family: var(--eox-body-font-family, "Roboto", sans-serif);}* { font-size: normal; font-family: var(--body-font-family); color: var(--eox-color);}h1,h2,h3,h4,h5,h6 { font-family: var(--header-font-family);}span,p,div,main,label { font-family: var(--body-font-family);}@media (min-width: 576px) { .container { max-width: 510px; padding-right: 0; padding-left: 0; --block-spacing-vertical: calc(var(--spacing) * 2.5); }}@media (min-width: 768px) { .container { max-width: 700px; --block-spacing-vertical: calc(var(--spacing) * 3); }}@media (min-width: 992px) { .container { max-width: 920px; --block-spacing-vertical: calc(var(--spacing) * 3.5); }}@media (min-width: 1200px) { .container { max-width: 1130px; --block-spacing-vertical: calc(var(--spacing) * 4); }}.container { width: 100%; margin-right: auto; margin-left: auto; display: block; padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);}h1,h2,h3 { line-height: 120%; margin-top: 0.8rem; margin-bottom: 0.8rem;}p { --font-size: 1rem; font-weight: 400; line-height: 170%; margin-top: 0.8rem; margin-bottom: 1.6rem; font-size: var(--font-size);}body { padding: 0; margin: 0;}.sb-show-main.sb-main-padded { padding: 0;}h1,h2,h3,h4,h5,h6 { --font-weight: 700;}h1 { --font-size: 3rem; --typography-spacing-vertical: 0.5rem;}h2 { --font-size: 2rem; --typography-spacing-vertical: 0.5rem;}h3 { --font-size: 1.75rem; --typography-spacing-vertical: 0.5rem;}h4 { --font-size: 1.5rem; --typography-spacing-vertical: 0.5rem;}h5 { --font-size: 1.25rem; --typography-spacing-vertical: 0.5rem;}h1,h2,h3,h4,h5,h6 { margin-top: 0; margin-bottom: var(--typography-spacing-vertical); color: var(--h-color); font-weight: var(--font-weight); font-size: var(--font-size); font-family: var(--header-font-family);}pre { position: relative; border-radius: 4px; z-index: 1; margin: 0; padding: 20px 0; background: transparent; background: var(--code-bg-color, #8e96aa24); overflow: auto;}code { display: block; padding: 0 24px; width: fit-content; min-width: 100%; line-height: var(--code-line-height, 1.7); font-family: var(--code-font-family, monospace); font-size: var(--code-font-size, var(--font-size)); color: var(--code-color, #004170);}:not(pre) > code { display: inline; border-radius: 4px; background: var(--code-bg-color, #8e96aa24); padding: var(--code-padding, 3px 6px);}';function no(n,t){function e(s){s.preventDefault(),s.stopPropagation()}function i(s){s.srcElement.style.opacity="0.4"}function r(s){s.srcElement.style.opacity="1"}["dragenter","dragover","dragleave","drop"].forEach(s=>{t.addEventListener(s,e,!1),["dragenter","dragover"].includes(s)?t.addEventListener(s,i,!1):t.addEventListener(s,r,!1)}),t.addEventListener("drop",s=>cn(s,n),!1)}function ro(n){n.preventDefault(),n.stopPropagation()}function cn(n,t){ro(n);const e=n.dataTransfer?n.dataTransfer.files:n.target.files;Array.from(e).forEach(i=>so(i,t))}function so(n,t){const e=new FileReader;e.readAsText(n),e.onloadend=function(){typeof e.result=="string"&&t.handleFeatureChange(e.result)}}class un extends H{constructor(){super();R(this,ct);R(this,ut);R(this,Gt);R(this,dt);R(this,Lt);this.allowModify=!1,this.for="eox-map",this.currentlyDrawing=!1,this.draw=null,this.drawLayer=null,this.layerId="",this.drawnFeatures=[],this.featureName="Feature",this.featureStyles=null,this.modify=null,this.multipleFeatures=!1,this.importFeatures=!1,this.showEditor=!1,this.showList=!1,this.projection="EPSG:4326",this.type="Polygon",this.selectionEvents=null,this.format="feature",this.unstyled=!1,this.noShadow=!1}static get properties(){return{allowModify:{attribute:"allow-modify",type:Boolean},for:{type:String},currentlyDrawing:{attribute:!1,state:!0,type:Boolean},continuous:{type:Boolean},draw:{attribute:!1,state:!0},drawLayer:{attribute:!1,state:!0},drawnFeatures:{attribute:!1,state:!0,type:Array},featureName:{attribute:"feature-name",type:String},layerId:{attribute:"layer-id",type:String},featureStyles:{attribute:!1},modify:{attribute:!1,state:!0},multipleFeatures:{attribute:"multiple-features",type:Boolean},importFeatures:{attribute:"import-features",type:Boolean},showEditor:{attribute:"show-editor",type:Boolean},showList:{attribute:"show-list",type:Boolean},projection:{type:String},noShadow:{type:Boolean},format:{type:String},type:{type:String},unstyled:{type:Boolean}}}set continuous(e){L(this,Lt,e),e&&(this.multipleFeatures=!0)}get continuous(){return A(this,Lt)}set layerId(e){eo(this,this.eoxMap,e,A(this,dt)),L(this,dt,e)}get layerId(){return A(this,dt)}startDrawing(){Zs(this)}discardDrawing(){Ks(this)}handleFeatureChange(e,i=!1,r=!0){this.eoxMap.parseTextToFeature(e||JSON.stringify(ni),this.drawLayer,this.eoxMap,i,{dataProjection:this.eoxMap.projection,featureProjection:this.projection},r)}handleFilesChange(e){cn(e,this)}onModifyEnd(){this.emitDrawnFeatures()}updateGeoJSON(){L(this,Gt,JSON.stringify(this.eoxMap.parseFeature(this.drawnFeatures)||ni,void 0,2))}emitDrawnFeatures(){Qs(this,i=>{this.dispatchEvent(new CustomEvent("drawupdate",{detail:i}))})}createRenderRoot(){return this.noShadow?this:super.createRenderRoot()}firstUpdated(){const{EoxMap:e,OlMap:i}=ln(this,this.multipleFeatures);this.eoxMap=e,L(this,ut,i),this.selectionEvents=to(this),this.importFeatures&&no(this,this.eoxMap),this.updateGeoJSON(),this.requestUpdate()}updated(e){if(e.has("for")){const{EoxMap:i,OlMap:r}=ln(this,this.multipleFeatures);this.eoxMap=i,L(this,ut,r)}}get eoxMap(){return A(this,ct)}set eoxMap(e){const i=A(this,ct);L(this,ct,e),this.requestUpdate("eoxMap",i)}disconnectedCallback(){var e;(e=this.eoxMap)==null||e.map.removeLayer(this.drawLayer),super.disconnectedCallback()}render(){var e;return k`
181
+ `,qs=n=>{(()=>{if(n.emitDrawnFeatures(),!n.multipleFeatures)n.draw.setActive(!1),n.selectionEvents.removeSelectionEvent(),n.currentlyDrawing=!1;else if(n.continuous)if(!n.layerId)n.drawLayer.getSource().clear(),n.drawnFeatures=[];else{const i=n.drawLayer.getSource().getFeatures().at(-1);n.drawLayer.getSource().clear(),n.drawLayer.getSource().addFeature(i),n.drawnFeatures=[i]}})(),n.requestUpdate()},Zs=n=>{const t=()=>{n.drawLayer.set("isDrawingEnabled",!0),n.draw.setActive(!0),n.selectionEvents.addSelectionEvent()},e=()=>{n.currentlyDrawing=!0,n.requestUpdate()};t(),e()},Ds=n=>{let t;return typeof n=="string"?t=document.querySelector(n):t=n,t},ln=(n,t)=>{var s,o,a,l,h;const i=Ds(n.for),r=i.map;return n.drawLayer=i.addOrUpdateLayer({zIndex:100,type:"Vector",properties:{id:"drawLayer",layerControlHide:!0,isDrawingEnabled:!1,multipleFeatures:t},source:{type:"Vector"},style:(s=n.featureStyles)==null?void 0:s.layer,interactions:[{type:"draw",options:{active:!1,id:"drawInteraction",type:n.type,modify:n.allowModify,stopClick:!0,style:(o=n.featureStyles)==null?void 0:o.layer}},{type:"select",options:{id:"SelectLayerHoverInteraction",condition:"pointermove",style:((a=n.featureStyles)==null?void 0:a.hover)||{"fill-color":"rgba(51, 153, 204,0.5)","stroke-color":"#3399CC","stroke-width":2.5},tooltip:!1}},{type:"select",options:{id:"SelectLayerClickInteraction",condition:"click",panIn:!0,style:((l=n.featureStyles)==null?void 0:l.click)||{"fill-color":"rgba(51, 153, 204,0.5)","stroke-color":"#3399CC","stroke-width":2.5}}}]}),n.draw=i.interactions.drawInteraction,n.modify=i.interactions.drawInteractionmodify,je(n,i,n.layerId),(h=n.modify)==null||h.on("modifyend",()=>n.onModifyEnd()),i.addEventListener("addfeatures",()=>qs(n)),{EoxMap:i,OlMap:r}},Ks=n=>{const t=()=>{n.drawnFeatures=[],n.draw.setActive(!1),n.selectionEvents.removeSelectionEvent(),n.drawLayer.getSource().clear(),n.geoJSON=null},e=()=>{n.emitDrawnFeatures(),n.currentlyDrawing=!1,n.requestUpdate()};t(),e()},Qs=(n,t)=>{setTimeout(()=>{const i=n.drawLayer.getSource().getFeatures(),r=n.eoxMap.projection||"EPSG:3857",s=n.projection;n.drawnFeatures=s?i.map(a=>{a=a.clone();const l=a.getGeometry().transform(r,s);return a.setGeometry(l),a}):i;let o;switch(n.format){case"geojson":o=Is(n.drawnFeatures);break;case"wkt":o=Js(n.drawnFeatures);break;case"feature":o=n.drawnFeatures;break;default:o=n.drawnFeatures;break}n.updateGeoJSON(),n.requestUpdate(),t(o)},0)},to=n=>{const t=r=>{(r==null?void 0:r.detail.id)!=="SelectLayerClickInteraction"||!r.detail.feature||(n.drawLayer.getSource().addFeature(r.detail.feature),n.eoxMap.dispatchEvent(new CustomEvent("addfeatures",{detail:r.detail})))};return{addSelectionEvent:()=>{n.layerId&&(n.eoxMap.selectInteractions.SelectLayerHoverInteraction.setActive(!0),n.eoxMap.addEventListener("select",t))},removeSelectionEvent:()=>{var s;const r=(s=n.eoxMap.selectInteractions)==null?void 0:s.SelectLayerHoverInteraction;r&&(r.selectedFids=[],r.setActive(!1)),n.eoxMap.removeEventListener("select",t)}}},je=(n,t,e)=>{var a,l;if(!e||!t)return;const i=JSON.parse(JSON.stringify(t.getLayerById(e).get("_jsonDefinition")))||null;if(!i){console.error(`Layer with id ${e} not found`);return}const r={type:"select",active:!1,options:{id:"SelectLayerHoverInteraction",condition:"pointermove",active:!1,style:((a=n.featureStyles)==null?void 0:a.hover)||{"fill-color":"rgba(0, 0, 0,0.0)","stroke-color":"#3399CC","stroke-width":2.5}}},s={type:"select",options:{id:"SelectLayerClickInteraction",condition:"click",multi:n.multipleFeatures,modify:n.allowModify,active:!1,style:((l=n.featureStyles)==null?void 0:l.click)||{"fill-color":"rgba(0, 0, 0,0.0)","stroke-color":"rgba(0, 0, 0,0.0)"}}};i.interactions=[r,s],t.addOrUpdateLayer(i);const o=n.draw;n.draw=t.selectInteractions.SelectLayerClickInteraction,o.setActive(!1),t.selectInteractions.SelectLayerClickInteraction.setActive(!1),t.selectInteractions.SelectLayerHoverInteraction.setActive(!1)},eo=(n,t,e,i)=>{if(t){if(e){i&&e!==i&&hn(n,t),je(n,t,e);return}if(!e&&i){hn(n,t);return}}};function hn(n,t){t&&(n.discardDrawing(),n.selectionEvents.removeSelectionEvent(),n.draw=t.interactions.drawInteraction,t.selectInteractions.SelectLayerClickInteraction.remove(),t.selectInteractions.SelectLayerHoverInteraction.remove())}const io=':root,:host { --spacing: 1rem; --block-spacing-vertical: calc(var(--spacing) * 2); --block-spacing-horizontal: var(--spacing); --background-color: var(--eox-background-color, transparent); --color: var(--eox-color, #2c3d49); --h-color: var(--eox-h-color, var(--color)); --hover-transparency: var(--eox-hover-transparency, 20%); --bg-hover-transparency: var(--eox-bg-hover-transparency, 40%); --btn-hover-transparency: var(--eox-btn-hover-transparency, 80%); --primary-color: var(--eox-primary-color, #004170); --primary-color-hover: color-mix( in srgb, var(--primary-color) var(--hover-transparency), transparent ); --primary-bg-color-hover: color-mix( in srgb, var(--primary-color) var(--bg-hover-transparency), transparent ); --primary-btn-color-hover: color-mix( in srgb, var(--primary-color) var(--btn-hover-transparency), transparent ); --secondary-color: var(--eox-secondary-color, #c6d4df); --secondary-color-hover: color-mix( in srgb, var(--secondary-color) var(--hover-transparency), transparent ); --secondary-bg-color-hover: color-mix( in srgb, var(--secondary-color) var(--bg-hover-transparency), transparent ); --secondary-btn-color-hover: color-mix( in srgb, var(--secondary-color) var(--btn-hover-transparency), transparent ); --success: var(--eox-success, #26cc0f); --warning: var(--eox-warning, #f18e32); --error: var(--eox-error, #ff5252); --header-font-family: var(--eox-header-font-family, "Roboto", sans-serif); --body-font-family: var(--eox-body-font-family, "Roboto", sans-serif);}* { font-size: normal; font-family: var(--body-font-family); color: var(--eox-color);}h1,h2,h3,h4,h5,h6 { font-family: var(--header-font-family);}span,p,div,main,label { font-family: var(--body-font-family);}@media (min-width: 576px) { .container { max-width: 510px; padding-right: 0; padding-left: 0; --block-spacing-vertical: calc(var(--spacing) * 2.5); }}@media (min-width: 768px) { .container { max-width: 700px; --block-spacing-vertical: calc(var(--spacing) * 3); }}@media (min-width: 992px) { .container { max-width: 920px; --block-spacing-vertical: calc(var(--spacing) * 3.5); }}@media (min-width: 1200px) { .container { max-width: 1130px; --block-spacing-vertical: calc(var(--spacing) * 4); }}.container { width: 100%; margin-right: auto; margin-left: auto; display: block; padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);}h1,h2,h3 { line-height: 120%; margin-top: 0.8rem; margin-bottom: 0.8rem;}p { --font-size: 1rem; font-weight: 400; line-height: 170%; margin-top: 0.8rem; margin-bottom: 1.6rem; font-size: var(--font-size);}body { padding: 0; margin: 0;}.sb-show-main.sb-main-padded { padding: 0;}h1,h2,h3,h4,h5,h6 { --font-weight: 700;}h1 { --font-size: 3rem; --typography-spacing-vertical: 0.5rem;}h2 { --font-size: 2rem; --typography-spacing-vertical: 0.5rem;}h3 { --font-size: 1.75rem; --typography-spacing-vertical: 0.5rem;}h4 { --font-size: 1.5rem; --typography-spacing-vertical: 0.5rem;}h5 { --font-size: 1.25rem; --typography-spacing-vertical: 0.5rem;}h1,h2,h3,h4,h5,h6 { margin-top: 0; margin-bottom: var(--typography-spacing-vertical); color: var(--h-color); font-weight: var(--font-weight); font-size: var(--font-size); font-family: var(--header-font-family);}pre { position: relative; border-radius: 4px; z-index: 1; margin: 0; padding: 20px 0; background: transparent; background: var(--code-bg-color, #8e96aa24); overflow: auto;}code { display: block; padding: 0 24px; width: fit-content; min-width: 100%; line-height: var(--code-line-height, 1.7); font-family: var(--code-font-family, monospace); font-size: var(--code-font-size, var(--font-size)); color: var(--code-color, #004170);}:not(pre) > code { display: inline; border-radius: 4px; background: var(--code-bg-color, #8e96aa24); padding: var(--code-padding, 3px 6px);}';function no(n,t){function e(s){s.preventDefault(),s.stopPropagation()}function i(s){s.srcElement.style.opacity="0.4"}function r(s){s.srcElement.style.opacity="1"}["dragenter","dragover","dragleave","drop"].forEach(s=>{t.addEventListener(s,e,!1),["dragenter","dragover"].includes(s)?t.addEventListener(s,i,!1):t.addEventListener(s,r,!1)}),t.addEventListener("drop",s=>cn(s,n),!1)}function ro(n){n.preventDefault(),n.stopPropagation()}function cn(n,t){ro(n);const e=n.dataTransfer?n.dataTransfer.files:n.target.files;Array.from(e).forEach(i=>so(i,t))}function so(n,t){const e=new FileReader;e.readAsText(n),e.onloadend=function(){typeof e.result=="string"&&t.handleFeatureChange(e.result)}}class un extends H{constructor(){super();R(this,ct);R(this,ut);R(this,Gt);R(this,dt);R(this,Lt);this.allowModify=!1,this.for="eox-map",this.currentlyDrawing=!1,this.draw=null,this.drawLayer=null,this.layerId="",this.drawnFeatures=[],this.featureName="Feature",this.featureStyles=null,this.modify=null,this.multipleFeatures=!1,this.importFeatures=!1,this.showEditor=!1,this.showList=!1,this.projection="EPSG:4326",this.type="Polygon",this.selectionEvents=null,this.format="feature",this.unstyled=!1,this.noShadow=!1}static get properties(){return{allowModify:{attribute:"allow-modify",type:Boolean},for:{type:String},currentlyDrawing:{attribute:!1,state:!0,type:Boolean},continuous:{type:Boolean},draw:{attribute:!1,state:!0},drawLayer:{attribute:!1,state:!0},drawnFeatures:{attribute:!1,state:!0,type:Array},featureName:{attribute:"feature-name",type:String},layerId:{attribute:"layer-id",type:String},featureStyles:{attribute:!1},modify:{attribute:!1,state:!0},multipleFeatures:{attribute:"multiple-features",type:Boolean},importFeatures:{attribute:"import-features",type:Boolean},showEditor:{attribute:"show-editor",type:Boolean},showList:{attribute:"show-list",type:Boolean},projection:{type:String},noShadow:{type:Boolean},format:{type:String},type:{type:String},unstyled:{type:Boolean}}}set continuous(e){L(this,Lt,e),e&&(this.multipleFeatures=!0)}get continuous(){return A(this,Lt)}set layerId(e){eo(this,this.eoxMap,e,A(this,dt)),L(this,dt,e)}get layerId(){return A(this,dt)}startDrawing(){Zs(this)}discardDrawing(){Ks(this)}handleFeatureChange(e,i=!1,r=!0){this.eoxMap.parseTextToFeature(e||JSON.stringify(ni),this.drawLayer,this.eoxMap,i,{dataProjection:this.eoxMap.projection,featureProjection:this.projection},r)}handleFilesChange(e){cn(e,this)}onModifyEnd(){this.emitDrawnFeatures()}updateGeoJSON(){L(this,Gt,JSON.stringify(this.eoxMap.parseFeature(this.drawnFeatures)||ni,void 0,2))}emitDrawnFeatures(){Qs(this,i=>{this.dispatchEvent(new CustomEvent("drawupdate",{detail:i}))})}createRenderRoot(){return this.noShadow?this:super.createRenderRoot()}firstUpdated(){const{EoxMap:e,OlMap:i}=ln(this,this.multipleFeatures);this.eoxMap=e,L(this,ut,i),this.selectionEvents=to(this),this.importFeatures&&no(this,this.eoxMap),this.updateGeoJSON(),this.requestUpdate()}updated(e){if(e.has("for")){const{EoxMap:i,OlMap:r}=ln(this,this.multipleFeatures);this.eoxMap=i,L(this,ut,r)}}get eoxMap(){return A(this,ct)}set eoxMap(e){const i=A(this,ct);L(this,ct,e),this.requestUpdate("eoxMap",i)}disconnectedCallback(){var e;(e=this.eoxMap)==null||e.map.removeLayer(this.drawLayer),super.disconnectedCallback()}render(){var e;return k`
182
182
  <style>
183
183
  :host { display: block; }
184
184
  ${!this.unstyled&&io}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/drawtools",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
6
  "@eox/map": "^1.19.3",
@@ -16,12 +16,12 @@ const onDrawEndMethod = (EoxDrawTool) => {
16
16
  if (EoxDrawTool.continuous) {
17
17
  // the selection event selects the feature after draw ends
18
18
  if (!EoxDrawTool.layerId) {
19
- EoxDrawTool.drawLayer.getSource().clear(true);
19
+ EoxDrawTool.drawLayer.getSource().clear();
20
20
  EoxDrawTool.drawnFeatures = [];
21
21
  } else {
22
22
  const features = EoxDrawTool.drawLayer.getSource().getFeatures();
23
23
  const latest = features.at(-1);
24
- EoxDrawTool.drawLayer.getSource().clear(true);
24
+ EoxDrawTool.drawLayer.getSource().clear();
25
25
  EoxDrawTool.drawLayer.getSource().addFeature(latest);
26
26
  EoxDrawTool.drawnFeatures = [latest];
27
27
  }