@nextgis/ngw-map 1.19.2 → 2.0.0-alpha.0
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/README.md +1 -1
- package/lib/index.d.ts +240 -272
- package/lib/ngw-map.cjs.js +609 -634
- package/lib/ngw-map.cjs.js.map +1 -1
- package/lib/ngw-map.cjs.prod.js +1 -1
- package/lib/ngw-map.cjs.prod.js.map +1 -1
- package/lib/ngw-map.esm-browser.js +9000 -8086
- 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 +712 -626
- package/lib/ngw-map.esm-bundler.js.map +1 -1
- package/lib/ngw-map.esm-bundler.prod.js +1 -1
- package/lib/ngw-map.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-map.global.js +9413 -9507
- 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 +10 -10
|
@@ -1,656 +1,742 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version:
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 2.0.0-alpha.0; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import CancelablePromise from '@nextgis/cancelable-promise';
|
|
4
|
+
import { getIcon } from '@nextgis/icons';
|
|
5
|
+
import { NgwKit, fetchNgwLayerItem, fetchNgwLayerItems, fetchNgwLayerFeature, fetchNgwLayerFeatureCollection, fetchIdentifyItem, fetchIdentifyGeoJson, createNgwLayerAdapter, fetchNgwExtent, sendIdentifyRequest, getCompanyLogo, getIdentifyItems, createIdentifyItem } from '@nextgis/ngw-kit';
|
|
4
6
|
import { deepmerge, deprecatedWarn, defined, isObject, getIdentifyRadius } from '@nextgis/utils';
|
|
5
7
|
import { getDefaultControls, WebMap } from '@nextgis/webmap';
|
|
6
8
|
export * from '@nextgis/webmap';
|
|
7
|
-
import { NgwKit, createNgwLayerAdapter, fetchNgwLayerItem, fetchNgwLayerItems, fetchNgwLayerFeature, fetchNgwLayerFeatureCollection, fetchIdentifyItem, fetchIdentifyGeoJson, fetchNgwExtent, sendIdentifyRequest, getCompanyLogo, getIdentifyItems, createIdentifyItem } from '@nextgis/ngw-kit';
|
|
8
|
-
import { getIcon } from '@nextgis/icons';
|
|
9
9
|
import NgwConnector from '@nextgis/ngw-connector';
|
|
10
10
|
import { QmsKit } from '@nextgis/qms-kit';
|
|
11
11
|
|
|
12
|
+
var __defProp$2 = Object.defineProperty;
|
|
13
|
+
var __defProps$2 = Object.defineProperties;
|
|
14
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
15
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
16
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
18
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
|
+
var __spreadValues$2 = (a, b) => {
|
|
20
|
+
for (var prop in b || (b = {}))
|
|
21
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
22
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
23
|
+
if (__getOwnPropSymbols$2)
|
|
24
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
25
|
+
if (__propIsEnum$2.call(b, prop))
|
|
26
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
27
|
+
}
|
|
28
|
+
return a;
|
|
29
|
+
};
|
|
30
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
12
31
|
function appendNgwResources(options, resource, defOptions, overwriteOptions) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else if (typeof resource === 'object') {
|
|
30
|
-
options.push({ ...defOptions, ...resource, ...overwriteOptions });
|
|
31
|
-
}
|
|
32
|
+
if (typeof resource === "number" || typeof resource === "string") {
|
|
33
|
+
resource = Number(resource);
|
|
34
|
+
options.push(__spreadProps$2(__spreadValues$2({}, defOptions), {
|
|
35
|
+
resource
|
|
36
|
+
}));
|
|
37
|
+
} else if (Array.isArray(resource)) {
|
|
38
|
+
const [resourceId, id] = resource;
|
|
39
|
+
options.push(__spreadValues$2(__spreadProps$2(__spreadValues$2({}, defOptions), {
|
|
40
|
+
resource: resourceId,
|
|
41
|
+
id
|
|
42
|
+
}), overwriteOptions));
|
|
43
|
+
} else if (typeof resource === "object") {
|
|
44
|
+
options.push(__spreadValues$2(__spreadValues$2(__spreadValues$2({}, defOptions), resource), overwriteOptions));
|
|
45
|
+
}
|
|
32
46
|
}
|
|
33
47
|
|
|
48
|
+
var __defProp$1 = Object.defineProperty;
|
|
49
|
+
var __defProps$1 = Object.defineProperties;
|
|
50
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
51
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
52
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
53
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
54
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
55
|
+
var __spreadValues$1 = (a, b) => {
|
|
56
|
+
for (var prop in b || (b = {}))
|
|
57
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
58
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
59
|
+
if (__getOwnPropSymbols$1)
|
|
60
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
61
|
+
if (__propIsEnum$1.call(b, prop))
|
|
62
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
63
|
+
}
|
|
64
|
+
return a;
|
|
65
|
+
};
|
|
66
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
34
67
|
const OPTIONS = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
target: "map",
|
|
69
|
+
baseUrl: "",
|
|
70
|
+
whitlabel: false,
|
|
71
|
+
controls: getDefaultControls(),
|
|
72
|
+
controlsOptions: {
|
|
73
|
+
ZOOM: { position: "top-left" },
|
|
74
|
+
ATTRIBUTION: {
|
|
75
|
+
position: "bottom-right",
|
|
76
|
+
customAttribution: [
|
|
77
|
+
'<a href="https://nextgis.com" target="_blank">\xA9NextGIS</a>'
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
pixelRadius: 10
|
|
49
82
|
};
|
|
50
83
|
function prepareWebMapOptions(options) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return options;
|
|
84
|
+
const kits = [new QmsKit()];
|
|
85
|
+
if (options.starterKits) {
|
|
86
|
+
options.starterKits.forEach((x) => {
|
|
87
|
+
kits.push(x);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (!options.connector) {
|
|
91
|
+
options.connector = new NgwConnector({
|
|
92
|
+
baseUrl: options.baseUrl || "",
|
|
93
|
+
auth: options.auth
|
|
94
|
+
});
|
|
95
|
+
} else if (options.connector) {
|
|
96
|
+
options.baseUrl = options.connector.options.baseUrl;
|
|
97
|
+
}
|
|
98
|
+
options = deepmerge(OPTIONS, options);
|
|
99
|
+
if (!options.center && !options.bounds) {
|
|
100
|
+
options.bounds = [-179, -90, 180, 90];
|
|
101
|
+
}
|
|
102
|
+
if (options.connector) {
|
|
103
|
+
kits.push(
|
|
104
|
+
new NgwKit({
|
|
105
|
+
connector: options.connector,
|
|
106
|
+
auth: options.auth
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
options = __spreadProps$1(__spreadValues$1({}, options), {
|
|
111
|
+
starterKits: kits,
|
|
112
|
+
create: false
|
|
113
|
+
});
|
|
114
|
+
return options;
|
|
83
115
|
}
|
|
84
116
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
var __defProp = Object.defineProperty;
|
|
118
|
+
var __defProps = Object.defineProperties;
|
|
119
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
120
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
121
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
122
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
123
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
124
|
+
var __reflectGet = Reflect.get;
|
|
125
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
126
|
+
var __spreadValues = (a, b) => {
|
|
127
|
+
for (var prop in b || (b = {}))
|
|
128
|
+
if (__hasOwnProp.call(b, prop))
|
|
129
|
+
__defNormalProp(a, prop, b[prop]);
|
|
130
|
+
if (__getOwnPropSymbols)
|
|
131
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
132
|
+
if (__propIsEnum.call(b, prop))
|
|
133
|
+
__defNormalProp(a, prop, b[prop]);
|
|
134
|
+
}
|
|
135
|
+
return a;
|
|
136
|
+
};
|
|
137
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
138
|
+
var __publicField = (obj, key, value) => {
|
|
139
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
140
|
+
return value;
|
|
141
|
+
};
|
|
142
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
143
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
var fulfilled = (value) => {
|
|
146
|
+
try {
|
|
147
|
+
step(generator.next(value));
|
|
148
|
+
} catch (e) {
|
|
149
|
+
reject(e);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var rejected = (value) => {
|
|
153
|
+
try {
|
|
154
|
+
step(generator.throw(value));
|
|
155
|
+
} catch (e) {
|
|
156
|
+
reject(e);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
160
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const _NgwMap = class _NgwMap extends WebMap {
|
|
164
|
+
constructor(options) {
|
|
165
|
+
super(prepareWebMapOptions(options));
|
|
166
|
+
__publicField(this, "emitter", new EventEmitter());
|
|
167
|
+
__publicField(this, "connector");
|
|
168
|
+
__publicField(this, "_ngwLayers", {});
|
|
169
|
+
__publicField(this, "$$selectFromNgwRaster");
|
|
170
|
+
__publicField(this, "$$selectFromNgwVector");
|
|
171
|
+
__publicField(this, "_promises", {
|
|
172
|
+
select: [],
|
|
173
|
+
identify: []
|
|
174
|
+
});
|
|
175
|
+
if (options.connector) {
|
|
176
|
+
this.connector = options.connector;
|
|
177
|
+
}
|
|
178
|
+
this._createWebMap().then(() => {
|
|
179
|
+
const container = this.getContainer();
|
|
180
|
+
if (container) {
|
|
181
|
+
container.classList.add("ngw-map-container");
|
|
182
|
+
}
|
|
183
|
+
if (this.options.whitlabel) {
|
|
184
|
+
this._whiteLabel();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Organized addition to the map design and controls elements,
|
|
190
|
+
* calling `control.onAdd(this.webMap.mapAdapter)`
|
|
191
|
+
* @param control - object with onAdd and onRemove methods
|
|
192
|
+
* or a string value indicating the name of the control installed in the map adapter
|
|
193
|
+
* @param position - position relative to the map angles
|
|
194
|
+
* @param options - initialization parameters if the control is set as a string value
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```javascript
|
|
198
|
+
* ngwMap.addControl(new CustomControl(), 'bottom-left');
|
|
199
|
+
* ngwMap.addControl('ZOOM', 'top-right')
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
addControl(controlDef, position, options) {
|
|
203
|
+
return __async$1(this, null, function* () {
|
|
204
|
+
yield this.onLoad("controls:create");
|
|
205
|
+
return __superGet(_NgwMap.prototype, this, "addControl").call(this, controlDef, position, options);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Add any (style, vector, webmap) NGW layer by resource definition.
|
|
210
|
+
* @param options - set layer identification parameters and render method.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```javascript
|
|
214
|
+
* // Add raster layer resourceId is the style of 4004 layer
|
|
215
|
+
* ngwMap.addNgwLayer({ resource: 4005 });
|
|
216
|
+
* // Add vector data from layer GEOJSON source
|
|
217
|
+
* ngwMap.addNgwLayer({
|
|
218
|
+
* resource: 4038,
|
|
219
|
+
* adapter: 'GEOJSON',
|
|
220
|
+
* adapterOptions: { paint: { color: 'red' } }
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
addNgwLayer(options) {
|
|
225
|
+
return __async$1(this, null, function* () {
|
|
226
|
+
yield this.onMapLoad();
|
|
227
|
+
const { keyname, resourceId } = options;
|
|
228
|
+
if (keyname || resourceId !== void 0) {
|
|
229
|
+
deprecatedWarn(
|
|
230
|
+
"set `resource` options instead of `keyname` or `resourceId`"
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const resource = options.resource;
|
|
234
|
+
if (!keyname && !resourceId && !resource) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
"resource, resourceId or keyname is required parameter to add NGW layer"
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
if (defined(this.options.baseUrl)) {
|
|
240
|
+
try {
|
|
241
|
+
if (defined(this.options.setViewDelay)) {
|
|
242
|
+
options.adapterOptions = options.adapterOptions || {};
|
|
243
|
+
if (!defined(options.adapterOptions.setViewDelay)) {
|
|
244
|
+
options.adapterOptions.setViewDelay = this.options.setViewDelay;
|
|
123
245
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
async addControl(controlDef, position, options) {
|
|
141
|
-
await this.onLoad('controls:create');
|
|
142
|
-
return super.addControl(controlDef, position, options);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Add any (style, vector, webmap) NGW layer by resource definition.
|
|
146
|
-
* @param options - set layer identification parameters and render method.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```javascript
|
|
150
|
-
* // Add raster layer resourceId is the style of 4004 layer
|
|
151
|
-
* ngwMap.addNgwLayer({ resource: 4005 });
|
|
152
|
-
* // Add vector data from layer GEOJSON source
|
|
153
|
-
* ngwMap.addNgwLayer({
|
|
154
|
-
* resource: 4038,
|
|
155
|
-
* adapter: 'GEOJSON',
|
|
156
|
-
* adapterOptions: { paint: { color: 'red' } }
|
|
157
|
-
* });
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
async addNgwLayer(options) {
|
|
161
|
-
await this.onMapLoad();
|
|
162
|
-
// @ts-ignore for backward compatibility
|
|
163
|
-
const { keyname, resourceId } = options;
|
|
164
|
-
if (keyname || resourceId !== undefined) {
|
|
165
|
-
deprecatedWarn('set `resource` options instead of `keyname` or `resourceId`');
|
|
166
|
-
}
|
|
167
|
-
const resource = options.resource;
|
|
168
|
-
if (!keyname && !resourceId && !resource) {
|
|
169
|
-
throw new Error('resource, resourceId or keyname is required parameter to add NGW layer');
|
|
170
|
-
}
|
|
171
|
-
if (defined(this.options.baseUrl)) {
|
|
172
|
-
try {
|
|
173
|
-
if (defined(this.options.setViewDelay)) {
|
|
174
|
-
options.adapterOptions = options.adapterOptions || {};
|
|
175
|
-
if (!defined(options.adapterOptions.setViewDelay)) {
|
|
176
|
-
options.adapterOptions.setViewDelay = this.options.setViewDelay;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const adapter = createNgwLayerAdapter(options, this, this.connector);
|
|
180
|
-
const adapterOpts = {
|
|
181
|
-
visibility: true,
|
|
182
|
-
// TODO: do not merge options, use only `adapterOptions`
|
|
183
|
-
...options,
|
|
184
|
-
...options.adapterOptions,
|
|
185
|
-
};
|
|
186
|
-
const layer = (await this.addLayer(adapter, adapterOpts));
|
|
187
|
-
const id = layer && this.getLayerId(layer);
|
|
188
|
-
if (layer && id) {
|
|
189
|
-
this._ngwLayers[id] = { layer, resourceId: layer.resourceId };
|
|
190
|
-
layer.options.name =
|
|
191
|
-
layer.options.name ||
|
|
192
|
-
(layer.item && layer.item.resource.display_name);
|
|
193
|
-
if (layer.options.baselayer) {
|
|
194
|
-
const visibleLayerBaseLayer = this.getActiveBaseLayer();
|
|
195
|
-
if (visibleLayerBaseLayer) {
|
|
196
|
-
return layer;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
246
|
+
}
|
|
247
|
+
const adapter = createNgwLayerAdapter(options, this, this.connector);
|
|
248
|
+
const adapterOpts = __spreadValues(__spreadValues({
|
|
249
|
+
visibility: true
|
|
250
|
+
}, options), options.adapterOptions);
|
|
251
|
+
const layer = yield this.addLayer(
|
|
252
|
+
adapter,
|
|
253
|
+
adapterOpts
|
|
254
|
+
);
|
|
255
|
+
const id = layer && this.getLayerId(layer);
|
|
256
|
+
if (layer && id) {
|
|
257
|
+
this._ngwLayers[id] = { layer, resourceId: layer.resourceId };
|
|
258
|
+
layer.options.name = layer.options.name || layer.item && layer.item.resource.display_name;
|
|
259
|
+
if (layer.options.baselayer) {
|
|
260
|
+
const visibleLayerBaseLayer = this.getActiveBaseLayer();
|
|
261
|
+
if (visibleLayerBaseLayer) {
|
|
200
262
|
return layer;
|
|
263
|
+
}
|
|
201
264
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
fetchNgwLayerItems(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
cancelPromises(...args)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
265
|
+
}
|
|
266
|
+
return layer;
|
|
267
|
+
} catch (er) {
|
|
268
|
+
const resId = isObject(resource) && "id" in resource ? resource.id : keyname || resourceId || resource;
|
|
269
|
+
console.error(`Can't add NGW layer ${resId}.`, er);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Pans and zooms the map to the initial position specified in the options
|
|
276
|
+
*/
|
|
277
|
+
fit() {
|
|
278
|
+
const { center, zoom, bounds } = this.options;
|
|
279
|
+
if (center) {
|
|
280
|
+
this.setCenter(center);
|
|
281
|
+
if (zoom) {
|
|
282
|
+
this.setZoom(zoom);
|
|
283
|
+
}
|
|
284
|
+
} else if (bounds) {
|
|
285
|
+
this.fitBounds(bounds);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
fetchNgwLayerItem(options) {
|
|
289
|
+
return fetchNgwLayerItem(__spreadValues({
|
|
290
|
+
connector: this.connector
|
|
291
|
+
}, options));
|
|
292
|
+
}
|
|
293
|
+
fetchNgwLayerItems(options) {
|
|
294
|
+
return fetchNgwLayerItems(__spreadValues({
|
|
295
|
+
connector: this.connector
|
|
296
|
+
}, options));
|
|
297
|
+
}
|
|
298
|
+
fetchNgwLayerFeature(options) {
|
|
299
|
+
return fetchNgwLayerFeature(__spreadValues({
|
|
300
|
+
connector: this.connector
|
|
301
|
+
}, options));
|
|
302
|
+
}
|
|
303
|
+
fetchNgwLayerFeatures(options) {
|
|
304
|
+
return fetchNgwLayerFeatureCollection(__spreadValues({
|
|
305
|
+
connector: this.connector
|
|
306
|
+
}, options));
|
|
307
|
+
}
|
|
308
|
+
fetchIdentifyItem(identify, requestOptions) {
|
|
309
|
+
const promise = fetchIdentifyItem({
|
|
310
|
+
identify,
|
|
311
|
+
connector: this.connector,
|
|
312
|
+
requestOptions
|
|
313
|
+
// multiple,
|
|
314
|
+
});
|
|
315
|
+
this._addPromise("identify", promise);
|
|
316
|
+
return promise;
|
|
317
|
+
}
|
|
318
|
+
fetchIdentifyGeoJson(identify, multiple = false) {
|
|
319
|
+
const promise = fetchIdentifyGeoJson({
|
|
320
|
+
identify,
|
|
321
|
+
connector: this.connector,
|
|
322
|
+
multiple
|
|
323
|
+
});
|
|
324
|
+
if (promise && "then" in promise) {
|
|
325
|
+
this._addPromise("identify", promise);
|
|
326
|
+
return promise;
|
|
327
|
+
} else {
|
|
328
|
+
return CancelablePromise.resolve(promise);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @deprecated use {@link fetchIdentifyGeoJson} instead
|
|
333
|
+
*/
|
|
334
|
+
getIdentifyGeoJson(identify, multiple = false) {
|
|
335
|
+
return this.fetchIdentifyGeoJson(identify, multiple);
|
|
336
|
+
}
|
|
337
|
+
getNgwLayers() {
|
|
338
|
+
return __async$1(this, null, function* () {
|
|
339
|
+
yield this.onLoad();
|
|
340
|
+
return this._ngwLayers;
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
getNgwLayerByResourceId(id) {
|
|
344
|
+
return __async$1(this, null, function* () {
|
|
345
|
+
for (const n in this._ngwLayers) {
|
|
346
|
+
const mem = this._ngwLayers[n];
|
|
347
|
+
if (mem.resourceId === id) {
|
|
348
|
+
return mem && mem.layer;
|
|
349
|
+
} else if (mem.layer.getIdentificationIds) {
|
|
350
|
+
const ids = yield mem.layer.getIdentificationIds();
|
|
351
|
+
if (ids && ids.some((x) => x === id)) {
|
|
352
|
+
return mem.layer;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (mem.layer.getDependLayers) {
|
|
356
|
+
const dependLayers = mem.layer.getDependLayers();
|
|
357
|
+
const dependFit = dependLayers.find((x) => {
|
|
358
|
+
return x.item && x.item.parentId === id;
|
|
359
|
+
});
|
|
360
|
+
if (dependFit) {
|
|
361
|
+
return dependFit.layer;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Move map to layer. If the layer is NGW resource, extent will be received from the server
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```javascript
|
|
372
|
+
* const ngwLayer = ngwMap.addNgwLayer({ id: 'ngw_layer_name', resource: 4005 });
|
|
373
|
+
* ngwMap.fitLayer(ngwLayer);
|
|
374
|
+
* ngwMap.fitLayer('ngw_layer_name');
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
fitLayer(layerDef, options) {
|
|
378
|
+
return __async$1(this, null, function* () {
|
|
379
|
+
let id;
|
|
380
|
+
if (typeof layerDef === "string" || typeof layerDef === "number") {
|
|
381
|
+
id = String(id);
|
|
382
|
+
} else {
|
|
383
|
+
id = layerDef.id;
|
|
384
|
+
}
|
|
385
|
+
const ngwLayer = id && this._ngwLayers[id];
|
|
386
|
+
if (ngwLayer) {
|
|
387
|
+
if (ngwLayer.layer.getBounds) {
|
|
388
|
+
const bounds = yield ngwLayer.layer.getBounds();
|
|
389
|
+
if (bounds) {
|
|
390
|
+
this.fitBounds(bounds, options);
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
let item;
|
|
394
|
+
if (ngwLayer.layer.item) {
|
|
395
|
+
item = ngwLayer.layer.item;
|
|
396
|
+
} else {
|
|
397
|
+
const resourceId = ngwLayer.resourceId;
|
|
398
|
+
item = yield this.connector.getResource(resourceId);
|
|
399
|
+
}
|
|
400
|
+
if (item) {
|
|
401
|
+
fetchNgwExtent({
|
|
402
|
+
resourceId: item.resource.id,
|
|
403
|
+
connector: this.connector
|
|
404
|
+
}).then((extent) => {
|
|
405
|
+
if (extent) {
|
|
406
|
+
this.fitBounds(extent, options);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
__superGet(_NgwMap.prototype, this, "fitLayer").call(
|
|
413
|
+
this,
|
|
414
|
+
typeof layerDef === "number" ? String(layerDef) : layerDef,
|
|
415
|
+
options
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
/** @deprecated use {@link fitLayer} instead */
|
|
421
|
+
zoomToLayer(layerDef) {
|
|
422
|
+
return __async$1(this, null, function* () {
|
|
423
|
+
return this.fitLayer(layerDef);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
onLoad(event = "ngw-map:create") {
|
|
427
|
+
return super.onLoad(event);
|
|
428
|
+
}
|
|
429
|
+
removeLayer(layerDef) {
|
|
430
|
+
const layer = this.getLayer(layerDef);
|
|
431
|
+
if (layer) {
|
|
432
|
+
const layerId = this.getLayerId(layer);
|
|
433
|
+
if (layerId) {
|
|
434
|
+
delete this._ngwLayers[layerId];
|
|
435
|
+
}
|
|
436
|
+
super.removeLayer(layer);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
enableSelection() {
|
|
440
|
+
if (!this.$$selectFromNgwRaster) {
|
|
441
|
+
this.$$selectFromNgwRaster = (ev) => {
|
|
442
|
+
const count = this._getSelectListenersCount();
|
|
443
|
+
if (count) {
|
|
444
|
+
this.selectFromNgwRaster(ev);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
this.$$selectFromNgwVector = (ev) => {
|
|
448
|
+
const count = this._getSelectListenersCount();
|
|
449
|
+
if (count) {
|
|
450
|
+
this._selectFromNgwVector(ev);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
this.emitter.on("click", this.$$selectFromNgwRaster);
|
|
454
|
+
this.emitter.on("layer:click", this.$$selectFromNgwVector);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
disableSelection() {
|
|
458
|
+
if (this.$$selectFromNgwRaster) {
|
|
459
|
+
this.emitter.removeListener("click", this.$$selectFromNgwRaster);
|
|
460
|
+
this.$$selectFromNgwRaster = void 0;
|
|
461
|
+
}
|
|
462
|
+
if (this.$$selectFromNgwVector) {
|
|
463
|
+
this.emitter.removeListener("layer:click", this.$$selectFromNgwVector);
|
|
464
|
+
this.$$selectFromNgwVector = void 0;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @deprecated use {@link fetchNgwLayerItem} instead
|
|
469
|
+
*/
|
|
470
|
+
getNgwLayerItem(options) {
|
|
471
|
+
return this.fetchNgwLayerItem(options);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* @deprecated use {@link fetchNgwLayerItems} instead
|
|
475
|
+
*/
|
|
476
|
+
getNgwLayerItems(options) {
|
|
477
|
+
return this.fetchNgwLayerItems(options);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* @deprecated use {@link fetchNgwLayerFeature} instead
|
|
481
|
+
*/
|
|
482
|
+
getNgwLayerFeature(options) {
|
|
483
|
+
return this.fetchNgwLayerFeature(options);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @deprecated use {@link fetchNgwLayerFeatures} instead
|
|
487
|
+
*/
|
|
488
|
+
getNgwLayerFeatures(options) {
|
|
489
|
+
return this.fetchNgwLayerFeatures(options);
|
|
490
|
+
}
|
|
491
|
+
/** @deprecated use {@link cancelPromises} instead */
|
|
492
|
+
cancelPromise(...args) {
|
|
493
|
+
this.cancelPromises(...args);
|
|
494
|
+
}
|
|
495
|
+
cancelPromises(...args) {
|
|
496
|
+
if (!args.length) {
|
|
497
|
+
args = Object.keys(this._promises);
|
|
498
|
+
}
|
|
499
|
+
args.forEach((name) => {
|
|
500
|
+
const group = this._promises[name];
|
|
501
|
+
if (group) {
|
|
502
|
+
group.forEach((x) => x.cancel());
|
|
503
|
+
this._promises[name] = [];
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
selectFromNgwRaster(ev) {
|
|
508
|
+
return __async$1(this, null, function* () {
|
|
509
|
+
var _a;
|
|
510
|
+
this._emitStatusEvent("ngw:preselect");
|
|
511
|
+
const promises = [];
|
|
512
|
+
const layers = Object.values(this._ngwLayers);
|
|
513
|
+
layers.sort((a, b) => {
|
|
514
|
+
if (a.layer.order && b.layer.order) {
|
|
515
|
+
return b.layer.order - a.layer.order;
|
|
516
|
+
}
|
|
517
|
+
return 1;
|
|
518
|
+
});
|
|
519
|
+
for (const l of layers) {
|
|
520
|
+
const layer = l.layer;
|
|
521
|
+
const identFunc = typeof layer.getIdentificationIds === "function" ? layer.getIdentificationIds : false;
|
|
522
|
+
const interactive = (_a = layer.options.interactive) != null ? _a : true;
|
|
523
|
+
if (identFunc && layer.options.selectable && interactive && this.isLayerVisible(layer)) {
|
|
524
|
+
promises.push(identFunc.call(layer));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
const getIdsPromise = Promise.all(promises);
|
|
528
|
+
const getIds = yield getIdsPromise;
|
|
529
|
+
const ids = [];
|
|
530
|
+
for (const x of getIds) {
|
|
531
|
+
if (x) {
|
|
532
|
+
ids.push(...x);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (!ids.length) {
|
|
536
|
+
this._emitStatusEvent("ngw:select", null);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const pixelRadius = this.options.pixelRadius || 10;
|
|
540
|
+
const center = this.getCenter();
|
|
541
|
+
let zoom = this.getZoom();
|
|
542
|
+
zoom = zoom !== void 0 ? zoom : 20;
|
|
543
|
+
if (!center || !zoom) {
|
|
544
|
+
this._emitStatusEvent("ngw:select", null);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const radius = getIdentifyRadius(center, zoom, pixelRadius);
|
|
548
|
+
const selectPromise = sendIdentifyRequest(ev, {
|
|
549
|
+
layers: ids,
|
|
550
|
+
connector: this.connector,
|
|
551
|
+
radius
|
|
552
|
+
}).then((resp) => {
|
|
553
|
+
const identify = __spreadProps(__spreadValues({}, resp), {
|
|
554
|
+
resources: ids,
|
|
555
|
+
sourceType: "raster",
|
|
556
|
+
event: ev
|
|
452
557
|
});
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
event: ev,
|
|
497
|
-
};
|
|
498
|
-
const identifyEvent = this._prepareToIdentify(identify);
|
|
499
|
-
this._emitStatusEvent('ngw:select', identifyEvent);
|
|
500
|
-
return identifyEvent;
|
|
558
|
+
const identifyEvent = this._prepareToIdentify(identify);
|
|
559
|
+
this._emitStatusEvent("ngw:select", identifyEvent);
|
|
560
|
+
return identifyEvent;
|
|
561
|
+
});
|
|
562
|
+
this._addPromise("select", selectPromise);
|
|
563
|
+
return selectPromise;
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
_addPromise(groupName, promise) {
|
|
567
|
+
const group = this._promises[groupName];
|
|
568
|
+
if (group && group.indexOf(promise) === -1) {
|
|
569
|
+
const removeFromGroup = () => {
|
|
570
|
+
const index = group.indexOf(promise);
|
|
571
|
+
if (index !== -1) {
|
|
572
|
+
group.splice(index, 1);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
promise.then(removeFromGroup);
|
|
576
|
+
promise.catch(removeFromGroup);
|
|
577
|
+
group.push(promise);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
_isFitFromResource() {
|
|
581
|
+
const params = this._initMapState;
|
|
582
|
+
if (params.zoom && params.center) {
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
_createWebMap() {
|
|
588
|
+
return __async$1(this, null, function* () {
|
|
589
|
+
yield this.create();
|
|
590
|
+
if (this.options.qmsId) {
|
|
591
|
+
this._addQmsBaseLayer();
|
|
592
|
+
}
|
|
593
|
+
if (this.options.osm) {
|
|
594
|
+
this._addOsmBaseLayer();
|
|
595
|
+
}
|
|
596
|
+
const resources = [];
|
|
597
|
+
const layerFitAllowed = this._isFitFromResource();
|
|
598
|
+
if (this.options.webmapId) {
|
|
599
|
+
appendNgwResources(resources, this.options.webmapId, {
|
|
600
|
+
fit: layerFitAllowed
|
|
501
601
|
});
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
_addOsmBaseLayer() {
|
|
562
|
-
this.addBaseLayer('OSM');
|
|
563
|
-
}
|
|
564
|
-
_addQmsBaseLayer() {
|
|
565
|
-
let qmsId;
|
|
566
|
-
let qmsLayerName;
|
|
567
|
-
if (Array.isArray(this.options.qmsId)) {
|
|
568
|
-
qmsId = this.options.qmsId[0];
|
|
569
|
-
qmsLayerName = this.options.qmsId[1];
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
qmsId = Number(this.options.qmsId);
|
|
573
|
-
}
|
|
574
|
-
const qmsLayerOptions = {
|
|
575
|
-
qmsId,
|
|
602
|
+
}
|
|
603
|
+
if (this.options.resources && Array.isArray(this.options.resources)) {
|
|
604
|
+
for (const x of this.options.resources) {
|
|
605
|
+
const overwriteOptions = {};
|
|
606
|
+
if (!layerFitAllowed) {
|
|
607
|
+
overwriteOptions.fit = false;
|
|
608
|
+
}
|
|
609
|
+
appendNgwResources(resources, x, {}, overwriteOptions);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
for (const r of resources) {
|
|
613
|
+
try {
|
|
614
|
+
yield this.addNgwLayer(r);
|
|
615
|
+
} catch (er) {
|
|
616
|
+
console.warn(er);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
this._emitStatusEvent("ngw-map:create", this);
|
|
620
|
+
this.enableSelection();
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
_addOsmBaseLayer() {
|
|
624
|
+
this.addBaseLayer("OSM");
|
|
625
|
+
}
|
|
626
|
+
_addQmsBaseLayer() {
|
|
627
|
+
let qmsId;
|
|
628
|
+
let qmsLayerName;
|
|
629
|
+
if (Array.isArray(this.options.qmsId)) {
|
|
630
|
+
qmsId = this.options.qmsId[0];
|
|
631
|
+
qmsLayerName = this.options.qmsId[1];
|
|
632
|
+
} else {
|
|
633
|
+
qmsId = Number(this.options.qmsId);
|
|
634
|
+
}
|
|
635
|
+
const qmsLayerOptions = {
|
|
636
|
+
qmsId
|
|
637
|
+
};
|
|
638
|
+
if (qmsLayerName) {
|
|
639
|
+
qmsLayerOptions.id = qmsLayerName;
|
|
640
|
+
}
|
|
641
|
+
this.addBaseLayer("QMS", qmsLayerOptions);
|
|
642
|
+
}
|
|
643
|
+
_selectFromNgwVector(ev) {
|
|
644
|
+
const layer = ev.layer;
|
|
645
|
+
const selectable = layer.options.selectable && this.isLayerVisible(layer);
|
|
646
|
+
if (!selectable) {
|
|
647
|
+
return void 0;
|
|
648
|
+
}
|
|
649
|
+
const id = layer.item && layer.item.resource.id;
|
|
650
|
+
const feature = ev.feature;
|
|
651
|
+
if (id !== void 0 && feature) {
|
|
652
|
+
const featureId = feature.id;
|
|
653
|
+
if (featureId) {
|
|
654
|
+
const identifyFeature = {
|
|
655
|
+
id: Number(featureId),
|
|
656
|
+
fields: feature.properties || {},
|
|
657
|
+
label: `#${id}`,
|
|
658
|
+
layerId: Number(id),
|
|
659
|
+
parent: "",
|
|
660
|
+
geom: feature.geometry
|
|
576
661
|
};
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
this.addBaseLayer('QMS', qmsLayerOptions);
|
|
581
|
-
}
|
|
582
|
-
_selectFromNgwVector(ev) {
|
|
583
|
-
const layer = ev.layer;
|
|
584
|
-
const selectable = layer.options.selectable && this.isLayerVisible(layer);
|
|
585
|
-
if (!selectable) {
|
|
586
|
-
return undefined;
|
|
587
|
-
}
|
|
588
|
-
// Item property means layer is NgwResource
|
|
589
|
-
const id = layer.item && layer.item.resource.id;
|
|
590
|
-
const feature = ev.feature;
|
|
591
|
-
if (id !== undefined && feature) {
|
|
592
|
-
const featureId = feature.id;
|
|
593
|
-
if (featureId) {
|
|
594
|
-
const identifyFeature = {
|
|
595
|
-
id: Number(featureId),
|
|
596
|
-
fields: feature.properties || {},
|
|
597
|
-
label: `#${id}`,
|
|
598
|
-
layerId: Number(id),
|
|
599
|
-
parent: '',
|
|
600
|
-
geom: feature.geometry,
|
|
601
|
-
};
|
|
602
|
-
const items = {
|
|
603
|
-
featureCount: 1,
|
|
604
|
-
features: [identifyFeature],
|
|
605
|
-
};
|
|
606
|
-
const identify = {
|
|
607
|
-
featureCount: 1,
|
|
608
|
-
[id]: items,
|
|
609
|
-
};
|
|
610
|
-
this._emitStatusEvent('ngw:select', this._prepareToIdentify({
|
|
611
|
-
...identify,
|
|
612
|
-
resources: [id],
|
|
613
|
-
sourceType: 'vector',
|
|
614
|
-
}));
|
|
615
|
-
return identify;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
_prepareToIdentify(identify) {
|
|
620
|
-
const getIdentifyItems_ = () => {
|
|
621
|
-
return getIdentifyItems(identify, true).map((x) => {
|
|
622
|
-
return createIdentifyItem({
|
|
623
|
-
feature: x.feature,
|
|
624
|
-
connector: this.connector,
|
|
625
|
-
});
|
|
626
|
-
});
|
|
662
|
+
const items = {
|
|
663
|
+
featureCount: 1,
|
|
664
|
+
features: [identifyFeature]
|
|
627
665
|
};
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
666
|
+
const identify = {
|
|
667
|
+
featureCount: 1,
|
|
668
|
+
[id]: items
|
|
631
669
|
};
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
670
|
+
this._emitStatusEvent(
|
|
671
|
+
"ngw:select",
|
|
672
|
+
this._prepareToIdentify(__spreadProps(__spreadValues({}, identify), {
|
|
673
|
+
resources: [id],
|
|
674
|
+
sourceType: "vector"
|
|
675
|
+
}))
|
|
676
|
+
);
|
|
677
|
+
return identify;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
_prepareToIdentify(identify) {
|
|
682
|
+
const getIdentifyItems_ = () => {
|
|
683
|
+
return getIdentifyItems(identify, true).map((x) => {
|
|
684
|
+
return createIdentifyItem({
|
|
685
|
+
feature: x.feature,
|
|
686
|
+
connector: this.connector
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
return __spreadProps(__spreadValues({}, identify), {
|
|
691
|
+
getIdentifyItems: getIdentifyItems_
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
_getSelectListenersCount() {
|
|
695
|
+
return this.emitter.listenerCount("ngw:select");
|
|
696
|
+
}
|
|
697
|
+
_whiteLabel() {
|
|
698
|
+
return __async$1(this, null, function* () {
|
|
699
|
+
const container = this.getContainer();
|
|
700
|
+
if (container) {
|
|
701
|
+
const logo = yield getCompanyLogo(
|
|
702
|
+
this.connector,
|
|
703
|
+
this.options.companyLogoOptions
|
|
704
|
+
);
|
|
705
|
+
if (logo) {
|
|
706
|
+
container.appendChild(logo);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
__publicField(_NgwMap, "getIcon", getIcon);
|
|
713
|
+
let NgwMap = _NgwMap;
|
|
647
714
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
715
|
+
var __async = (__this, __arguments, generator) => {
|
|
716
|
+
return new Promise((resolve, reject) => {
|
|
717
|
+
var fulfilled = (value) => {
|
|
718
|
+
try {
|
|
719
|
+
step(generator.next(value));
|
|
720
|
+
} catch (e) {
|
|
721
|
+
reject(e);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
var rejected = (value) => {
|
|
725
|
+
try {
|
|
726
|
+
step(generator.throw(value));
|
|
727
|
+
} catch (e) {
|
|
728
|
+
reject(e);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
732
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
function createNgwMap(options) {
|
|
736
|
+
return __async(this, null, function* () {
|
|
652
737
|
const ngwMap = new NgwMap(options);
|
|
653
738
|
return ngwMap.onLoad();
|
|
739
|
+
});
|
|
654
740
|
}
|
|
655
741
|
|
|
656
742
|
export { NgwMap, createNgwMap };
|