Socket
Socket
Sign inDemoInstall

@nextgis/ol-map-adapter

Package Overview
Dependencies
44
Maintainers
3
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.1 to 1.13.0

4

lib/index.d.ts

@@ -135,3 +135,3 @@ /// <reference types="node" />

};
options: any;
options: MapOptions<Map_2>;
layerAdapters: {

@@ -159,3 +159,3 @@ IMAGE: typeof ImageAdapter;

private _positionMem;
create(options: MapOptions): void;
create(options: MapOptions<Map_2>): void;
destroy(): void;

@@ -162,0 +162,0 @@ getContainer(): HTMLElement | undefined;

@@ -15,3 +15,3 @@ import{EventEmitter as t}from"events";import e from"ol/Map";import o from"ol/View";import{transform as n,transformExtent as i,fromLonLat as r}from"ol/proj";import s from"ol/layer/Tile";import a from"ol/source/TileWMS";import p from"ol/format/GeoJSON";import c,{ATTRIBUTION as l}from"ol/source/OSM";import u from"ol/source/XYZ";import h from"ol/layer/Image";import f from"ol/renderer/canvas/ImageLayer";import m from"ol/source/ImageWMS";import d from"ol/source/WMSServerType";import y from"ol/Overlay";import v from"ol/layer/Vector";import g from"ol/source/Vector";import{create as _}from"@nextgis/dom";import{getCoordinates as P,defined as w}from"@nextgis/utils";import O from"polylabel";import{getCenter as b}from"ol/extent";import C from"ol/style/Circle";import{asArray as E}from"ol/color";import{Style as x,Text as L,Fill as j,Stroke as S}from"ol/style";import F from"ol/style/IconAnchorUnits";import A from"ol/style/Icon";import{isPaintCallback as V,isPaint as M}from"@nextgis/paint";import k from"ol/control/Zoom";import I from"ol/control/Attribution";import Z from"ol/control/Control";import T from"@nextgis/control-container";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var R=function(t,e){return(R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function B(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}R(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var D=function(){return(D=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function G(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{p(n.next(t))}catch(e){r(e)}}function a(t){try{p(n.throw(t))}catch(e){r(e)}}function p(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}p((n=n.apply(t,e||[])).next())}))}function U(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(a){r=[6,a],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function H(t,e){var o={minZoom:e.minZoom,maxZoom:e.maxZoom};return e.maxScale&&(o.minResolution=z(t,e.maxScale)),e.minScale&&(o.maxResolution=z(t,e.minScale)),o}function z(t,e){if(e)return function(t,e){return t/(39.37*e*90.71446714322)}(e,t.getView().getProjection().getMetersPerUnit()||1)}function W(t){return(new p).writeFeatureObject(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})}function N(t){for(var e,o,n=decodeURIComponent,i=t.split("&"),r={},s=0,a=i.length,p=void 0;s<a;++s)if((p=i[s]).length){var c=p.indexOf("=");c<0?(e=n(p),o=""):(e=n(p.slice(0,c)),o=n(p.slice(c+1))),"string"==typeof r[e]&&(r[e]=[r[e]]),Array.isArray(r[e])?r[e].push(o):r[e]=o}return r}function X(t,e){var o,n=[];for(o in t){var i=e?e+"["+o+"]":o,r=t[o];n.push(null!==r&&"object"==typeof r?X(r,i):encodeURIComponent(i)+"="+encodeURIComponent(r))}return n.join("&")}function Y(t,e,o){var n=new XMLHttpRequest;for(var i in n.open("GET",e),n.responseType="arraybuffer",o)n.setRequestHeader(i,o[i]);n.onload=function(){var e=new Uint8Array(this.response),o=new Blob([e],{type:"image/png"}),n=(window.URL||window.webkitURL).createObjectURL(o);t.getImage().src=n},n.send()}var q=function(){function t(t,e){this.map=t,this.options=e}return t.prototype.setOpacity=function(t){this.options.opacity=Number(t),this.layer&&this.layer.setOpacity&&this.layer.setOpacity(this.options.opacity)},t}(),J=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e={url:t.url,params:{LAYERS:t.layers,VERSION:t.version},projection:void 0},o=t.updateWmsParams;o&&(e.tileLoadFunction=function(e,n){var i=n.split("?")[0],r=N(n.split("?")[1]),s=X(o({resource:r.resource,bbox:r.BBOX,width:r.WIDTH,height:r.HEIGHT})),a=t.headers,p=i+"?"+s;a?Y(e,p,a):e.getImage().src=p});var n=new a(e),i=new s(D(D({source:n,opacity:t.opacity},H(this.map,t)),t.nativeOptions));return this.layer=i,i},e}(q),K=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n.name="OpenStreetMap",n}return B(e,t),e.prototype.addLayer=function(t){return Object.assign(this.options,t),this.options.name=this.name,new s(D({source:new c({attributions:[l]})},t.nativeOptions))},e}(q);var Q=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e=function(t,e){var o=[],n="string"==typeof e?e.split(""):e;return(null==n?void 0:n.length)?n.forEach((function(e){o.push(t.replace(/{s}/,e))})):o.push(t),o}(t.url,t.subdomains),o={attributions:t.attribution?[t.attribution]:[],urls:e};t.crossOrigin&&(o.crossOrigin=t.crossOrigin);var n=new u(o),i=t.headers;return i&&n.setTileLoadFunction((function(t,e){Y(t,e,i)})),new s(D(D({source:n,opacity:t.opacity},H(this.map,t)),t.nativeOptions))},e}(q),$=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){if(Object.assign(this.options,t),t.url){var e=void 0!==t.ratio?t.ratio:1,o={url:t.url,params:D({},t.params),projection:void 0},n=t.updateWmsParams;o.imageLoadFunction=function(e,o){var i=o.split("?")[0],r=N(o.split("?")[1]),s=r.resource,a=r.BBOX,p=r.WIDTH,c=r.HEIGHT,l=function(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(o[n[i]]=t[n[i]])}return o}(r,["resource","BBOX","WIDTH","HEIGHT"]),u=D({resource:s,bbox:a,width:p,height:c},l),h=X(n?n(u):l),f=t.headers,m=i+"?"+h;f?Y(e,m,f):e.getImage().src=m};var i=h,r=m;if(e>1){o.ratio=e,o.serverType=d.MAPSERVER;var s=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return B(o,t),o.prototype.renderFrame=function(o,n){return o.pixelRatio=e,t.prototype.renderFrame.call(this,o,n)},o}(f);i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return B(e,t),e.prototype.createRenderer=function(){return new s(this)},e}(h),r=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return B(o,t),o.prototype.getImageInternal=function(o,n,i,r){return t.prototype.getImageInternal.call(this,o,n,e,r)},o}(m)}var a=new r(o),p=new i(D(D({source:a,opacity:t.opacity},H(this.map,t)),t.nativeOptions));return this.layer=p,p}},e}(q);function tt(t,e,o){void 0===e&&(e="EPSG:3857"),void 0===o&&(o="EPSG:4326");var i=n(t.coordinate,e,o),r=i[0],s=i[1];return{latLng:{lat:s,lng:r},lngLat:[r,s],pixel:{left:t.pixel[0],top:t.pixel[1]},source:t}}function et(t){var e=function(t){var e=t.feature,o=t.dataProjection,n=t.featureProjection,i=(new p).readFeatures({type:"FeatureCollection",features:Array.isArray(e)?e:[e]},{dataProjection:o,featureProjection:n}),r=new g;return r.addFeatures(i),r}(t),o=e.getExtent(),n=i(o,t.featureProjection,t.dataProjection);return e.dispose(),n}function ot(t){return{getBounds:function(){return et(t)},getCenter:function(){return function(t){var e=et(t);return b(e)}(t)}}}var nt={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon",Circle:"point"},it={polygon:"path",line:"path",point:"circle"};function rt(t,e){var o=E(t).slice();return o[3]=void 0!==e?e:1,o}function st(t,e){if(void 0===e&&(e={}),V(e))return st(t,e(W(t)));if(M(e)){var o=t.getGeometry(),n=o&&o.getType()||"Point",i={};if(!e.type){var r=nt[n],s="polygon"===r||"line"===r?"path":"html"in e||"className"in e?"icon":it[r];s&&(e.type=s)}if("path"===e.type||"circle"===e.type){var a=D({},e),p=a.radius,c=a.fillColor,l=a.fillOpacity,u=a.strokeColor,h=a.stroke,f=a.strokeOpacity;a.fill&&c&&"string"==typeof c&&"number"==typeof l&&(i.fill=new j({color:rt(c,l)})),u&&"string"==typeof u&&"number"==typeof f&&(h||-1!==["MultiLineString","LineString"].indexOf(n))&&(i.stroke=new S({width:e.weight,color:rt(u,f)})),"circle"===e.type&&"number"==typeof p&&(i.image=new C(D({radius:p},i)))}else if("icon"===e.type){var m=e.html;if(m){var d={src:"data:image/svg+xml,"+escape(m),anchorXUnits:F.PIXELS,anchorYUnits:F.PIXELS,anchor:e.iconAnchor,imgSize:e.iconSize};i.image=new A(d)}}return new x(i)}}var at=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n.selected=!1,n.displayProjection="EPSG:3857",n.lonlatProjection="EPSG:4326",n.vectorSource=new g,n._features=[],n._selectedFeatures=[],n._openedPopup=[],n._forEachFeatureAtPixel=[],n._mapClickEvents=[],n._styleCache={},n.displayProjection=e.getView().getProjection().getCode(),n}return B(e,t),Object.defineProperty(e.prototype,"addUnselectCb",{get:function(){return this.map.get("_addUnselectCb")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mapClickEvents",{get:function(){return this.map.get("_mapClickEvents")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forEachFeatureAtPixel",{get:function(){return this.map.get("_forEachFeatureAtPixel")},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){var e,o=this;Object.assign(this.options,t),this.paint=t.paint,this.selectedPaint=t.selectedPaint;var n=t.data;return n&&this.addData(n),this.layer=new v(D(D({source:this.vectorSource,style:function(e){var n=[],i=e.getId(),r=void 0!==i&&o._styleCache[i];if(r)return r;var s=st(e,t.paint);s&&n.push(s);var a=o.options,p=a.labelField,c=a.label,l="";if("string"==typeof p?l=e.get(p):c&&(l=c(o._createLayerDefOpts(W(e)))),l=String(l)){var u=w(l)?l:"";if(u){var h=function(t,e){var o={font:"12px Calibri,sans-serif",overflow:!0,fill:new j({color:"#000"}),stroke:new S({color:"#fff",width:3})};return"point"===t&&(o=D(D({},o),{placement:"point",textBaseline:"bottom",offsetY:20})),new x({text:new L(o)})}(t.type||"polygon");h.getText().setText(u),n.push(h)}}return void 0!==i&&(o._styleCache[i]=n),n}},H(this.map,t)),t.nativeOptions)),(null===(e=t.interactive)||void 0===e||e)&&this._addEventListener(),this.layer},e.prototype.beforeRemove=function(){for(var t=this.forEachFeatureAtPixel,e=function(e){var o=t[e][1];-1!==t.findIndex((function(t){return t[1]===o}))&&t.splice(e,1)},o=t.length;o--;)e(o);this._forEachFeatureAtPixel.length=0;var n=this.mapClickEvents;for(o=n.length;o--;){-1!==n.indexOf(n[o])&&n.splice(o,1)}this._mapClickEvents.length=0,this._removeAllPopup()},e.prototype.clearLayer=function(t){if(this.unselect(),t)for(var e=this.vectorSource.getFeatures().values(),o=void 0;!(o=e.next()).done;){t(W(o.value))&&this.vectorSource.removeFeature(o.value)}else this.vectorSource.clear()},e.prototype.setData=function(t){this.clearLayer(),this.addData(t)},e.prototype.addData=function(t){var e=this.options.srs,o="EPSG:"+(null!=e?e:"4326"),n=(new p).readFeatures(t,{dataProjection:o,featureProjection:this.displayProjection});if(this._features=this._features.concat(n),this._filterFun)this.filter(this._filterFun);else if(this.vectorSource.addFeatures(n),this.options.popup)for(var i=0,r=this._features;i<r.length;i++){this._openPopup({feature:r[i],type:"api",options:this.options.popupOptions})}},e.prototype.select=function(t){var e=this;"function"==typeof t?this._features.filter((function(o){return t(e._createLayerDefOpts(W(o)))})).forEach((function(t){e._selectFeature(t)})):this.selected||(this.selected=!0,this.selectedPaint&&this._setPaintEachLayer(this.selectedPaint))},e.prototype.unselect=function(t){var e=this,o=this._selectedFeatures;"function"==typeof t?o=this._selectedFeatures.filter((function(o){return t(e._createLayerDefOpts(W(o)))})):this.selected&&(this.selected=!1);for(var n=0,i=o;n<i.length;n++){this._unselectFeature(i[n])}this._removeAllPopup()},e.prototype.getLayers=function(){var t=this;return this._features.map((function(e){return t._createLayerDefOpts(W(e))}))},e.prototype.getSelected=function(){var t=this;return this._selectedFeatures.map((function(e){return t._createLayerDefOpts(W(e))}))},e.prototype.filter=function(t){var e=this;this._filterFun=t;var o=this._features,n=t?o.filter((function(o){return t(e._createLayerDefOpts(W(o)))})):o;this.vectorSource.clear();for(var i=n.length,r=0;r<i;r++)this.vectorSource.addFeature(n[r]);return n.map((function(t){return e._createLayerDefOpts(W(t))}))},e.prototype.cleanFilter=function(){this.filter()},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){if(this.layer){var t=this.layer.getSource().getExtent();return i(t,this.displayProjection,this.lonlatProjection)}},e.prototype.setPaint=function(t){t&&(this.paint=t,this._setPaintEachLayer(this.paint))},e.prototype.setSelectedPaint=function(t){t&&(this.selectedPaint=t,this._setPaintEachLayer(this.selectedPaint))},e.prototype.updatePaint=function(t){this.paint=D(D({},this.paint),t),this._setPaintEachLayer(this.paint)},e.prototype.updateSelectedPaint=function(t){this.selectedPaint=D(D({},this.selectedPaint),t),this._setPaintEachLayer(this.selectedPaint)},e.prototype._createLayerDefOpts=function(t){return D({target:this,feature:t},ot({feature:t,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection}))},e.prototype._setPaintEachLayer=function(t){this.layer&&this.layer.getSource().getFeatures().forEach((function(e){var o=st(e,t);o&&e.setStyle(o)}))},e.prototype._addEventListener=function(){var t,e=this,o=this.forEachFeatureAtPixel,n=[this.options.order||0,function(t,o,n){return e._onFeatureAtPixel(t,o,n)}];this._forEachFeatureAtPixel.push(n),o.push(n),(null===(t=this.options.unselectOnClick)||void 0===t||t)&&(this._mapClickEvents.push((function(){return e.unselect()})),this.mapClickEvents.push((function(){return e.unselect()})))},e.prototype._onFeatureAtPixel=function(t,e,o){var n,i=this,r=t&&this.map.getFeaturesAtPixel(t,{layerFilter:function(t){return t===i.layer}})[0],s={layer:i,event:tt(n=e),source:n};if(r){var a=D(D({},s),this._createLayerDefOpts(W(r))),p=-1!==this._selectedFeatures.indexOf(r);return this.options.selectable&&("hover"===o&&this.options.selectOnHover||"click"===o)&&(p?this.options&&this.options.unselectOnSecondClick&&(this._unselectFeature(r),p=!1):(this._selectFeature(r,a.event.lngLat),p=!0)),"click"===o&&this.options.onClick&&this.options.onClick(D({selected:p},a)),"hover"===o&&(this._mouseOver=!0,this.options.onMouseOver&&this.options.onMouseOver(a)),!0}return"hover"===o&&this._mouseOver&&(this._mouseOver=!1,this.options.onMouseOut&&this.options.onMouseOut(s),this.options.selectOnHover&&this.unselect()),!1},e.prototype._selectFeature=function(t,e){var o=this;this.addUnselectCb((function(){return o._unselectFeature(t)}));var n=this.options,i=e?"click":"api";if(n&&!n.multiselect&&this._selectedFeatures.forEach((function(t){return o._unselectFeature(t)})),this._selectedFeatures.push(t),this.selected=!0,n&&n.selectedPaint){var r=st(t,n.selectedPaint);r&&t.setStyle(r)}if(this.options.popupOnSelect&&this._openPopup({coordinates:e,feature:t,options:this.options.popupOptions,type:"click"}),this.options.onSelect){var s=W(t);this.options.onSelect(D({layer:this,features:[],type:i},ot({feature:s,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})))}},e.prototype._unselectFeature=function(t){var e=this._selectedFeatures.indexOf(t);if(-1!==e){this._selectedFeatures.splice(e,1);var o=this._openedPopup.find((function(e){return e[0]===t}));o&&this._removePopup(o[1])}if(this.selected=this._selectedFeatures.length>0,this.options&&this.options.paint){var n=st(t,this.options.paint);n&&t.setStyle(n)}},e.prototype._openPopup=function(t){var e=t.coordinates,o=t.feature,i=t.options,r=void 0===i?{}:i,s=t.type;return G(this,void 0,void 0,(function(){var t,i,a,p,c,l,u,h,f,m,d,v,g=this;return U(this,(function(_){switch(_.label){case 0:return(t=this.map)?(a=[],p=function(t){a.push(t)},c=function(){i&&g._removePopup(i)},l=r.createPopupContent,u=r.popupContent,h=W(o),l?[4,l(D({close:c,onClose:p,type:s},this._createLayerDefOpts(h)))]:[3,2]):[2];case 1:return m=_.sent(),[3,3];case 2:m=u,_.label=3;case 3:return f=m,e=e||h&&function(t){return"Polygon"===t.geometry.type?O(t.geometry.coordinates):"Point"===t.geometry.type?t.geometry.coordinates:(e=P(t)).reduce((function(t,o){return[t[0]+o[0]/e.length,t[1]+o[1]/e.length]}),[0,0]);var e}(h),f&&e&&(d="string"==typeof f?(w=f,(b=document.createElement("div")).innerHTML=w,b):f,v=this._createPopupElement(D(D({},r),{popupContent:d,close:c})),(i=new y({element:v})).setPosition(n(e,this.lonlatProjection,this.displayProjection)),t.addOverlay(i),this._openedPopup.push([o,i,a])),[2]}var w,b}))}))},e.prototype._createPopupElement=function(t){var e=t.closeButton,o=t.popupContent,n=t.maxWidth,i=t.minWidth,r=t.close;e=null!=e?e:!this.options.selectOnHover;var s=_("div","ol-popup");if(n&&(s.style.maxWidth=n+"px"),i&&(s.style.minWidth=i+"px"),e){var a=_("a","ol-popup-closer",s);a.setAttribute("href","#"),a.addEventListener("click",r)}return _("div","popup-content",s).appendChild(o),s},e.prototype._removeAllPopup=function(){var t=function(t,e,o){if(o||2===arguments.length)for(var n,i=0,r=e.length;i<r;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([],this._openedPopup,!0);this._openedPopup=[];for(var e=0,o=t;e<o.length;e++){this._removePopup(o[e][1])}},e.prototype._removePopup=function(t){var e,o,n=this.map;if(n){n.removeOverlay(t);var i=this._openedPopup.findIndex((function(e){return e[1]===t}));if(-1!==i){for(var r=this._openedPopup[i],s=r[0],a=r[2],p=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o,c=0,l=a;c<l.length;c++){(0,l[c])(this._createLayerDefOpts(W(s)))}a.length=0,p&&this._unselectFeature(s),this._openedPopup.splice(i,1)}}},e}(q),pt=function(t){function e(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];var n=t.apply(this,e)||this;return n.element.classList.remove("ol-control"),n.element.classList.add("webmap-ctrl-group"),n}return B(e,t),e}(k),ct={collapsible:!1},lt=function(t){function e(e){return t.call(this,D(D({},ct),e))||this}return B(e,t),e}(I),ut={collapsible:!1},ht=function(t){function e(e){var o=this,n=new T,i=n.getContainer();return(o=t.call(this,D(D(D({},ut),e),{element:i}))||this).panelContainer=n,o}return B(e,t),e.prototype.addControl=function(t,e){return G(this,void 0,void 0,(function(){var o,n,i,r;return U(this,(function(s){switch(s.label){case 0:return(o=this.getMap())&&(n=this.panelContainer.newPositionContainer(e))?[4,t]:[3,2];case 1:i=s.sent(),(r=i.element)&&r.classList.add("webmap-ctrl"),i.setTarget(n),o.addControl(i),s.label=2;case 2:return[2]}}))}))},e.prototype.removeControl=function(t){var e=this.getMap();e&&e.removeControl(t)},e.prototype.getContainer=function(){return this.panelContainer.getContainer()},e}(Z);var ft=function(){function s(){this.options={target:"map"},this.layerAdapters=s.layerAdapters,this.controlAdapters=s.controlAdapters,this.emitter=new t,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this._mapClickEvents=[],this._forEachFeatureAtPixel=[],this._unselectCb=[],this._isLoaded=!1,this._positionMem={}}return s.prototype.create=function(t){var n=this;this.options=D({},t);var i=this.getViewOptions(this.options),r={controls:[],view:new o(i),layers:[]};t.mapAdapterOptions&&Object.assign(r,t.mapAdapterOptions);var s=D(D({},r),{target:this.options.target||"map"});this.map=new e(s),this._panelControl=new ht,this.map.addControl(this._panelControl),this.map.set("_mapClickEvents",this._mapClickEvents),this.map.set("_forEachFeatureAtPixel",this._forEachFeatureAtPixel),this.map.set("_addUnselectCb",(function(t){return n._addUnselectCb(t)})),this.emitter.emit("create",this),this._olView=this.map.getView(),this._isLoaded=!0,this._addMapListeners(),this._addViewListeners()},s.prototype.destroy=function(){this.map&&this.map.dispose()},s.prototype.getContainer=function(){if(this.options.target){var t=void 0;return"string"==typeof this.options.target?t=document.getElementById(this.options.target):this.options.target instanceof HTMLElement&&(t=this.options.target),t}},s.prototype.getControlContainer=function(){if(this._panelControl)return this._panelControl.getContainer();throw new Error("The ol-map-adapter ControlPanel has not been initialized yet")},s.prototype.setCenter=function(t){this._olView&&this._olView.setCenter(r(t))},s.prototype.getCenter=function(){if(this._olView){var t=this._olView.getCenter();if(t)return n(t,this.displayProjection,this.lonlatProjection)}},s.prototype.setZoom=function(t){this._olView&&this._olView.setZoom(t)},s.prototype.getZoom=function(){if(this._olView)return this._olView.getZoom()},s.prototype.fitBounds=function(t,e){if(void 0===e&&(e={}),this._olView){var o=e.padding,n=e.maxZoom,r=e.offset,s=this.getZoom(),a=i(t,this.lonlatProjection,this.displayProjection),p={};n&&(p.maxZoom=n),o&&(p.padding=[o,o]),r&&(p.padding=r),this._olView.fit(a,p),this._emitMoveEndEvents({zoom:s})}},s.prototype.getBounds=function(){if(this._olView){var t=this._olView.calculateExtent();return i(t,this.displayProjection,this.lonlatProjection)}},s.prototype.setRotation=function(t){this._olView&&this._olView.setRotation(t)},s.prototype.setView=function(t,e){if(this.map)if(Array.isArray(t)){this._setView({zoom:e,center:r(t)})}else{var o=t.bounds,n=this.getViewOptions(t);Object.values(n).some(Boolean)&&this._setView(n),o&&this.fitBounds(o)}},s.prototype.removeLayer=function(t){this.map&&this.map.removeLayer(t)},s.prototype.showLayer=function(t){this.map&&this.map.addLayer(t)},s.prototype.hideLayer=function(t){this.map&&this.map.removeLayer(t)},s.prototype.setLayerOpacity=function(t,e){t.setOpacity&&t.setOpacity(Number(e))},s.prototype.setLayerOrder=function(t,e){t&&t.setZIndex&&t.setZIndex(e)},s.prototype.createControl=function(t,e){return function(t,e,o){return void 0===e&&(e={}),new(function(n){function i(){var i=document.createElement("div");i.className=(e.addClass?e.addClass+" ":"")+"ol-unselectable"+(e.bar?" webmap-ctrl-group":"")+(e.margin?" ol-control-margin":"");var r=t.onAdd(o);r&&i.appendChild(r),n.call(this,{element:i})}return n&&(i.__proto__=n),(i.prototype=Object.create(Z&&Z.prototype)).constructor=i,i.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},i}(Z))}(t,e,this)},s.prototype.createButtonControl=function(t){return function(t){return new(function(e){function o(){var o=document.createElement("button");o.className="custom-button-control","string"==typeof t.html?o.innerHTML=t.html:t.html&&o.appendChild(t.html),"string"==typeof t.title&&(o.title=t.title);var n=document.createElement("div");n.className=(t.addClass?t.addClass+" ":"")+"ol-unselectable webmap-ctrl-group",n.appendChild(o),e.call(this,{element:n}),o.addEventListener("click",(function(){return t.onClick()}),!1)}return e&&(o.__proto__=e),(o.prototype=Object.create(Z&&Z.prototype)).constructor=o,o.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},o}(Z))}(t)},s.prototype.addControl=function(t,e){if(this._panelControl)return this._panelControl.addControl(t,e),t},s.prototype.removeControl=function(t){this._panelControl&&this._panelControl.removeControl(t)},s.prototype.onMapClick=function(t){var e=tt(t);this.emitter.emit("preclick",e),this._callEachFeatureAtPixel(t,"click")||this._mapClickEvents.forEach((function(e){e(t)})),this.emitter.emit("click",e)},s.prototype.getViewOptions=function(t){var e=t.center,o=t.maxBounds,n={zoom:t.zoom,minZoom:t.minZoom,maxZoom:t.maxZoom,projection:this.displayProjection};if(e&&(n.center=r(e)),o){var s=i(o,this.lonlatProjection,this.displayProjection);n.extent=s}return n},s.prototype._callEachFeatureAtPixel=function(t,e){if(t&&t.pixel&&this._forEachFeatureAtPixel.length&&this.map)for(var o=0,n=this._forEachFeatureAtPixel.sort((function(t,e){return e[0]-t[0]}));o<n.length;o++){if(n[o][1](t.pixel,t,e))return!0}return!1},s.prototype._emitMoveEndEvents=function(t){if(this._isLoaded){var e=this.getZoom();t.zoom!==e&&this.emitter.emit("zoomend")}},s.prototype._addMapListeners=function(){var t=this,e=this.map;if(e){var o=e.getViewport();e.on("click",(function(e){t.onMapClick(e)})),e.on("pointermove",(function(e){t.emitter.emit("mousemove",tt(e)),t._callEachFeatureAtPixel(e,"hover")}));var n=function(t){var o=[t.x,t.y];return tt(D({pixel:o,coordinate:e.getCoordinateFromPixel(o)},t))};o.addEventListener("mouseout",(function(e){t.emitter.emit("mouseout",n(e))}),!1),o.addEventListener("mouseover",(function(e){t.emitter.emit("mouseover",n(e))}),!1);for(var i=this.getCenter(),r=this.getZoom(),s=function(o){a._positionMem[o]={center:i,zoom:r},e.on(o,(function(){t._emitPositionChangeEvent(o)}))},a=this,p=0,c=["movestart","moveend"];p<c.length;p++){s(c[p])}}},s.prototype._addViewListeners=function(){var t=this;this._olView&&(this._olView.on("change:resolution",(function(){t.emitter.emit("zoom",t)})),this._olView.on("change:center",(function(){t.emitter.emit("move",t)})))},s.prototype._setView=function(t){var e=t.center,n=t.zoom,i=t.extent,r=t.minZoom,s=t.maxZoom,a=this.map;if(a){var p=a.getView();if(void 0!==i){p.dispose();var c=new o(t);this._olView=c,this._addViewListeners(),a.setView(c)}else e&&p.setCenter(e),void 0!==n&&p.setZoom(n),void 0!==r&&p.setMinZoom(r),void 0!==s&&p.setMaxZoom(s)}},s.prototype._addUnselectCb=function(t){for(var e=0,o=this._unselectCb;e<o.length;e++){(0,o[e])()}this._unselectCb.length=0,this._unselectCb.push(t)},s.prototype._emitPositionChangeEvent=function(t){var e,o,n=this._positionMem[t];n&&(e=n.center,o=n.zoom);var i=this.getCenter(),r=this.getZoom();o!==r&&this.emitter.emit("movestart"===t?"zoomstart":"zoomend",this);e&&i?i[0]===e[0]&&i[1]===e[1]||this.emitter.emit(t,this):e!==i&&this.emitter.emit(t,this);this._positionMem[t]={center:i,zoom:r}},s.layerAdapters={IMAGE:$,TILE:Q,WMS:J,OSM:K,GEOJSON:at},s.controlAdapters={ZOOM:pt,ATTRIBUTION:lt},s}();export{ft as default};
***************************************************************************** */var R=function(t,e){return(R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function B(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}R(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var D=function(){return(D=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function G(t,e,o,n){return new(o||(o=Promise))((function(i,r){function s(t){try{p(n.next(t))}catch(e){r(e)}}function a(t){try{p(n.throw(t))}catch(e){r(e)}}function p(t){var e;t.done?i(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,a)}p((n=n.apply(t,e||[])).next())}))}function U(t,e){var o,n,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(a){r=[6,a],n=0}finally{o=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function H(t,e){var o={minZoom:e.minZoom,maxZoom:e.maxZoom};return e.maxScale&&(o.minResolution=z(t,e.maxScale)),e.minScale&&(o.maxResolution=z(t,e.minScale)),o}function z(t,e){if(e)return function(t,e){return t/(39.37*e*90.71446714322)}(e,t.getView().getProjection().getMetersPerUnit()||1)}function W(t){return(new p).writeFeatureObject(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})}function N(t){for(var e,o,n=decodeURIComponent,i=t.split("&"),r={},s=0,a=i.length,p=void 0;s<a;++s)if((p=i[s]).length){var c=p.indexOf("=");c<0?(e=n(p),o=""):(e=n(p.slice(0,c)),o=n(p.slice(c+1))),"string"==typeof r[e]&&(r[e]=[r[e]]),Array.isArray(r[e])?r[e].push(o):r[e]=o}return r}function X(t,e){var o,n=[];for(o in t){var i=e?e+"["+o+"]":o,r=t[o];n.push(null!==r&&"object"==typeof r?X(r,i):encodeURIComponent(i)+"="+encodeURIComponent(r))}return n.join("&")}function Y(t,e,o){var n=new XMLHttpRequest;for(var i in n.open("GET",e),n.responseType="arraybuffer",o)n.setRequestHeader(i,o[i]);n.onload=function(){var e=new Uint8Array(this.response),o=new Blob([e],{type:"image/png"}),n=(window.URL||window.webkitURL).createObjectURL(o);t.getImage().src=n},n.send()}var q=function(){function t(t,e){this.map=t,this.options=e}return t.prototype.setOpacity=function(t){this.options.opacity=Number(t),this.layer&&this.layer.setOpacity&&this.layer.setOpacity(this.options.opacity)},t}(),J=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e={url:t.url,params:{LAYERS:t.layers,VERSION:t.version},projection:void 0},o=t.updateWmsParams;o&&(e.tileLoadFunction=function(e,n){var i=n.split("?")[0],r=N(n.split("?")[1]),s=X(o({resource:r.resource,bbox:r.BBOX,width:r.WIDTH,height:r.HEIGHT})),a=t.headers,p=i+"?"+s;a?Y(e,p,a):e.getImage().src=p});var n=new a(e),i=new s(D(D({source:n,opacity:t.opacity},H(this.map,t)),t.nativeOptions));return this.layer=i,i},e}(q),K=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n.name="OpenStreetMap",n}return B(e,t),e.prototype.addLayer=function(t){return Object.assign(this.options,t),this.options.name=this.name,new s(D({source:new c({attributions:[l]})},t.nativeOptions))},e}(q);var Q=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e=function(t,e){var o=[],n="string"==typeof e?e.split(""):e;return(null==n?void 0:n.length)?n.forEach((function(e){o.push(t.replace(/{s}/,e))})):o.push(t),o}(t.url,t.subdomains),o={attributions:t.attribution?[t.attribution]:[],urls:e};t.crossOrigin&&(o.crossOrigin=t.crossOrigin);var n=new u(o),i=t.headers;return i&&n.setTileLoadFunction((function(t,e){Y(t,e,i)})),new s(D(D({source:n,opacity:t.opacity},H(this.map,t)),t.nativeOptions))},e}(q),$=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n}return B(e,t),e.prototype.addLayer=function(t){if(Object.assign(this.options,t),t.url){var e=void 0!==t.ratio?t.ratio:1,o={url:t.url,params:D({},t.params),projection:void 0},n=t.updateWmsParams;o.imageLoadFunction=function(e,o){var i=o.split("?")[0],r=N(o.split("?")[1]),s=r.resource,a=r.BBOX,p=r.WIDTH,c=r.HEIGHT,l=function(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(o[n[i]]=t[n[i]])}return o}(r,["resource","BBOX","WIDTH","HEIGHT"]),u=D({resource:s,bbox:a,width:p,height:c},l),h=X(n?n(u):l),f=t.headers,m=i+"?"+h;f?Y(e,m,f):e.getImage().src=m};var i=h,r=m;if(e>1){o.ratio=e,o.serverType=d.MAPSERVER;var s=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return B(o,t),o.prototype.renderFrame=function(o,n){return o.pixelRatio=e,t.prototype.renderFrame.call(this,o,n)},o}(f);i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return B(e,t),e.prototype.createRenderer=function(){return new s(this)},e}(h),r=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return B(o,t),o.prototype.getImageInternal=function(o,n,i,r){return t.prototype.getImageInternal.call(this,o,n,e,r)},o}(m)}var a=new r(o),p=new i(D(D({source:a,opacity:t.opacity},H(this.map,t)),t.nativeOptions));return this.layer=p,p}},e}(q);function tt(t,e,o){void 0===e&&(e="EPSG:3857"),void 0===o&&(o="EPSG:4326");var i=n(t.coordinate,e,o),r=i[0],s=i[1];return{latLng:{lat:s,lng:r},lngLat:[r,s],pixel:{left:t.pixel[0],top:t.pixel[1]},source:t}}function et(t){var e=function(t){var e=t.feature,o=t.dataProjection,n=t.featureProjection,i=(new p).readFeatures({type:"FeatureCollection",features:Array.isArray(e)?e:[e]},{dataProjection:o,featureProjection:n}),r=new g;return r.addFeatures(i),r}(t),o=e.getExtent(),n=i(o,t.featureProjection,t.dataProjection);return e.dispose(),n}function ot(t){return{getBounds:function(){return et(t)},getCenter:function(){return function(t){var e=et(t);return b(e)}(t)}}}var nt={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon",Circle:"point"},it={polygon:"path",line:"path",point:"circle"};function rt(t,e){var o=E(t).slice();return o[3]=void 0!==e?e:1,o}function st(t,e){if(void 0===e&&(e={}),V(e))return st(t,e(W(t)));if(M(e)){var o=t.getGeometry(),n=o&&o.getType()||"Point",i={};if(!e.type){var r=nt[n],s="polygon"===r||"line"===r?"path":"html"in e||"className"in e?"icon":it[r];s&&(e.type=s)}if("path"===e.type||"circle"===e.type){var a=D({},e),p=a.radius,c=a.fillColor,l=a.fillOpacity,u=a.strokeColor,h=a.stroke,f=a.strokeOpacity;a.fill&&c&&"string"==typeof c&&"number"==typeof l&&(i.fill=new j({color:rt(c,l)})),u&&"string"==typeof u&&"number"==typeof f&&(h||-1!==["MultiLineString","LineString"].indexOf(n))&&(i.stroke=new S({width:e.weight,color:rt(u,f)})),"circle"===e.type&&"number"==typeof p&&(i.image=new C(D({radius:p},i)))}else if("icon"===e.type){var m=e.html;if(m){var d={src:"data:image/svg+xml,"+escape(m),anchorXUnits:F.PIXELS,anchorYUnits:F.PIXELS,anchor:e.iconAnchor,imgSize:e.iconSize};i.image=new A(d)}}return new x(i)}}var at=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.map=e,n.options=o,n.selected=!1,n.displayProjection="EPSG:3857",n.lonlatProjection="EPSG:4326",n.vectorSource=new g,n._features=[],n._selectedFeatures=[],n._openedPopup=[],n._forEachFeatureAtPixel=[],n._mapClickEvents=[],n._styleCache={},n.displayProjection=e.getView().getProjection().getCode(),n}return B(e,t),Object.defineProperty(e.prototype,"addUnselectCb",{get:function(){return this.map.get("_addUnselectCb")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mapClickEvents",{get:function(){return this.map.get("_mapClickEvents")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forEachFeatureAtPixel",{get:function(){return this.map.get("_forEachFeatureAtPixel")},enumerable:!1,configurable:!0}),e.prototype.addLayer=function(t){var e,o=this;Object.assign(this.options,t),this.paint=t.paint,this.selectedPaint=t.selectedPaint;var n=t.data;return n&&this.addData(n),this.layer=new v(D(D({source:this.vectorSource,style:function(e){var n=[],i=e.getId(),r=void 0!==i&&o._styleCache[i];if(r)return r;var s=st(e,t.paint);s&&n.push(s);var a=o.options,p=a.labelField,c=a.label,l="";if("string"==typeof p?l=e.get(p):c&&(l=c(o._createLayerDefOpts(W(e)))),l=String(l)){var u=w(l)?l:"";if(u){var h=function(t,e){var o={font:"12px Calibri,sans-serif",overflow:!0,fill:new j({color:"#000"}),stroke:new S({color:"#fff",width:3})};return"point"===t&&(o=D(D({},o),{placement:"point",textBaseline:"bottom",offsetY:20})),new x({text:new L(o)})}(t.type||"polygon");h.getText().setText(u),n.push(h)}}return void 0!==i&&(o._styleCache[i]=n),n}},H(this.map,t)),t.nativeOptions)),(null===(e=t.interactive)||void 0===e||e)&&this._addEventListener(),this.layer},e.prototype.beforeRemove=function(){for(var t=this.forEachFeatureAtPixel,e=function(e){var o=t[e][1];-1!==t.findIndex((function(t){return t[1]===o}))&&t.splice(e,1)},o=t.length;o--;)e(o);this._forEachFeatureAtPixel.length=0;var n=this.mapClickEvents;for(o=n.length;o--;){-1!==n.indexOf(n[o])&&n.splice(o,1)}this._mapClickEvents.length=0,this._removeAllPopup()},e.prototype.clearLayer=function(t){if(this.unselect(),t)for(var e=this.vectorSource.getFeatures().values(),o=void 0;!(o=e.next()).done;){t(W(o.value))&&this.vectorSource.removeFeature(o.value)}else this.vectorSource.clear()},e.prototype.setData=function(t){this.clearLayer(),this.addData(t)},e.prototype.addData=function(t){var e=this.options.srs,o="EPSG:"+(null!=e?e:"4326"),n=(new p).readFeatures(t,{dataProjection:o,featureProjection:this.displayProjection});if(this._features=this._features.concat(n),this._filterFun)this.filter(this._filterFun);else if(this.vectorSource.addFeatures(n),this.options.popup)for(var i=0,r=this._features;i<r.length;i++){this._openPopup({feature:r[i],type:"api",options:this.options.popupOptions})}},e.prototype.select=function(t){var e=this;"function"==typeof t?this._features.filter((function(o){return t(e._createLayerDefOpts(W(o)))})).forEach((function(t){e._selectFeature(t)})):this.selected||(this.selected=!0,this.selectedPaint&&this._setPaintEachLayer(this.selectedPaint))},e.prototype.unselect=function(t){var e=this,o=this._selectedFeatures;"function"==typeof t?o=this._selectedFeatures.filter((function(o){return t(e._createLayerDefOpts(W(o)))})):this.selected&&(this.selected=!1);for(var n=0,i=o;n<i.length;n++){this._unselectFeature(i[n])}this._removeAllPopup()},e.prototype.getLayers=function(){var t=this;return this._features.map((function(e){return t._createLayerDefOpts(W(e))}))},e.prototype.getSelected=function(){var t=this;return this._selectedFeatures.map((function(e){return t._createLayerDefOpts(W(e))}))},e.prototype.filter=function(t){var e=this;this._filterFun=t;var o=this._features,n=t?o.filter((function(o){return t(e._createLayerDefOpts(W(o)))})):o;this.vectorSource.clear();for(var i=n.length,r=0;r<i;r++)this.vectorSource.addFeature(n[r]);return n.map((function(t){return e._createLayerDefOpts(W(t))}))},e.prototype.cleanFilter=function(){this.filter()},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){if(this.layer){var t=this.layer.getSource();if(t){var e=t.getExtent();return i(e,this.displayProjection,this.lonlatProjection)}}},e.prototype.setPaint=function(t){t&&(this.paint=t,this._setPaintEachLayer(this.paint))},e.prototype.setSelectedPaint=function(t){t&&(this.selectedPaint=t,this._setPaintEachLayer(this.selectedPaint))},e.prototype.updatePaint=function(t){this.paint=D(D({},this.paint),t),this._setPaintEachLayer(this.paint)},e.prototype.updateSelectedPaint=function(t){this.selectedPaint=D(D({},this.selectedPaint),t),this._setPaintEachLayer(this.selectedPaint)},e.prototype._createLayerDefOpts=function(t){return D({target:this,feature:t},ot({feature:t,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection}))},e.prototype._setPaintEachLayer=function(t){if(this.layer){var e=this.layer.getSource();if(e)e.getFeatures().forEach((function(e){var o=st(e,t);o&&e.setStyle(o)}))}},e.prototype._addEventListener=function(){var t,e=this,o=this.forEachFeatureAtPixel,n=[this.options.order||0,function(t,o,n){return e._onFeatureAtPixel(t,o,n)}];this._forEachFeatureAtPixel.push(n),o.push(n),(null===(t=this.options.unselectOnClick)||void 0===t||t)&&(this._mapClickEvents.push((function(){return e.unselect()})),this.mapClickEvents.push((function(){return e.unselect()})))},e.prototype._onFeatureAtPixel=function(t,e,o){var n,i=this,r=t&&this.map.getFeaturesAtPixel(t,{layerFilter:function(t){return t===i.layer}})[0],s={layer:i,event:tt(n=e),source:n};if(r){var a=D(D({},s),this._createLayerDefOpts(W(r))),p=-1!==this._selectedFeatures.indexOf(r);return this.options.selectable&&("hover"===o&&this.options.selectOnHover||"click"===o)&&(p?this.options&&this.options.unselectOnSecondClick&&(this._unselectFeature(r),p=!1):(this._selectFeature(r,a.event.lngLat),p=!0)),"click"===o&&this.options.onClick&&this.options.onClick(D({selected:p},a)),"hover"===o&&(this._mouseOver=!0,this.options.onMouseOver&&this.options.onMouseOver(a)),!0}return"hover"===o&&this._mouseOver&&(this._mouseOver=!1,this.options.onMouseOut&&this.options.onMouseOut(s),this.options.selectOnHover&&this.unselect()),!1},e.prototype._selectFeature=function(t,e){var o=this;this.addUnselectCb((function(){return o._unselectFeature(t)}));var n=this.options,i=e?"click":"api";if(n&&!n.multiselect&&this._selectedFeatures.forEach((function(t){return o._unselectFeature(t)})),this._selectedFeatures.push(t),this.selected=!0,n&&n.selectedPaint){var r=st(t,n.selectedPaint);r&&t.setStyle(r)}if(this.options.popupOnSelect&&this._openPopup({coordinates:e,feature:t,options:this.options.popupOptions,type:"click"}),this.options.onSelect){var s=W(t);this.options.onSelect(D({layer:this,features:[],type:i},ot({feature:s,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})))}},e.prototype._unselectFeature=function(t){var e=this._selectedFeatures.indexOf(t);if(-1!==e){this._selectedFeatures.splice(e,1);var o=this._openedPopup.find((function(e){return e[0]===t}));o&&this._removePopup(o[1])}if(this.selected=this._selectedFeatures.length>0,this.options&&this.options.paint){var n=st(t,this.options.paint);n&&t.setStyle(n)}},e.prototype._openPopup=function(t){var e=t.coordinates,o=t.feature,i=t.options,r=void 0===i?{}:i,s=t.type;return G(this,void 0,void 0,(function(){var t,i,a,p,c,l,u,h,f,m,d,v,g=this;return U(this,(function(_){switch(_.label){case 0:return(t=this.map)?(a=[],p=function(t){a.push(t)},c=function(){i&&g._removePopup(i)},l=r.createPopupContent,u=r.popupContent,h=W(o),l?[4,l(D({close:c,onClose:p,type:s},this._createLayerDefOpts(h)))]:[3,2]):[2];case 1:return m=_.sent(),[3,3];case 2:m=u,_.label=3;case 3:return f=m,e=e||h&&function(t){return"Polygon"===t.geometry.type?O(t.geometry.coordinates):"Point"===t.geometry.type?t.geometry.coordinates:(e=P(t)).reduce((function(t,o){return[t[0]+o[0]/e.length,t[1]+o[1]/e.length]}),[0,0]);var e}(h),f&&e&&(d="string"==typeof f?(w=f,(b=document.createElement("div")).innerHTML=w,b):f,v=this._createPopupElement(D(D({},r),{popupContent:d,close:c})),(i=new y({element:v})).setPosition(n(e,this.lonlatProjection,this.displayProjection)),t.addOverlay(i),this._openedPopup.push([o,i,a])),[2]}var w,b}))}))},e.prototype._createPopupElement=function(t){var e=t.closeButton,o=t.popupContent,n=t.maxWidth,i=t.minWidth,r=t.close;e=null!=e?e:!this.options.selectOnHover;var s=_("div","ol-popup");if(n&&(s.style.maxWidth=n+"px"),i&&(s.style.minWidth=i+"px"),e){var a=_("a","ol-popup-closer",s);a.setAttribute("href","#"),a.addEventListener("click",r)}return _("div","popup-content",s).appendChild(o),s},e.prototype._removeAllPopup=function(){var t=function(t,e,o){if(o||2===arguments.length)for(var n,i=0,r=e.length;i<r;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([],this._openedPopup,!0);this._openedPopup=[];for(var e=0,o=t;e<o.length;e++){this._removePopup(o[e][1])}},e.prototype._removePopup=function(t){var e,o,n=this.map;if(n){n.removeOverlay(t);var i=this._openedPopup.findIndex((function(e){return e[1]===t}));if(-1!==i){for(var r=this._openedPopup[i],s=r[0],a=r[2],p=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o,c=0,l=a;c<l.length;c++){(0,l[c])(this._createLayerDefOpts(W(s)))}a.length=0,p&&this._unselectFeature(s),this._openedPopup.splice(i,1)}}},e}(q),pt=function(t){function e(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];var n=t.apply(this,e)||this;return n.element.classList.remove("ol-control"),n.element.classList.add("webmap-ctrl-group"),n}return B(e,t),e}(k),ct={collapsible:!1},lt=function(t){function e(e){return t.call(this,D(D({},ct),e))||this}return B(e,t),e}(I),ut={collapsible:!1},ht=function(t){function e(e){var o=this,n=new T,i=n.getContainer();return(o=t.call(this,D(D(D({},ut),e),{element:i}))||this).panelContainer=n,o}return B(e,t),e.prototype.addControl=function(t,e){return G(this,void 0,void 0,(function(){var o,n,i,r;return U(this,(function(s){switch(s.label){case 0:return(o=this.getMap())&&(n=this.panelContainer.newPositionContainer(e))?[4,t]:[3,2];case 1:i=s.sent(),(r=i.element)&&r.classList.add("webmap-ctrl"),i.setTarget(n),o.addControl(i),s.label=2;case 2:return[2]}}))}))},e.prototype.removeControl=function(t){var e=this.getMap();e&&e.removeControl(t)},e.prototype.getContainer=function(){return this.panelContainer.getContainer()},e}(Z);var ft=function(){function s(){this.options={target:"map"},this.layerAdapters=s.layerAdapters,this.controlAdapters=s.controlAdapters,this.emitter=new t,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this._mapClickEvents=[],this._forEachFeatureAtPixel=[],this._unselectCb=[],this._isLoaded=!1,this._positionMem={}}return s.prototype.create=function(t){var n=this;this.options=D({},t);var i=this.getViewOptions(this.options),r={controls:[],view:new o(i),layers:[]};t.mapAdapterOptions&&Object.assign(r,t.mapAdapterOptions);var s=D(D({},r),{target:this.options.target||"map"});this.map=this.options.map||new e(s),this._panelControl=new ht,this.map.addControl(this._panelControl),this.map.set("_mapClickEvents",this._mapClickEvents),this.map.set("_forEachFeatureAtPixel",this._forEachFeatureAtPixel),this.map.set("_addUnselectCb",(function(t){return n._addUnselectCb(t)})),this.emitter.emit("create",this),this._olView=this.map.getView(),this._isLoaded=!0,this._addMapListeners(),this._addViewListeners()},s.prototype.destroy=function(){this.map&&this.map.dispose()},s.prototype.getContainer=function(){if(this.options.target){var t=void 0;return"string"==typeof this.options.target?t=document.getElementById(this.options.target):this.options.target instanceof HTMLElement&&(t=this.options.target),t}},s.prototype.getControlContainer=function(){if(this._panelControl)return this._panelControl.getContainer();throw new Error("The ol-map-adapter ControlPanel has not been initialized yet")},s.prototype.setCenter=function(t){this._olView&&this._olView.setCenter(r(t))},s.prototype.getCenter=function(){if(this._olView){var t=this._olView.getCenter();if(t)return n(t,this.displayProjection,this.lonlatProjection)}},s.prototype.setZoom=function(t){this._olView&&this._olView.setZoom(t)},s.prototype.getZoom=function(){if(this._olView)return this._olView.getZoom()},s.prototype.fitBounds=function(t,e){if(void 0===e&&(e={}),this._olView){var o=e.padding,n=e.maxZoom,r=e.offset,s=this.getZoom(),a=i(t,this.lonlatProjection,this.displayProjection),p={};n&&(p.maxZoom=n),o&&(p.padding=[o,o]),r&&(p.padding=r),this._olView.fit(a,p),this._emitMoveEndEvents({zoom:s})}},s.prototype.getBounds=function(){if(this._olView){var t=this._olView.calculateExtent();return i(t,this.displayProjection,this.lonlatProjection)}},s.prototype.setRotation=function(t){this._olView&&this._olView.setRotation(t)},s.prototype.setView=function(t,e){if(this.map)if(Array.isArray(t)){this._setView({zoom:e,center:r(t)})}else{var o=t.bounds,n=this.getViewOptions(t);Object.values(n).some(Boolean)&&this._setView(n),o&&this.fitBounds(o)}},s.prototype.removeLayer=function(t){this.map&&this.map.removeLayer(t)},s.prototype.showLayer=function(t){this.map&&this.map.addLayer(t)},s.prototype.hideLayer=function(t){this.map&&this.map.removeLayer(t)},s.prototype.setLayerOpacity=function(t,e){t.setOpacity&&t.setOpacity(Number(e))},s.prototype.setLayerOrder=function(t,e){t&&t.setZIndex&&t.setZIndex(e)},s.prototype.createControl=function(t,e){return function(t,e,o){return void 0===e&&(e={}),new(function(n){function i(){var i=document.createElement("div");i.className=(e.addClass?e.addClass+" ":"")+"ol-unselectable"+(e.bar?" webmap-ctrl-group":"")+(e.margin?" ol-control-margin":"");var r=t.onAdd(o);r&&i.appendChild(r),n.call(this,{element:i})}return n&&(i.__proto__=n),(i.prototype=Object.create(Z&&Z.prototype)).constructor=i,i.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},i}(Z))}(t,e,this)},s.prototype.createButtonControl=function(t){return function(t){return new(function(e){function o(){var o=document.createElement("button");o.className="custom-button-control","string"==typeof t.html?o.innerHTML=t.html:t.html&&o.appendChild(t.html),"string"==typeof t.title&&(o.title=t.title);var n=document.createElement("div");n.className=(t.addClass?t.addClass+" ":"")+"ol-unselectable webmap-ctrl-group",n.appendChild(o),e.call(this,{element:n}),o.addEventListener("click",(function(){return t.onClick()}),!1)}return e&&(o.__proto__=e),(o.prototype=Object.create(Z&&Z.prototype)).constructor=o,o.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},o}(Z))}(t)},s.prototype.addControl=function(t,e){if(this._panelControl)return this._panelControl.addControl(t,e),t},s.prototype.removeControl=function(t){this._panelControl&&this._panelControl.removeControl(t)},s.prototype.onMapClick=function(t){var e=tt(t);this.emitter.emit("preclick",e),this._callEachFeatureAtPixel(t,"click")||this._mapClickEvents.forEach((function(e){e(t)})),this.emitter.emit("click",e)},s.prototype.getViewOptions=function(t){var e=t.center,o=t.maxBounds,n={zoom:t.zoom,minZoom:t.minZoom,maxZoom:t.maxZoom,projection:this.displayProjection};if(e&&(n.center=r(e)),o){var s=i(o,this.lonlatProjection,this.displayProjection);n.extent=s}return n},s.prototype._callEachFeatureAtPixel=function(t,e){if(t&&t.pixel&&this._forEachFeatureAtPixel.length&&this.map)for(var o=0,n=this._forEachFeatureAtPixel.sort((function(t,e){return e[0]-t[0]}));o<n.length;o++){if(n[o][1](t.pixel,t,e))return!0}return!1},s.prototype._emitMoveEndEvents=function(t){if(this._isLoaded){var e=this.getZoom();t.zoom!==e&&this.emitter.emit("zoomend")}},s.prototype._addMapListeners=function(){var t=this,e=this.map;if(e){var o=e.getViewport();e.on("click",(function(e){t.onMapClick(e)})),e.on("pointermove",(function(e){t.emitter.emit("mousemove",tt(e)),t._callEachFeatureAtPixel(e,"hover")}));var n=function(t){var o=[t.x,t.y];return tt(D({pixel:o,coordinate:e.getCoordinateFromPixel(o)},t))};o.addEventListener("mouseout",(function(e){t.emitter.emit("mouseout",n(e))}),!1),o.addEventListener("mouseover",(function(e){t.emitter.emit("mouseover",n(e))}),!1);for(var i=this.getCenter(),r=this.getZoom(),s=function(o){a._positionMem[o]={center:i,zoom:r},e.on(o,(function(){t._emitPositionChangeEvent(o)}))},a=this,p=0,c=["movestart","moveend"];p<c.length;p++){s(c[p])}}},s.prototype._addViewListeners=function(){var t=this;this._olView&&(this._olView.on("change:resolution",(function(){t.emitter.emit("zoom",t)})),this._olView.on("change:center",(function(){t.emitter.emit("move",t)})))},s.prototype._setView=function(t){var e=t.center,n=t.zoom,i=t.extent,r=t.minZoom,s=t.maxZoom,a=this.map;if(a){var p=a.getView();if(void 0!==i){p.dispose();var c=new o(t);this._olView=c,this._addViewListeners(),a.setView(c)}else e&&p.setCenter(e),void 0!==n&&p.setZoom(n),void 0!==r&&p.setMinZoom(r),void 0!==s&&p.setMaxZoom(s)}},s.prototype._addUnselectCb=function(t){for(var e=0,o=this._unselectCb;e<o.length;e++){(0,o[e])()}this._unselectCb.length=0,this._unselectCb.push(t)},s.prototype._emitPositionChangeEvent=function(t){var e,o,n=this._positionMem[t];n&&(e=n.center,o=n.zoom);var i=this.getCenter(),r=this.getZoom();o!==r&&this.emitter.emit("movestart"===t?"zoomstart":"zoomend",this);e&&i?i[0]===e[0]&&i[1]===e[1]||this.emitter.emit(t,this):e!==i&&this.emitter.emit(t,this);this._positionMem[t]={center:i,zoom:r}},s.layerAdapters={IMAGE:$,TILE:Q,WMS:J,OSM:K,GEOJSON:at},s.controlAdapters={ZOOM:pt,ATTRIBUTION:lt},s}();export{ft as default};
//# sourceMappingURL=ol-map-adapter.esm-bundler.prod.js.map
{
"name": "@nextgis/ol-map-adapter",
"version": "1.12.1",
"version": "1.13.0",
"_priority": 16,

@@ -12,11 +12,11 @@ "description": "",

"dependencies": {
"@nextgis/control-container": "^1.12.1",
"@nextgis/control-container": "^1.13.0",
"@nextgis/dom": "^1.12.0",
"@nextgis/paint": "^1.12.0",
"@nextgis/properties-filter": "^1.12.0",
"@nextgis/webmap": "^1.12.1",
"@nextgis/webmap": "^1.13.0",
"@types/events": "^3.0.0",
"@types/polylabel": "^1.0.5",
"events": "^3.3.0",
"ol": "^6.9.0",
"ol": "^6.14.1",
"polylabel": "^1.1.0"

@@ -66,3 +66,3 @@ },

},
"gitHead": "0c6f276fd74c321635160e0aeaa31861ada05390"
"gitHead": "d8ae4237117c3e512781a3b1ed690179790281e7"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc