@nextgis/ol-map-adapter
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -71,2 +71,3 @@ /// <reference types="node" /> | ||
private _mapClickEvents; | ||
private _styleCache; | ||
constructor(map: Map_2, options: GeoJsonAdapterOptions); | ||
@@ -187,3 +188,3 @@ private get addUnselectCb(); | ||
constructor(map: Map_2, options: AdapterOptions); | ||
addLayer(): TileLayer<OSM>; | ||
addLayer(options: Omit<TileAdapterOptions, 'url'>): TileLayer<OSM>; | ||
} | ||
@@ -190,0 +191,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** Bundle of @nextgis/ol-map-adapter; version: 1.7.0; author: NextGIS */ | ||
/** Bundle of @nextgis/ol-map-adapter; version: 1.8.0; author: NextGIS */ | ||
import { EventEmitter } from 'events'; | ||
@@ -142,2 +142,3 @@ import Map from 'ol/Map'; | ||
addLayer(options) { | ||
Object.assign(this.options, options); | ||
const wmsOptions = { | ||
@@ -176,2 +177,3 @@ url: options.url, | ||
...resolutionOptions(this.map, options), | ||
...options.nativeOptions, | ||
}); | ||
@@ -190,3 +192,4 @@ this.layer = layer; | ||
} | ||
addLayer() { | ||
addLayer(options) { | ||
Object.assign(this.options, options); | ||
this.options.name = this.name; | ||
@@ -198,2 +201,3 @@ const attributions = [ATTRIBUTION]; | ||
}), | ||
...options.nativeOptions, | ||
}); | ||
@@ -211,2 +215,3 @@ return layer; | ||
addLayer(options) { | ||
Object.assign(this.options, options); | ||
const urls = []; | ||
@@ -243,2 +248,3 @@ const subdomains = typeof options.subdomains === 'string' | ||
...resolutionOptions(this.map, options), | ||
...options.nativeOptions, | ||
}); | ||
@@ -256,2 +262,3 @@ return layer; | ||
addLayer(options) { | ||
Object.assign(this.options, options); | ||
if (options.url) { | ||
@@ -326,2 +333,3 @@ const ratio = options.ratio !== undefined ? options.ratio : 1; | ||
...resolutionOptions(this.map, options), | ||
...options.nativeOptions, | ||
}); | ||
@@ -524,2 +532,3 @@ this.layer = layer; | ||
this._mapClickEvents = []; | ||
this._styleCache = {}; | ||
this.displayProjection = map.getView().getProjection().getCode(); | ||
@@ -538,3 +547,3 @@ } | ||
var _a; | ||
this.options = options; | ||
Object.assign(this.options, options); | ||
this.paint = options.paint; | ||
@@ -550,2 +559,7 @@ this.selectedPaint = options.selectedPaint; | ||
const style = []; | ||
const id = f.getId(); | ||
const fromCache = id !== undefined && this._styleCache[id]; | ||
if (fromCache) { | ||
return fromCache; | ||
} | ||
const vectorStyle = styleFunction(f, options.paint); | ||
@@ -565,5 +579,9 @@ if (vectorStyle) { | ||
} | ||
if (id !== undefined) { | ||
this._styleCache[id] = style; | ||
} | ||
return style; | ||
}, | ||
...resolutionOptions(this.map, options), | ||
...options.nativeOptions, | ||
}); | ||
@@ -570,0 +588,0 @@ const interactive = (_a = options.interactive) !== null && _a !== void 0 ? _a : true; |
@@ -1,2 +0,2 @@ | ||
import{EventEmitter as t}from"events";import e from"ol/Map";import o from"ol/View";import{transform as i,transformExtent as s,fromLonLat as n}from"ol/proj";import r from"ol/layer/Tile";import a from"ol/source/TileWMS";import l from"ol/format/GeoJSON";import c,{ATTRIBUTION as p}from"ol/source/OSM";import h from"ol/source/XYZ";import u from"ol/layer/Image";import m from"ol/renderer/canvas/ImageLayer";import d from"ol/source/ImageWMS";import f from"ol/source/WMSServerType";import y from"ol/Overlay";import g from"ol/layer/Vector";import _ from"ol/source/Vector";import{create as P}from"@nextgis/dom";import{getCoordinates as v,defined as C}from"@nextgis/utils";import w from"polylabel";import{getCenter as E}from"ol/extent";import x from"ol/style/Circle";import{asArray as O}from"ol/color";import{Style as L,Text as F,Fill as b,Stroke as S}from"ol/style";import j from"ol/style/IconAnchorUnits";import A from"ol/style/Icon";import{isPaintCallback as M,isPaint as k}from"@nextgis/paint";import I from"ol/control/Zoom";import V from"ol/control/Attribution";import R from"ol/control/Control";import T from"@nextgis/control-container";function Z(t,e){return{minResolution:e.maxScale&&U(t,e.maxScale)||void 0,maxResolution:e.minScale&&U(t,e.minScale)||void 0}}function U(t,e){if(e)return function(t,e){return t/(39.37*e*90.71446714322)}(e,t.getView().getProjection().getMetersPerUnit()||1)}function D(t){return(new l).writeFeatureObject(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})}function G(t){const e=decodeURIComponent,o=t.split("&"),i={};let s,n;for(let t,r=0,a=o.length;r<a;++r)if(t=o[r],t.length){const o=t.indexOf("=");o<0?(s=e(t),n=""):(s=e(t.slice(0,o)),n=e(t.slice(o+1))),"string"==typeof i[s]&&(i[s]=[i[s]]),Array.isArray(i[s])?i[s].push(n):i[s]=n}return i}function B(t,e){const o=[];let i;for(i in t){const s=e?e+"["+i+"]":i,n=t[i];o.push(null!==n&&"object"==typeof n?B(n,s):encodeURIComponent(s)+"="+encodeURIComponent(n))}return o.join("&")}function z(t,e,o){const i=new XMLHttpRequest;i.open("GET",e),i.responseType="arraybuffer";for(const t in o)i.setRequestHeader(t,o[t]);i.onload=function(){const e=new Uint8Array(this.response),o=new Blob([e],{type:"image/png"}),i=(window.URL||window.webkitURL).createObjectURL(o);t.getImage().src=i},i.send()}class H{constructor(t,e){this.map=t,this.options=e}setOpacity(t){this.options.opacity=Number(t),this.layer&&this.layer.setOpacity&&this.layer.setOpacity(this.options.opacity)}}function N(t,e="EPSG:3857",o="EPSG:4326"){const[s,n]=i(t.coordinate,e,o);return{latLng:{lat:n,lng:s},lngLat:[s,n],pixel:{left:t.pixel[0],top:t.pixel[1]},source:t}}function W(t){const e=function({feature:t,dataProjection:e,featureProjection:o}){const i=(new l).readFeatures({type:"FeatureCollection",features:Array.isArray(t)?t:[t]},{dataProjection:e,featureProjection:o}),s=new _;return s.addFeatures(i),s}(t),o=e.getExtent(),i=s(o,t.featureProjection,t.dataProjection);return e.dispose(),i}function X(t){return{getBounds:()=>W(t),getCenter:()=>function(t){const e=W(t);return E(e)}(t)}}const Y={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon",Circle:"point"},q={polygon:"path",line:"path",point:"circle"};function J(t,e){const o=O(t).slice();return o[3]=void 0!==e?e:1,o}function K(t,e={}){if(M(e)){return K(t,e(D(t)))}if(k(e)){const o=t.getGeometry(),i=o&&o.getType()||"Point",s={};if(!e.type){const t=Y[i],o="polygon"===t||"line"===t?"path":"html"in e||"className"in e?"icon":q[t];o&&(e.type=o)}if("path"===e.type||"circle"===e.type){const{radius:t,fill:o,fillColor:n,fillOpacity:r,strokeColor:a,stroke:l,strokeOpacity:c}={...e};o&&n&&"string"==typeof n&&"number"==typeof r&&(s.fill=new b({color:J(n,r)})),a&&"string"==typeof a&&"number"==typeof c&&(l||-1!==["MultiLineString","LineString"].indexOf(i))&&(s.stroke=new S({width:e.weight,color:J(a,c)})),"circle"===e.type&&"number"==typeof t&&(s.image=new x({radius:t,...s}))}else if("icon"===e.type){const t=e.html;if(t){const o={src:"data:image/svg+xml,"+escape(t),anchorXUnits:j.PIXELS,anchorYUnits:j.PIXELS,anchor:e.iconAnchor,imgSize:e.iconSize};s.image=new A(o)}}return new L(s)}}const Q={collapsible:!1};const $={collapsible:!1};class tt extends R{constructor(t){const e=new T,o=e.getContainer();super({...$,...t,element:o}),this.panelContainer=e}async addControl(t,e){const o=this.getMap(),i=this.panelContainer.newPositionContainer(e);if(i){const e=await t,s=e.element;s&&s.classList.add("webmap-ctrl"),e.setTarget(i),o.addControl(e)}}removeControl(t){this.getMap().removeControl(t)}getContainer(){return this.panelContainer.getContainer()}}class et{constructor(){this.options={target:"map"},this.layerAdapters=et.layerAdapters,this.controlAdapters=et.controlAdapters,this.emitter=new t,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this._mapClickEvents=[],this._forEachFeatureAtPixel=[],this._unselectCb=[],this._isLoaded=!1,this._positionMem={}}create(t){this.options={...t};const i={...{controls:[],view:new o({center:this.options.center,zoom:this.options.zoom,minZoom:this.options.minZoom,maxZoom:this.options.maxZoom,projection:this.displayProjection}),layers:[]},target:this.options.target||"map"};this.map=new e(i),this._panelControl=new tt,this.map.addControl(this._panelControl),this.map.set("_mapClickEvents",this._mapClickEvents),this.map.set("_forEachFeatureAtPixel",this._forEachFeatureAtPixel),this.map.set("_addUnselectCb",(t=>this._addUnselectCb(t))),this.emitter.emit("create",this),this._olView=this.map.getView(),this._isLoaded=!0,this._addMapListeners()}destroy(){this.map&&this.map.dispose()}getContainer(){if(this.options.target){let t;return"string"==typeof this.options.target?t=document.getElementById(this.options.target):this.options.target instanceof HTMLElement&&(t=this.options.target),t}}getControlContainer(){if(this._panelControl)return this._panelControl.getContainer();throw new Error("The ol-map-adapter ControlPanel has not been initialized yet")}setCenter(t){this._olView&&this._olView.setCenter(n(t))}getCenter(){if(this._olView){const t=this._olView.getCenter();if(t){return i(t,this.displayProjection,this.lonlatProjection)}}}setZoom(t){this._olView&&this._olView.setZoom(t)}getZoom(){if(this._olView)return this._olView.getZoom()}fitBounds(t,e={}){if(this._olView){const{padding:o,maxZoom:i,offset:n}=e,r=this.getZoom(),a=s(t,this.lonlatProjection,this.displayProjection),l={};i&&(l.maxZoom=i),o&&(l.padding=[o,o]),n&&(l.padding=n),this._olView.fit(a,l),this._emitMoveEndEvents({zoom:r})}}getBounds(){if(!this._olView)return;const t=this._olView.calculateExtent();return s(t,this.displayProjection,this.lonlatProjection)}setRotation(t){this._olView&&this._olView.setRotation(t)}removeLayer(t){this.map&&this.map.removeLayer(t)}showLayer(t){this.map&&this.map.addLayer(t)}hideLayer(t){this.map&&this.map.removeLayer(t)}setLayerOpacity(t,e){t.setOpacity&&t.setOpacity(Number(e))}setLayerOrder(t,e){t&&t.setZIndex&&t.setZIndex(e)}createControl(t,e){return function(t,e={},o){return new(function(i){function s(){const s=document.createElement("div");s.className=(e.addClass?e.addClass+" ":"")+"ol-unselectable"+(e.bar?" webmap-ctrl-group":"")+(e.margin?" ol-control-margin":"");const n=t.onAdd(o);n&&s.appendChild(n),i.call(this,{element:s})}return i&&(s.__proto__=i),(s.prototype=Object.create(R&&R.prototype)).constructor=s,s.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},s}(R))}(t,e,this)}createButtonControl(t){return function(t){return new(function(e){function o(){const 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);const i=document.createElement("div");i.className=(t.addClass?t.addClass+" ":"")+"ol-unselectable webmap-ctrl-group",i.appendChild(o),e.call(this,{element:i}),o.addEventListener("click",(()=>t.onClick()),!1)}return e&&(o.__proto__=e),(o.prototype=Object.create(R&&R.prototype)).constructor=o,o.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},o}(R))}(t)}addControl(t,e){if(this._panelControl)return this._panelControl.addControl(t,e),t}removeControl(t){this._panelControl&&this._panelControl.removeControl(t)}onMapClick(t){const e=N(t);this.emitter.emit("preclick",e);this._callEachFeatureAtPixel(t,"click")||this._mapClickEvents.forEach((e=>{e(t)})),this.emitter.emit("click",e)}_callEachFeatureAtPixel(t,e){if(t&&t.pixel&&this._forEachFeatureAtPixel.length&&this.map){const o=this._forEachFeatureAtPixel.sort(((t,e)=>e[0]-t[0]));for(const i of o){if(i[1](t.pixel,t,e))return!0}}return!1}_emitMoveEndEvents(t){if(this._isLoaded){const e=this.getZoom();t.zoom!==e&&this.emitter.emit("zoomend")}}_addMapListeners(){const t=this.map;if(t){t.on("click",(t=>{this.onMapClick(t)})),t.on("pointermove",(t=>{this._callEachFeatureAtPixel(t,"hover")}));const e=this.getCenter(),o=this.getZoom();["movestart","moveend"].forEach((i=>{this._positionMem[i]={center:e,zoom:o},t.on(i,(()=>{this._emitPositionChangeEvent(i)}))})),this._olView&&(this._olView.on("change:resolution",(()=>{this.emitter.emit("zoom",this)})),this._olView.on("change:center",(()=>{this.emitter.emit("move",this)})))}}_addUnselectCb(t){for(const t of this._unselectCb)t();this._unselectCb.length=0,this._unselectCb.push(t)}_emitPositionChangeEvent(t){const e=this._positionMem[t];let o,i;e&&(o=e.center,i=e.zoom);const s=this.getCenter(),n=this.getZoom();if(i!==n){this.emitter.emit("movestart"===t?"zoomstart":"zoomend",this)}if(o&&s){const[e,i]=s,[n,r]=o;e===n&&i===r||this.emitter.emit(t,this)}else o!==s&&this.emitter.emit(t,this);this._positionMem[t]={center:s,zoom:n}}}et.layerAdapters={IMAGE:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){if(t.url){const e=void 0!==t.ratio?t.ratio:1,o={url:t.url,params:{...t.params},projection:void 0},i=t.updateWmsParams;o.imageLoadFunction=(e,o)=>{const s=o.split("?")[0],n=o.split("?")[1],{resource:r,BBOX:a,WIDTH:l,HEIGHT:c,...p}=G(n),h={resource:r,bbox:a,width:l,height:c,...p},u=B(i?i(h):p),m=t.headers,d=s+"?"+u;m?z(e,d,m):e.getImage().src=d};let s=u,n=d;if(e>1){o.ratio=e,o.serverType=f.MAPSERVER;class t extends m{renderFrame(t,o){return t.pixelRatio=e,super.renderFrame(t,o)}}class i extends u{createRenderer(){return new t(this)}}s=i;class r extends d{getImageInternal(t,o,i,s){return super.getImageInternal(t,o,e,s)}}n=r}const r=new s({source:new n(o),opacity:t.opacity,...Z(this.map,t)});return this.layer=r,r}}},TILE:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){const e=[],o="string"==typeof t.subdomains?t.subdomains.split(""):t.subdomains;(null==o?void 0:o.length)?o.forEach((o=>{e.push(t.url.replace(/{s}/,o))})):e.push(t.url);const i={attributions:t.attribution?[t.attribution]:[],urls:e};t.crossOrigin&&(i.crossOrigin=t.crossOrigin);const s=new h(i),n=t.headers;n&&s.setTileLoadFunction(((t,e)=>{z(t,e,n)}));return new r({source:s,opacity:t.opacity,...Z(this.map,t)})}},WMS:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){const e={url:t.url,params:{LAYERS:t.layers,VERSION:t.version},projection:void 0},o=t.updateWmsParams;o&&(e.tileLoadFunction=(e,i)=>{const s=i.split("?")[0],n=i.split("?")[1],{resource:r,BBOX:a,WIDTH:l,HEIGHT:c}=G(n),p=B(o({resource:r,bbox:a,width:l,height:c})),h=t.headers,u=s+"?"+p;h?z(e,u,h):e.getImage().src=u});const i=new a(e),s=new r({source:i,opacity:t.opacity,...Z(this.map,t)});return this.layer=s,s}},OSM:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e,this.name="OpenStreetMap"}addLayer(){this.options.name=this.name;return new r({source:new c({attributions:[p]})})}},GEOJSON:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e,this.selected=!1,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this.vectorSource=new _,this._features=[],this._selectedFeatures=[],this._openedPopup=[],this._forEachFeatureAtPixel=[],this._mapClickEvents=[],this.displayProjection=t.getView().getProjection().getCode()}get addUnselectCb(){return this.map.get("_addUnselectCb")}get mapClickEvents(){return this.map.get("_mapClickEvents")}get forEachFeatureAtPixel(){return this.map.get("_forEachFeatureAtPixel")}addLayer(t){var e;this.options=t,this.paint=t.paint,this.selectedPaint=t.selectedPaint;const o=t.data;o&&this.addData(o),this.layer=new g({source:this.vectorSource,style:e=>{const o=[],i=K(e,t.paint);i&&o.push(i);const s=this.options.labelField;if(s){const i=e.get(s),n=C(i)?String(i):"";if(n){const e=function(t,e){let o={font:"12px Calibri,sans-serif",overflow:!0,fill:new b({color:"#000"}),stroke:new S({color:"#fff",width:3})};return"point"===t&&(o={...o,placement:"point",textBaseline:"bottom",offsetY:20}),new L({text:new F(o)})}(t.type||"polygon");e.getText().setText(n),o.push(e)}}return o},...Z(this.map,t)});return(null===(e=t.interactive)||void 0===e||e)&&this._addEventListener(),this.layer}beforeRemove(){const t=this.forEachFeatureAtPixel;for(let e=t.length;e--;){const o=t[e][1];-1!==t.findIndex((t=>t[1]===o))&&t.splice(e,1)}this._forEachFeatureAtPixel.length=0;const e=this.mapClickEvents;for(let t=e.length;t--;){-1!==e.indexOf(e[t])&&e.splice(t,1)}this._mapClickEvents.length=0,this._removeAllPopup()}clearLayer(t){if(this.unselect(),t){const e=this.vectorSource.getFeatures().values();let o;for(;!(o=e.next()).done;){t(D(o.value))&&this.vectorSource.removeFeature(o.value)}}else this.vectorSource.clear()}setData(t){this.clearLayer(),this.addData(t)}addData(t){const e=this.options.srs,o="EPSG:"+(null!=e?e:"4326"),i=(new l).readFeatures(t,{dataProjection:o,featureProjection:this.displayProjection});if(this._features=this._features.concat(i),this._filterFun)this.filter(this._filterFun);else if(this.vectorSource.addFeatures(i),this.options.popup)for(const t of this._features)this._openPopup({feature:t,type:"api",options:this.options.popupOptions})}select(t){if("function"==typeof t){this._features.filter((e=>t(this._createLayerDefOpts(D(e))))).forEach((t=>{this._selectFeature(t)}))}else this.selected||(this.selected=!0,this.selectedPaint&&this.setPaintEachLayer(this.selectedPaint))}unselect(t){let e=this._selectedFeatures;"function"==typeof t?e=this._selectedFeatures.filter((e=>t(this._createLayerDefOpts(D(e))))):this.selected&&(this.selected=!1);for(const t of e)this._unselectFeature(t);this._removeAllPopup()}getLayers(){return this._features.map((t=>this._createLayerDefOpts(D(t))))}getSelected(){return this._selectedFeatures.map((t=>this._createLayerDefOpts(D(t))))}filter(t){this._filterFun=t;const e=this._features,o=t?e.filter((e=>t(this._createLayerDefOpts(D(e))))):e;this.vectorSource.clear();const i=o.length;for(let t=0;t<i;t++)this.vectorSource.addFeature(o[t]);return o.map((t=>this._createLayerDefOpts(D(t))))}cleanFilter(){this.filter()}getExtent(){return this.getBounds()}getBounds(){if(this.layer){const t=this.layer.getSource().getExtent();return s(t,this.displayProjection,this.lonlatProjection)}}_createLayerDefOpts(t){return{target:this,feature:t,...X({feature:t,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})}}setPaintEachLayer(t){if(this.layer){this.layer.getSource().getFeatures().forEach((e=>{const o=K(e,t);o&&e.setStyle(o)}))}}_addEventListener(){var t;const e=this.forEachFeatureAtPixel,o=[this.options.order||0,(t,e,o)=>this._onFeatureAtPixel(t,e,o)];this._forEachFeatureAtPixel.push(o),e.push(o);(null===(t=this.options.unselectOnClick)||void 0===t||t)&&(this._mapClickEvents.push((()=>this.unselect())),this.mapClickEvents.push((()=>this.unselect())))}_onFeatureAtPixel(t,e,o){const i=t&&this.map.getFeaturesAtPixel(t,{layerFilter:t=>t===this.layer})[0],s=(t=>({layer:this,event:N(t),source:t}))(e);if(i){const t={...s,...this._createLayerDefOpts(D(i))};let e=-1!==this._selectedFeatures.indexOf(i);return this.options.selectable&&("hover"===o&&this.options.selectOnHover||"click"===o)&&(e?this.options&&this.options.unselectOnSecondClick&&(this._unselectFeature(i),e=!1):(this._selectFeature(i,t.event.lngLat),e=!0)),"click"===o&&this.options.onClick&&this.options.onClick({selected:e,...t}),"hover"===o&&(this._mouseOver=!0,this.options.onMouseOver&&this.options.onMouseOver(t)),!0}return"hover"===o&&this._mouseOver&&(this._mouseOver=!1,this.options.onMouseOut&&this.options.onMouseOut(s),this.options.selectOnHover&&this.unselect()),!1}_selectFeature(t,e){this.addUnselectCb((()=>this._unselectFeature(t)));const o=this.options,i=e?"click":"api";if(o&&!o.multiselect&&this._selectedFeatures.forEach((t=>this._unselectFeature(t))),this._selectedFeatures.push(t),this.selected=!0,o&&o.selectedPaint){const e=K(t,o.selectedPaint);e&&t.setStyle(e)}if(this.options.popupOnSelect&&this._openPopup({coordinates:e,feature:t,options:this.options.popupOptions,type:"click"}),this.options.onSelect){const e=D(t);this.options.onSelect({layer:this,features:[],type:i,...X({feature:e,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})})}}_unselectFeature(t){const e=this._selectedFeatures.indexOf(t);if(-1!==e){this._selectedFeatures.splice(e,1);const o=this._openedPopup.find((e=>e[0]===t));o&&this._removePopup(o[1])}if(this.selected=this._selectedFeatures.length>0,this.options&&this.options.paint){const e=K(t,this.options.paint);e&&t.setStyle(e)}}async _openPopup({coordinates:t,feature:e,options:o={},type:s}){const n=this.map;if(!n)return;let r;const a=[],l=()=>{r&&this._removePopup(r)},{createPopupContent:c,popupContent:p}=o,h=D(e),u=c?await c({close:l,onClose:t=>{a.push(t)},type:s,...this._createLayerDefOpts(h)}):p;if(t=t||h&&function(t){return"Polygon"===t.geometry.type?w(t.geometry.coordinates):"Point"===t.geometry.type?t.geometry.coordinates:(e=v(t)).reduce(((t,o)=>[t[0]+o[0]/e.length,t[1]+o[1]/e.length]),[0,0]);var e}(h),u&&t){const s="string"==typeof u?function(t){const e=document.createElement("div");return e.innerHTML=t,e}(u):u,c=this._createPopupElement({...o,popupContent:s,close:l});r=new y({element:c}),r.setPosition(i(t,this.lonlatProjection,this.displayProjection)),n.addOverlay(r),this._openedPopup.push([e,r,a])}}_createPopupElement({closeButton:t,popupContent:e,maxWidth:o,minWidth:i,close:s}){t=null!=t?t:!this.options.selectOnHover;const n=P("div","ol-popup");if(o&&(n.style.maxWidth=o+"px"),i&&(n.style.minWidth=i+"px"),t){const t=P("a","ol-popup-closer",n);t.setAttribute("href","#"),t.addEventListener("click",s)}return P("div","popup-content",n).appendChild(e),n}_removeAllPopup(){const t=[...this._openedPopup];this._openedPopup=[];for(const e of t)this._removePopup(e[1])}_removePopup(t){var e,o;const i=this.map;if(i){i.removeOverlay(t);const s=this._openedPopup.findIndex((e=>e[1]===t));if(-1!==s){const[t,,i]=this._openedPopup[s],n=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o;for(const e of i)e(this._createLayerDefOpts(D(t)));i.length=0,n&&this._unselectFeature(t),this._openedPopup.splice(s,1)}}}}},et.controlAdapters={ZOOM:class extends I{constructor(...t){super(...t),this.element.classList.remove("ol-control"),this.element.classList.add("webmap-ctrl-group")}},ATTRIBUTION:class extends V{constructor(t){super({...Q,...t})}}};var ot=et;export{ot as default}; | ||
import{EventEmitter as t}from"events";import e from"ol/Map";import o from"ol/View";import{transform as i,transformExtent as s,fromLonLat as n}from"ol/proj";import r from"ol/layer/Tile";import a from"ol/source/TileWMS";import l from"ol/format/GeoJSON";import c,{ATTRIBUTION as p}from"ol/source/OSM";import h from"ol/source/XYZ";import u from"ol/layer/Image";import m from"ol/renderer/canvas/ImageLayer";import d from"ol/source/ImageWMS";import f from"ol/source/WMSServerType";import y from"ol/Overlay";import g from"ol/layer/Vector";import _ from"ol/source/Vector";import{create as P}from"@nextgis/dom";import{getCoordinates as v,defined as C}from"@nextgis/utils";import w from"polylabel";import{getCenter as E}from"ol/extent";import x from"ol/style/Circle";import{asArray as O}from"ol/color";import{Style as L,Text as b,Fill as F,Stroke as S}from"ol/style";import j from"ol/style/IconAnchorUnits";import A from"ol/style/Icon";import{isPaintCallback as M,isPaint as k}from"@nextgis/paint";import I from"ol/control/Zoom";import V from"ol/control/Attribution";import R from"ol/control/Control";import T from"@nextgis/control-container";function Z(t,e){return{minResolution:e.maxScale&&U(t,e.maxScale)||void 0,maxResolution:e.minScale&&U(t,e.minScale)||void 0}}function U(t,e){if(e)return function(t,e){return t/(39.37*e*90.71446714322)}(e,t.getView().getProjection().getMetersPerUnit()||1)}function D(t){return(new l).writeFeatureObject(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:3857"})}function G(t){const e=decodeURIComponent,o=t.split("&"),i={};let s,n;for(let t,r=0,a=o.length;r<a;++r)if(t=o[r],t.length){const o=t.indexOf("=");o<0?(s=e(t),n=""):(s=e(t.slice(0,o)),n=e(t.slice(o+1))),"string"==typeof i[s]&&(i[s]=[i[s]]),Array.isArray(i[s])?i[s].push(n):i[s]=n}return i}function B(t,e){const o=[];let i;for(i in t){const s=e?e+"["+i+"]":i,n=t[i];o.push(null!==n&&"object"==typeof n?B(n,s):encodeURIComponent(s)+"="+encodeURIComponent(n))}return o.join("&")}function z(t,e,o){const i=new XMLHttpRequest;i.open("GET",e),i.responseType="arraybuffer";for(const t in o)i.setRequestHeader(t,o[t]);i.onload=function(){const e=new Uint8Array(this.response),o=new Blob([e],{type:"image/png"}),i=(window.URL||window.webkitURL).createObjectURL(o);t.getImage().src=i},i.send()}class H{constructor(t,e){this.map=t,this.options=e}setOpacity(t){this.options.opacity=Number(t),this.layer&&this.layer.setOpacity&&this.layer.setOpacity(this.options.opacity)}}function N(t,e="EPSG:3857",o="EPSG:4326"){const[s,n]=i(t.coordinate,e,o);return{latLng:{lat:n,lng:s},lngLat:[s,n],pixel:{left:t.pixel[0],top:t.pixel[1]},source:t}}function W(t){const e=function({feature:t,dataProjection:e,featureProjection:o}){const i=(new l).readFeatures({type:"FeatureCollection",features:Array.isArray(t)?t:[t]},{dataProjection:e,featureProjection:o}),s=new _;return s.addFeatures(i),s}(t),o=e.getExtent(),i=s(o,t.featureProjection,t.dataProjection);return e.dispose(),i}function X(t){return{getBounds:()=>W(t),getCenter:()=>function(t){const e=W(t);return E(e)}(t)}}const Y={Point:"point",MultiPoint:"point",LineString:"line",MultiLineString:"line",Polygon:"polygon",MultiPolygon:"polygon",Circle:"point"},q={polygon:"path",line:"path",point:"circle"};function J(t,e){const o=O(t).slice();return o[3]=void 0!==e?e:1,o}function K(t,e={}){if(M(e)){return K(t,e(D(t)))}if(k(e)){const o=t.getGeometry(),i=o&&o.getType()||"Point",s={};if(!e.type){const t=Y[i],o="polygon"===t||"line"===t?"path":"html"in e||"className"in e?"icon":q[t];o&&(e.type=o)}if("path"===e.type||"circle"===e.type){const{radius:t,fill:o,fillColor:n,fillOpacity:r,strokeColor:a,stroke:l,strokeOpacity:c}={...e};o&&n&&"string"==typeof n&&"number"==typeof r&&(s.fill=new F({color:J(n,r)})),a&&"string"==typeof a&&"number"==typeof c&&(l||-1!==["MultiLineString","LineString"].indexOf(i))&&(s.stroke=new S({width:e.weight,color:J(a,c)})),"circle"===e.type&&"number"==typeof t&&(s.image=new x({radius:t,...s}))}else if("icon"===e.type){const t=e.html;if(t){const o={src:"data:image/svg+xml,"+escape(t),anchorXUnits:j.PIXELS,anchorYUnits:j.PIXELS,anchor:e.iconAnchor,imgSize:e.iconSize};s.image=new A(o)}}return new L(s)}}const Q={collapsible:!1};const $={collapsible:!1};class tt extends R{constructor(t){const e=new T,o=e.getContainer();super({...$,...t,element:o}),this.panelContainer=e}async addControl(t,e){const o=this.getMap(),i=this.panelContainer.newPositionContainer(e);if(i){const e=await t,s=e.element;s&&s.classList.add("webmap-ctrl"),e.setTarget(i),o.addControl(e)}}removeControl(t){this.getMap().removeControl(t)}getContainer(){return this.panelContainer.getContainer()}}class et{constructor(){this.options={target:"map"},this.layerAdapters=et.layerAdapters,this.controlAdapters=et.controlAdapters,this.emitter=new t,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this._mapClickEvents=[],this._forEachFeatureAtPixel=[],this._unselectCb=[],this._isLoaded=!1,this._positionMem={}}create(t){this.options={...t};const i={...{controls:[],view:new o({center:this.options.center,zoom:this.options.zoom,minZoom:this.options.minZoom,maxZoom:this.options.maxZoom,projection:this.displayProjection}),layers:[]},target:this.options.target||"map"};this.map=new e(i),this._panelControl=new tt,this.map.addControl(this._panelControl),this.map.set("_mapClickEvents",this._mapClickEvents),this.map.set("_forEachFeatureAtPixel",this._forEachFeatureAtPixel),this.map.set("_addUnselectCb",(t=>this._addUnselectCb(t))),this.emitter.emit("create",this),this._olView=this.map.getView(),this._isLoaded=!0,this._addMapListeners()}destroy(){this.map&&this.map.dispose()}getContainer(){if(this.options.target){let t;return"string"==typeof this.options.target?t=document.getElementById(this.options.target):this.options.target instanceof HTMLElement&&(t=this.options.target),t}}getControlContainer(){if(this._panelControl)return this._panelControl.getContainer();throw new Error("The ol-map-adapter ControlPanel has not been initialized yet")}setCenter(t){this._olView&&this._olView.setCenter(n(t))}getCenter(){if(this._olView){const t=this._olView.getCenter();if(t){return i(t,this.displayProjection,this.lonlatProjection)}}}setZoom(t){this._olView&&this._olView.setZoom(t)}getZoom(){if(this._olView)return this._olView.getZoom()}fitBounds(t,e={}){if(this._olView){const{padding:o,maxZoom:i,offset:n}=e,r=this.getZoom(),a=s(t,this.lonlatProjection,this.displayProjection),l={};i&&(l.maxZoom=i),o&&(l.padding=[o,o]),n&&(l.padding=n),this._olView.fit(a,l),this._emitMoveEndEvents({zoom:r})}}getBounds(){if(!this._olView)return;const t=this._olView.calculateExtent();return s(t,this.displayProjection,this.lonlatProjection)}setRotation(t){this._olView&&this._olView.setRotation(t)}removeLayer(t){this.map&&this.map.removeLayer(t)}showLayer(t){this.map&&this.map.addLayer(t)}hideLayer(t){this.map&&this.map.removeLayer(t)}setLayerOpacity(t,e){t.setOpacity&&t.setOpacity(Number(e))}setLayerOrder(t,e){t&&t.setZIndex&&t.setZIndex(e)}createControl(t,e){return function(t,e={},o){return new(function(i){function s(){const s=document.createElement("div");s.className=(e.addClass?e.addClass+" ":"")+"ol-unselectable"+(e.bar?" webmap-ctrl-group":"")+(e.margin?" ol-control-margin":"");const n=t.onAdd(o);n&&s.appendChild(n),i.call(this,{element:s})}return i&&(s.__proto__=i),(s.prototype=Object.create(R&&R.prototype)).constructor=s,s.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},s}(R))}(t,e,this)}createButtonControl(t){return function(t){return new(function(e){function o(){const 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);const i=document.createElement("div");i.className=(t.addClass?t.addClass+" ":"")+"ol-unselectable webmap-ctrl-group",i.appendChild(o),e.call(this,{element:i}),o.addEventListener("click",(()=>t.onClick()),!1)}return e&&(o.__proto__=e),(o.prototype=Object.create(R&&R.prototype)).constructor=o,o.prototype.handleRotateNorth=function(){this.getMap().getView().setRotation(0)},o}(R))}(t)}addControl(t,e){if(this._panelControl)return this._panelControl.addControl(t,e),t}removeControl(t){this._panelControl&&this._panelControl.removeControl(t)}onMapClick(t){const e=N(t);this.emitter.emit("preclick",e);this._callEachFeatureAtPixel(t,"click")||this._mapClickEvents.forEach((e=>{e(t)})),this.emitter.emit("click",e)}_callEachFeatureAtPixel(t,e){if(t&&t.pixel&&this._forEachFeatureAtPixel.length&&this.map){const o=this._forEachFeatureAtPixel.sort(((t,e)=>e[0]-t[0]));for(const i of o){if(i[1](t.pixel,t,e))return!0}}return!1}_emitMoveEndEvents(t){if(this._isLoaded){const e=this.getZoom();t.zoom!==e&&this.emitter.emit("zoomend")}}_addMapListeners(){const t=this.map;if(t){t.on("click",(t=>{this.onMapClick(t)})),t.on("pointermove",(t=>{this._callEachFeatureAtPixel(t,"hover")}));const e=this.getCenter(),o=this.getZoom();["movestart","moveend"].forEach((i=>{this._positionMem[i]={center:e,zoom:o},t.on(i,(()=>{this._emitPositionChangeEvent(i)}))})),this._olView&&(this._olView.on("change:resolution",(()=>{this.emitter.emit("zoom",this)})),this._olView.on("change:center",(()=>{this.emitter.emit("move",this)})))}}_addUnselectCb(t){for(const t of this._unselectCb)t();this._unselectCb.length=0,this._unselectCb.push(t)}_emitPositionChangeEvent(t){const e=this._positionMem[t];let o,i;e&&(o=e.center,i=e.zoom);const s=this.getCenter(),n=this.getZoom();if(i!==n){this.emitter.emit("movestart"===t?"zoomstart":"zoomend",this)}if(o&&s){const[e,i]=s,[n,r]=o;e===n&&i===r||this.emitter.emit(t,this)}else o!==s&&this.emitter.emit(t,this);this._positionMem[t]={center:s,zoom:n}}}et.layerAdapters={IMAGE:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){if(Object.assign(this.options,t),t.url){const e=void 0!==t.ratio?t.ratio:1,o={url:t.url,params:{...t.params},projection:void 0},i=t.updateWmsParams;o.imageLoadFunction=(e,o)=>{const s=o.split("?")[0],n=o.split("?")[1],{resource:r,BBOX:a,WIDTH:l,HEIGHT:c,...p}=G(n),h={resource:r,bbox:a,width:l,height:c,...p},u=B(i?i(h):p),m=t.headers,d=s+"?"+u;m?z(e,d,m):e.getImage().src=d};let s=u,n=d;if(e>1){o.ratio=e,o.serverType=f.MAPSERVER;class t extends m{renderFrame(t,o){return t.pixelRatio=e,super.renderFrame(t,o)}}class i extends u{createRenderer(){return new t(this)}}s=i;class r extends d{getImageInternal(t,o,i,s){return super.getImageInternal(t,o,e,s)}}n=r}const r=new s({source:new n(o),opacity:t.opacity,...Z(this.map,t),...t.nativeOptions});return this.layer=r,r}}},TILE:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){Object.assign(this.options,t);const e=[],o="string"==typeof t.subdomains?t.subdomains.split(""):t.subdomains;(null==o?void 0:o.length)?o.forEach((o=>{e.push(t.url.replace(/{s}/,o))})):e.push(t.url);const i={attributions:t.attribution?[t.attribution]:[],urls:e};t.crossOrigin&&(i.crossOrigin=t.crossOrigin);const s=new h(i),n=t.headers;n&&s.setTileLoadFunction(((t,e)=>{z(t,e,n)}));return new r({source:s,opacity:t.opacity,...Z(this.map,t),...t.nativeOptions})}},WMS:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e}addLayer(t){Object.assign(this.options,t);const e={url:t.url,params:{LAYERS:t.layers,VERSION:t.version},projection:void 0},o=t.updateWmsParams;o&&(e.tileLoadFunction=(e,i)=>{const s=i.split("?")[0],n=i.split("?")[1],{resource:r,BBOX:a,WIDTH:l,HEIGHT:c}=G(n),p=B(o({resource:r,bbox:a,width:l,height:c})),h=t.headers,u=s+"?"+p;h?z(e,u,h):e.getImage().src=u});const i=new a(e),s=new r({source:i,opacity:t.opacity,...Z(this.map,t),...t.nativeOptions});return this.layer=s,s}},OSM:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e,this.name="OpenStreetMap"}addLayer(t){Object.assign(this.options,t),this.options.name=this.name;return new r({source:new c({attributions:[p]}),...t.nativeOptions})}},GEOJSON:class extends H{constructor(t,e){super(t,e),this.map=t,this.options=e,this.selected=!1,this.displayProjection="EPSG:3857",this.lonlatProjection="EPSG:4326",this.vectorSource=new _,this._features=[],this._selectedFeatures=[],this._openedPopup=[],this._forEachFeatureAtPixel=[],this._mapClickEvents=[],this._styleCache={},this.displayProjection=t.getView().getProjection().getCode()}get addUnselectCb(){return this.map.get("_addUnselectCb")}get mapClickEvents(){return this.map.get("_mapClickEvents")}get forEachFeatureAtPixel(){return this.map.get("_forEachFeatureAtPixel")}addLayer(t){var e;Object.assign(this.options,t),this.paint=t.paint,this.selectedPaint=t.selectedPaint;const o=t.data;o&&this.addData(o),this.layer=new g({source:this.vectorSource,style:e=>{const o=[],i=e.getId(),s=void 0!==i&&this._styleCache[i];if(s)return s;const n=K(e,t.paint);n&&o.push(n);const r=this.options.labelField;if(r){const i=e.get(r),s=C(i)?String(i):"";if(s){const e=function(t,e){let o={font:"12px Calibri,sans-serif",overflow:!0,fill:new F({color:"#000"}),stroke:new S({color:"#fff",width:3})};return"point"===t&&(o={...o,placement:"point",textBaseline:"bottom",offsetY:20}),new L({text:new b(o)})}(t.type||"polygon");e.getText().setText(s),o.push(e)}}return void 0!==i&&(this._styleCache[i]=o),o},...Z(this.map,t),...t.nativeOptions});return(null===(e=t.interactive)||void 0===e||e)&&this._addEventListener(),this.layer}beforeRemove(){const t=this.forEachFeatureAtPixel;for(let e=t.length;e--;){const o=t[e][1];-1!==t.findIndex((t=>t[1]===o))&&t.splice(e,1)}this._forEachFeatureAtPixel.length=0;const e=this.mapClickEvents;for(let t=e.length;t--;){-1!==e.indexOf(e[t])&&e.splice(t,1)}this._mapClickEvents.length=0,this._removeAllPopup()}clearLayer(t){if(this.unselect(),t){const e=this.vectorSource.getFeatures().values();let o;for(;!(o=e.next()).done;){t(D(o.value))&&this.vectorSource.removeFeature(o.value)}}else this.vectorSource.clear()}setData(t){this.clearLayer(),this.addData(t)}addData(t){const e=this.options.srs,o="EPSG:"+(null!=e?e:"4326"),i=(new l).readFeatures(t,{dataProjection:o,featureProjection:this.displayProjection});if(this._features=this._features.concat(i),this._filterFun)this.filter(this._filterFun);else if(this.vectorSource.addFeatures(i),this.options.popup)for(const t of this._features)this._openPopup({feature:t,type:"api",options:this.options.popupOptions})}select(t){if("function"==typeof t){this._features.filter((e=>t(this._createLayerDefOpts(D(e))))).forEach((t=>{this._selectFeature(t)}))}else this.selected||(this.selected=!0,this.selectedPaint&&this.setPaintEachLayer(this.selectedPaint))}unselect(t){let e=this._selectedFeatures;"function"==typeof t?e=this._selectedFeatures.filter((e=>t(this._createLayerDefOpts(D(e))))):this.selected&&(this.selected=!1);for(const t of e)this._unselectFeature(t);this._removeAllPopup()}getLayers(){return this._features.map((t=>this._createLayerDefOpts(D(t))))}getSelected(){return this._selectedFeatures.map((t=>this._createLayerDefOpts(D(t))))}filter(t){this._filterFun=t;const e=this._features,o=t?e.filter((e=>t(this._createLayerDefOpts(D(e))))):e;this.vectorSource.clear();const i=o.length;for(let t=0;t<i;t++)this.vectorSource.addFeature(o[t]);return o.map((t=>this._createLayerDefOpts(D(t))))}cleanFilter(){this.filter()}getExtent(){return this.getBounds()}getBounds(){if(this.layer){const t=this.layer.getSource().getExtent();return s(t,this.displayProjection,this.lonlatProjection)}}_createLayerDefOpts(t){return{target:this,feature:t,...X({feature:t,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})}}setPaintEachLayer(t){if(this.layer){this.layer.getSource().getFeatures().forEach((e=>{const o=K(e,t);o&&e.setStyle(o)}))}}_addEventListener(){var t;const e=this.forEachFeatureAtPixel,o=[this.options.order||0,(t,e,o)=>this._onFeatureAtPixel(t,e,o)];this._forEachFeatureAtPixel.push(o),e.push(o);(null===(t=this.options.unselectOnClick)||void 0===t||t)&&(this._mapClickEvents.push((()=>this.unselect())),this.mapClickEvents.push((()=>this.unselect())))}_onFeatureAtPixel(t,e,o){const i=t&&this.map.getFeaturesAtPixel(t,{layerFilter:t=>t===this.layer})[0],s=(t=>({layer:this,event:N(t),source:t}))(e);if(i){const t={...s,...this._createLayerDefOpts(D(i))};let e=-1!==this._selectedFeatures.indexOf(i);return this.options.selectable&&("hover"===o&&this.options.selectOnHover||"click"===o)&&(e?this.options&&this.options.unselectOnSecondClick&&(this._unselectFeature(i),e=!1):(this._selectFeature(i,t.event.lngLat),e=!0)),"click"===o&&this.options.onClick&&this.options.onClick({selected:e,...t}),"hover"===o&&(this._mouseOver=!0,this.options.onMouseOver&&this.options.onMouseOver(t)),!0}return"hover"===o&&this._mouseOver&&(this._mouseOver=!1,this.options.onMouseOut&&this.options.onMouseOut(s),this.options.selectOnHover&&this.unselect()),!1}_selectFeature(t,e){this.addUnselectCb((()=>this._unselectFeature(t)));const o=this.options,i=e?"click":"api";if(o&&!o.multiselect&&this._selectedFeatures.forEach((t=>this._unselectFeature(t))),this._selectedFeatures.push(t),this.selected=!0,o&&o.selectedPaint){const e=K(t,o.selectedPaint);e&&t.setStyle(e)}if(this.options.popupOnSelect&&this._openPopup({coordinates:e,feature:t,options:this.options.popupOptions,type:"click"}),this.options.onSelect){const e=D(t);this.options.onSelect({layer:this,features:[],type:i,...X({feature:e,dataProjection:this.lonlatProjection,featureProjection:this.displayProjection})})}}_unselectFeature(t){const e=this._selectedFeatures.indexOf(t);if(-1!==e){this._selectedFeatures.splice(e,1);const o=this._openedPopup.find((e=>e[0]===t));o&&this._removePopup(o[1])}if(this.selected=this._selectedFeatures.length>0,this.options&&this.options.paint){const e=K(t,this.options.paint);e&&t.setStyle(e)}}async _openPopup({coordinates:t,feature:e,options:o={},type:s}){const n=this.map;if(!n)return;let r;const a=[],l=()=>{r&&this._removePopup(r)},{createPopupContent:c,popupContent:p}=o,h=D(e),u=c?await c({close:l,onClose:t=>{a.push(t)},type:s,...this._createLayerDefOpts(h)}):p;if(t=t||h&&function(t){return"Polygon"===t.geometry.type?w(t.geometry.coordinates):"Point"===t.geometry.type?t.geometry.coordinates:(e=v(t)).reduce(((t,o)=>[t[0]+o[0]/e.length,t[1]+o[1]/e.length]),[0,0]);var e}(h),u&&t){const s="string"==typeof u?function(t){const e=document.createElement("div");return e.innerHTML=t,e}(u):u,c=this._createPopupElement({...o,popupContent:s,close:l});r=new y({element:c}),r.setPosition(i(t,this.lonlatProjection,this.displayProjection)),n.addOverlay(r),this._openedPopup.push([e,r,a])}}_createPopupElement({closeButton:t,popupContent:e,maxWidth:o,minWidth:i,close:s}){t=null!=t?t:!this.options.selectOnHover;const n=P("div","ol-popup");if(o&&(n.style.maxWidth=o+"px"),i&&(n.style.minWidth=i+"px"),t){const t=P("a","ol-popup-closer",n);t.setAttribute("href","#"),t.addEventListener("click",s)}return P("div","popup-content",n).appendChild(e),n}_removeAllPopup(){const t=[...this._openedPopup];this._openedPopup=[];for(const e of t)this._removePopup(e[1])}_removePopup(t){var e,o;const i=this.map;if(i){i.removeOverlay(t);const s=this._openedPopup.findIndex((e=>e[1]===t));if(-1!==s){const[t,,i]=this._openedPopup[s],n=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o;for(const e of i)e(this._createLayerDefOpts(D(t)));i.length=0,n&&this._unselectFeature(t),this._openedPopup.splice(s,1)}}}}},et.controlAdapters={ZOOM:class extends I{constructor(...t){super(...t),this.element.classList.remove("ol-control"),this.element.classList.add("webmap-ctrl-group")}},ATTRIBUTION:class extends V{constructor(t){super({...Q,...t})}}};var ot=et;export{ot as default}; | ||
//# sourceMappingURL=ol-map-adapter.esm-bundler.prod.js.map |
{ | ||
"name": "@nextgis/ol-map-adapter", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"_priority": 16, | ||
@@ -12,7 +12,7 @@ "description": "", | ||
"dependencies": { | ||
"@nextgis/control-container": "^1.7.0", | ||
"@nextgis/control-container": "^1.8.0", | ||
"@nextgis/dom": "^1.7.0", | ||
"@nextgis/paint": "^1.7.0", | ||
"@nextgis/properties-filter": "^1.7.0", | ||
"@nextgis/webmap": "^1.7.0", | ||
"@nextgis/webmap": "^1.8.0", | ||
"@types/events": "^3.0.0", | ||
@@ -66,3 +66,3 @@ "@types/polylabel": "^1.0.5", | ||
}, | ||
"gitHead": "a3113b03e87540abf798c1151d3243a1e20c8607" | ||
"gitHead": "9d65a0f80bff7c2a9fc04229bef131cec5c7e752" | ||
} |
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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14084182
83118
Updated@nextgis/webmap@^1.8.0