@nextgis/ngw-map 1.9.6 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +39 -12
- package/lib/ngw-map.cjs.js +1 -1
- package/lib/ngw-map.cjs.prod.js +1 -1
- package/lib/ngw-map.esm-browser.js +65 -22
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +1 -1
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +1 -1
- package/lib/ngw-map.esm-bundler.prod.js +1 -1
- package/lib/ngw-map.global.js +110 -63
- package/lib/ngw-map.global.js.map +1 -1
- package/lib/ngw-map.global.prod.js +1 -1
- package/lib/ngw-map.global.prod.js.map +1 -1
- package/package.json +9 -9
package/lib/index.d.ts
CHANGED
|
@@ -206,7 +206,7 @@ export declare interface NgwMapOptions<C = any> extends MapOptions<C> {
|
|
|
206
206
|
*
|
|
207
207
|
* @example
|
|
208
208
|
* ```javascript
|
|
209
|
-
*
|
|
209
|
+
* const ngwMap = new NgwMap({webmapId: [3985, 'my-webmap']});
|
|
210
210
|
* ngwMap.hideLayer('my-webmap');
|
|
211
211
|
* ```
|
|
212
212
|
*/
|
|
@@ -219,25 +219,52 @@ export declare interface NgwMapOptions<C = any> extends MapOptions<C> {
|
|
|
219
219
|
*
|
|
220
220
|
* @example
|
|
221
221
|
* ```javascript
|
|
222
|
-
*
|
|
222
|
+
* const ngwMap = new NgwMap({qmsId: [465, 'qms-basemap']});
|
|
223
223
|
* ngwMap.hideLayer('qms-basemap');
|
|
224
224
|
* ```
|
|
225
225
|
*/
|
|
226
|
-
resources?: NgwResourceDefinition[];
|
|
227
226
|
qmsId?: number | [number, string];
|
|
228
227
|
/**
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
*
|
|
228
|
+
* List of NGW resources to be displayed on the map.
|
|
229
|
+
*
|
|
230
|
+
* The resources list may include:
|
|
231
|
+
*
|
|
232
|
+
* - number - resource id; // also for resource
|
|
233
|
+
* - string - resource keyname; // also for resource
|
|
234
|
+
* - object - configuration of the layer to be added
|
|
235
|
+
* with the one required parameter `resource` (the comment "also for resource" above refers to it)
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```javascript
|
|
239
|
+
* NgwMap.create({
|
|
240
|
+
* baseUrl: "https://demo.nextgis.com",
|
|
241
|
+
* target: "map",
|
|
242
|
+
* resources: [
|
|
243
|
+
* // Basemap resource
|
|
244
|
+
* 1665,
|
|
245
|
+
* // Digital Elevation Model (DEM)-style
|
|
246
|
+
* 4117,
|
|
247
|
+
* // Hillshade-style
|
|
248
|
+
* { resource: 4115, adapter: "TILE", opacity: 0.3 },
|
|
249
|
+
* // Elevation contours-style
|
|
250
|
+
* 'contours-style',
|
|
251
|
+
* // Vector from Order boundary-style
|
|
252
|
+
* {
|
|
253
|
+
* resource: 4111,
|
|
254
|
+
* fit: true,
|
|
255
|
+
* adapter: "GEOJSON",
|
|
256
|
+
* adapterOptions: { paint: { color: "red", fill: false, weight: 4 } },
|
|
257
|
+
* },
|
|
258
|
+
* ],
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
234
261
|
*/
|
|
262
|
+
resources?: NgwResourceDefinition[];
|
|
235
263
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* @defaultValue false
|
|
264
|
+
* Shortcut to add OSM baselayer.
|
|
239
265
|
*/
|
|
240
|
-
|
|
266
|
+
osm?: boolean;
|
|
267
|
+
/* Excluded from this release type: identification */
|
|
241
268
|
whitlabel?: boolean;
|
|
242
269
|
companyLogoOptions?: CompanyLogoOptions;
|
|
243
270
|
pixelRadius?: number;
|
package/lib/ngw-map.cjs.js
CHANGED
package/lib/ngw-map.cjs.prod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("events"),t=require("@nextgis/cancelable-promise"),s=require("@nextgis/utils"),r=require("@nextgis/webmap"),i=require("@nextgis/ngw-kit"),o=require("@nextgis/icons"),n=require("@nextgis/ngw-connector"),a=require("@nextgis/qms-kit");function c(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var h=c(t),d=c(n);function u(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[i,o]=t;e.push({...s,resource:i,id:o,...r})}else"object"==typeof t&&e.push({...s,...t,...r})}const l={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 y extends r.WebMap{constructor(t){super(function(e){const t=[new a.QmsKit];return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new d({baseUrl:e.baseUrl||"",auth:e.auth}),(e=s.deepmerge(l,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new i.NgwKit({connector:e.connector,auth:e.auth})),{...e,starterKits:t,create:!1}}(t)),this.emitter=new e.EventEmitter,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:r}=e;(t||void 0!==r)&&s.deprecatedWarn("set `resource` options instead of `keyname` or `resourceId`");const o=e.resource;if(!t&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(s.defined(this.options.baseUrl))try{s.defined(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},s.defined(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=i.createNgwLayerAdapter(e,this,this.connector),r={visibility:!0,...e,...e.adapterOptions},o=await this.addLayer(t,r),n=o&&this.getLayerId(o);if(o&&n&&(this._ngwLayers[n]={layer:o,resourceId:o.resourceId},o.options.name=o.options.name||o.item&&o.item.resource.display_name,o.options.baselayer)){if(this.getActiveBaseLayer())return o}return o}catch(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("events"),t=require("@nextgis/cancelable-promise"),s=require("@nextgis/utils"),r=require("@nextgis/webmap"),i=require("@nextgis/ngw-kit"),o=require("@nextgis/icons"),n=require("@nextgis/ngw-connector"),a=require("@nextgis/qms-kit");function c(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var h=c(t),d=c(n);function u(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[i,o]=t;e.push({...s,resource:i,id:o,...r})}else"object"==typeof t&&e.push({...s,...t,...r})}const l={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 y extends r.WebMap{constructor(t){super(function(e){const t=[new a.QmsKit];return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new d({baseUrl:e.baseUrl||"",auth:e.auth}),(e=s.deepmerge(l,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new i.NgwKit({connector:e.connector,auth:e.auth})),{...e,starterKits:t,create:!1}}(t)),this.emitter=new e.EventEmitter,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:r}=e;(t||void 0!==r)&&s.deprecatedWarn("set `resource` options instead of `keyname` or `resourceId`");const o=e.resource;if(!t&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(s.defined(this.options.baseUrl))try{s.defined(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},s.defined(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=i.createNgwLayerAdapter(e,this,this.connector),r={visibility:!0,...e,...e.adapterOptions},o=await this.addLayer(t,r),n=o&&this.getLayerId(o);if(o&&n&&(this._ngwLayers[n]={layer:o,resourceId:o.resourceId},o.options.name=o.options.name||o.item&&o.item.resource.display_name,o.options.baselayer)){if(this.getActiveBaseLayer())return o}return o}catch(n){const e=s.isObject(o)&&"id"in o?o.id:t||r||o;console.error(`Can't add NGW layer ${e}.`,n)}}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 i.fetchNgwLayerItem({connector:this.connector,...e})}fetchNgwLayerItems(e){return i.fetchNgwLayerItems({connector:this.connector,...e})}fetchNgwLayerFeature(e){return i.fetchNgwLayerFeature({connector:this.connector,...e})}fetchNgwLayerFeatures(e){return i.fetchNgwLayerFeatureCollection({connector:this.connector,...e})}fetchIdentifyItem(e,t){const s=i.fetchIdentifyItem({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",s),s}fetchIdentifyGeoJson(e,t=!1){const s=i.fetchIdentifyGeoJson({identify:e,connector:this.connector,multiple:t});return s&&"then"in s?(this._addPromise("identify",s),s):h.resolve(s)}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&&i.fetchNgwResourceExtent(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&&u(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),u(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,n=[];if(o.forEach((e=>{e&&e.forEach((e=>n.push(e)))})),!n.length)return void this._emitStatusEvent("ngw:select",null);const a=this.options.pixelRadius||10,c=this.getCenter();let h=this.getZoom();if(h=void 0!==h?h:20,!c||!h)return void this._emitStatusEvent("ngw:select",null);const d=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}(c,h,a),u=i.sendIdentifyRequest(e,{layers:n,connector:this.connector,radius:d}).then((t=>(this._emitStatusEvent("ngw:select",this._prepareToIdentify({...t,resources:n,sourceType:"raster",event:e})),t)));return this._addPromise("select",u),u}_prepareToIdentify(e){return{...e,getIdentifyItems:()=>i.getIdentifyItems(e,!0).map((e=>i.createIdentifyItem({feature:e.feature,connector:this.connector})))}}async _whiteLabel(){const e=this.getContainer();if(e){const t=await i.getCompanyLogo(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}}for(var m in y.getIcon=o.getIcon,exports.NgwMap=y,exports.createNgwMap=async function(e){return new y(e).onLoad()},r)"default"===m||exports.hasOwnProperty(m)||(exports[m]=r[m]);
|
|
2
2
|
//# sourceMappingURL=ngw-map.cjs.prod.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.11.2; author: NextGIS */
|
|
2
2
|
var events = {exports: {}};
|
|
3
3
|
|
|
4
4
|
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
@@ -1686,7 +1686,7 @@ const OPTIONS$1 = {
|
|
|
1686
1686
|
minZoom: 0,
|
|
1687
1687
|
maxZoom: 20,
|
|
1688
1688
|
paint: {
|
|
1689
|
-
color: '
|
|
1689
|
+
color: '#0000ff',
|
|
1690
1690
|
opacity: 0.4,
|
|
1691
1691
|
strokeOpacity: 1,
|
|
1692
1692
|
stroke: true,
|
|
@@ -1694,7 +1694,7 @@ const OPTIONS$1 = {
|
|
|
1694
1694
|
weight: 1,
|
|
1695
1695
|
},
|
|
1696
1696
|
selectedPaint: {
|
|
1697
|
-
color: '
|
|
1697
|
+
color: '#00008b',
|
|
1698
1698
|
opacity: 0.4,
|
|
1699
1699
|
strokeOpacity: 1,
|
|
1700
1700
|
stroke: true,
|
|
@@ -2844,6 +2844,30 @@ class WebMapLayers extends WebMapMain {
|
|
|
2844
2844
|
adapter.clearLayer(cb);
|
|
2845
2845
|
}
|
|
2846
2846
|
}
|
|
2847
|
+
setLayerPaint(layerDef, paint) {
|
|
2848
|
+
const layer = this.getLayer(layerDef);
|
|
2849
|
+
if (paint && layer && layer.setPaint) {
|
|
2850
|
+
layer.setPaint(paint);
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
setLayerSelectedPaint(layerDef, paint) {
|
|
2854
|
+
const layer = this.getLayer(layerDef);
|
|
2855
|
+
if (paint && layer && layer.setSelectedPaint) {
|
|
2856
|
+
layer.setSelectedPaint(paint);
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
updateLayerPaint(layerDef, paint) {
|
|
2860
|
+
const layer = this.getLayer(layerDef);
|
|
2861
|
+
if (paint && layer && layer.updatePaint) {
|
|
2862
|
+
layer.updatePaint(paint);
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
updateLayerSelectedPaint(layerDef, paint) {
|
|
2866
|
+
const layer = this.getLayer(layerDef);
|
|
2867
|
+
if (paint && layer && layer.updateSelectedPaint) {
|
|
2868
|
+
layer.updateSelectedPaint(paint);
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2847
2871
|
getAttributions(options) {
|
|
2848
2872
|
const attributions = [];
|
|
2849
2873
|
for (const l in this._layers) {
|
|
@@ -3587,6 +3611,10 @@ class NetworkError extends Error {
|
|
|
3587
3611
|
}
|
|
3588
3612
|
}
|
|
3589
3613
|
|
|
3614
|
+
function isObject(val) {
|
|
3615
|
+
return Object.prototype.toString.call(val) === '[object Object]';
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3590
3618
|
let loadData;
|
|
3591
3619
|
// @ts-ignore
|
|
3592
3620
|
{
|
|
@@ -3620,7 +3648,7 @@ let loadData;
|
|
|
3620
3648
|
}
|
|
3621
3649
|
};
|
|
3622
3650
|
xhr.onload = () => {
|
|
3623
|
-
if ([401, 403, 404, 500].indexOf(xhr.status) !== -1) {
|
|
3651
|
+
if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
|
|
3624
3652
|
error(new NgwError(getResponseText()));
|
|
3625
3653
|
}
|
|
3626
3654
|
processingResponse();
|
|
@@ -3675,7 +3703,7 @@ let loadData;
|
|
|
3675
3703
|
data = new FormData();
|
|
3676
3704
|
data.append('file', options.file);
|
|
3677
3705
|
if (options.data) {
|
|
3678
|
-
for (const d in data) {
|
|
3706
|
+
for (const d in options.data) {
|
|
3679
3707
|
data.append(d, data[d]);
|
|
3680
3708
|
}
|
|
3681
3709
|
}
|
|
@@ -3761,10 +3789,6 @@ function removeConnector(connector) {
|
|
|
3761
3789
|
}
|
|
3762
3790
|
}
|
|
3763
3791
|
|
|
3764
|
-
function isObject(val) {
|
|
3765
|
-
return Object.prototype.toString.call(val) === '[object Object]';
|
|
3766
|
-
}
|
|
3767
|
-
|
|
3768
3792
|
const exclude = ['description'];
|
|
3769
3793
|
/**
|
|
3770
3794
|
* @remarks
|
|
@@ -3989,7 +4013,7 @@ class ResourcesControl {
|
|
|
3989
4013
|
}
|
|
3990
4014
|
}
|
|
3991
4015
|
_fetchResourceById(id, requestOptions) {
|
|
3992
|
-
const promise = () => this.connector.get('resource.item', requestOptions, { id })
|
|
4016
|
+
const promise = () => this.connector.get('resource.item', requestOptions, { id });
|
|
3993
4017
|
return this.cache
|
|
3994
4018
|
.add('resource.item', promise, {
|
|
3995
4019
|
id,
|
|
@@ -4191,7 +4215,7 @@ class NgwConnector$1 {
|
|
|
4191
4215
|
headers: this.getAuthorizationHeaders(credentials),
|
|
4192
4216
|
// withCredentials: true
|
|
4193
4217
|
};
|
|
4194
|
-
// Do not use
|
|
4218
|
+
// Do not use apiRequest('auth.current_user') to avoid circular-references
|
|
4195
4219
|
return this.makeQuery('/api/component/auth/current_user', {}, options)
|
|
4196
4220
|
.then((data) => {
|
|
4197
4221
|
this.user = data;
|
|
@@ -6179,8 +6203,17 @@ class NgwWebmapLayerAdapter {
|
|
|
6179
6203
|
}
|
|
6180
6204
|
}
|
|
6181
6205
|
async addLayer(options) {
|
|
6206
|
+
var _a, _b;
|
|
6182
6207
|
this.options = { ...this.options, ...options };
|
|
6183
6208
|
this.layer = await this._getWebMapLayerItem();
|
|
6209
|
+
const extentConstrained = (_b = (_a = this.response) === null || _a === void 0 ? void 0 : _a.webmap) === null || _b === void 0 ? void 0 : _b.extent_constrained;
|
|
6210
|
+
if (this.options.useExtentConstrained &&
|
|
6211
|
+
this._extent &&
|
|
6212
|
+
extentConstrained) {
|
|
6213
|
+
this.options.webMap.setView({ maxBounds: this._extent });
|
|
6214
|
+
// @ts-ignore
|
|
6215
|
+
window.webmap = this.options.webMap;
|
|
6216
|
+
}
|
|
6184
6217
|
return this.layer;
|
|
6185
6218
|
}
|
|
6186
6219
|
removeLayer() {
|
|
@@ -6199,6 +6232,9 @@ class NgwWebmapLayerAdapter {
|
|
|
6199
6232
|
this.options.webMap.showLayer(this._lastActiveBaselayer);
|
|
6200
6233
|
}
|
|
6201
6234
|
}
|
|
6235
|
+
if (this.options.useExtentConstrained && this._extent) {
|
|
6236
|
+
this.options.webMap.setView({ maxBounds: null });
|
|
6237
|
+
}
|
|
6202
6238
|
delete this.layer;
|
|
6203
6239
|
delete this.response;
|
|
6204
6240
|
delete this._webmapLayersIds;
|
|
@@ -6321,7 +6357,24 @@ class NgwWebmapLayerAdapter {
|
|
|
6321
6357
|
if (data) {
|
|
6322
6358
|
this.response = data;
|
|
6323
6359
|
const webmap = data[this.webmapClassName];
|
|
6324
|
-
|
|
6360
|
+
this._setupBaselayers(data);
|
|
6361
|
+
if (webmap) {
|
|
6362
|
+
this._extent = [
|
|
6363
|
+
webmap.extent_left,
|
|
6364
|
+
webmap.extent_bottom,
|
|
6365
|
+
webmap.extent_right,
|
|
6366
|
+
webmap.extent_top,
|
|
6367
|
+
];
|
|
6368
|
+
this._updateItemsParams(webmap.root_item, this.options.webMap, data);
|
|
6369
|
+
return webmap;
|
|
6370
|
+
}
|
|
6371
|
+
}
|
|
6372
|
+
}
|
|
6373
|
+
_setupBaselayers(data) {
|
|
6374
|
+
var _a;
|
|
6375
|
+
const webMap = this.options.webMap;
|
|
6376
|
+
const basemap = (_a = this.options.useBasemap) !== null && _a !== void 0 ? _a : true;
|
|
6377
|
+
if (basemap) {
|
|
6325
6378
|
if (data.basemap_webmap && data.basemap_webmap.basemaps.length) {
|
|
6326
6379
|
const activeBaselayer = webMap.getActiveBaseLayer();
|
|
6327
6380
|
this._lastActiveBaselayer = activeBaselayer
|
|
@@ -6335,16 +6388,6 @@ class NgwWebmapLayerAdapter {
|
|
|
6335
6388
|
name: 'OpenStreetMap',
|
|
6336
6389
|
});
|
|
6337
6390
|
}
|
|
6338
|
-
if (webmap) {
|
|
6339
|
-
this._extent = [
|
|
6340
|
-
webmap.extent_left,
|
|
6341
|
-
webmap.extent_bottom,
|
|
6342
|
-
webmap.extent_right,
|
|
6343
|
-
webmap.extent_top,
|
|
6344
|
-
];
|
|
6345
|
-
this._updateItemsParams(webmap.root_item, this.options.webMap, data);
|
|
6346
|
-
return webmap;
|
|
6347
|
-
}
|
|
6348
6391
|
}
|
|
6349
6392
|
}
|
|
6350
6393
|
_setBasemaps(baseWebmap) {
|