ol-contextmenu
Advanced tools
Comparing version 5.1.5 to 5.2.0
/*! | ||
* ol-contextmenu - v5.1.5 | ||
* ol-contextmenu - v5.2.0 | ||
* https://github.com/jonataswalker/ol-contextmenu | ||
* Built: Sat Mar 11 2023 15:05:27 GMT-0300 (Brasilia Standard Time) | ||
* Built: Mon Mar 13 2023 13:25:53 GMT-0300 (Brasilia Standard Time) | ||
*/ | ||
var ContextMenu=function(f,h){"use strict";var U=Object.defineProperty;var F=(f,h,u)=>h in f?U(f,h,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[h]=u;var a=(f,h,u)=>(F(f,typeof h!="symbol"?h+"":h,u),u);var u=(n=>(n.CONTEXTMENU="contextmenu",n.CLICK="click",n.DBLCLICK="dblclick",n))(u||{}),p=(n=>(n.BEFOREOPEN="beforeopen",n.OPEN="open",n.CLOSE="close",n.ADD_MENU_ENTRY="add-menu-entry",n))(p||{});class A extends h.MapBrowserEvent{constructor(t){super(t.type,t.map,t.originalEvent)}}const k={width:150,scrollAt:4,eventType:u.CONTEXTMENU,defaultItems:!0,items:[]},m="ol-ctx-menu",r={namespace:m,container:`${m}-container`,separator:`${m}-separator`,submenu:`${m}-submenu`,hidden:`${m}-hidden`,icon:`${m}-icon`,zoomIn:`${m}-zoom-in`,zoomOut:`${m}-zoom-out`,unselectable:"ol-unselectable"},N=[{text:"Zoom In",classname:`${r.zoomIn} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())+1,duration:700,center:n.coordinate})}},{text:"Zoom Out",classname:`${r.zoomOut} ${r.icon}`,callback:(n,t)=>{const e=t.getView();e.animate({zoom:Number(e.getZoom())-1,duration:700,center:n.coordinate})}}];var x={},T={get exports(){return x},set exports(n){x=n}};function L(){}L.prototype={on:function(n,t,e){var s=this.e||(this.e={});return(s[n]||(s[n]=[])).push({fn:t,ctx:e}),this},once:function(n,t,e){var s=this;function i(){s.off(n,i),t.apply(e,arguments)}return i._=t,this.on(n,i,e)},emit:function(n){var t=[].slice.call(arguments,1),e=((this.e||(this.e={}))[n]||[]).slice(),s=0,i=e.length;for(s;s<i;s++)e[s].fn.apply(e[s].ctx,t);return this},off:function(n,t){var e=this.e||(this.e={}),s=e[n],i=[];if(s&&t)for(var o=0,l=s.length;o<l;o++)s[o].fn!==t&&s[o].fn._!==t&&i.push(s[o]);return i.length?e[n]=i:delete e[n],this}},T.exports=L;var O=x.TinyEmitter=L;const y=new O;function v(n){const t=document.createDocumentFragment(),e=document.createElement("div");for(e.innerHTML=n;e.firstChild;)t.append(e.firstChild);return t}function D(n){const t=document.importNode(n),e=n.offsetWidth;t.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;const s=v("<span>Foo</span>"),i=v("<span>Foo</span>"),o=document.createElement("li"),l=document.createElement("li");o.append(s),l.append(i),t.append(o),t.append(l),n.parentNode?.append(t);const E=t.offsetHeight/2;return n.parentNode?.removeChild(t),E}function S(n,t,e=!1,s=!1){const i=`_${Math.random().toString(36).slice(2,11)}`;if(typeof t!="string"&&"text"in t){const b=`<span>${t.text}</span>`,g=v(b),c=document.createElement("li");t.classname=t.classname||"",t.icon&&(t.classname===""?t.classname=r.icon:t.classname.includes(r.icon)===!1&&(t.classname+=` ${r.icon}`),c.setAttribute("style",`background-image:url(${t.icon})`)),c.id=i,c.className=t.classname,c.append(g),n.append(c);const $={id:i,isSubmenu:e,isInsideSubmenu:s,isSeparator:!1,callback:"callback"in t?t.callback:null,data:"data"in t?t.data:null};return y.emit(p.ADD_MENU_ENTRY,$,c),c}const o=`<li id="${i}" class="${r.separator}"><hr></li>`,l=v(o);n.append(l);const E=n.lastChild,M={id:i,isSubmenu:!1,isInsideSubmenu:!1,isSeparator:!0,callback:null,data:null};return y.emit(p.ADD_MENU_ENTRY,M,E),E}function w(n,t,e,s){t.forEach(i=>{if(typeof i!="string"&&"items"in i&&Array.isArray(i.items)){const o=S(n,i,!0);o.classList.add(r.submenu);const l=document.createElement("ul");l.classList.add(r.container),l.style.width=`${e}px`,o.append(l),w(l,i.items,e,!0)}else S(n,i,!1,s)})}const R="";function C(n,t){if(!n)throw new Error(t)}class I extends f{constructor(e={}){C(typeof e=="object","@param `opts` should be object type!");const s=document.createElement("div");super({element:s});a(this,"map");a(this,"container");a(this,"coordinate",[]);a(this,"pixel",[]);a(this,"contextMenuEventListener");a(this,"entryCallbackEventListener");a(this,"mapMoveListener");a(this,"lineHeight",0);a(this,"disabled");a(this,"opened");a(this,"items",[]);a(this,"menuEntries",new Map);a(this,"options");this.options={...k,...e};const i=document.createElement("ul");s.append(i),s.style.width=`${this.options.width}px`,s.classList.add(r.container,r.unselectable,r.hidden),this.container=s,this.contextMenuEventListener=o=>{this.handleContextMenu(o)},this.entryCallbackEventListener=o=>{this.handleEntryCallback(o)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1,window.addEventListener("beforeunload",()=>{this.removeListeners()},{once:!0})}clear(){for(const e of this.menuEntries.keys())this.removeMenuEntry(e);this.container.replaceChildren(),this.container.append(document.createElement("ul"))}enable(){this.disabled=!1}disable(){this.disabled=!0}getDefaultItems(){return N}countItems(){return this.menuEntries.size}extend(e){C(Array.isArray(e),"@param `items` should be an Array."),w(this.container.firstElementChild,e,this.options.width)}closeMenu(){this.opened=!1,this.container.classList.add(r.hidden),this.dispatchEvent(p.CLOSE)}isOpen(){return this.opened}updatePosition(e){C(Array.isArray(e),"@param `pixel` should be an Array."),this.isOpen()&&(this.pixel=e,this.positionContainer())}pop(){const e=Array.from(this.menuEntries.keys()).pop();e&&this.removeMenuEntry(e)}shift(){const e=Array.from(this.menuEntries.keys()).shift();e&&this.removeMenuEntry(e)}push(e){e&&this.extend([e])}setMap(e){if(super.setMap(e),e){this.map=e,this.map.getViewport().addEventListener(this.options.eventType,this.contextMenuEventListener,!1),this.map.on("movestart",()=>{this.handleMapMove()}),y.on(p.ADD_MENU_ENTRY,(i,o)=>{this.handleAddMenuEntry(i,o)},this),this.items=this.options.defaultItems?this.options.items.concat(N):this.options.items,w(this.container.firstElementChild,this.items,this.options.width);const s=this.getMenuEntriesLength();this.lineHeight=s>0?this.container.offsetHeight/s:D(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),y.off(p.ADD_MENU_ENTRY)}removeMenuEntry(e){const s=document.getElementById(e);s?.remove(),s?.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(e)}handleContextMenu(e){this.coordinate=this.map.getEventCoordinate(e),this.pixel=this.map.getEventPixel(e),this.dispatchEvent(new A({type:p.BEFOREOPEN,map:this.map,originalEvent:e})),!this.disabled&&(this.options.eventType===u.CONTEXTMENU&&(e.stopPropagation(),e.preventDefault()),setTimeout(()=>{this.openMenu(e)}),e.target?.addEventListener("pointerdown",s=>{this.opened&&(s.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(e){this.opened=!0,this.positionContainer(),this.container.classList.remove(r.hidden),this.dispatchEvent(new A({type:p.OPEN,map:this.map,originalEvent:e}))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,e])=>e.isSeparator===!1&&e.isSubmenu===!1&&e.isInsideSubmenu===!1).length}positionContainer(){const e=this.map.getSize()||[0,0],s={w:e[0]-this.pixel[0],h:e[1]-this.pixel[1]},i=this.getMenuEntriesLength(),o={w:this.container.offsetWidth,h:Math.round(this.lineHeight*i)},l=s.w>=o.w?this.pixel[0]+5:this.pixel[0]-o.w;this.container.style.left=`${l}px`,this.container.style.top=s.h>=o.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-o.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",s.w-=o.w;const E=g=>Array.from(g.children).filter(c=>c.tagName==="LI"&&c.classList.contains(r.submenu));let M=0;const b=(g,c)=>{M+=1,E(g).forEach(_=>{const z=c>=o.w?o.w-8:(o.w+8)*-1,d=_.querySelector(`ul.${r.container}`),P=Math.round(this.lineHeight*Array.from(d.children).filter(H=>H.tagName==="LI").length);d.style.left=`${z}px`,d.style.right="auto",d.style.top=s.h>=P+o.h?"0":`-${d.offsetHeight-25}px`,d.style.bottom="auto",d.style.zIndex=String(M),E(d).length>0&&b(d,c-o.w)})};b(this.container.firstElementChild,s.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(e){e.preventDefault(),e.stopPropagation();const s=e.currentTarget,i=this.menuEntries.get(s.id);if(!i)return;const o={coordinate:this.coordinate,data:i.data};this.closeMenu(),i.callback?.(o,this.map)}handleAddMenuEntry(e,s){this.menuEntries.set(e.id,e),this.positionContainer(),"callback"in e&&typeof e.callback=="function"&&s.addEventListener("click",this.entryCallbackEventListener,!1)}}return I}(ol.control.Control,ol); | ||
var ContextMenu=function(){"use strict";var pe=Object.defineProperty;var fe=(v,u,g)=>u in v?pe(v,u,{enumerable:!0,configurable:!0,writable:!0,value:g}):v[u]=g;var l=(v,u,g)=>(fe(v,typeof u!="symbol"?u+"":u,g),g);class v{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const u=v,g={PROPERTYCHANGE:"propertychange"};class K{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}const U=K;function M(){}function S(s){for(const e in s)delete s[e]}function z(s){let e;for(e in s)return!1;return!e}class B extends U{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const n=this.listeners_||(this.listeners_={}),i=n[e]||(n[e]=[]);i.includes(t)||i.push(t)}dispatchEvent(e){const t=typeof e=="string",n=t?e:e.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=t?new u(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),d=this.pendingRemovals_||(this.pendingRemovals_={});n in o||(o[n]=0,d[n]=0),++o[n];let p;for(let c=0,y=i.length;c<y;++c)if("handleEvent"in i[c]?p=i[c].handleEvent(r):p=i[c].call(this,r),p===!1||r.propagationStopped){p=!1;break}if(--o[n]===0){let c=d[n];for(delete d[n];c--;)this.removeEventListener(n,M);delete o[n]}return p}disposeInternal(){this.listeners_&&S(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){const n=this.listeners_&&this.listeners_[e];if(n){const i=n.indexOf(t);i!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(n[i]=M,++this.pendingRemovals_[e]):(n.splice(i,1),n.length===0&&delete this.listeners_[e]))}}}const F=B,V={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function _(s,e,t,n,i){if(n&&n!==s&&(t=t.bind(n)),i){const o=t;t=function(){s.removeEventListener(e,t),o.apply(this,arguments)}}const r={target:s,type:e,listener:t};return s.addEventListener(e,t),r}function D(s,e,t,n){return _(s,e,t,n,!0)}function C(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),S(s))}class L extends F{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(V.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const n=e.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=_(this,e[r],t);return i}return _(this,e,t)}onceInternal(e,t){let n;if(Array.isArray(e)){const i=e.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=D(this,e[r],t)}else n=D(this,e,t);return t.ol_key=n,n}unInternal(e,t){const n=t.ol_key;if(n)j(n);else if(Array.isArray(e))for(let i=0,r=e.length;i<r;++i)this.removeEventListener(e[i],t);else this.removeEventListener(e,t)}}L.prototype.on,L.prototype.once,L.prototype.un;function j(s){if(Array.isArray(s))for(let e=0,t=s.length;e<t;++e)C(s[e]);else C(s)}const Y=L;let G=0;function Z(s){return s.ol_uid||(s.ol_uid=String(++G))}class R extends u{constructor(e,t,n){super(e),this.key=t,this.oldValue=n}}class X extends Y{constructor(e){super(),this.on,this.once,this.un,Z(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(e,t){let n;n=`change:${e}`,this.hasListener(n)&&this.dispatchEvent(new R(n,e,t)),n=g.PROPERTYCHANGE,this.hasListener(n)&&this.dispatchEvent(new R(n,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,n){const i=this.values_||(this.values_={});if(n)i[e]=t;else{const r=i[e];i[e]=t,r!==t&&this.notify(e,r)}}setProperties(e,t){for(const n in e)this.set(n,e[n],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const n=this.values_[e];delete this.values_[e],z(this.values_)&&(this.values_=null),t||this.notify(e,n)}}}const W=X,q={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};function P(s){return s&&s.parentNode?s.parentNode.removeChild(s):null}class J extends W{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){P(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&P(this.element);for(let t=0,n=this.listenerKeys.length;t<n;++t)C(this.listenerKeys[t]);this.listenerKeys.length=0,this.map_=e,e&&((this.target_?this.target_:e.getOverlayContainerStopEvent()).appendChild(this.element),this.render!==M&&this.listenerKeys.push(_(e,q.POSTRENDER,this.render,this)),e.render())}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}}const Q=J;class ee extends u{constructor(e,t,n){super(e),this.map=t,this.frameState=n!==void 0?n:null}}const te=ee;class ne extends te{constructor(e,t,n,i,r,o){super(e,t,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=i!==void 0?i:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const se=ne;var O=(s=>(s.CONTEXTMENU="contextmenu",s.CLICK="click",s.DBLCLICK="dblclick",s))(O||{}),m=(s=>(s.BEFOREOPEN="beforeopen",s.OPEN="open",s.CLOSE="close",s.ADD_MENU_ENTRY="add-menu-entry",s))(m||{});class $ extends se{constructor(e){super(e.type,e.map,e.originalEvent)}}const ie={width:150,scrollAt:4,eventType:O.CONTEXTMENU,defaultItems:!0,items:[]},E="ol-ctx-menu",a={namespace:E,container:`${E}-container`,separator:`${E}-separator`,submenu:`${E}-submenu`,hidden:`${E}-hidden`,icon:`${E}-icon`,zoomIn:`${E}-zoom-in`,zoomOut:`${E}-zoom-out`,unselectable:"ol-unselectable"},I=[{text:"Zoom In",classname:`${a.zoomIn} ${a.icon}`,callback:(s,e)=>{const t=e.getView();t.animate({zoom:Number(t.getZoom())+1,duration:700,center:s.coordinate})}},{text:"Zoom Out",classname:`${a.zoomOut} ${a.icon}`,callback:(s,e)=>{const t=e.getView();t.animate({zoom:Number(t.getZoom())-1,duration:700,center:s.coordinate})}}];var w={},re={get exports(){return w},set exports(s){w=s}};function A(){}A.prototype={on:function(s,e,t){var n=this.e||(this.e={});return(n[s]||(n[s]=[])).push({fn:e,ctx:t}),this},once:function(s,e,t){var n=this;function i(){n.off(s,i),e.apply(t,arguments)}return i._=e,this.on(s,i,t)},emit:function(s){var e=[].slice.call(arguments,1),t=((this.e||(this.e={}))[s]||[]).slice(),n=0,i=t.length;for(n;n<i;n++)t[n].fn.apply(t[n].ctx,e);return this},off:function(s,e){var t=this.e||(this.e={}),n=t[s],i=[];if(n&&e)for(var r=0,o=n.length;r<o;r++)n[r].fn!==e&&n[r].fn._!==e&&i.push(n[r]);return i.length?t[s]=i:delete t[s],this}},re.exports=A;var oe=w.TinyEmitter=A;const b=new oe;function x(s){const e=document.createDocumentFragment(),t=document.createElement("div");for(t.innerHTML=s;t.firstChild;)e.append(t.firstChild);return e}function ae(s){const e=document.importNode(s),t=s.offsetWidth;e.style.cssText=`position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;const n=x("<span>Foo</span>"),i=x("<span>Foo</span>"),r=document.createElement("li"),o=document.createElement("li");r.append(n),o.append(i),e.append(r),e.append(o),s.parentNode?.append(e);const d=e.offsetHeight/2;return s.parentNode?.removeChild(e),d}function k(s,e,t=!1,n=!1){const i=`_${Math.random().toString(36).slice(2,11)}`;if(typeof e!="string"&&"text"in e){const c=`<span>${e.text}</span>`,y=x(c),h=document.createElement("li");e.classname=e.classname||"",e.icon&&(e.classname===""?e.classname=a.icon:e.classname.includes(a.icon)===!1&&(e.classname+=` ${a.icon}`),h.setAttribute("style",`background-image:url(${e.icon})`)),h.id=i,h.className=e.classname,h.append(y),s.append(h);const H={id:i,isSubmenu:t,isInsideSubmenu:n,isSeparator:!1,callback:"callback"in e?e.callback:null,data:"data"in e?e.data:null};return b.emit(m.ADD_MENU_ENTRY,H,h),h}const r=`<li id="${i}" class="${a.separator}"><hr></li>`,o=x(r);s.append(o);const d=s.lastChild,p={id:i,isSubmenu:!1,isInsideSubmenu:!1,isSeparator:!0,callback:null,data:null};return b.emit(m.ADD_MENU_ENTRY,p,d),d}function N(s,e,t,n){e.forEach(i=>{if(typeof i!="string"&&"items"in i&&Array.isArray(i.items)){const r=k(s,i,!0);r.classList.add(a.submenu);const o=document.createElement("ul");o.classList.add(a.container),o.style.width=`${t}px`,r.append(o),N(o,i.items,t,!0)}else k(s,i,!1,n)})}const me="";function T(s,e){if(!s)throw new Error(e)}class le extends Q{constructor(t={}){T(typeof t=="object","@param `opts` should be object type!");const n=document.createElement("div");super({element:n});l(this,"map");l(this,"container");l(this,"coordinate",[]);l(this,"pixel",[]);l(this,"contextMenuEventListener");l(this,"entryCallbackEventListener");l(this,"mapMoveListener");l(this,"lineHeight",0);l(this,"disabled");l(this,"opened");l(this,"items",[]);l(this,"menuEntries",new Map);l(this,"options");this.options={...ie,...t};const i=document.createElement("ul");n.append(i),n.style.width=`${this.options.width}px`,n.classList.add(a.container,a.unselectable,a.hidden),this.container=n,this.contextMenuEventListener=r=>{this.handleContextMenu(r)},this.entryCallbackEventListener=r=>{this.handleEntryCallback(r)},this.mapMoveListener=()=>{this.handleMapMove()},this.disabled=!1,this.opened=!1,window.addEventListener("beforeunload",()=>{this.removeListeners()},{once:!0})}clear(){for(const t of this.menuEntries.keys())this.removeMenuEntry(t);this.container.replaceChildren(),this.container.append(document.createElement("ul"))}enable(){this.disabled=!1}disable(){this.disabled=!0}getDefaultItems(){return I}countItems(){return this.menuEntries.size}extend(t){T(Array.isArray(t),"@param `items` should be an Array."),N(this.container.firstElementChild,t,this.options.width)}closeMenu(){this.opened=!1,this.container.classList.add(a.hidden),this.dispatchEvent(m.CLOSE)}isOpen(){return this.opened}updatePosition(t){T(Array.isArray(t),"@param `pixel` should be an Array."),this.isOpen()&&(this.pixel=t,this.positionContainer())}pop(){const t=Array.from(this.menuEntries.keys()).pop();t&&this.removeMenuEntry(t)}shift(){const t=Array.from(this.menuEntries.keys()).shift();t&&this.removeMenuEntry(t)}push(t){t&&this.extend([t])}setMap(t){if(super.setMap(t),t){this.map=t,this.map.getViewport().addEventListener(this.options.eventType,this.contextMenuEventListener,!1),this.map.on("movestart",()=>{this.handleMapMove()}),b.on(m.ADD_MENU_ENTRY,(i,r)=>{this.handleAddMenuEntry(i,r)},this),this.items=this.options.defaultItems?this.options.items.concat(I):this.options.items,N(this.container.firstElementChild,this.items,this.options.width);const n=this.getMenuEntriesLength();this.lineHeight=n>0?this.container.offsetHeight/n:ae(this.container)}else this.removeListeners(),this.clear()}removeListeners(){this.map.getViewport().removeEventListener(this.options.eventType,this.contextMenuEventListener,!1),b.off(m.ADD_MENU_ENTRY)}removeMenuEntry(t){const n=document.getElementById(t);n?.remove(),n?.removeEventListener("click",this.entryCallbackEventListener),this.menuEntries.delete(t)}handleContextMenu(t){this.coordinate=this.map.getEventCoordinate(t),this.pixel=this.map.getEventPixel(t),this.dispatchEvent(new $({type:m.BEFOREOPEN,map:this.map,originalEvent:t})),!this.disabled&&(this.options.eventType===O.CONTEXTMENU&&(t.stopPropagation(),t.preventDefault()),setTimeout(()=>{this.openMenu(t)}),t.target?.addEventListener("pointerdown",n=>{this.opened&&(n.stopPropagation(),this.closeMenu())},{once:!0}))}openMenu(t){this.opened=!0,this.positionContainer(),this.container.classList.remove(a.hidden),this.dispatchEvent(new $({type:m.OPEN,map:this.map,originalEvent:t}))}getMenuEntriesLength(){return Array.from(this.menuEntries).filter(([,t])=>t.isSeparator===!1&&t.isSubmenu===!1&&t.isInsideSubmenu===!1).length}positionContainer(){const t=this.map.getSize()||[0,0],n={w:t[0]-this.pixel[0],h:t[1]-this.pixel[1]},i=this.getMenuEntriesLength(),r={w:this.container.offsetWidth,h:Math.round(this.lineHeight*i)},o=n.w>=r.w?this.pixel[0]+5:this.pixel[0]-r.w;this.container.style.left=`${o}px`,this.container.style.top=n.h>=r.h?`${this.pixel[1]-10}px`:`${this.pixel[1]-r.h}px`,this.container.style.right="auto",this.container.style.bottom="auto",n.w-=r.w;const d=y=>Array.from(y.children).filter(h=>h.tagName==="LI"&&h.classList.contains(a.submenu));let p=0;const c=(y,h)=>{p+=1,d(y).forEach(he=>{const ce=h>=r.w?r.w-8:(r.w+8)*-1,f=he.querySelector(`ul.${a.container}`),ue=Math.round(this.lineHeight*Array.from(f.children).filter(de=>de.tagName==="LI").length);f.style.left=`${ce}px`,f.style.right="auto",f.style.top=n.h>=ue+r.h?"0":`-${f.offsetHeight-25}px`,f.style.bottom="auto",f.style.zIndex=String(p),d(f).length>0&&c(f,h-r.w)})};c(this.container.firstElementChild,n.w)}handleMapMove(){this.closeMenu()}handleEntryCallback(t){t.preventDefault(),t.stopPropagation();const n=t.currentTarget,i=this.menuEntries.get(n.id);if(!i)return;const r={coordinate:this.coordinate,data:i.data};this.closeMenu(),i.callback?.(r,this.map)}handleAddMenuEntry(t,n){this.menuEntries.set(t.id,t),this.positionContainer(),"callback"in t&&typeof t.callback=="function"&&n.addEventListener("click",this.entryCallbackEventListener,!1)}}return le}(); |
/*! | ||
* ol-contextmenu - v5.1.5 | ||
* ol-contextmenu - v5.2.0 | ||
* https://github.com/jonataswalker/ol-contextmenu | ||
* Built: Sat Mar 11 2023 15:05:27 GMT-0300 (Brasilia Standard Time) | ||
* Built: Mon Mar 13 2023 13:25:53 GMT-0300 (Brasilia Standard Time) | ||
*/ | ||
var O = Object.defineProperty; | ||
var D = (n, t, e) => t in n ? O(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; | ||
var a = (n, t, e) => (D(n, typeof t != "symbol" ? t + "" : t, e), e); | ||
import I from "ol/control/Control"; | ||
import { MapBrowserEvent as _ } from "ol"; | ||
var x = /* @__PURE__ */ ((n) => (n.CONTEXTMENU = "contextmenu", n.CLICK = "click", n.DBLCLICK = "dblclick", n))(x || {}), d = /* @__PURE__ */ ((n) => (n.BEFOREOPEN = "beforeopen", n.OPEN = "open", n.CLOSE = "close", n.ADD_MENU_ENTRY = "add-menu-entry", n))(d || {}); | ||
class C extends _ { | ||
constructor(t) { | ||
super(t.type, t.map, t.originalEvent); | ||
var z = Object.defineProperty; | ||
var B = (s, e, t) => e in s ? z(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t; | ||
var l = (s, e, t) => (B(s, typeof e != "symbol" ? e + "" : e, t), t); | ||
class F { | ||
/** | ||
* @param {string} type Type. | ||
*/ | ||
constructor(e) { | ||
this.propagationStopped, this.defaultPrevented, this.type = e, this.target = null; | ||
} | ||
/** | ||
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events | ||
* will be fired. | ||
* @api | ||
*/ | ||
preventDefault() { | ||
this.defaultPrevented = !0; | ||
} | ||
/** | ||
* Stop event propagation. | ||
* @api | ||
*/ | ||
stopPropagation() { | ||
this.propagationStopped = !0; | ||
} | ||
} | ||
const z = { | ||
const O = F, V = { | ||
/** | ||
* Triggered when a property is changed. | ||
* @event module:ol/Object.ObjectEvent#propertychange | ||
* @api | ||
*/ | ||
PROPERTYCHANGE: "propertychange" | ||
}; | ||
class j { | ||
constructor() { | ||
this.disposed = !1; | ||
} | ||
/** | ||
* Clean up. | ||
*/ | ||
dispose() { | ||
this.disposed || (this.disposed = !0, this.disposeInternal()); | ||
} | ||
/** | ||
* Extension point for disposable objects. | ||
* @protected | ||
*/ | ||
disposeInternal() { | ||
} | ||
} | ||
const Y = j; | ||
function b() { | ||
} | ||
function I(s) { | ||
for (const e in s) | ||
delete s[e]; | ||
} | ||
function G(s) { | ||
let e; | ||
for (e in s) | ||
return !1; | ||
return !e; | ||
} | ||
class Z extends Y { | ||
/** | ||
* @param {*} [target] Default event target for dispatched events. | ||
*/ | ||
constructor(e) { | ||
super(), this.eventTarget_ = e, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null; | ||
} | ||
/** | ||
* @param {string} type Type. | ||
* @param {import("../events.js").Listener} listener Listener. | ||
*/ | ||
addEventListener(e, t) { | ||
if (!e || !t) | ||
return; | ||
const n = this.listeners_ || (this.listeners_ = {}), i = n[e] || (n[e] = []); | ||
i.includes(t) || i.push(t); | ||
} | ||
/** | ||
* Dispatches an event and calls all listeners listening for events | ||
* of this type. The event parameter can either be a string or an | ||
* Object with a `type` property. | ||
* | ||
* @param {import("./Event.js").default|string} event Event object. | ||
* @return {boolean|undefined} `false` if anyone called preventDefault on the | ||
* event object or if any of the listeners returned false. | ||
* @api | ||
*/ | ||
dispatchEvent(e) { | ||
const t = typeof e == "string", n = t ? e : e.type, i = this.listeners_ && this.listeners_[n]; | ||
if (!i) | ||
return; | ||
const r = t ? new O(e) : ( | ||
/** @type {Event} */ | ||
e | ||
); | ||
r.target || (r.target = this.eventTarget_ || this); | ||
const o = this.dispatching_ || (this.dispatching_ = {}), u = this.pendingRemovals_ || (this.pendingRemovals_ = {}); | ||
n in o || (o[n] = 0, u[n] = 0), ++o[n]; | ||
let d; | ||
for (let c = 0, E = i.length; c < E; ++c) | ||
if ("handleEvent" in i[c] ? d = /** @type {import("../events.js").ListenerObject} */ | ||
i[c].handleEvent(r) : d = /** @type {import("../events.js").ListenerFunction} */ | ||
i[c].call(this, r), d === !1 || r.propagationStopped) { | ||
d = !1; | ||
break; | ||
} | ||
if (--o[n] === 0) { | ||
let c = u[n]; | ||
for (delete u[n]; c--; ) | ||
this.removeEventListener(n, b); | ||
delete o[n]; | ||
} | ||
return d; | ||
} | ||
/** | ||
* Clean up. | ||
*/ | ||
disposeInternal() { | ||
this.listeners_ && I(this.listeners_); | ||
} | ||
/** | ||
* Get the listeners for a specified event type. Listeners are returned in the | ||
* order that they will be called in. | ||
* | ||
* @param {string} type Type. | ||
* @return {Array<import("../events.js").Listener>|undefined} Listeners. | ||
*/ | ||
getListeners(e) { | ||
return this.listeners_ && this.listeners_[e] || void 0; | ||
} | ||
/** | ||
* @param {string} [type] Type. If not provided, | ||
* `true` will be returned if this event target has any listeners. | ||
* @return {boolean} Has listeners. | ||
*/ | ||
hasListener(e) { | ||
return this.listeners_ ? e ? e in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1; | ||
} | ||
/** | ||
* @param {string} type Type. | ||
* @param {import("../events.js").Listener} listener Listener. | ||
*/ | ||
removeEventListener(e, t) { | ||
const n = this.listeners_ && this.listeners_[e]; | ||
if (n) { | ||
const i = n.indexOf(t); | ||
i !== -1 && (this.pendingRemovals_ && e in this.pendingRemovals_ ? (n[i] = b, ++this.pendingRemovals_[e]) : (n.splice(i, 1), n.length === 0 && delete this.listeners_[e])); | ||
} | ||
} | ||
} | ||
const X = Z, W = { | ||
/** | ||
* Generic change event. Triggered when the revision counter is increased. | ||
* @event module:ol/events/Event~BaseEvent#change | ||
* @api | ||
*/ | ||
CHANGE: "change", | ||
/** | ||
* Generic error event. Triggered when an error occurs. | ||
* @event module:ol/events/Event~BaseEvent#error | ||
* @api | ||
*/ | ||
ERROR: "error", | ||
BLUR: "blur", | ||
CLEAR: "clear", | ||
CONTEXTMENU: "contextmenu", | ||
CLICK: "click", | ||
DBLCLICK: "dblclick", | ||
DRAGENTER: "dragenter", | ||
DRAGOVER: "dragover", | ||
DROP: "drop", | ||
FOCUS: "focus", | ||
KEYDOWN: "keydown", | ||
KEYPRESS: "keypress", | ||
LOAD: "load", | ||
RESIZE: "resize", | ||
TOUCHMOVE: "touchmove", | ||
WHEEL: "wheel" | ||
}; | ||
function v(s, e, t, n, i) { | ||
if (n && n !== s && (t = t.bind(n)), i) { | ||
const o = t; | ||
t = function() { | ||
s.removeEventListener(e, t), o.apply(this, arguments); | ||
}; | ||
} | ||
const r = { | ||
target: s, | ||
type: e, | ||
listener: t | ||
}; | ||
return s.addEventListener(e, t), r; | ||
} | ||
function T(s, e, t, n) { | ||
return v(s, e, t, n, !0); | ||
} | ||
function x(s) { | ||
s && s.target && (s.target.removeEventListener(s.type, s.listener), I(s)); | ||
} | ||
class _ extends X { | ||
constructor() { | ||
super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */ | ||
this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */ | ||
this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */ | ||
this.unInternal, this.revision_ = 0; | ||
} | ||
/** | ||
* Increases the revision counter and dispatches a 'change' event. | ||
* @api | ||
*/ | ||
changed() { | ||
++this.revision_, this.dispatchEvent(W.CHANGE); | ||
} | ||
/** | ||
* Get the version number for this object. Each time the object is modified, | ||
* its version number will be incremented. | ||
* @return {number} Revision. | ||
* @api | ||
*/ | ||
getRevision() { | ||
return this.revision_; | ||
} | ||
/** | ||
* @param {string|Array<string>} type Type. | ||
* @param {function((Event|import("./events/Event").default)): ?} listener Listener. | ||
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. | ||
* @protected | ||
*/ | ||
onInternal(e, t) { | ||
if (Array.isArray(e)) { | ||
const n = e.length, i = new Array(n); | ||
for (let r = 0; r < n; ++r) | ||
i[r] = v(this, e[r], t); | ||
return i; | ||
} | ||
return v( | ||
this, | ||
/** @type {string} */ | ||
e, | ||
t | ||
); | ||
} | ||
/** | ||
* @param {string|Array<string>} type Type. | ||
* @param {function((Event|import("./events/Event").default)): ?} listener Listener. | ||
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. | ||
* @protected | ||
*/ | ||
onceInternal(e, t) { | ||
let n; | ||
if (Array.isArray(e)) { | ||
const i = e.length; | ||
n = new Array(i); | ||
for (let r = 0; r < i; ++r) | ||
n[r] = T(this, e[r], t); | ||
} else | ||
n = T( | ||
this, | ||
/** @type {string} */ | ||
e, | ||
t | ||
); | ||
return t.ol_key = n, n; | ||
} | ||
/** | ||
* Unlisten for a certain type of event. | ||
* @param {string|Array<string>} type Type. | ||
* @param {function((Event|import("./events/Event").default)): ?} listener Listener. | ||
* @protected | ||
*/ | ||
unInternal(e, t) { | ||
const n = ( | ||
/** @type {Object} */ | ||
t.ol_key | ||
); | ||
if (n) | ||
q(n); | ||
else if (Array.isArray(e)) | ||
for (let i = 0, r = e.length; i < r; ++i) | ||
this.removeEventListener(e[i], t); | ||
else | ||
this.removeEventListener(e, t); | ||
} | ||
} | ||
_.prototype.on; | ||
_.prototype.once; | ||
_.prototype.un; | ||
function q(s) { | ||
if (Array.isArray(s)) | ||
for (let e = 0, t = s.length; e < t; ++e) | ||
x(s[e]); | ||
else | ||
x( | ||
/** @type {import("./events.js").EventsKey} */ | ||
s | ||
); | ||
} | ||
const J = _; | ||
let Q = 0; | ||
function ee(s) { | ||
return s.ol_uid || (s.ol_uid = String(++Q)); | ||
} | ||
class S extends O { | ||
/** | ||
* @param {string} type The event type. | ||
* @param {string} key The property name. | ||
* @param {*} oldValue The old value for `key`. | ||
*/ | ||
constructor(e, t, n) { | ||
super(e), this.key = t, this.oldValue = n; | ||
} | ||
} | ||
class te extends J { | ||
/** | ||
* @param {Object<string, *>} [values] An object with key-value pairs. | ||
*/ | ||
constructor(e) { | ||
super(), this.on, this.once, this.un, ee(this), this.values_ = null, e !== void 0 && this.setProperties(e); | ||
} | ||
/** | ||
* Gets a value. | ||
* @param {string} key Key name. | ||
* @return {*} Value. | ||
* @api | ||
*/ | ||
get(e) { | ||
let t; | ||
return this.values_ && this.values_.hasOwnProperty(e) && (t = this.values_[e]), t; | ||
} | ||
/** | ||
* Get a list of object property names. | ||
* @return {Array<string>} List of property names. | ||
* @api | ||
*/ | ||
getKeys() { | ||
return this.values_ && Object.keys(this.values_) || []; | ||
} | ||
/** | ||
* Get an object of all property names and values. | ||
* @return {Object<string, *>} Object. | ||
* @api | ||
*/ | ||
getProperties() { | ||
return this.values_ && Object.assign({}, this.values_) || {}; | ||
} | ||
/** | ||
* @return {boolean} The object has properties. | ||
*/ | ||
hasProperties() { | ||
return !!this.values_; | ||
} | ||
/** | ||
* @param {string} key Key name. | ||
* @param {*} oldValue Old value. | ||
*/ | ||
notify(e, t) { | ||
let n; | ||
n = `change:${e}`, this.hasListener(n) && this.dispatchEvent(new S(n, e, t)), n = V.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new S(n, e, t)); | ||
} | ||
/** | ||
* @param {string} key Key name. | ||
* @param {import("./events.js").Listener} listener Listener. | ||
*/ | ||
addChangeListener(e, t) { | ||
this.addEventListener(`change:${e}`, t); | ||
} | ||
/** | ||
* @param {string} key Key name. | ||
* @param {import("./events.js").Listener} listener Listener. | ||
*/ | ||
removeChangeListener(e, t) { | ||
this.removeEventListener(`change:${e}`, t); | ||
} | ||
/** | ||
* Sets a value. | ||
* @param {string} key Key name. | ||
* @param {*} value Value. | ||
* @param {boolean} [silent] Update without triggering an event. | ||
* @api | ||
*/ | ||
set(e, t, n) { | ||
const i = this.values_ || (this.values_ = {}); | ||
if (n) | ||
i[e] = t; | ||
else { | ||
const r = i[e]; | ||
i[e] = t, r !== t && this.notify(e, r); | ||
} | ||
} | ||
/** | ||
* Sets a collection of key-value pairs. Note that this changes any existing | ||
* properties and adds new ones (it does not remove any existing properties). | ||
* @param {Object<string, *>} values Values. | ||
* @param {boolean} [silent] Update without triggering an event. | ||
* @api | ||
*/ | ||
setProperties(e, t) { | ||
for (const n in e) | ||
this.set(n, e[n], t); | ||
} | ||
/** | ||
* Apply any properties from another object without triggering events. | ||
* @param {BaseObject} source The source object. | ||
* @protected | ||
*/ | ||
applyProperties(e) { | ||
e.values_ && Object.assign(this.values_ || (this.values_ = {}), e.values_); | ||
} | ||
/** | ||
* Unsets a property. | ||
* @param {string} key Key name. | ||
* @param {boolean} [silent] Unset without triggering an event. | ||
* @api | ||
*/ | ||
unset(e, t) { | ||
if (this.values_ && e in this.values_) { | ||
const n = this.values_[e]; | ||
delete this.values_[e], G(this.values_) && (this.values_ = null), t || this.notify(e, n); | ||
} | ||
} | ||
} | ||
const ne = te, se = { | ||
/** | ||
* Triggered after a map frame is rendered. | ||
* @event module:ol/MapEvent~MapEvent#postrender | ||
* @api | ||
*/ | ||
POSTRENDER: "postrender", | ||
/** | ||
* Triggered when the map starts moving. | ||
* @event module:ol/MapEvent~MapEvent#movestart | ||
* @api | ||
*/ | ||
MOVESTART: "movestart", | ||
/** | ||
* Triggered after the map is moved. | ||
* @event module:ol/MapEvent~MapEvent#moveend | ||
* @api | ||
*/ | ||
MOVEEND: "moveend", | ||
/** | ||
* Triggered when loading of additional map data (tiles, images, features) starts. | ||
* @event module:ol/MapEvent~MapEvent#loadstart | ||
* @api | ||
*/ | ||
LOADSTART: "loadstart", | ||
/** | ||
* Triggered when loading of additional map data has completed. | ||
* @event module:ol/MapEvent~MapEvent#loadend | ||
* @api | ||
*/ | ||
LOADEND: "loadend" | ||
}; | ||
function D(s) { | ||
return s && s.parentNode ? s.parentNode.removeChild(s) : null; | ||
} | ||
class ie extends ne { | ||
/** | ||
* @param {Options} options Control options. | ||
*/ | ||
constructor(e) { | ||
super(); | ||
const t = e.element; | ||
t && !e.target && !t.style.pointerEvents && (t.style.pointerEvents = "auto"), this.element = t || null, this.target_ = null, this.map_ = null, this.listenerKeys = [], e.render && (this.render = e.render), e.target && this.setTarget(e.target); | ||
} | ||
/** | ||
* Clean up. | ||
*/ | ||
disposeInternal() { | ||
D(this.element), super.disposeInternal(); | ||
} | ||
/** | ||
* Get the map associated with this control. | ||
* @return {import("../Map.js").default|null} Map. | ||
* @api | ||
*/ | ||
getMap() { | ||
return this.map_; | ||
} | ||
/** | ||
* Remove the control from its current map and attach it to the new map. | ||
* Pass `null` to just remove the control from the current map. | ||
* Subclasses may set up event handlers to get notified about changes to | ||
* the map here. | ||
* @param {import("../Map.js").default|null} map Map. | ||
* @api | ||
*/ | ||
setMap(e) { | ||
this.map_ && D(this.element); | ||
for (let t = 0, n = this.listenerKeys.length; t < n; ++t) | ||
x(this.listenerKeys[t]); | ||
this.listenerKeys.length = 0, this.map_ = e, e && ((this.target_ ? this.target_ : e.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== b && this.listenerKeys.push( | ||
v(e, se.POSTRENDER, this.render, this) | ||
), e.render()); | ||
} | ||
/** | ||
* Renders the control. | ||
* @param {import("../MapEvent.js").default} mapEvent Map event. | ||
* @api | ||
*/ | ||
render(e) { | ||
} | ||
/** | ||
* This function is used to set a target element for the control. It has no | ||
* effect if it is called after the control has been added to the map (i.e. | ||
* after `setMap` is called on the control). If no `target` is set in the | ||
* options passed to the control constructor and if `setTarget` is not called | ||
* then the control is added to the map's overlay container. | ||
* @param {HTMLElement|string} target Target. | ||
* @api | ||
*/ | ||
setTarget(e) { | ||
this.target_ = typeof e == "string" ? document.getElementById(e) : e; | ||
} | ||
} | ||
const re = ie; | ||
class oe extends O { | ||
/** | ||
* @param {string} type Event type. | ||
* @param {import("./Map.js").default} map Map. | ||
* @param {?import("./Map.js").FrameState} [frameState] Frame state. | ||
*/ | ||
constructor(e, t, n) { | ||
super(e), this.map = t, this.frameState = n !== void 0 ? n : null; | ||
} | ||
} | ||
const ae = oe; | ||
class le extends ae { | ||
/** | ||
* @param {string} type Event type. | ||
* @param {import("./Map.js").default} map Map. | ||
* @param {EVENT} originalEvent Original event. | ||
* @param {boolean} [dragging] Is the map currently being dragged? | ||
* @param {import("./Map.js").FrameState} [frameState] Frame state. | ||
* @param {Array<PointerEvent>} [activePointers] Active pointers. | ||
*/ | ||
constructor(e, t, n, i, r, o) { | ||
super(e, t, r), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = i !== void 0 ? i : !1, this.activePointers = o; | ||
} | ||
/** | ||
* The map pixel relative to the viewport corresponding to the original event. | ||
* @type {import("./pixel.js").Pixel} | ||
* @api | ||
*/ | ||
get pixel() { | ||
return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_; | ||
} | ||
set pixel(e) { | ||
this.pixel_ = e; | ||
} | ||
/** | ||
* The coordinate corresponding to the original browser event. This will be in the user | ||
* projection if one is set. Otherwise it will be in the view projection. | ||
* @type {import("./coordinate.js").Coordinate} | ||
* @api | ||
*/ | ||
get coordinate() { | ||
return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_; | ||
} | ||
set coordinate(e) { | ||
this.coordinate_ = e; | ||
} | ||
/** | ||
* Prevents the default browser action. | ||
* See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault. | ||
* @api | ||
*/ | ||
preventDefault() { | ||
super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault(); | ||
} | ||
/** | ||
* Prevents further propagation of the current event. | ||
* See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation. | ||
* @api | ||
*/ | ||
stopPropagation() { | ||
super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation(); | ||
} | ||
} | ||
const he = le; | ||
var w = /* @__PURE__ */ ((s) => (s.CONTEXTMENU = "contextmenu", s.CLICK = "click", s.DBLCLICK = "dblclick", s))(w || {}), m = /* @__PURE__ */ ((s) => (s.BEFOREOPEN = "beforeopen", s.OPEN = "open", s.CLOSE = "close", s.ADD_MENU_ENTRY = "add-menu-entry", s))(m || {}); | ||
class R extends he { | ||
constructor(e) { | ||
super(e.type, e.map, e.originalEvent); | ||
} | ||
} | ||
const ce = { | ||
width: 150, | ||
scrollAt: 4, | ||
eventType: x.CONTEXTMENU, | ||
eventType: w.CONTEXTMENU, | ||
defaultItems: !0, | ||
items: [] | ||
}, u = "ol-ctx-menu", r = { | ||
namespace: u, | ||
container: `${u}-container`, | ||
separator: `${u}-separator`, | ||
submenu: `${u}-submenu`, | ||
hidden: `${u}-hidden`, | ||
icon: `${u}-icon`, | ||
zoomIn: `${u}-zoom-in`, | ||
zoomOut: `${u}-zoom-out`, | ||
}, f = "ol-ctx-menu", a = { | ||
namespace: f, | ||
container: `${f}-container`, | ||
separator: `${f}-separator`, | ||
submenu: `${f}-submenu`, | ||
hidden: `${f}-hidden`, | ||
icon: `${f}-icon`, | ||
zoomIn: `${f}-zoom-in`, | ||
zoomOut: `${f}-zoom-out`, | ||
unselectable: "ol-unselectable" | ||
}, A = [ | ||
}, P = [ | ||
{ | ||
text: "Zoom In", | ||
classname: `${r.zoomIn} ${r.icon}`, | ||
callback: (n, t) => { | ||
const e = t.getView(); | ||
e.animate({ | ||
zoom: Number(e.getZoom()) + 1, | ||
classname: `${a.zoomIn} ${a.icon}`, | ||
callback: (s, e) => { | ||
const t = e.getView(); | ||
t.animate({ | ||
zoom: Number(t.getZoom()) + 1, | ||
duration: 700, | ||
center: n.coordinate | ||
center: s.coordinate | ||
}); | ||
@@ -50,9 +629,9 @@ } | ||
text: "Zoom Out", | ||
classname: `${r.zoomOut} ${r.icon}`, | ||
callback: (n, t) => { | ||
const e = t.getView(); | ||
e.animate({ | ||
zoom: Number(e.getZoom()) - 1, | ||
classname: `${a.zoomOut} ${a.icon}`, | ||
callback: (s, e) => { | ||
const t = e.getView(); | ||
t.animate({ | ||
zoom: Number(t.getZoom()) - 1, | ||
duration: 700, | ||
center: n.coordinate | ||
center: s.coordinate | ||
}); | ||
@@ -62,76 +641,76 @@ } | ||
]; | ||
var M = {}, P = { | ||
var M = {}, ue = { | ||
get exports() { | ||
return M; | ||
}, | ||
set exports(n) { | ||
M = n; | ||
set exports(s) { | ||
M = s; | ||
} | ||
}; | ||
function L() { | ||
function A() { | ||
} | ||
L.prototype = { | ||
on: function(n, t, e) { | ||
var s = this.e || (this.e = {}); | ||
return (s[n] || (s[n] = [])).push({ | ||
fn: t, | ||
ctx: e | ||
A.prototype = { | ||
on: function(s, e, t) { | ||
var n = this.e || (this.e = {}); | ||
return (n[s] || (n[s] = [])).push({ | ||
fn: e, | ||
ctx: t | ||
}), this; | ||
}, | ||
once: function(n, t, e) { | ||
var s = this; | ||
once: function(s, e, t) { | ||
var n = this; | ||
function i() { | ||
s.off(n, i), t.apply(e, arguments); | ||
n.off(s, i), e.apply(t, arguments); | ||
} | ||
return i._ = t, this.on(n, i, e); | ||
return i._ = e, this.on(s, i, t); | ||
}, | ||
emit: function(n) { | ||
var t = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[n] || []).slice(), s = 0, i = e.length; | ||
for (s; s < i; s++) | ||
e[s].fn.apply(e[s].ctx, t); | ||
emit: function(s) { | ||
var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[s] || []).slice(), n = 0, i = t.length; | ||
for (n; n < i; n++) | ||
t[n].fn.apply(t[n].ctx, e); | ||
return this; | ||
}, | ||
off: function(n, t) { | ||
var e = this.e || (this.e = {}), s = e[n], i = []; | ||
if (s && t) | ||
for (var o = 0, l = s.length; o < l; o++) | ||
s[o].fn !== t && s[o].fn._ !== t && i.push(s[o]); | ||
return i.length ? e[n] = i : delete e[n], this; | ||
off: function(s, e) { | ||
var t = this.e || (this.e = {}), n = t[s], i = []; | ||
if (n && e) | ||
for (var r = 0, o = n.length; r < o; r++) | ||
n[r].fn !== e && n[r].fn._ !== e && i.push(n[r]); | ||
return i.length ? t[s] = i : delete t[s], this; | ||
} | ||
}; | ||
P.exports = L; | ||
var H = M.TinyEmitter = L; | ||
const g = new H(); | ||
function y(n) { | ||
const t = document.createDocumentFragment(), e = document.createElement("div"); | ||
for (e.innerHTML = n; e.firstChild; ) | ||
t.append(e.firstChild); | ||
return t; | ||
ue.exports = A; | ||
var de = M.TinyEmitter = A; | ||
const g = new de(); | ||
function y(s) { | ||
const e = document.createDocumentFragment(), t = document.createElement("div"); | ||
for (t.innerHTML = s; t.firstChild; ) | ||
e.append(t.firstChild); | ||
return e; | ||
} | ||
function U(n) { | ||
const t = document.importNode(n), e = n.offsetWidth; | ||
t.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`; | ||
const s = y("<span>Foo</span>"), i = y("<span>Foo</span>"), o = document.createElement("li"), l = document.createElement("li"); | ||
o.append(s), l.append(i), t.append(o), t.append(l), n.parentNode?.append(t); | ||
const p = t.offsetHeight / 2; | ||
return n.parentNode?.removeChild(t), p; | ||
function pe(s) { | ||
const e = document.importNode(s), t = s.offsetWidth; | ||
e.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`; | ||
const n = y("<span>Foo</span>"), i = y("<span>Foo</span>"), r = document.createElement("li"), o = document.createElement("li"); | ||
r.append(n), o.append(i), e.append(r), e.append(o), s.parentNode?.append(e); | ||
const u = e.offsetHeight / 2; | ||
return s.parentNode?.removeChild(e), u; | ||
} | ||
function N(n, t, e = !1, s = !1) { | ||
function $(s, e, t = !1, n = !1) { | ||
const i = `_${Math.random().toString(36).slice(2, 11)}`; | ||
if (typeof t != "string" && "text" in t) { | ||
const E = `<span>${t.text}</span>`, m = y(E), c = document.createElement("li"); | ||
t.classname = t.classname || "", t.icon && (t.classname === "" ? t.classname = r.icon : t.classname.includes(r.icon) === !1 && (t.classname += ` ${r.icon}`), c.setAttribute("style", `background-image:url(${t.icon})`)), c.id = i, c.className = t.classname, c.append(m), n.append(c); | ||
const w = { | ||
if (typeof e != "string" && "text" in e) { | ||
const c = `<span>${e.text}</span>`, E = y(c), h = document.createElement("li"); | ||
e.classname = e.classname || "", e.icon && (e.classname === "" ? e.classname = a.icon : e.classname.includes(a.icon) === !1 && (e.classname += ` ${a.icon}`), h.setAttribute("style", `background-image:url(${e.icon})`)), h.id = i, h.className = e.classname, h.append(E), s.append(h); | ||
const N = { | ||
id: i, | ||
isSubmenu: e, | ||
isInsideSubmenu: s, | ||
isSubmenu: t, | ||
isInsideSubmenu: n, | ||
isSeparator: !1, | ||
callback: "callback" in t ? t.callback : null, | ||
data: "data" in t ? t.data : null | ||
callback: "callback" in e ? e.callback : null, | ||
data: "data" in e ? e.data : null | ||
}; | ||
return g.emit(d.ADD_MENU_ENTRY, w, c), c; | ||
return g.emit(m.ADD_MENU_ENTRY, N, h), h; | ||
} | ||
const o = `<li id="${i}" class="${r.separator}"><hr></li>`, l = y(o); | ||
n.append(l); | ||
const p = n.lastChild, f = { | ||
const r = `<li id="${i}" class="${a.separator}"><hr></li>`, o = y(r); | ||
s.append(o); | ||
const u = s.lastChild, d = { | ||
id: i, | ||
@@ -144,47 +723,47 @@ isSubmenu: !1, | ||
}; | ||
return g.emit(d.ADD_MENU_ENTRY, f, p), p; | ||
return g.emit(m.ADD_MENU_ENTRY, d, u), u; | ||
} | ||
function b(n, t, e, s) { | ||
t.forEach((i) => { | ||
function C(s, e, t, n) { | ||
e.forEach((i) => { | ||
if (typeof i != "string" && "items" in i && Array.isArray(i.items)) { | ||
const o = N(n, i, !0); | ||
o.classList.add(r.submenu); | ||
const l = document.createElement("ul"); | ||
l.classList.add(r.container), l.style.width = `${e}px`, o.append(l), b(l, i.items, e, !0); | ||
const r = $(s, i, !0); | ||
r.classList.add(a.submenu); | ||
const o = document.createElement("ul"); | ||
o.classList.add(a.container), o.style.width = `${t}px`, r.append(o), C(o, i.items, t, !0); | ||
} else | ||
N(n, i, !1, s); | ||
$(s, i, !1, n); | ||
}); | ||
} | ||
function v(n, t) { | ||
if (!n) | ||
throw new Error(t); | ||
function L(s, e) { | ||
if (!s) | ||
throw new Error(e); | ||
} | ||
class Y extends I { | ||
constructor(e = {}) { | ||
v(typeof e == "object", "@param `opts` should be object type!"); | ||
const s = document.createElement("div"); | ||
super({ element: s }); | ||
a(this, "map"); | ||
a(this, "container"); | ||
a(this, "coordinate", []); | ||
a(this, "pixel", []); | ||
a(this, "contextMenuEventListener"); | ||
a(this, "entryCallbackEventListener"); | ||
a(this, "mapMoveListener"); | ||
a(this, "lineHeight", 0); | ||
a(this, "disabled"); | ||
a(this, "opened"); | ||
a(this, "items", []); | ||
a(this, "menuEntries", /* @__PURE__ */ new Map()); | ||
a(this, "options"); | ||
this.options = { ...z, ...e }; | ||
class me extends re { | ||
constructor(t = {}) { | ||
L(typeof t == "object", "@param `opts` should be object type!"); | ||
const n = document.createElement("div"); | ||
super({ element: n }); | ||
l(this, "map"); | ||
l(this, "container"); | ||
l(this, "coordinate", []); | ||
l(this, "pixel", []); | ||
l(this, "contextMenuEventListener"); | ||
l(this, "entryCallbackEventListener"); | ||
l(this, "mapMoveListener"); | ||
l(this, "lineHeight", 0); | ||
l(this, "disabled"); | ||
l(this, "opened"); | ||
l(this, "items", []); | ||
l(this, "menuEntries", /* @__PURE__ */ new Map()); | ||
l(this, "options"); | ||
this.options = { ...ce, ...t }; | ||
const i = document.createElement("ul"); | ||
s.append(i), s.style.width = `${this.options.width}px`, s.classList.add( | ||
r.container, | ||
r.unselectable, | ||
r.hidden | ||
), this.container = s, this.contextMenuEventListener = (o) => { | ||
this.handleContextMenu(o); | ||
}, this.entryCallbackEventListener = (o) => { | ||
this.handleEntryCallback(o); | ||
n.append(i), n.style.width = `${this.options.width}px`, n.classList.add( | ||
a.container, | ||
a.unselectable, | ||
a.hidden | ||
), this.container = n, this.contextMenuEventListener = (r) => { | ||
this.handleContextMenu(r); | ||
}, this.entryCallbackEventListener = (r) => { | ||
this.handleEntryCallback(r); | ||
}, this.mapMoveListener = () => { | ||
@@ -201,4 +780,4 @@ this.handleMapMove(); | ||
clear() { | ||
for (const e of this.menuEntries.keys()) | ||
this.removeMenuEntry(e); | ||
for (const t of this.menuEntries.keys()) | ||
this.removeMenuEntry(t); | ||
this.container.replaceChildren(), this.container.append(document.createElement("ul")); | ||
@@ -213,3 +792,3 @@ } | ||
getDefaultItems() { | ||
return A; | ||
return P; | ||
} | ||
@@ -219,6 +798,6 @@ countItems() { | ||
} | ||
extend(e) { | ||
v(Array.isArray(e), "@param `items` should be an Array."), b( | ||
extend(t) { | ||
L(Array.isArray(t), "@param `items` should be an Array."), C( | ||
this.container.firstElementChild, | ||
e, | ||
t, | ||
this.options.width | ||
@@ -228,3 +807,3 @@ ); | ||
closeMenu() { | ||
this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(d.CLOSE); | ||
this.opened = !1, this.container.classList.add(a.hidden), this.dispatchEvent(m.CLOSE); | ||
} | ||
@@ -234,27 +813,27 @@ isOpen() { | ||
} | ||
updatePosition(e) { | ||
v(Array.isArray(e), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = e, this.positionContainer()); | ||
updatePosition(t) { | ||
L(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer()); | ||
} | ||
pop() { | ||
const e = Array.from(this.menuEntries.keys()).pop(); | ||
e && this.removeMenuEntry(e); | ||
const t = Array.from(this.menuEntries.keys()).pop(); | ||
t && this.removeMenuEntry(t); | ||
} | ||
shift() { | ||
const e = Array.from(this.menuEntries.keys()).shift(); | ||
e && this.removeMenuEntry(e); | ||
const t = Array.from(this.menuEntries.keys()).shift(); | ||
t && this.removeMenuEntry(t); | ||
} | ||
push(e) { | ||
e && this.extend([e]); | ||
push(t) { | ||
t && this.extend([t]); | ||
} | ||
setMap(e) { | ||
if (super.setMap(e), e) { | ||
this.map = e, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => { | ||
setMap(t) { | ||
if (super.setMap(t), t) { | ||
this.map = t, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => { | ||
this.handleMapMove(); | ||
}), g.on( | ||
d.ADD_MENU_ENTRY, | ||
(i, o) => { | ||
this.handleAddMenuEntry(i, o); | ||
m.ADD_MENU_ENTRY, | ||
(i, r) => { | ||
this.handleAddMenuEntry(i, r); | ||
}, | ||
this | ||
), this.items = this.options.defaultItems ? this.options.items.concat(A) : this.options.items, b( | ||
), this.items = this.options.defaultItems ? this.options.items.concat(P) : this.options.items, C( | ||
this.container.firstElementChild, | ||
@@ -264,4 +843,4 @@ this.items, | ||
); | ||
const s = this.getMenuEntriesLength(); | ||
this.lineHeight = s > 0 ? this.container.offsetHeight / s : U(this.container); | ||
const n = this.getMenuEntriesLength(); | ||
this.lineHeight = n > 0 ? this.container.offsetHeight / n : pe(this.container); | ||
} else | ||
@@ -271,21 +850,21 @@ this.removeListeners(), this.clear(); | ||
removeListeners() { | ||
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(d.ADD_MENU_ENTRY); | ||
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(m.ADD_MENU_ENTRY); | ||
} | ||
removeMenuEntry(e) { | ||
const s = document.getElementById(e); | ||
s?.remove(), s?.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(e); | ||
removeMenuEntry(t) { | ||
const n = document.getElementById(t); | ||
n?.remove(), n?.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(t); | ||
} | ||
handleContextMenu(e) { | ||
this.coordinate = this.map.getEventCoordinate(e), this.pixel = this.map.getEventPixel(e), this.dispatchEvent( | ||
new C({ | ||
type: d.BEFOREOPEN, | ||
handleContextMenu(t) { | ||
this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent( | ||
new R({ | ||
type: m.BEFOREOPEN, | ||
map: this.map, | ||
originalEvent: e | ||
originalEvent: t | ||
}) | ||
), !this.disabled && (this.options.eventType === x.CONTEXTMENU && (e.stopPropagation(), e.preventDefault()), setTimeout(() => { | ||
this.openMenu(e); | ||
}), e.target?.addEventListener( | ||
), !this.disabled && (this.options.eventType === w.CONTEXTMENU && (t.stopPropagation(), t.preventDefault()), setTimeout(() => { | ||
this.openMenu(t); | ||
}), t.target?.addEventListener( | ||
"pointerdown", | ||
(s) => { | ||
this.opened && (s.stopPropagation(), this.closeMenu()); | ||
(n) => { | ||
this.opened && (n.stopPropagation(), this.closeMenu()); | ||
}, | ||
@@ -295,8 +874,8 @@ { once: !0 } | ||
} | ||
openMenu(e) { | ||
this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent( | ||
new C({ | ||
type: d.OPEN, | ||
openMenu(t) { | ||
this.opened = !0, this.positionContainer(), this.container.classList.remove(a.hidden), this.dispatchEvent( | ||
new R({ | ||
type: m.OPEN, | ||
map: this.map, | ||
originalEvent: e | ||
originalEvent: t | ||
}) | ||
@@ -307,10 +886,10 @@ ); | ||
return Array.from(this.menuEntries).filter( | ||
([, e]) => e.isSeparator === !1 && e.isSubmenu === !1 && e.isInsideSubmenu === !1 | ||
([, t]) => t.isSeparator === !1 && t.isSubmenu === !1 && t.isInsideSubmenu === !1 | ||
).length; | ||
} | ||
positionContainer() { | ||
const e = this.map.getSize() || [0, 0], s = { | ||
w: e[0] - this.pixel[0], | ||
h: e[1] - this.pixel[1] | ||
}, i = this.getMenuEntriesLength(), o = { | ||
const t = this.map.getSize() || [0, 0], n = { | ||
w: t[0] - this.pixel[0], | ||
h: t[1] - this.pixel[1] | ||
}, i = this.getMenuEntriesLength(), r = { | ||
w: this.container.offsetWidth, | ||
@@ -320,19 +899,19 @@ // a cheap way to recalculate container height | ||
h: Math.round(this.lineHeight * i) | ||
}, l = s.w >= o.w ? this.pixel[0] + 5 : this.pixel[0] - o.w; | ||
this.container.style.left = `${l}px`, this.container.style.top = s.h >= o.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - o.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", s.w -= o.w; | ||
const p = (m) => Array.from(m.children).filter( | ||
(c) => c.tagName === "LI" && c.classList.contains(r.submenu) | ||
}, o = n.w >= r.w ? this.pixel[0] + 5 : this.pixel[0] - r.w; | ||
this.container.style.left = `${o}px`, this.container.style.top = n.h >= r.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - r.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", n.w -= r.w; | ||
const u = (E) => Array.from(E.children).filter( | ||
(h) => h.tagName === "LI" && h.classList.contains(a.submenu) | ||
); | ||
let f = 0; | ||
const E = (m, c) => { | ||
f += 1, p(m).forEach((S) => { | ||
const $ = c >= o.w ? o.w - 8 : (o.w + 8) * -1, h = S.querySelector( | ||
`ul.${r.container}` | ||
), k = Math.round( | ||
this.lineHeight * Array.from(h.children).filter((T) => T.tagName === "LI").length | ||
let d = 0; | ||
const c = (E, h) => { | ||
d += 1, u(E).forEach((k) => { | ||
const H = h >= r.w ? r.w - 8 : (r.w + 8) * -1, p = k.querySelector( | ||
`ul.${a.container}` | ||
), K = Math.round( | ||
this.lineHeight * Array.from(p.children).filter((U) => U.tagName === "LI").length | ||
); | ||
h.style.left = `${$}px`, h.style.right = "auto", h.style.top = s.h >= k + o.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(f), p(h).length > 0 && E(h, c - o.w); | ||
p.style.left = `${H}px`, p.style.right = "auto", p.style.top = n.h >= K + r.h ? "0" : `-${p.offsetHeight - 25}px`, p.style.bottom = "auto", p.style.zIndex = String(d), u(p).length > 0 && c(p, h - r.w); | ||
}); | ||
}; | ||
E(this.container.firstElementChild, s.w); | ||
c(this.container.firstElementChild, n.w); | ||
} | ||
@@ -342,19 +921,19 @@ handleMapMove() { | ||
} | ||
handleEntryCallback(e) { | ||
e.preventDefault(), e.stopPropagation(); | ||
const s = e.currentTarget, i = this.menuEntries.get(s.id); | ||
handleEntryCallback(t) { | ||
t.preventDefault(), t.stopPropagation(); | ||
const n = t.currentTarget, i = this.menuEntries.get(n.id); | ||
if (!i) | ||
return; | ||
const o = { | ||
const r = { | ||
coordinate: this.coordinate, | ||
data: i.data | ||
}; | ||
this.closeMenu(), i.callback?.(o, this.map); | ||
this.closeMenu(), i.callback?.(r, this.map); | ||
} | ||
handleAddMenuEntry(e, s) { | ||
this.menuEntries.set(e.id, e), this.positionContainer(), "callback" in e && typeof e.callback == "function" && s.addEventListener("click", this.entryCallbackEventListener, !1); | ||
handleAddMenuEntry(t, n) { | ||
this.menuEntries.set(t.id, t), this.positionContainer(), "callback" in t && typeof t.callback == "function" && n.addEventListener("click", this.entryCallbackEventListener, !1); | ||
} | ||
} | ||
export { | ||
Y as default | ||
me as default | ||
}; |
import type { Coordinate } from 'ol/coordinate'; | ||
import { Map as OlMap, MapBrowserEvent } from 'ol'; | ||
import OlMap from 'ol/Map'; | ||
import MapBrowserEvent from 'ol/MapBrowserEvent'; | ||
export declare enum EventTypes { | ||
@@ -4,0 +5,0 @@ CONTEXTMENU = "contextmenu", |
{ | ||
"name": "ol-contextmenu", | ||
"version": "5.1.5", | ||
"version": "5.2.0", | ||
"description": "Custom Context Menu for Openlayers", | ||
"type": "module", | ||
"main": "./dist/ol-contextmenu.umd.cjs", | ||
"browser": "./dist/ol-contextmenu.iife.js", | ||
"jsdelivr": "./dist/ol-contextmenu.iife.js", | ||
"module": "./dist/ol-contextmenu.js", | ||
@@ -50,3 +50,3 @@ "exports": { | ||
"devDependencies": { | ||
"@swc/core": "^1.3.39", | ||
"@swc/core": "^1.3.40", | ||
"@swc/jest": "^0.2.24", | ||
@@ -53,0 +53,0 @@ "@types/jest": "^29.4.0", |
@@ -57,3 +57,3 @@ # OpenLayers Custom Context Menu | ||
```javascript | ||
var contextmenu = new ContextMenu({ | ||
const contextmenu = new ContextMenu({ | ||
width: 170, | ||
@@ -85,3 +85,3 @@ defaultItems: true, // defaultItems are (for now) Zoom In/Zoom Out | ||
```javascript | ||
var all_items = [ | ||
const all_items = [ | ||
{ | ||
@@ -113,6 +113,6 @@ text: 'Some Actions', | ||
```javascript | ||
var removeMarker = function (obj) { | ||
const removeMarker = function (obj) { | ||
vectorLayer.getSource().removeFeature(obj.data.marker); | ||
}; | ||
var removeMarkerItem = { | ||
const removeMarkerItem = { | ||
text: 'Remove this Marker', | ||
@@ -123,5 +123,5 @@ icon: 'img/marker.png', | ||
var restore = false; | ||
let restore = false; | ||
contextmenu.on('open', function (evt) { | ||
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
return ft; | ||
@@ -175,6 +175,6 @@ }); | ||
```js | ||
var contextmenu = new ContextMenu(); | ||
const contextmenu = new ContextMenu(); | ||
map.addControl(contextmenu); | ||
var add_later = [ | ||
const add_later = [ | ||
'-', // this is a separator | ||
@@ -224,3 +224,3 @@ { | ||
contextmenu.on('beforeopen', function (evt) { | ||
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
return ft; | ||
@@ -242,3 +242,3 @@ }); | ||
contextmenu.on('open', function (evt) { | ||
var feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
const feature = map.forEachFeatureAtPixel(evt.pixel, function (ft, l) { | ||
return ft; | ||
@@ -245,0 +245,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
76652
1203
0
1