@nextgis/ngw-map 1.11.10 → 1.13.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/lib/index.d.ts +2 -2
- package/lib/ngw-map.cjs.js +547 -371
- 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 +4369 -3334
- package/lib/ngw-map.esm-browser.js.map +1 -1
- package/lib/ngw-map.esm-browser.prod.js +15 -1
- package/lib/ngw-map.esm-browser.prod.js.map +1 -1
- package/lib/ngw-map.esm-bundler.js +548 -372
- package/lib/ngw-map.esm-bundler.js.map +1 -1
- package/lib/ngw-map.esm-bundler.prod.js +15 -1
- package/lib/ngw-map.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-map.global.js +194 -90
- 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
|
@@ -1,37 +1,109 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-map; version: 1.
|
|
1
|
+
/** Bundle of @nextgis/ngw-map; version: 1.13.0; author: NextGIS */
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import CancelablePromise from '@nextgis/cancelable-promise';
|
|
4
|
-
import { deepmerge,
|
|
4
|
+
import { deepmerge, isObject, defined, deprecatedWarn } from '@nextgis/utils';
|
|
5
5
|
import { WebMap } from '@nextgis/webmap';
|
|
6
6
|
export * from '@nextgis/webmap';
|
|
7
|
-
import { NgwKit,
|
|
7
|
+
import { NgwKit, fetchNgwLayerItem, fetchNgwLayerItems, fetchNgwLayerFeature, fetchNgwLayerFeatureCollection, fetchIdentifyItem, fetchIdentifyGeoJson, getIdentifyItems, createIdentifyItem, createNgwLayerAdapter, sendIdentifyRequest, getCompanyLogo, fetchNgwResourceExtent } from '@nextgis/ngw-kit';
|
|
8
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
|
+
/*! *****************************************************************************
|
|
13
|
+
Copyright (c) Microsoft Corporation.
|
|
14
|
+
|
|
15
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
16
|
+
purpose with or without fee is hereby granted.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
19
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
20
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
21
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
22
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
23
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
24
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
25
|
+
***************************************************************************** */
|
|
26
|
+
/* global Reflect, Promise */
|
|
27
|
+
|
|
28
|
+
var extendStatics = function(d, b) {
|
|
29
|
+
extendStatics = Object.setPrototypeOf ||
|
|
30
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
31
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
32
|
+
return extendStatics(d, b);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function __extends(d, b) {
|
|
36
|
+
if (typeof b !== "function" && b !== null)
|
|
37
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
38
|
+
extendStatics(d, b);
|
|
39
|
+
function __() { this.constructor = d; }
|
|
40
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var __assign = function() {
|
|
44
|
+
__assign = Object.assign || function __assign(t) {
|
|
45
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
46
|
+
s = arguments[i];
|
|
47
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
48
|
+
}
|
|
49
|
+
return t;
|
|
50
|
+
};
|
|
51
|
+
return __assign.apply(this, arguments);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
55
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
56
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
57
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
58
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
59
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
60
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function __generator(thisArg, body) {
|
|
65
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
66
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
67
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
68
|
+
function step(op) {
|
|
69
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
70
|
+
while (_) try {
|
|
71
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
72
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
73
|
+
switch (op[0]) {
|
|
74
|
+
case 0: case 1: t = op; break;
|
|
75
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
76
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
77
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
78
|
+
default:
|
|
79
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
80
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
81
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
82
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
83
|
+
if (t[2]) _.ops.pop();
|
|
84
|
+
_.trys.pop(); continue;
|
|
85
|
+
}
|
|
86
|
+
op = body.call(thisArg, _);
|
|
87
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
88
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
12
92
|
function appendNgwResources(options, resource, defOptions, overwriteOptions) {
|
|
13
93
|
if (typeof resource === 'number' || typeof resource === 'string') {
|
|
14
94
|
resource = Number(resource);
|
|
15
|
-
options.push({
|
|
16
|
-
...defOptions,
|
|
17
|
-
resource,
|
|
18
|
-
});
|
|
95
|
+
options.push(__assign(__assign({}, defOptions), { resource: resource }));
|
|
19
96
|
}
|
|
20
97
|
else if (Array.isArray(resource)) {
|
|
21
|
-
|
|
22
|
-
options.push({
|
|
23
|
-
...defOptions,
|
|
24
|
-
resource: resourceId,
|
|
25
|
-
id,
|
|
26
|
-
...overwriteOptions,
|
|
27
|
-
});
|
|
98
|
+
var resourceId = resource[0], id = resource[1];
|
|
99
|
+
options.push(__assign(__assign(__assign({}, defOptions), { resource: resourceId, id: id }), overwriteOptions));
|
|
28
100
|
}
|
|
29
101
|
else if (typeof resource === 'object') {
|
|
30
|
-
options.push({
|
|
102
|
+
options.push(__assign(__assign(__assign({}, defOptions), resource), overwriteOptions));
|
|
31
103
|
}
|
|
32
104
|
}
|
|
33
105
|
|
|
34
|
-
|
|
106
|
+
var OPTIONS = {
|
|
35
107
|
target: 'map',
|
|
36
108
|
baseUrl: '',
|
|
37
109
|
whitlabel: false,
|
|
@@ -48,9 +120,9 @@ const OPTIONS = {
|
|
|
48
120
|
pixelRadius: 10,
|
|
49
121
|
};
|
|
50
122
|
function prepareWebMapOptions(options) {
|
|
51
|
-
|
|
123
|
+
var kits = [new QmsKit()];
|
|
52
124
|
if (options.starterKits) {
|
|
53
|
-
options.starterKits.forEach((x)
|
|
125
|
+
options.starterKits.forEach(function (x) {
|
|
54
126
|
kits.push(x);
|
|
55
127
|
});
|
|
56
128
|
}
|
|
@@ -74,19 +146,15 @@ function prepareWebMapOptions(options) {
|
|
|
74
146
|
auth: options.auth,
|
|
75
147
|
}));
|
|
76
148
|
}
|
|
77
|
-
options = {
|
|
78
|
-
...options,
|
|
79
|
-
starterKits: kits,
|
|
80
|
-
create: false,
|
|
81
|
-
};
|
|
149
|
+
options = __assign(__assign({}, options), { starterKits: kits, create: false });
|
|
82
150
|
return options;
|
|
83
151
|
}
|
|
84
152
|
|
|
85
153
|
function getIdentifyRadius(center, zoom, pixelRadius) {
|
|
86
154
|
pixelRadius = pixelRadius !== null && pixelRadius !== void 0 ? pixelRadius : 10;
|
|
87
|
-
|
|
155
|
+
var metresPerPixel = (40075016.686 * Math.abs(Math.cos((center[1] * 180) / Math.PI))) /
|
|
88
156
|
Math.pow(2, zoom + 8);
|
|
89
|
-
|
|
157
|
+
var radius = pixelRadius * metresPerPixel * 0.0005;
|
|
90
158
|
return radius;
|
|
91
159
|
}
|
|
92
160
|
|
|
@@ -109,27 +177,29 @@ function getIdentifyRadius(center, zoom, pixelRadius) {
|
|
|
109
177
|
* });
|
|
110
178
|
* ```
|
|
111
179
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
180
|
+
var NgwMap = /** @class */ (function (_super) {
|
|
181
|
+
__extends(NgwMap, _super);
|
|
182
|
+
function NgwMap(options) {
|
|
183
|
+
var _this = _super.call(this, prepareWebMapOptions(options)) || this;
|
|
184
|
+
_this.emitter = new EventEmitter();
|
|
185
|
+
_this._ngwLayers = {};
|
|
186
|
+
_this._promises = {
|
|
118
187
|
select: [],
|
|
119
188
|
identify: [],
|
|
120
189
|
};
|
|
121
190
|
if (options.connector) {
|
|
122
|
-
|
|
191
|
+
_this.connector = options.connector;
|
|
123
192
|
}
|
|
124
|
-
|
|
125
|
-
|
|
193
|
+
_this._createWebMap().then(function () {
|
|
194
|
+
var container = _this.getContainer();
|
|
126
195
|
if (container) {
|
|
127
196
|
container.classList.add('ngw-map-container');
|
|
128
197
|
}
|
|
129
|
-
if (
|
|
130
|
-
|
|
198
|
+
if (_this.options.whitlabel) {
|
|
199
|
+
_this._whiteLabel();
|
|
131
200
|
}
|
|
132
201
|
});
|
|
202
|
+
return _this;
|
|
133
203
|
}
|
|
134
204
|
/**
|
|
135
205
|
* Organized addition to the map design and controls elements,
|
|
@@ -145,10 +215,18 @@ class NgwMap extends WebMap {
|
|
|
145
215
|
* ngwMap.addControl('ZOOM', 'top-right')
|
|
146
216
|
* ```
|
|
147
217
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
218
|
+
NgwMap.prototype.addControl = function (controlDef, position, options) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0: return [4 /*yield*/, this.onLoad('controls:create')];
|
|
223
|
+
case 1:
|
|
224
|
+
_a.sent();
|
|
225
|
+
return [2 /*return*/, _super.prototype.addControl.call(this, controlDef, position, options)];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
152
230
|
/**
|
|
153
231
|
* Add any (style, vector, webmap) NGW layer by resource definition.
|
|
154
232
|
* @param options - set layer identification parameters and render method.
|
|
@@ -165,61 +243,68 @@ class NgwMap extends WebMap {
|
|
|
165
243
|
* });
|
|
166
244
|
* ```
|
|
167
245
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (defined(this.options.baseUrl)) {
|
|
180
|
-
try {
|
|
181
|
-
if (defined(this.options.setViewDelay)) {
|
|
182
|
-
options.adapterOptions = options.adapterOptions || {};
|
|
183
|
-
if (!defined(options.adapterOptions.setViewDelay)) {
|
|
184
|
-
options.adapterOptions.setViewDelay = this.options.setViewDelay;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const adapter = createNgwLayerAdapter(options, this, this.connector);
|
|
188
|
-
const adapterOpts = {
|
|
189
|
-
visibility: true,
|
|
190
|
-
// TODO: do not merge options, use only `adapterOptions`
|
|
191
|
-
...options,
|
|
192
|
-
...options.adapterOptions,
|
|
193
|
-
};
|
|
194
|
-
const layer = (await this.addLayer(adapter, adapterOpts));
|
|
195
|
-
const id = layer && this.getLayerId(layer);
|
|
196
|
-
if (layer && id) {
|
|
197
|
-
this._ngwLayers[id] = { layer, resourceId: layer.resourceId };
|
|
198
|
-
layer.options.name =
|
|
199
|
-
layer.options.name ||
|
|
200
|
-
(layer.item && layer.item.resource.display_name);
|
|
201
|
-
if (layer.options.baselayer) {
|
|
202
|
-
const visibleLayerBaseLayer = this.getActiveBaseLayer();
|
|
203
|
-
if (visibleLayerBaseLayer) {
|
|
204
|
-
return layer;
|
|
246
|
+
NgwMap.prototype.addNgwLayer = function (options) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
var keyname, resourceId, resource, adapter, adapterOpts, layer, id, visibleLayerBaseLayer, er_1, resId;
|
|
249
|
+
return __generator(this, function (_a) {
|
|
250
|
+
switch (_a.label) {
|
|
251
|
+
case 0: return [4 /*yield*/, this.onMapLoad()];
|
|
252
|
+
case 1:
|
|
253
|
+
_a.sent();
|
|
254
|
+
keyname = options.keyname, resourceId = options.resourceId;
|
|
255
|
+
if (keyname || resourceId !== undefined) {
|
|
256
|
+
deprecatedWarn('set `resource` options instead of `keyname` or `resourceId`');
|
|
205
257
|
}
|
|
206
|
-
|
|
258
|
+
resource = options.resource;
|
|
259
|
+
if (!keyname && !resourceId && !resource) {
|
|
260
|
+
throw new Error('resource, resourceId or keyname is required parameter to add NGW layer');
|
|
261
|
+
}
|
|
262
|
+
if (!defined(this.options.baseUrl)) return [3 /*break*/, 5];
|
|
263
|
+
_a.label = 2;
|
|
264
|
+
case 2:
|
|
265
|
+
_a.trys.push([2, 4, , 5]);
|
|
266
|
+
if (defined(this.options.setViewDelay)) {
|
|
267
|
+
options.adapterOptions = options.adapterOptions || {};
|
|
268
|
+
if (!defined(options.adapterOptions.setViewDelay)) {
|
|
269
|
+
options.adapterOptions.setViewDelay = this.options.setViewDelay;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
adapter = createNgwLayerAdapter(options, this, this.connector);
|
|
273
|
+
adapterOpts = __assign(__assign({ visibility: true }, options), options.adapterOptions);
|
|
274
|
+
return [4 /*yield*/, this.addLayer(adapter, adapterOpts)];
|
|
275
|
+
case 3:
|
|
276
|
+
layer = (_a.sent());
|
|
277
|
+
id = layer && this.getLayerId(layer);
|
|
278
|
+
if (layer && id) {
|
|
279
|
+
this._ngwLayers[id] = { layer: layer, resourceId: layer.resourceId };
|
|
280
|
+
layer.options.name =
|
|
281
|
+
layer.options.name ||
|
|
282
|
+
(layer.item && layer.item.resource.display_name);
|
|
283
|
+
if (layer.options.baselayer) {
|
|
284
|
+
visibleLayerBaseLayer = this.getActiveBaseLayer();
|
|
285
|
+
if (visibleLayerBaseLayer) {
|
|
286
|
+
return [2 /*return*/, layer];
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return [2 /*return*/, layer];
|
|
291
|
+
case 4:
|
|
292
|
+
er_1 = _a.sent();
|
|
293
|
+
resId = isObject(resource) && 'id' in resource
|
|
294
|
+
? resource.id
|
|
295
|
+
: keyname || resourceId || resource;
|
|
296
|
+
console.error("Can't add NGW layer ".concat(resId, "."), er_1);
|
|
297
|
+
return [3 /*break*/, 5];
|
|
298
|
+
case 5: return [2 /*return*/];
|
|
207
299
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const resId = isObject(resource) && 'id' in resource
|
|
212
|
-
? resource.id
|
|
213
|
-
: keyname || resourceId || resource;
|
|
214
|
-
console.error(`Can't add NGW layer ${resId}.`, er);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
218
303
|
/**
|
|
219
304
|
* Pans and zooms the map to the initial position specified in the options
|
|
220
305
|
*/
|
|
221
|
-
fit() {
|
|
222
|
-
|
|
306
|
+
NgwMap.prototype.fit = function () {
|
|
307
|
+
var _a = this.options, center = _a.center, zoom = _a.zoom, bounds = _a.bounds;
|
|
223
308
|
if (center) {
|
|
224
309
|
this.setCenter(center);
|
|
225
310
|
if (zoom) {
|
|
@@ -229,46 +314,35 @@ class NgwMap extends WebMap {
|
|
|
229
314
|
else if (bounds) {
|
|
230
315
|
this.fitBounds(bounds);
|
|
231
316
|
}
|
|
232
|
-
}
|
|
233
|
-
fetchNgwLayerItem(options) {
|
|
234
|
-
return fetchNgwLayerItem({
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
...options,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
fetchNgwLayerFeatures(options) {
|
|
252
|
-
return fetchNgwLayerFeatureCollection({
|
|
253
|
-
connector: this.connector,
|
|
254
|
-
...options,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
fetchIdentifyItem(identify, requestOptions) {
|
|
258
|
-
const promise = fetchIdentifyItem({
|
|
259
|
-
identify,
|
|
317
|
+
};
|
|
318
|
+
NgwMap.prototype.fetchNgwLayerItem = function (options) {
|
|
319
|
+
return fetchNgwLayerItem(__assign({ connector: this.connector }, options));
|
|
320
|
+
};
|
|
321
|
+
NgwMap.prototype.fetchNgwLayerItems = function (options) {
|
|
322
|
+
return fetchNgwLayerItems(__assign({ connector: this.connector }, options));
|
|
323
|
+
};
|
|
324
|
+
NgwMap.prototype.fetchNgwLayerFeature = function (options) {
|
|
325
|
+
return fetchNgwLayerFeature(__assign({ connector: this.connector }, options));
|
|
326
|
+
};
|
|
327
|
+
NgwMap.prototype.fetchNgwLayerFeatures = function (options) {
|
|
328
|
+
return fetchNgwLayerFeatureCollection(__assign({ connector: this.connector }, options));
|
|
329
|
+
};
|
|
330
|
+
NgwMap.prototype.fetchIdentifyItem = function (identify, requestOptions) {
|
|
331
|
+
var promise = fetchIdentifyItem({
|
|
332
|
+
identify: identify,
|
|
260
333
|
connector: this.connector,
|
|
261
|
-
requestOptions,
|
|
334
|
+
requestOptions: requestOptions,
|
|
262
335
|
// multiple,
|
|
263
336
|
});
|
|
264
337
|
this._addPromise('identify', promise);
|
|
265
338
|
return promise;
|
|
266
|
-
}
|
|
267
|
-
fetchIdentifyGeoJson(identify, multiple
|
|
268
|
-
|
|
269
|
-
|
|
339
|
+
};
|
|
340
|
+
NgwMap.prototype.fetchIdentifyGeoJson = function (identify, multiple) {
|
|
341
|
+
if (multiple === void 0) { multiple = false; }
|
|
342
|
+
var promise = fetchIdentifyGeoJson({
|
|
343
|
+
identify: identify,
|
|
270
344
|
connector: this.connector,
|
|
271
|
-
multiple,
|
|
345
|
+
multiple: multiple,
|
|
272
346
|
});
|
|
273
347
|
if (promise && 'then' in promise) {
|
|
274
348
|
this._addPromise('identify', promise);
|
|
@@ -277,40 +351,71 @@ class NgwMap extends WebMap {
|
|
|
277
351
|
else {
|
|
278
352
|
return CancelablePromise.resolve(promise);
|
|
279
353
|
}
|
|
280
|
-
}
|
|
354
|
+
};
|
|
281
355
|
/**
|
|
282
356
|
* @deprecated use {@link fetchIdentifyGeoJson} instead
|
|
283
357
|
*/
|
|
284
|
-
getIdentifyGeoJson(identify, multiple
|
|
358
|
+
NgwMap.prototype.getIdentifyGeoJson = function (identify, multiple) {
|
|
359
|
+
if (multiple === void 0) { multiple = false; }
|
|
285
360
|
return this.fetchIdentifyGeoJson(identify, multiple);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return mem && mem.layer;
|
|
296
|
-
}
|
|
297
|
-
else if (mem.layer.getIdentificationIds) {
|
|
298
|
-
const ids = await mem.layer.getIdentificationIds();
|
|
299
|
-
if (ids && ids.some((x) => x === id)) {
|
|
300
|
-
return mem.layer;
|
|
361
|
+
};
|
|
362
|
+
NgwMap.prototype.getNgwLayers = function () {
|
|
363
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
364
|
+
return __generator(this, function (_a) {
|
|
365
|
+
switch (_a.label) {
|
|
366
|
+
case 0: return [4 /*yield*/, this.onLoad()];
|
|
367
|
+
case 1:
|
|
368
|
+
_a.sent();
|
|
369
|
+
return [2 /*return*/, this._ngwLayers];
|
|
301
370
|
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
NgwMap.prototype.getNgwLayerByResourceId = function (id) {
|
|
375
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
376
|
+
var _a, _b, _i, n, mem, ids, dependLayers, dependFit;
|
|
377
|
+
return __generator(this, function (_c) {
|
|
378
|
+
switch (_c.label) {
|
|
379
|
+
case 0:
|
|
380
|
+
_a = [];
|
|
381
|
+
for (_b in this._ngwLayers)
|
|
382
|
+
_a.push(_b);
|
|
383
|
+
_i = 0;
|
|
384
|
+
_c.label = 1;
|
|
385
|
+
case 1:
|
|
386
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
387
|
+
n = _a[_i];
|
|
388
|
+
mem = this._ngwLayers[n];
|
|
389
|
+
if (!(mem.resourceId === id)) return [3 /*break*/, 2];
|
|
390
|
+
return [2 /*return*/, mem && mem.layer];
|
|
391
|
+
case 2:
|
|
392
|
+
if (!mem.layer.getIdentificationIds) return [3 /*break*/, 4];
|
|
393
|
+
return [4 /*yield*/, mem.layer.getIdentificationIds()];
|
|
394
|
+
case 3:
|
|
395
|
+
ids = _c.sent();
|
|
396
|
+
if (ids && ids.some(function (x) { return x === id; })) {
|
|
397
|
+
return [2 /*return*/, mem.layer];
|
|
398
|
+
}
|
|
399
|
+
_c.label = 4;
|
|
400
|
+
case 4:
|
|
401
|
+
if (mem.layer.getDependLayers) {
|
|
402
|
+
dependLayers = mem.layer.getDependLayers();
|
|
403
|
+
dependFit = dependLayers.find(function (x) {
|
|
404
|
+
return x.item && x.item.parentId === id;
|
|
405
|
+
});
|
|
406
|
+
if (dependFit) {
|
|
407
|
+
return [2 /*return*/, dependFit.layer];
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
_c.label = 5;
|
|
411
|
+
case 5:
|
|
412
|
+
_i++;
|
|
413
|
+
return [3 /*break*/, 1];
|
|
414
|
+
case 6: return [2 /*return*/];
|
|
310
415
|
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
};
|
|
314
419
|
/**
|
|
315
420
|
* Move map to layer. If the layer is NGW resource, extent will be received from the server
|
|
316
421
|
*
|
|
@@ -321,131 +426,160 @@ class NgwMap extends WebMap {
|
|
|
321
426
|
* ngwMap.fitLayer('ngw_layer_name');
|
|
322
427
|
* ```
|
|
323
428
|
*/
|
|
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
|
-
|
|
429
|
+
NgwMap.prototype.fitLayer = function (layerDef, options) {
|
|
430
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
431
|
+
var id, ngwLayer, bounds, item, resourceId;
|
|
432
|
+
var _this = this;
|
|
433
|
+
return __generator(this, function (_a) {
|
|
434
|
+
switch (_a.label) {
|
|
435
|
+
case 0:
|
|
436
|
+
if (typeof layerDef === 'string' || typeof layerDef === 'number') {
|
|
437
|
+
id = String(id);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
id = layerDef.id;
|
|
441
|
+
}
|
|
442
|
+
ngwLayer = id && this._ngwLayers[id];
|
|
443
|
+
if (!ngwLayer) return [3 /*break*/, 7];
|
|
444
|
+
if (!ngwLayer.layer.getBounds) return [3 /*break*/, 2];
|
|
445
|
+
return [4 /*yield*/, ngwLayer.layer.getBounds()];
|
|
446
|
+
case 1:
|
|
447
|
+
bounds = _a.sent();
|
|
448
|
+
if (bounds) {
|
|
449
|
+
this.fitBounds(bounds, options);
|
|
450
|
+
}
|
|
451
|
+
return [3 /*break*/, 6];
|
|
452
|
+
case 2:
|
|
453
|
+
item = void 0;
|
|
454
|
+
if (!ngwLayer.layer.item) return [3 /*break*/, 3];
|
|
455
|
+
item = ngwLayer.layer.item;
|
|
456
|
+
return [3 /*break*/, 5];
|
|
457
|
+
case 3:
|
|
458
|
+
resourceId = ngwLayer.resourceId;
|
|
459
|
+
return [4 /*yield*/, this.connector.getResource(resourceId)];
|
|
460
|
+
case 4:
|
|
461
|
+
item = _a.sent();
|
|
462
|
+
_a.label = 5;
|
|
463
|
+
case 5:
|
|
464
|
+
if (item) {
|
|
465
|
+
fetchNgwResourceExtent(item, this.connector).then(function (extent) {
|
|
466
|
+
if (extent) {
|
|
467
|
+
_this.fitBounds(extent, options);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
353
470
|
}
|
|
354
|
-
|
|
471
|
+
_a.label = 6;
|
|
472
|
+
case 6: return [3 /*break*/, 8];
|
|
473
|
+
case 7:
|
|
474
|
+
_super.prototype.fitLayer.call(this, layerDef, options);
|
|
475
|
+
_a.label = 8;
|
|
476
|
+
case 8: return [2 /*return*/];
|
|
355
477
|
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
super.fitLayer(layerDef, options);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
};
|
|
362
481
|
/** @deprecated use {@link NgwMap.fitLayer} instead */
|
|
363
|
-
|
|
364
|
-
return this
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
482
|
+
NgwMap.prototype.zoomToLayer = function (layerDef) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
484
|
+
return __generator(this, function (_a) {
|
|
485
|
+
return [2 /*return*/, this.fitLayer(layerDef)];
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
NgwMap.prototype.onLoad = function (event) {
|
|
490
|
+
if (event === void 0) { event = 'ngw-map:create'; }
|
|
491
|
+
return _super.prototype.onLoad.call(this, event);
|
|
492
|
+
};
|
|
493
|
+
NgwMap.prototype.removeLayer = function (layerDef) {
|
|
494
|
+
var layer = this.getLayer(layerDef);
|
|
371
495
|
if (layer) {
|
|
372
|
-
|
|
496
|
+
var layerId = this.getLayerId(layer);
|
|
373
497
|
if (layerId) {
|
|
374
498
|
delete this._ngwLayers[layerId];
|
|
375
499
|
}
|
|
376
|
-
|
|
500
|
+
_super.prototype.removeLayer.call(this, layer);
|
|
377
501
|
}
|
|
378
|
-
}
|
|
379
|
-
enableSelection() {
|
|
502
|
+
};
|
|
503
|
+
NgwMap.prototype.enableSelection = function () {
|
|
504
|
+
var _this = this;
|
|
380
505
|
if (!this.$$selectFromNgwRaster) {
|
|
381
|
-
this.$$selectFromNgwRaster = (ev)
|
|
382
|
-
|
|
506
|
+
this.$$selectFromNgwRaster = function (ev) {
|
|
507
|
+
var count = _this.emitter.listenerCount('ngw:select');
|
|
383
508
|
if (count) {
|
|
384
|
-
|
|
509
|
+
_this._selectFromNgwRaster(ev);
|
|
385
510
|
}
|
|
386
511
|
};
|
|
387
|
-
this.$$selectFromNgwVector = (ev)
|
|
388
|
-
if (
|
|
389
|
-
|
|
512
|
+
this.$$selectFromNgwVector = function (ev) {
|
|
513
|
+
if (_this.emitter.listenerCount('ngw:select')) {
|
|
514
|
+
_this._selectFromNgwVector(ev);
|
|
390
515
|
}
|
|
391
516
|
};
|
|
392
517
|
this.emitter.on('click', this.$$selectFromNgwRaster);
|
|
393
518
|
this.emitter.on('layer:click', this.$$selectFromNgwVector);
|
|
394
519
|
}
|
|
395
|
-
}
|
|
396
|
-
disableSelection() {
|
|
520
|
+
};
|
|
521
|
+
NgwMap.prototype.disableSelection = function () {
|
|
397
522
|
if (this.$$selectFromNgwRaster) {
|
|
398
523
|
this.emitter.removeListener('click', this.$$selectFromNgwRaster);
|
|
399
524
|
this.emitter.removeListener('click', this._selectFromNgwVector);
|
|
400
525
|
this.$$selectFromNgwRaster = undefined;
|
|
401
526
|
this.$$selectFromNgwVector = undefined;
|
|
402
527
|
}
|
|
403
|
-
}
|
|
528
|
+
};
|
|
404
529
|
/**
|
|
405
530
|
* @deprecated use {@link NgwMap.fetchNgwLayerItem} instead
|
|
406
531
|
*/
|
|
407
|
-
getNgwLayerItem(options) {
|
|
532
|
+
NgwMap.prototype.getNgwLayerItem = function (options) {
|
|
408
533
|
return this.fetchNgwLayerItem(options);
|
|
409
|
-
}
|
|
534
|
+
};
|
|
410
535
|
/**
|
|
411
536
|
* @deprecated use {@link NgwMap.fetchNgwLayerItems} instead
|
|
412
537
|
*/
|
|
413
|
-
getNgwLayerItems(options) {
|
|
538
|
+
NgwMap.prototype.getNgwLayerItems = function (options) {
|
|
414
539
|
return this.fetchNgwLayerItems(options);
|
|
415
|
-
}
|
|
540
|
+
};
|
|
416
541
|
/**
|
|
417
542
|
* @deprecated use {@link NgwMap.fetchNgwLayerFeature} instead
|
|
418
543
|
*/
|
|
419
|
-
getNgwLayerFeature(options) {
|
|
544
|
+
NgwMap.prototype.getNgwLayerFeature = function (options) {
|
|
420
545
|
return this.fetchNgwLayerFeature(options);
|
|
421
|
-
}
|
|
546
|
+
};
|
|
422
547
|
/**
|
|
423
548
|
* @deprecated use {@link NgwMap.fetchNgwLayerFeatures} instead
|
|
424
549
|
*/
|
|
425
|
-
getNgwLayerFeatures(options) {
|
|
550
|
+
NgwMap.prototype.getNgwLayerFeatures = function (options) {
|
|
426
551
|
return this.fetchNgwLayerFeatures(options);
|
|
427
|
-
}
|
|
552
|
+
};
|
|
428
553
|
/** @deprecated use {@link NgwMap.cancelPromises} instead */
|
|
429
|
-
cancelPromise(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
554
|
+
NgwMap.prototype.cancelPromise = function () {
|
|
555
|
+
var args = [];
|
|
556
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
557
|
+
args[_i] = arguments[_i];
|
|
558
|
+
}
|
|
559
|
+
this.cancelPromises.apply(this, args);
|
|
560
|
+
};
|
|
561
|
+
NgwMap.prototype.cancelPromises = function () {
|
|
562
|
+
var _this = this;
|
|
563
|
+
var args = [];
|
|
564
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
565
|
+
args[_i] = arguments[_i];
|
|
566
|
+
}
|
|
433
567
|
if (!args.length) {
|
|
434
568
|
args = Object.keys(this._promises);
|
|
435
569
|
}
|
|
436
|
-
args.forEach((name)
|
|
437
|
-
|
|
570
|
+
args.forEach(function (name) {
|
|
571
|
+
var group = _this._promises[name];
|
|
438
572
|
if (group) {
|
|
439
|
-
group.forEach((x)
|
|
440
|
-
|
|
573
|
+
group.forEach(function (x) { return x.cancel(); });
|
|
574
|
+
_this._promises[name] = [];
|
|
441
575
|
}
|
|
442
576
|
});
|
|
443
|
-
}
|
|
444
|
-
_addPromise(groupName, promise) {
|
|
445
|
-
|
|
577
|
+
};
|
|
578
|
+
NgwMap.prototype._addPromise = function (groupName, promise) {
|
|
579
|
+
var group = this._promises[groupName];
|
|
446
580
|
if (group && group.indexOf(promise) === -1) {
|
|
447
|
-
|
|
448
|
-
|
|
581
|
+
var removeFromGroup = function () {
|
|
582
|
+
var index = group.indexOf(promise);
|
|
449
583
|
if (index !== -1) {
|
|
450
584
|
group.splice(index, 1);
|
|
451
585
|
}
|
|
@@ -454,55 +588,78 @@ class NgwMap extends WebMap {
|
|
|
454
588
|
promise.catch(removeFromGroup);
|
|
455
589
|
group.push(promise);
|
|
456
590
|
}
|
|
457
|
-
}
|
|
458
|
-
_isFitFromResource() {
|
|
459
|
-
|
|
591
|
+
};
|
|
592
|
+
NgwMap.prototype._isFitFromResource = function () {
|
|
593
|
+
var params = this._initMapState;
|
|
460
594
|
if (params.zoom && params.center) {
|
|
461
595
|
return false;
|
|
462
596
|
}
|
|
463
597
|
return true;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
this
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
598
|
+
};
|
|
599
|
+
NgwMap.prototype._createWebMap = function () {
|
|
600
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
601
|
+
var resources, layerFitAllowed, _i, _a, x, overwriteOptions, _b, resources_1, r, er_2;
|
|
602
|
+
return __generator(this, function (_c) {
|
|
603
|
+
switch (_c.label) {
|
|
604
|
+
case 0: return [4 /*yield*/, this.create()];
|
|
605
|
+
case 1:
|
|
606
|
+
_c.sent();
|
|
607
|
+
if (this.options.qmsId) {
|
|
608
|
+
this._addQmsBaseLayer();
|
|
609
|
+
}
|
|
610
|
+
if (this.options.osm) {
|
|
611
|
+
this._addOsmBaseLayer();
|
|
612
|
+
}
|
|
613
|
+
resources = [];
|
|
614
|
+
layerFitAllowed = this._isFitFromResource();
|
|
615
|
+
if (this.options.webmapId) {
|
|
616
|
+
appendNgwResources(resources, this.options.webmapId, {
|
|
617
|
+
fit: layerFitAllowed,
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
if (this.options.resources && Array.isArray(this.options.resources)) {
|
|
621
|
+
for (_i = 0, _a = this.options.resources; _i < _a.length; _i++) {
|
|
622
|
+
x = _a[_i];
|
|
623
|
+
overwriteOptions = {};
|
|
624
|
+
if (!layerFitAllowed) {
|
|
625
|
+
overwriteOptions.fit = false;
|
|
626
|
+
}
|
|
627
|
+
appendNgwResources(resources, x, {}, overwriteOptions);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
_b = 0, resources_1 = resources;
|
|
631
|
+
_c.label = 2;
|
|
632
|
+
case 2:
|
|
633
|
+
if (!(_b < resources_1.length)) return [3 /*break*/, 7];
|
|
634
|
+
r = resources_1[_b];
|
|
635
|
+
_c.label = 3;
|
|
636
|
+
case 3:
|
|
637
|
+
_c.trys.push([3, 5, , 6]);
|
|
638
|
+
return [4 /*yield*/, this.addNgwLayer(r)];
|
|
639
|
+
case 4:
|
|
640
|
+
_c.sent();
|
|
641
|
+
return [3 /*break*/, 6];
|
|
642
|
+
case 5:
|
|
643
|
+
er_2 = _c.sent();
|
|
644
|
+
console.warn(er_2);
|
|
645
|
+
return [3 /*break*/, 6];
|
|
646
|
+
case 6:
|
|
647
|
+
_b++;
|
|
648
|
+
return [3 /*break*/, 2];
|
|
649
|
+
case 7:
|
|
650
|
+
this._emitStatusEvent('ngw-map:create', this);
|
|
651
|
+
this.enableSelection();
|
|
652
|
+
return [2 /*return*/];
|
|
485
653
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
try {
|
|
491
|
-
await this.addNgwLayer(r);
|
|
492
|
-
}
|
|
493
|
-
catch (er) {
|
|
494
|
-
console.warn(er);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
this._emitStatusEvent('ngw-map:create', this);
|
|
498
|
-
this.enableSelection();
|
|
499
|
-
}
|
|
500
|
-
_addOsmBaseLayer() {
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
NgwMap.prototype._addOsmBaseLayer = function () {
|
|
501
658
|
this.addBaseLayer('OSM');
|
|
502
|
-
}
|
|
503
|
-
_addQmsBaseLayer() {
|
|
504
|
-
|
|
505
|
-
|
|
659
|
+
};
|
|
660
|
+
NgwMap.prototype._addQmsBaseLayer = function () {
|
|
661
|
+
var qmsId;
|
|
662
|
+
var qmsLayerName;
|
|
506
663
|
if (Array.isArray(this.options.qmsId)) {
|
|
507
664
|
qmsId = this.options.qmsId[0];
|
|
508
665
|
qmsLayerName = this.options.qmsId[1];
|
|
@@ -510,135 +667,154 @@ class NgwMap extends WebMap {
|
|
|
510
667
|
else {
|
|
511
668
|
qmsId = Number(this.options.qmsId);
|
|
512
669
|
}
|
|
513
|
-
|
|
514
|
-
qmsId,
|
|
670
|
+
var qmsLayerOptions = {
|
|
671
|
+
qmsId: qmsId,
|
|
515
672
|
};
|
|
516
673
|
if (qmsLayerName) {
|
|
517
674
|
qmsLayerOptions.id = qmsLayerName;
|
|
518
675
|
}
|
|
519
676
|
this.addBaseLayer('QMS', qmsLayerOptions);
|
|
520
|
-
}
|
|
521
|
-
_selectFromNgwVector(ev) {
|
|
522
|
-
|
|
677
|
+
};
|
|
678
|
+
NgwMap.prototype._selectFromNgwVector = function (ev) {
|
|
679
|
+
var _a;
|
|
680
|
+
var layer = ev.layer;
|
|
523
681
|
// item property means layer is NgwResource
|
|
524
|
-
|
|
525
|
-
|
|
682
|
+
var id = layer.item && layer.item.resource.id;
|
|
683
|
+
var feature = ev.feature;
|
|
526
684
|
if (id !== undefined && feature) {
|
|
527
|
-
|
|
685
|
+
var featureId = feature.id;
|
|
528
686
|
if (featureId) {
|
|
529
|
-
|
|
687
|
+
var identifyFeature = {
|
|
530
688
|
id: Number(featureId),
|
|
531
689
|
fields: feature.properties || {},
|
|
532
|
-
label:
|
|
690
|
+
label: "#".concat(id),
|
|
533
691
|
layerId: Number(id),
|
|
534
692
|
parent: '',
|
|
535
693
|
geom: feature.geometry,
|
|
536
694
|
};
|
|
537
|
-
|
|
695
|
+
var items = {
|
|
538
696
|
featureCount: 1,
|
|
539
697
|
features: [identifyFeature],
|
|
540
698
|
};
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
resources: [id],
|
|
548
|
-
sourceType: 'vector',
|
|
549
|
-
}));
|
|
699
|
+
var identify = (_a = {
|
|
700
|
+
featureCount: 1
|
|
701
|
+
},
|
|
702
|
+
_a[id] = items,
|
|
703
|
+
_a);
|
|
704
|
+
this._emitStatusEvent('ngw:select', this._prepareToIdentify(__assign(__assign({}, identify), { resources: [id], sourceType: 'vector' })));
|
|
550
705
|
return identify;
|
|
551
706
|
}
|
|
552
707
|
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
this
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
708
|
+
};
|
|
709
|
+
NgwMap.prototype._selectFromNgwRaster = function (ev) {
|
|
710
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
711
|
+
var promises, layers, getIdsPromise, getIds, ids, pixelRadius, center, zoom, radius, selectPromise;
|
|
712
|
+
var _this = this;
|
|
713
|
+
return __generator(this, function (_a) {
|
|
714
|
+
switch (_a.label) {
|
|
715
|
+
case 0:
|
|
716
|
+
this._emitStatusEvent('ngw:preselect');
|
|
717
|
+
promises = [];
|
|
718
|
+
layers = Object.values(this._ngwLayers);
|
|
719
|
+
layers.sort(function (a, b) {
|
|
720
|
+
if (a.layer.order && b.layer.order) {
|
|
721
|
+
return b.layer.order - a.layer.order;
|
|
722
|
+
}
|
|
723
|
+
return 1;
|
|
724
|
+
});
|
|
725
|
+
layers.forEach(function (l) {
|
|
726
|
+
var layer = l.layer;
|
|
727
|
+
var identFunc = typeof layer.getIdentificationIds === 'function'
|
|
728
|
+
? layer.getIdentificationIds
|
|
729
|
+
: false;
|
|
730
|
+
if (identFunc && layer.options.selectable && _this.isLayerVisible(layer)) {
|
|
731
|
+
promises.push(identFunc.call(layer));
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
getIdsPromise = Promise.all(promises);
|
|
735
|
+
return [4 /*yield*/, getIdsPromise];
|
|
736
|
+
case 1:
|
|
737
|
+
getIds = _a.sent();
|
|
738
|
+
ids = [];
|
|
739
|
+
getIds.forEach(function (x) {
|
|
740
|
+
if (x) {
|
|
741
|
+
x.forEach(function (y) { return ids.push(y); });
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
if (!ids.length) {
|
|
745
|
+
this._emitStatusEvent('ngw:select', null);
|
|
746
|
+
return [2 /*return*/];
|
|
747
|
+
}
|
|
748
|
+
pixelRadius = this.options.pixelRadius || 10;
|
|
749
|
+
center = this.getCenter();
|
|
750
|
+
zoom = this.getZoom();
|
|
751
|
+
zoom = zoom !== undefined ? zoom : 20;
|
|
752
|
+
if (!center || !zoom) {
|
|
753
|
+
this._emitStatusEvent('ngw:select', null);
|
|
754
|
+
return [2 /*return*/];
|
|
755
|
+
}
|
|
756
|
+
radius = getIdentifyRadius(center, zoom, pixelRadius);
|
|
757
|
+
selectPromise = sendIdentifyRequest(ev, {
|
|
758
|
+
layers: ids,
|
|
759
|
+
connector: this.connector,
|
|
760
|
+
radius: radius,
|
|
761
|
+
}).then(function (resp) {
|
|
762
|
+
_this._emitStatusEvent('ngw:select', _this._prepareToIdentify(__assign(__assign({}, resp), { resources: ids, sourceType: 'raster', event: ev })));
|
|
763
|
+
return resp;
|
|
764
|
+
});
|
|
765
|
+
this._addPromise('select', selectPromise);
|
|
766
|
+
return [2 /*return*/, selectPromise];
|
|
767
|
+
}
|
|
768
|
+
});
|
|
606
769
|
});
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return getIdentifyItems(identify, true).map((x) => {
|
|
770
|
+
};
|
|
771
|
+
NgwMap.prototype._prepareToIdentify = function (identify) {
|
|
772
|
+
var _this = this;
|
|
773
|
+
var getIdentifyItems_ = function () {
|
|
774
|
+
return getIdentifyItems(identify, true).map(function (x) {
|
|
613
775
|
return createIdentifyItem({
|
|
614
776
|
feature: x.feature,
|
|
615
|
-
connector:
|
|
777
|
+
connector: _this.connector,
|
|
616
778
|
});
|
|
617
779
|
});
|
|
618
780
|
};
|
|
619
|
-
return {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
781
|
+
return __assign(__assign({}, identify), { getIdentifyItems: getIdentifyItems_ });
|
|
782
|
+
};
|
|
783
|
+
NgwMap.prototype._whiteLabel = function () {
|
|
784
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
785
|
+
var container, logo;
|
|
786
|
+
return __generator(this, function (_a) {
|
|
787
|
+
switch (_a.label) {
|
|
788
|
+
case 0:
|
|
789
|
+
container = this.getContainer();
|
|
790
|
+
if (!container) return [3 /*break*/, 2];
|
|
791
|
+
return [4 /*yield*/, getCompanyLogo(this.connector, this.options.companyLogoOptions)];
|
|
792
|
+
case 1:
|
|
793
|
+
logo = _a.sent();
|
|
794
|
+
if (logo) {
|
|
795
|
+
container.appendChild(logo);
|
|
796
|
+
}
|
|
797
|
+
_a.label = 2;
|
|
798
|
+
case 2: return [2 /*return*/];
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
NgwMap.getIcon = getIcon;
|
|
804
|
+
return NgwMap;
|
|
805
|
+
}(WebMap));
|
|
635
806
|
|
|
636
807
|
/**
|
|
637
808
|
* @module ngw-map
|
|
638
809
|
*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
810
|
+
function createNgwMap(options) {
|
|
811
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
812
|
+
var ngwMap;
|
|
813
|
+
return __generator(this, function (_a) {
|
|
814
|
+
ngwMap = new NgwMap(options);
|
|
815
|
+
return [2 /*return*/, ngwMap.onLoad()];
|
|
816
|
+
});
|
|
817
|
+
});
|
|
642
818
|
}
|
|
643
819
|
|
|
644
820
|
export { NgwMap, createNgwMap };
|