@nextgis/ngw-map 1.10.0 → 1.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.10.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.11.7; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { deepmerge, deprecatedWarn, defined, isObject } from '@nextgis/utils';
@@ -1,2 +1,2 @@
1
- import{EventEmitter as e}from"events";import t from"@nextgis/cancelable-promise";import{deepmerge as s,deprecatedWarn as r,defined as o,isObject as i}from"@nextgis/utils";import{WebMap as n}from"@nextgis/webmap";export*from"@nextgis/webmap";import{NgwKit as a,createNgwLayerAdapter as c,fetchNgwLayerItem as h,fetchNgwLayerItems as d,fetchNgwLayerFeature as l,fetchNgwLayerFeatureCollection as m,fetchIdentifyItem as u,fetchIdentifyGeoJson as y,fetchNgwResourceExtent as p,sendIdentifyRequest as f,getCompanyLogo as g,getIdentifyItems as w,createIdentifyItem as L}from"@nextgis/ngw-kit";import{getIcon as I}from"@nextgis/icons";import _ from"@nextgis/ngw-connector";import{QmsKit as b}from"@nextgis/qms-kit";function N(e,t,s,r){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push({...s,resource:t});else if(Array.isArray(t)){const[o,i]=t;e.push({...s,resource:o,id:i,...r})}else"object"==typeof t&&e.push({...s,...t,...r})}const v={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};class F extends n{constructor(t){super(function(e){const t=[new b];return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new _({baseUrl:e.baseUrl||"",auth:e.auth}),(e=s(v,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new a({connector:e.connector,auth:e.auth})),{...e,starterKits:t,create:!1}}(t)),this.emitter=new e,this._ngwLayers={},this._promises={select:[],identify:[]},t.connector&&(this.connector=t.connector),this._createWebMap().then((()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()}))}async addControl(e,t,s){return await this.onLoad("controls:create"),super.addControl(e,t,s)}async addNgwLayer(e){await this.onMapLoad();const{keyname:t,resourceId:s}=e;(t||void 0!==s)&&r("set `resource` options instead of `keyname` or `resourceId`");const n=e.resource;if(!t&&!s&&!n)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(o(this.options.baseUrl))try{o(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},o(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=c(e,this,this.connector),s={visibility:!0,...e,...e.adapterOptions},r=await this.addLayer(t,s),i=r&&this.getLayerId(r);if(r&&i&&(this._ngwLayers[i]={layer:r,resourceId:r.resourceId},r.options.name=r.options.name||r.item&&r.item.resource.display_name,r.options.baselayer)){if(this.getActiveBaseLayer())return r}return r}catch(e){const r=i(n)&&"id"in n?n.id:t||s||n;console.error(`Can't add NGW layer ${r}.`,e)}}fit(){const{center:e,zoom:t,bounds:s}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):s&&this.fitBounds(s)}fetchNgwLayerItem(e){return h({connector:this.connector,...e})}fetchNgwLayerItems(e){return d({connector:this.connector,...e})}fetchNgwLayerFeature(e){return l({connector:this.connector,...e})}fetchNgwLayerFeatures(e){return m({connector:this.connector,...e})}fetchIdentifyItem(e,t){const s=u({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",s),s}fetchIdentifyGeoJson(e,s=!1){const r=y({identify:e,connector:this.connector,multiple:s});return r&&"then"in r?(this._addPromise("identify",r),r):t.resolve(r)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}async getNgwLayers(){return await this.onLoad(),this._ngwLayers}async getNgwLayerByResourceId(e){for(const t in this._ngwLayers){const s=this._ngwLayers[t];if(s.resourceId===e)return s&&s.layer;if(s.layer.getIdentificationIds){const t=await s.layer.getIdentificationIds();if(t&&t.some((t=>t===e)))return s.layer}if(s.layer.getDependLayers){const t=s.layer.getDependLayers().find((t=>t.item&&t.item.parentId===e));if(t)return t.layer}}}async fitLayer(e,t){let s;s="string"==typeof e||"number"==typeof e?String(s):e.id;const r=s&&this._ngwLayers[s];if(r)if(r.layer.getBounds){const e=await r.layer.getBounds();e&&this.fitBounds(e,t)}else{let e;if(r.layer.item)e=r.layer.item;else{const t=r.resourceId;e=await this.connector.getResource(t)}e&&p(e,this.connector).then((e=>{e&&this.fitBounds(e,t)}))}else super.fitLayer(e,t)}async zoomToLayer(e){return this.fitLayer(e)}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this.emitter.listenerCount("ngw:select")&&this._selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this.emitter.listenerCount("ngw:select")&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.emitter.removeListener("click",this._selectFromNgwVector),this.$$selectFromNgwRaster=void 0,this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach((e=>{const t=this._promises[e];t&&(t.forEach((e=>e.cancel())),this._promises[e]=[])}))}_addPromise(e,t){const s=this._promises[e];if(s&&-1===s.indexOf(t)){const e=()=>{const e=s.indexOf(t);-1!==e&&s.splice(e,1)};t.then(e),t.catch(e),s.push(t)}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}async _createWebMap(){await this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&N(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const s of this.options.resources){const r={};t||(r.fit=!1),N(e,s,{},r)}for(const t of e)try{await this.addNgwLayer(t)}catch(e){console.warn(e)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const s={qmsId:e};t&&(s.id=t),this.addBaseLayer("QMS",s)}_selectFromNgwVector(e){const t=e.layer,s=t.item&&t.item.resource.id,r=e.feature;if(void 0!==s&&r){const e=r.id;if(e){const t={featureCount:1,[s]:{featureCount:1,features:[{id:Number(e),fields:r.properties||{},label:`#${s}`,layerId:Number(s),parent:"",geom:r.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify({...t,resources:[s],sourceType:"vector"})),t}}}async _selectFromNgwRaster(e){this._emitStatusEvent("ngw:preselect");const t=[],s=Object.values(this._ngwLayers);s.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1)),s.forEach((e=>{const s=e.layer,r="function"==typeof s.getIdentificationIds&&s.getIdentificationIds;r&&s.options.selectable&&this.isLayerVisible(s)&&t.push(r.call(s))}));const r=Promise.all(t),o=await r,i=[];if(o.forEach((e=>{e&&e.forEach((e=>i.push(e)))})),!i.length)return void this._emitStatusEvent("ngw:select",null);const n=this.options.pixelRadius||10,a=this.getCenter();let c=this.getZoom();if(c=void 0!==c?c:20,!a||!c)return void this._emitStatusEvent("ngw:select",null);const h=function(e,t,s){return(s=null!=s?s:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(a,c,n),d=f(e,{layers:i,connector:this.connector,radius:h}).then((t=>(this._emitStatusEvent("ngw:select",this._prepareToIdentify({...t,resources:i,sourceType:"raster",event:e})),t)));return this._addPromise("select",d),d}_prepareToIdentify(e){return{...e,getIdentifyItems:()=>w(e,!0).map((e=>L({feature:e.feature,connector:this.connector})))}}async _whiteLabel(){const e=this.getContainer();if(e){const t=await g(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}}async function O(e){return new F(e).onLoad()}F.getIcon=I;export{F as NgwMap,O as createNgwMap};
1
+ import{EventEmitter as e}from"events";import t from"@nextgis/cancelable-promise";import{deepmerge as s,deprecatedWarn as r,defined as o,isObject as i}from"@nextgis/utils";import{WebMap as n}from"@nextgis/webmap";export*from"@nextgis/webmap";import{NgwKit as a,createNgwLayerAdapter as c,fetchNgwLayerItem as h,fetchNgwLayerItems as d,fetchNgwLayerFeature as l,fetchNgwLayerFeatureCollection as m,fetchIdentifyItem as u,fetchIdentifyGeoJson as y,fetchNgwResourceExtent as p,sendIdentifyRequest as f,getCompanyLogo as g,getIdentifyItems as w,createIdentifyItem as L}from"@nextgis/ngw-kit";import{getIcon as I}from"@nextgis/icons";import _ from"@nextgis/ngw-connector";import{QmsKit as b}from"@nextgis/qms-kit";function N(e,t,s,r){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push({...s,resource:t});else if(Array.isArray(t)){const[o,i]=t;e.push({...s,resource:o,id:i,...r})}else"object"==typeof t&&e.push({...s,...t,...r})}const v={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};class F extends n{constructor(t){super(function(e){const t=[new b];return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new _({baseUrl:e.baseUrl||"",auth:e.auth}),(e=s(v,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new a({connector:e.connector,auth:e.auth})),{...e,starterKits:t,create:!1}}(t)),this.emitter=new e,this._ngwLayers={},this._promises={select:[],identify:[]},t.connector&&(this.connector=t.connector),this._createWebMap().then((()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()}))}async addControl(e,t,s){return await this.onLoad("controls:create"),super.addControl(e,t,s)}async addNgwLayer(e){await this.onMapLoad();const{keyname:t,resourceId:s}=e;(t||void 0!==s)&&r("set `resource` options instead of `keyname` or `resourceId`");const n=e.resource;if(!t&&!s&&!n)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(o(this.options.baseUrl))try{o(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},o(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=c(e,this,this.connector),s={visibility:!0,...e,...e.adapterOptions},r=await this.addLayer(t,s),i=r&&this.getLayerId(r);if(r&&i&&(this._ngwLayers[i]={layer:r,resourceId:r.resourceId},r.options.name=r.options.name||r.item&&r.item.resource.display_name,r.options.baselayer)){if(this.getActiveBaseLayer())return r}return r}catch(a){const e=i(n)&&"id"in n?n.id:t||s||n;console.error(`Can't add NGW layer ${e}.`,a)}}fit(){const{center:e,zoom:t,bounds:s}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):s&&this.fitBounds(s)}fetchNgwLayerItem(e){return h({connector:this.connector,...e})}fetchNgwLayerItems(e){return d({connector:this.connector,...e})}fetchNgwLayerFeature(e){return l({connector:this.connector,...e})}fetchNgwLayerFeatures(e){return m({connector:this.connector,...e})}fetchIdentifyItem(e,t){const s=u({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",s),s}fetchIdentifyGeoJson(e,s=!1){const r=y({identify:e,connector:this.connector,multiple:s});return r&&"then"in r?(this._addPromise("identify",r),r):t.resolve(r)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}async getNgwLayers(){return await this.onLoad(),this._ngwLayers}async getNgwLayerByResourceId(e){for(const t in this._ngwLayers){const s=this._ngwLayers[t];if(s.resourceId===e)return s&&s.layer;if(s.layer.getIdentificationIds){const t=await s.layer.getIdentificationIds();if(t&&t.some((t=>t===e)))return s.layer}if(s.layer.getDependLayers){const t=s.layer.getDependLayers().find((t=>t.item&&t.item.parentId===e));if(t)return t.layer}}}async fitLayer(e,t){let s;s="string"==typeof e||"number"==typeof e?String(s):e.id;const r=s&&this._ngwLayers[s];if(r)if(r.layer.getBounds){const e=await r.layer.getBounds();e&&this.fitBounds(e,t)}else{let e;if(r.layer.item)e=r.layer.item;else{const t=r.resourceId;e=await this.connector.getResource(t)}e&&p(e,this.connector).then((e=>{e&&this.fitBounds(e,t)}))}else super.fitLayer(e,t)}async zoomToLayer(e){return this.fitLayer(e)}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this.emitter.listenerCount("ngw:select")&&this._selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this.emitter.listenerCount("ngw:select")&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.emitter.removeListener("click",this._selectFromNgwVector),this.$$selectFromNgwRaster=void 0,this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach((e=>{const t=this._promises[e];t&&(t.forEach((e=>e.cancel())),this._promises[e]=[])}))}_addPromise(e,t){const s=this._promises[e];if(s&&-1===s.indexOf(t)){const e=()=>{const e=s.indexOf(t);-1!==e&&s.splice(e,1)};t.then(e),t.catch(e),s.push(t)}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}async _createWebMap(){await this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&N(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const r of this.options.resources){const s={};t||(s.fit=!1),N(e,r,{},s)}for(const r of e)try{await this.addNgwLayer(r)}catch(s){console.warn(s)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const s={qmsId:e};t&&(s.id=t),this.addBaseLayer("QMS",s)}_selectFromNgwVector(e){const t=e.layer,s=t.item&&t.item.resource.id,r=e.feature;if(void 0!==s&&r){const e=r.id;if(e){const t={featureCount:1,[s]:{featureCount:1,features:[{id:Number(e),fields:r.properties||{},label:`#${s}`,layerId:Number(s),parent:"",geom:r.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify({...t,resources:[s],sourceType:"vector"})),t}}}async _selectFromNgwRaster(e){this._emitStatusEvent("ngw:preselect");const t=[],s=Object.values(this._ngwLayers);s.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1)),s.forEach((e=>{const s=e.layer,r="function"==typeof s.getIdentificationIds&&s.getIdentificationIds;r&&s.options.selectable&&this.isLayerVisible(s)&&t.push(r.call(s))}));const r=Promise.all(t),o=await r,i=[];if(o.forEach((e=>{e&&e.forEach((e=>i.push(e)))})),!i.length)return void this._emitStatusEvent("ngw:select",null);const n=this.options.pixelRadius||10,a=this.getCenter();let c=this.getZoom();if(c=void 0!==c?c:20,!a||!c)return void this._emitStatusEvent("ngw:select",null);const h=function(e,t,s){return(s=null!=s?s:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(a,c,n),d=f(e,{layers:i,connector:this.connector,radius:h}).then((t=>(this._emitStatusEvent("ngw:select",this._prepareToIdentify({...t,resources:i,sourceType:"raster",event:e})),t)));return this._addPromise("select",d),d}_prepareToIdentify(e){return{...e,getIdentifyItems:()=>w(e,!0).map((e=>L({feature:e.feature,connector:this.connector})))}}async _whiteLabel(){const e=this.getContainer();if(e){const t=await g(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}}async function O(e){return new F(e).onLoad()}F.getIcon=I;export{F as NgwMap,O as createNgwMap};
2
2
  //# sourceMappingURL=ngw-map.esm-bundler.prod.js.map
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-map; version: 1.10.0; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-map; version: 1.11.7; author: NextGIS */
2
2
  var NgwMap = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -106,10 +106,14 @@ var NgwMap = (function (exports) {
106
106
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
107
107
  }
108
108
 
109
- function __spreadArray(to, from) {
110
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
111
- to[j] = from[i];
112
- return to;
109
+ function __spreadArray(to, from, pack) {
110
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
111
+ if (ar || !(i in from)) {
112
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
113
+ ar[i] = from[i];
114
+ }
115
+ }
116
+ return to.concat(ar || Array.prototype.slice.call(from));
113
117
  }
114
118
 
115
119
  function __asyncValues(o) {
@@ -1113,7 +1117,7 @@ var NgwMap = (function (exports) {
1113
1117
 
1114
1118
  /** @internal */
1115
1119
  function deprecatedWarn(message) {
1116
- console.warn("DEPRECATED WARN: " + message);
1120
+ console.warn("DEPRECATED WARN: ".concat(message));
1117
1121
  }
1118
1122
 
1119
1123
  // based on https://github.com/bvaughn/debounce-decorator
@@ -1409,7 +1413,7 @@ var NgwMap = (function (exports) {
1409
1413
  return true;
1410
1414
  if (iLike && a.toUpperCase() === b.toUpperCase())
1411
1415
  return true;
1412
- var re = ("^" + reEscape(a) + "$").replace(/%/g, '.*').replace('_', '.');
1416
+ var re = "^".concat(reEscape(a), "$").replace(/%/g, '.*').replace('_', '.');
1413
1417
  return new RegExp(re, iLike ? 'i' : '').exec(b) !== null;
1414
1418
  }
1415
1419
  var operationsAliases = {
@@ -1628,9 +1632,6 @@ var NgwMap = (function (exports) {
1628
1632
  line: 'path',
1629
1633
  point: 'circle',
1630
1634
  };
1631
- /**
1632
- * @internal
1633
- */
1634
1635
  var typeAlias = {
1635
1636
  Point: 'point',
1636
1637
  LineString: 'line',
@@ -2649,7 +2650,7 @@ var NgwMap = (function (exports) {
2649
2650
  }
2650
2651
  layerId = String(_adapter.id);
2651
2652
  if (this._layers[layerId]) {
2652
- throw Error("layer with id '" + layerId + "' already exist");
2653
+ throw Error("layer with id '".concat(layerId, "' already exist"));
2653
2654
  }
2654
2655
  if (!layerId) return [3 /*break*/, 8];
2655
2656
  this._layers[layerId] = _adapter;
@@ -4050,12 +4051,16 @@ var NgwMap = (function (exports) {
4050
4051
  var _this = _super.call(this) || this;
4051
4052
  _this.name = 'NetworkError';
4052
4053
  Object.setPrototypeOf(_this, NetworkError.prototype);
4053
- _this.message = "Unable to request " + url + ".\n Possibly invalid NGW URL entered or CORS not configured to get request from " + location.origin; // /control-panel/cors
4054
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
4054
4055
  return _this;
4055
4056
  }
4056
4057
  return NetworkError;
4057
4058
  }(Error));
4058
4059
 
4060
+ function isObject(val) {
4061
+ return Object.prototype.toString.call(val) === '[object Object]';
4062
+ }
4063
+
4059
4064
  var loadData;
4060
4065
  // @ts-ignore
4061
4066
  {
@@ -4091,7 +4096,7 @@ var NgwMap = (function (exports) {
4091
4096
  }
4092
4097
  };
4093
4098
  xhr.onload = function () {
4094
- if ([401, 403, 404, 500].indexOf(xhr.status) !== -1) {
4099
+ if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
4095
4100
  error(new NgwError(getResponseText()));
4096
4101
  }
4097
4102
  processingResponse();
@@ -4146,7 +4151,7 @@ var NgwMap = (function (exports) {
4146
4151
  data = new FormData();
4147
4152
  data.append('file', options.file);
4148
4153
  if (options.data) {
4149
- for (var d in data) {
4154
+ for (var d in options.data) {
4150
4155
  data.append(d, data[d]);
4151
4156
  }
4152
4157
  }
@@ -4238,10 +4243,6 @@ var NgwMap = (function (exports) {
4238
4243
  }
4239
4244
  }
4240
4245
 
4241
- function isObject(val) {
4242
- return Object.prototype.toString.call(val) === '[object Object]';
4243
- }
4244
-
4245
4246
  var exclude = ['description'];
4246
4247
  /**
4247
4248
  * @remarks
@@ -4492,7 +4493,7 @@ var NgwMap = (function (exports) {
4492
4493
  ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
4493
4494
  var _this = this;
4494
4495
  var promise = function () {
4495
- return _this.connector.get('resource.item', requestOptions, { id: id }).catch();
4496
+ return _this.connector.get('resource.item', requestOptions, { id: id });
4496
4497
  };
4497
4498
  return this.cache
4498
4499
  .add('resource.item', promise, {
@@ -4539,7 +4540,7 @@ var NgwMap = (function (exports) {
4539
4540
  .then(function (apiItems) {
4540
4541
  var apiItem = apiItems && apiItems[opt.name];
4541
4542
  if (apiItem) {
4542
- apiItem = __spreadArray([], apiItem);
4543
+ apiItem = __spreadArray([], apiItem, true);
4543
4544
  var url = apiItem.shift();
4544
4545
  if (apiItem.length) {
4545
4546
  var replaceParams = {};
@@ -4561,12 +4562,12 @@ var NgwMap = (function (exports) {
4561
4562
  if (Array.isArray(paramList)) {
4562
4563
  delete params.paramList;
4563
4564
  paramList.forEach(function (x) {
4564
- paramArray_1.push(x[0] + "=" + x[1]);
4565
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
4565
4566
  });
4566
4567
  }
4567
4568
  for (var p in params) {
4568
4569
  if (apiItem.indexOf(p) === -1) {
4569
- paramArray_1.push(p + "=" + params[p]);
4570
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
4570
4571
  }
4571
4572
  }
4572
4573
  if (paramArray_1.length) {
@@ -4700,7 +4701,7 @@ var NgwMap = (function (exports) {
4700
4701
  headers: this.getAuthorizationHeaders(credentials),
4701
4702
  // withCredentials: true
4702
4703
  };
4703
- // Do not use request('auth.current_user') to avoid circular-references
4704
+ // Do not use apiRequest('auth.current_user') to avoid circular-references
4704
4705
  return this.makeQuery('/api/component/auth/current_user', {}, options)
4705
4706
  .then(function (data) {
4706
4707
  _this.user = data;
@@ -4727,7 +4728,7 @@ var NgwMap = (function (exports) {
4727
4728
  credentials = credentials || this.options.auth;
4728
4729
  if (credentials) {
4729
4730
  var login = credentials.login, password = credentials.password;
4730
- var str = unescape(encodeURIComponent(login + ":" + password));
4731
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
4731
4732
  // @ts-ignore
4732
4733
  {
4733
4734
  return window.btoa(str);
@@ -5012,7 +5013,7 @@ var NgwMap = (function (exports) {
5012
5013
  if (value) {
5013
5014
  var propElem = document.createElement('div');
5014
5015
  element_1.appendChild(propElem);
5015
- propElem.innerHTML = "<span>" + x.display_name + "</span>: " + value + "<span></span>";
5016
+ propElem.innerHTML = "<span>".concat(x.display_name, "</span>: ").concat(value, "<span></span>");
5016
5017
  }
5017
5018
  }
5018
5019
  });
@@ -5021,7 +5022,7 @@ var NgwMap = (function (exports) {
5021
5022
  for (var p in feature.properties) {
5022
5023
  var propElem = document.createElement('div');
5023
5024
  element_1.appendChild(propElem);
5024
- propElem.innerHTML = "<span>" + p + "</span>: " + feature.properties[p] + "<span></span>";
5025
+ propElem.innerHTML = "<span>".concat(p, "</span>: ").concat(feature.properties[p], "<span></span>");
5025
5026
  }
5026
5027
  }
5027
5028
  return element_1;
@@ -5204,15 +5205,15 @@ var NgwMap = (function (exports) {
5204
5205
  return b;
5205
5206
  });
5206
5207
  var v = vStart + value + vEnd;
5207
- return ["" + isFldStr + field_ + "__" + operation, v];
5208
+ return ["".concat(isFldStr).concat(field_, "__").concat(operation), v];
5208
5209
  };
5209
5210
  if (logic === 'any') {
5210
5211
  filters_.forEach(function (f) {
5211
5212
  if (isPropertyFilter(f)) {
5212
- _queries.push(fetchNgwLayerItemsRequest(__assign(__assign({}, opt), { paramList: __spreadArray(__spreadArray([], _parentAllParams, true), [createParam(f)]) })));
5213
+ _queries.push(fetchNgwLayerItemsRequest(__assign(__assign({}, opt), { paramList: __spreadArray(__spreadArray([], _parentAllParams, true), [createParam(f)], false) })));
5213
5214
  }
5214
5215
  else {
5215
- createFeatureFieldFilterQueries(__assign(__assign({}, opt), { filters: f }), _queries, __spreadArray([], _parentAllParams));
5216
+ createFeatureFieldFilterQueries(__assign(__assign({}, opt), { filters: f }), _queries, __spreadArray([], _parentAllParams, true));
5216
5217
  }
5217
5218
  });
5218
5219
  }
@@ -5231,11 +5232,11 @@ var NgwMap = (function (exports) {
5231
5232
  if (propertiesFilterList.length) {
5232
5233
  for (var _a = 0, propertiesFilterList_1 = propertiesFilterList; _a < propertiesFilterList_1.length; _a++) {
5233
5234
  var x = propertiesFilterList_1[_a];
5234
- createFeatureFieldFilterQueries(__assign(__assign({}, opt), { filters: x }), _queries, __spreadArray(__spreadArray([], _parentAllParams, true), filters_2));
5235
+ createFeatureFieldFilterQueries(__assign(__assign({}, opt), { filters: x }), _queries, __spreadArray(__spreadArray([], _parentAllParams, true), filters_2, true));
5235
5236
  }
5236
5237
  }
5237
5238
  else {
5238
- _queries.push(fetchNgwLayerItemsRequest(__assign(__assign({}, opt), { paramList: __spreadArray(__spreadArray([], _parentAllParams, true), filters_2) })));
5239
+ _queries.push(fetchNgwLayerItemsRequest(__assign(__assign({}, opt), { paramList: __spreadArray(__spreadArray([], _parentAllParams, true), filters_2, true) })));
5239
5240
  }
5240
5241
  }
5241
5242
  return CancelablePromise.all(_queries).then(function (itemsParts) {
@@ -5254,7 +5255,7 @@ var NgwMap = (function (exports) {
5254
5255
  var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
5255
5256
  return x + ' ' + y;
5256
5257
  });
5257
- return "POLYGON((" + polygon.join(', ') + "))";
5258
+ return "POLYGON((".concat(polygon.join(', '), "))");
5258
5259
  }
5259
5260
  function fetchNgwLayerItemsRequest(options) {
5260
5261
  var params = __assign({}, FEATURE_REQUEST_PARAMS);
@@ -5309,7 +5310,7 @@ var NgwMap = (function (exports) {
5309
5310
  dt_1.push(x);
5310
5311
  });
5311
5312
  }
5312
- fields[f] = new (Date.bind.apply(Date, __spreadArray([void 0], dt_1)))().toISOString();
5313
+ fields[f] = new (Date.bind.apply(Date, __spreadArray([void 0], dt_1, false)))().toISOString();
5313
5314
  }
5314
5315
  }
5315
5316
  };
@@ -5714,7 +5715,7 @@ var NgwMap = (function (exports) {
5714
5715
  }
5715
5716
  }
5716
5717
  if (adapter === 'WMS') {
5717
- url = baseUrl + "/api/resource/" + resourceId + "/wms";
5718
+ url = "".concat(baseUrl, "/api/resource/").concat(resourceId, "/wms");
5718
5719
  var adapterOptions = options.adapterOptions;
5719
5720
  return {
5720
5721
  url: url,
@@ -5738,12 +5739,12 @@ var NgwMap = (function (exports) {
5738
5739
  };
5739
5740
  }
5740
5741
  if (adapter === 'TERRAIN') {
5741
- url = baseUrl + ("/api/resource/" + resourceId + "/terrain_provider");
5742
+ url = baseUrl + "/api/resource/".concat(resourceId, "/terrain_provider");
5742
5743
  // `/api/resource/${resourceId}/terrain_provider/{z}/{x}/{y}.terrain`;
5743
5744
  return { url: url, adapter: adapter };
5744
5745
  }
5745
5746
  if (adapter === 'MODEL_3D') {
5746
- url = baseUrl + ("/api/component/model_3d/" + resourceId + "/data.glb");
5747
+ url = baseUrl + "/api/component/model_3d/".concat(resourceId, "/data.glb");
5747
5748
  return { url: url };
5748
5749
  }
5749
5750
  if (adapter === 'TILE') {
@@ -6029,7 +6030,7 @@ var NgwMap = (function (exports) {
6029
6030
  });
6030
6031
  };
6031
6032
  TreeHelper.prototype.getChildren = function () {
6032
- return __spreadArray([], this._children);
6033
+ return __spreadArray([], this._children, true);
6033
6034
  };
6034
6035
  return TreeHelper;
6035
6036
  }());
@@ -6551,7 +6552,7 @@ var NgwMap = (function (exports) {
6551
6552
  return options;
6552
6553
  };
6553
6554
  NgwWebmapItem.prototype.getChildren = function (item) {
6554
- return __spreadArray([], item.children).reverse();
6555
+ return __spreadArray([], item.children, true).reverse();
6555
6556
  };
6556
6557
  NgwWebmapItem.prototype._mapScaleToZoomLevel = function (scale) {
6557
6558
  return setScaleRatio(scale);
@@ -6871,16 +6872,25 @@ var NgwMap = (function (exports) {
6871
6872
  }
6872
6873
  }
6873
6874
  NgwWebmapLayerAdapter.prototype.addLayer = function (options) {
6875
+ var _a, _b;
6874
6876
  return __awaiter(this, void 0, void 0, function () {
6875
- var _a;
6876
- return __generator(this, function (_b) {
6877
- switch (_b.label) {
6877
+ var _c, extentConstrained;
6878
+ return __generator(this, function (_d) {
6879
+ switch (_d.label) {
6878
6880
  case 0:
6879
6881
  this.options = __assign(__assign({}, this.options), options);
6880
- _a = this;
6882
+ _c = this;
6881
6883
  return [4 /*yield*/, this._getWebMapLayerItem()];
6882
6884
  case 1:
6883
- _a.layer = _b.sent();
6885
+ _c.layer = _d.sent();
6886
+ extentConstrained = (_b = (_a = this.response) === null || _a === void 0 ? void 0 : _a.webmap) === null || _b === void 0 ? void 0 : _b.extent_constrained;
6887
+ if (this.options.useExtentConstrained &&
6888
+ this._extent &&
6889
+ extentConstrained) {
6890
+ this.options.webMap.setView({ maxBounds: this._extent });
6891
+ // @ts-ignore
6892
+ window.webmap = this.options.webMap;
6893
+ }
6884
6894
  return [2 /*return*/, this.layer];
6885
6895
  }
6886
6896
  });
@@ -6903,6 +6913,9 @@ var NgwMap = (function (exports) {
6903
6913
  this.options.webMap.showLayer(this._lastActiveBaselayer);
6904
6914
  }
6905
6915
  }
6916
+ if (this.options.useExtentConstrained && this._extent) {
6917
+ this.options.webMap.setView({ maxBounds: null });
6918
+ }
6906
6919
  delete this.layer;
6907
6920
  delete this.response;
6908
6921
  delete this._webmapLayersIds;
@@ -7585,7 +7598,7 @@ var NgwMap = (function (exports) {
7585
7598
  }
7586
7599
  }
7587
7600
  else {
7588
- throw "Resource class '" + cls + "' not yet supported.";
7601
+ throw "Resource class '".concat(cls, "' not yet supported.");
7589
7602
  }
7590
7603
  _a.label = 13;
7591
7604
  case 13: return [3 /*break*/, 15];
@@ -7946,7 +7959,7 @@ var NgwMap = (function (exports) {
7946
7959
  var _b = degrees2meters(lng, lat), x = _b[0], y = _b[1];
7947
7960
  polygon.push(x + ' ' + y);
7948
7961
  });
7949
- var wkt = "POLYGON((" + polygon.join(', ') + "))";
7962
+ var wkt = "POLYGON((".concat(polygon.join(', '), "))");
7950
7963
  var layers = options.layers;
7951
7964
  var data = {
7952
7965
  geom: wkt,
@@ -8036,7 +8049,7 @@ var NgwMap = (function (exports) {
8036
8049
  function insertSvg(width, height, stroke, content) {
8037
8050
  if (stroke === void 0) { stroke = 0; }
8038
8051
  var s = stroke / 2;
8039
- var svg = "<svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"" + width + "\"\n height=\"" + height + "\"\n viewBox=\"-" + s + " -" + s + " " + (width + stroke) + " " + (height + stroke) + "\"\n >" + content + "</svg>";
8052
+ var svg = "<svg\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"".concat(width, "\"\n height=\"").concat(height, "\"\n viewBox=\"-").concat(s, " -").concat(s, " ").concat(width + stroke, " ").concat(height + stroke, "\"\n >").concat(content, "</svg>");
8040
8053
  var oParser = new DOMParser();
8041
8054
  var oDOM = oParser.parseFromString(svg, 'image/svg+xml');
8042
8055
  return oDOM.documentElement;
@@ -8056,7 +8069,7 @@ var NgwMap = (function (exports) {
8056
8069
  var path = typeof pathAlias === 'string' ? pathAlias : pathAlias(opt);
8057
8070
  var svg = insertSvg(size, size, stroke * scale, path);
8058
8071
  var fistChild = svg.firstChild;
8059
- var transform = "scale(" + scale + ")";
8072
+ var transform = "scale(".concat(scale, ")");
8060
8073
  fistChild.setAttribute('fill', color);
8061
8074
  if (stroke) {
8062
8075
  fistChild.setAttribute('stroke', strokeColor);
@@ -8277,7 +8290,7 @@ var NgwMap = (function (exports) {
8277
8290
  resId = isObject$1(resource) && 'id' in resource
8278
8291
  ? resource.id
8279
8292
  : keyname || resourceId || resource;
8280
- console.error("Can't add NGW layer " + resId + ".", er_1);
8293
+ console.error("Can't add NGW layer ".concat(resId, "."), er_1);
8281
8294
  return [3 /*break*/, 5];
8282
8295
  case 5: return [2 /*return*/];
8283
8296
  }
@@ -8671,7 +8684,7 @@ var NgwMap = (function (exports) {
8671
8684
  var identifyFeature = {
8672
8685
  id: Number(featureId),
8673
8686
  fields: feature.properties || {},
8674
- label: "#" + id,
8687
+ label: "#".concat(id),
8675
8688
  layerId: Number(id),
8676
8689
  parent: '',
8677
8690
  geom: feature.geometry,