@artstesh/maps 4.0.0 → 4.0.3
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/dist/esm2020/map/map-plate/layers/tile-layer/tile-layer.component.mjs +40 -6
- package/dist/esm2020/map/map-plate/layers/tile-layer/tile-layer.factory.mjs +50 -0
- package/dist/esm2020/map/map-plate/layers/tile-layer/tile-layer.settings.mjs +14 -8
- package/dist/esm2020/map/map-plate/map-plate.component.mjs +8 -7
- package/dist/esm2020/map/map.module.mjs +3 -3
- package/dist/esm2020/map/messages/commands/add-tile.command.mjs +12 -0
- package/dist/esm2020/map/messages/commands/remove-tile.command.mjs +12 -0
- package/dist/esm2020/map/messages/events/map-click.event.mjs +13 -0
- package/dist/esm2020/map/messages/index.mjs +2 -1
- package/dist/esm2020/map/models/marker-model.mjs +4 -7
- package/dist/esm2020/map/services/map-click.service.mjs +49 -0
- package/dist/esm2020/map/services/map-management.service.mjs +21 -8
- package/dist/esm2020/map/services/map-postboy.service.mjs +6 -17
- package/dist/esm2020/map/services/map-state.service.mjs +4 -2
- package/dist/esm2020/map/services/message-registrator.service.mjs +23 -12
- package/dist/esm2020/src/map/map-plate/layers/tile-layer/tile-layer.component.mjs +40 -6
- package/dist/esm2020/src/map/map-plate/layers/tile-layer/tile-layer.factory.mjs +50 -0
- package/dist/esm2020/src/map/map-plate/layers/tile-layer/tile-layer.settings.mjs +14 -8
- package/dist/esm2020/src/map/map-plate/map-plate.component.mjs +8 -7
- package/dist/esm2020/src/map/map.module.mjs +3 -3
- package/dist/esm2020/src/map/messages/commands/add-tile.command.mjs +12 -0
- package/dist/esm2020/src/map/messages/commands/remove-tile.command.mjs +12 -0
- package/dist/esm2020/src/map/messages/events/map-click.event.mjs +13 -0
- package/dist/esm2020/src/map/messages/index.mjs +2 -1
- package/dist/esm2020/src/map/models/marker-model.mjs +4 -7
- package/dist/esm2020/src/map/services/map-click.service.mjs +49 -0
- package/dist/esm2020/src/map/services/map-management.service.mjs +21 -8
- package/dist/esm2020/src/map/services/map-postboy.service.mjs +6 -17
- package/dist/esm2020/src/map/services/map-state.service.mjs +4 -2
- package/dist/esm2020/src/map/services/message-registrator.service.mjs +23 -12
- package/dist/fesm2015/maps-components-src-map.mjs +263 -119
- package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2015/maps-components.mjs +263 -119
- package/dist/fesm2015/maps-components.mjs.map +1 -1
- package/dist/fesm2020/maps-components-src-map.mjs +261 -118
- package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2020/maps-components.mjs +261 -118
- package/dist/fesm2020/maps-components.mjs.map +1 -1
- package/dist/map/map-plate/layers/tile-layer/tile-layer.component.d.ts +14 -5
- package/dist/map/map-plate/layers/tile-layer/tile-layer.factory.d.ts +11 -0
- package/dist/map/map-plate/layers/tile-layer/tile-layer.settings.d.ts +3 -2
- package/dist/map/map-plate/map-plate.component.d.ts +2 -2
- package/dist/map/map.module.d.ts +1 -1
- package/dist/map/messages/commands/add-tile.command.d.ts +9 -0
- package/dist/map/messages/commands/remove-tile.command.d.ts +9 -0
- package/dist/map/messages/events/map-click.event.d.ts +12 -0
- package/dist/map/messages/index.d.ts +1 -0
- package/dist/map/models/marker-model.d.ts +2 -2
- package/dist/map/services/map-click.service.d.ts +16 -0
- package/dist/map/services/map-management.service.d.ts +5 -2
- package/dist/map/services/map-postboy.service.d.ts +4 -7
- package/dist/map/services/map-state.service.d.ts +3 -1
- package/dist/map/services/message-registrator.service.d.ts +7 -2
- package/dist/package.json +2 -1
- package/dist/src/map/map-plate/layers/tile-layer/tile-layer.component.d.ts +14 -5
- package/dist/src/map/map-plate/layers/tile-layer/tile-layer.factory.d.ts +11 -0
- package/dist/src/map/map-plate/layers/tile-layer/tile-layer.settings.d.ts +3 -2
- package/dist/src/map/map-plate/map-plate.component.d.ts +2 -2
- package/dist/src/map/map.module.d.ts +1 -1
- package/dist/src/map/messages/commands/add-tile.command.d.ts +9 -0
- package/dist/src/map/messages/commands/remove-tile.command.d.ts +9 -0
- package/dist/src/map/messages/events/map-click.event.d.ts +12 -0
- package/dist/src/map/messages/index.d.ts +1 -0
- package/dist/src/map/models/marker-model.d.ts +2 -2
- package/dist/src/map/services/map-click.service.d.ts +16 -0
- package/dist/src/map/services/map-management.service.d.ts +5 -2
- package/dist/src/map/services/map-postboy.service.d.ts +4 -7
- package/dist/src/map/services/map-state.service.d.ts +3 -1
- package/dist/src/map/services/message-registrator.service.d.ts +7 -2
- package/package.json +3 -2
- package/dist/esm2020/map/messages/commands/clear-layer.command.mjs +0 -12
- package/dist/esm2020/map/services/service.collector.mjs +0 -14
- package/dist/esm2020/src/map/messages/commands/clear-layer.command.mjs +0 -12
- package/dist/esm2020/src/map/services/service.collector.mjs +0 -14
- package/dist/map/messages/commands/clear-layer.command.d.ts +0 -7
- package/dist/map/services/service.collector.d.ts +0 -9
- package/dist/src/map/messages/commands/clear-layer.command.d.ts +0 -7
- package/dist/src/map/services/service.collector.d.ts +0 -9
|
@@ -4,14 +4,15 @@ import * as i4 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { Feature } from 'ol';
|
|
6
6
|
import { Point } from 'ol/geom';
|
|
7
|
-
import { useGeographic } from 'ol/proj';
|
|
8
|
-
import { Subject
|
|
7
|
+
import { useGeographic, get } from 'ol/proj';
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
|
+
import { PostboyService, PostboyAbstractRegistrator } from '@artstesh/postboy';
|
|
9
10
|
import Map from 'ol/Map';
|
|
10
11
|
import View from 'ol/View';
|
|
11
12
|
import TileLayer from 'ol/layer/Tile';
|
|
12
13
|
import OSM from 'ol/source/OSM';
|
|
13
14
|
import { filter, first } from 'rxjs/operators';
|
|
14
|
-
import { Vector } from 'ol/source';
|
|
15
|
+
import { XYZ, Vector } from 'ol/source';
|
|
15
16
|
import { Vector as Vector$1 } from 'ol/layer';
|
|
16
17
|
import Style from 'ol/style/Style';
|
|
17
18
|
import { Icon, Circle, Fill, Stroke } from 'ol/style';
|
|
@@ -122,10 +123,8 @@ class MarkerModel {
|
|
|
122
123
|
constructor(lat, lng, id, info) {
|
|
123
124
|
this.lat = lat;
|
|
124
125
|
this.lng = lng;
|
|
125
|
-
this.id = id;
|
|
126
126
|
this.info = info;
|
|
127
|
-
|
|
128
|
-
this.id = IdGenerator.get();
|
|
127
|
+
this.id = id == null ? IdGenerator.get() : id;
|
|
129
128
|
this._feature = this.getFeature();
|
|
130
129
|
}
|
|
131
130
|
get feature() {
|
|
@@ -134,9 +133,8 @@ class MarkerModel {
|
|
|
134
133
|
getFeature() {
|
|
135
134
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
136
135
|
feature.setId(this.id);
|
|
137
|
-
if (this.info)
|
|
138
|
-
|
|
139
|
-
}
|
|
136
|
+
if (this.info)
|
|
137
|
+
feature.set('info', this.info);
|
|
140
138
|
return feature;
|
|
141
139
|
}
|
|
142
140
|
}
|
|
@@ -166,6 +164,18 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
166
164
|
}
|
|
167
165
|
MapRenderedEvent.ID = 'b6121807-3b89-4cd3-82cf-089d2cefdc4f';
|
|
168
166
|
|
|
167
|
+
class MapClickEvent extends GenericMessage {
|
|
168
|
+
constructor(coordinates, entities) {
|
|
169
|
+
super();
|
|
170
|
+
this.coordinates = coordinates;
|
|
171
|
+
this.entities = entities;
|
|
172
|
+
}
|
|
173
|
+
get id() {
|
|
174
|
+
return MapClickEvent.ID;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
MapClickEvent.ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
|
|
178
|
+
|
|
169
179
|
class AddLayerCommand extends GenericMessage {
|
|
170
180
|
constructor(layer) {
|
|
171
181
|
super();
|
|
@@ -200,89 +210,72 @@ class RemoveLayerCommand extends GenericMessage {
|
|
|
200
210
|
}
|
|
201
211
|
RemoveLayerCommand.ID = 'ab484e0e-e185-45cd-8434-12101f3c7eb1';
|
|
202
212
|
|
|
203
|
-
class
|
|
213
|
+
class AddTileCommand extends GenericMessage {
|
|
204
214
|
constructor(layer) {
|
|
205
215
|
super();
|
|
206
216
|
this.layer = layer;
|
|
207
217
|
}
|
|
208
218
|
get id() {
|
|
209
|
-
return
|
|
219
|
+
return AddTileCommand.ID;
|
|
210
220
|
}
|
|
211
221
|
}
|
|
212
|
-
|
|
222
|
+
AddTileCommand.ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
|
|
213
223
|
|
|
214
|
-
class
|
|
215
|
-
constructor() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
register(id, sub) {
|
|
219
|
-
this.applications[id] = sub;
|
|
224
|
+
class RemoveTileCommand extends GenericMessage {
|
|
225
|
+
constructor(layer) {
|
|
226
|
+
super();
|
|
227
|
+
this.layer = layer;
|
|
220
228
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
throw new Error(`There is no event with id ${id}`);
|
|
224
|
-
return this.applications[id].asObservable();
|
|
229
|
+
get id() {
|
|
230
|
+
return RemoveTileCommand.ID;
|
|
225
231
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
}
|
|
233
|
+
RemoveTileCommand.ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
|
|
234
|
+
|
|
235
|
+
class MapPostboyService extends PostboyService {
|
|
236
|
+
constructor() {
|
|
237
|
+
super(...arguments);
|
|
238
|
+
this.observe = (id) => this.subscribe(id);
|
|
230
239
|
}
|
|
231
240
|
}
|
|
232
|
-
MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, deps:
|
|
241
|
+
MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
233
242
|
MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService });
|
|
234
243
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPostboyService, decorators: [{
|
|
235
244
|
type: Injectable
|
|
236
245
|
}] });
|
|
237
246
|
|
|
238
|
-
class MessageRegistratorService {
|
|
239
|
-
constructor(service) {
|
|
240
|
-
service.register(MapRenderedEvent.ID, new ReplaySubject(1));
|
|
241
|
-
service.register(AddLayerCommand.ID, new Subject());
|
|
242
|
-
service.register(PlaceLayerFeaturesCommand.ID, new ReplaySubject(1));
|
|
243
|
-
service.register(RemoveLayerCommand.ID, new Subject());
|
|
244
|
-
service.register(ClearLayerCommand.ID, new Subject());
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
248
|
-
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
249
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
250
|
-
type: Injectable
|
|
251
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
252
|
-
|
|
253
|
-
class MapStateService {
|
|
254
|
-
constructor(postboy) {
|
|
255
|
-
this.postboy = postboy;
|
|
256
|
-
postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
260
|
-
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService });
|
|
261
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, decorators: [{
|
|
262
|
-
type: Injectable
|
|
263
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
264
|
-
|
|
265
247
|
class MapManagementService {
|
|
266
248
|
constructor(postboy) {
|
|
267
249
|
this.postboy = postboy;
|
|
268
250
|
this.layers = {};
|
|
251
|
+
}
|
|
252
|
+
up() {
|
|
269
253
|
this.observeMapRender();
|
|
270
254
|
this.observeAddLayer();
|
|
271
255
|
this.observeRemoveLayer();
|
|
272
256
|
this.observePlaceFeatures();
|
|
273
|
-
this.
|
|
257
|
+
this.observeAddTile();
|
|
258
|
+
this.observeRemoveTile();
|
|
259
|
+
}
|
|
260
|
+
observeRemoveTile() {
|
|
261
|
+
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
262
|
+
if (!this.map)
|
|
263
|
+
return;
|
|
264
|
+
this.map.removeLayer(c.layer);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
observeAddTile() {
|
|
268
|
+
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
269
|
+
if (!this.map)
|
|
270
|
+
return;
|
|
271
|
+
this.map.addLayer(c.layer);
|
|
272
|
+
});
|
|
274
273
|
}
|
|
275
274
|
observeMapRender() {
|
|
276
275
|
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
277
276
|
this.map = m.map;
|
|
278
277
|
});
|
|
279
278
|
}
|
|
280
|
-
observeClearLayer() {
|
|
281
|
-
this.postboy.subscribe(ClearLayerCommand.ID).subscribe((c) => {
|
|
282
|
-
var _a, _b;
|
|
283
|
-
(_b = (_a = this.layers[c.layer]) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
279
|
observeAddLayer() {
|
|
287
280
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
288
281
|
if (!this.map)
|
|
@@ -315,14 +308,86 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
315
308
|
type: Injectable
|
|
316
309
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
317
310
|
|
|
318
|
-
class
|
|
319
|
-
constructor(
|
|
311
|
+
class MapStateService {
|
|
312
|
+
constructor(postboy) {
|
|
313
|
+
this.postboy = postboy;
|
|
314
|
+
}
|
|
315
|
+
up() {
|
|
316
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
|
|
317
|
+
}
|
|
320
318
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type:
|
|
319
|
+
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
320
|
+
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService });
|
|
321
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapStateService, decorators: [{
|
|
324
322
|
type: Injectable
|
|
325
|
-
}], ctorParameters: function () { return [{ type:
|
|
323
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
324
|
+
|
|
325
|
+
class MapClickService {
|
|
326
|
+
constructor(postboy) {
|
|
327
|
+
this.postboy = postboy;
|
|
328
|
+
}
|
|
329
|
+
up() {
|
|
330
|
+
this.observeMapRender();
|
|
331
|
+
}
|
|
332
|
+
observeMapRender() {
|
|
333
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
334
|
+
var _a;
|
|
335
|
+
this.map = m.map;
|
|
336
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.on('singleclick', (e) => {
|
|
337
|
+
this.postboy.fire(this.onClick(e));
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
onClick(ev) {
|
|
342
|
+
var _a;
|
|
343
|
+
const model = new MapClickEvent(ev.coordinate, {});
|
|
344
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
345
|
+
this.getFeatureCollectionWithInner([f])
|
|
346
|
+
.filter((f) => !!f.getId())
|
|
347
|
+
.forEach((fs) => {
|
|
348
|
+
let layerName = l.get('name');
|
|
349
|
+
if (!model.entities[layerName])
|
|
350
|
+
model.entities[layerName] = [];
|
|
351
|
+
model.entities[layerName].push(f.getId());
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
return model;
|
|
355
|
+
}
|
|
356
|
+
getFeatureCollectionWithInner(features) {
|
|
357
|
+
const result = [];
|
|
358
|
+
features === null || features === void 0 ? void 0 : features.forEach((f) => {
|
|
359
|
+
const innerFeatures = f.get('features');
|
|
360
|
+
(innerFeatures === null || innerFeatures === void 0 ? void 0 : innerFeatures.length) ? result.push(...innerFeatures) : result.push(f);
|
|
361
|
+
});
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
MapClickService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapClickService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
366
|
+
MapClickService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapClickService });
|
|
367
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapClickService, decorators: [{
|
|
368
|
+
type: Injectable
|
|
369
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
370
|
+
|
|
371
|
+
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
372
|
+
constructor(service, management, state, interaction) {
|
|
373
|
+
super(service);
|
|
374
|
+
this.registerServices([management, state, interaction]);
|
|
375
|
+
}
|
|
376
|
+
_up() {
|
|
377
|
+
this.registerReplay(MapRenderedEvent.ID);
|
|
378
|
+
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
379
|
+
this.registerSubject(AddLayerCommand.ID);
|
|
380
|
+
this.registerSubject(RemoveLayerCommand.ID);
|
|
381
|
+
this.registerSubject(AddTileCommand.ID);
|
|
382
|
+
this.registerSubject(RemoveTileCommand.ID);
|
|
383
|
+
this.registerSubject(MapClickEvent.ID);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
MessageRegistratorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
387
|
+
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService });
|
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
389
|
+
type: Injectable
|
|
390
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
|
|
326
391
|
|
|
327
392
|
class MapPlateFactory {
|
|
328
393
|
build(settings) {
|
|
@@ -407,6 +472,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
407
472
|
this.detector = detector;
|
|
408
473
|
this.osmUrl = '';
|
|
409
474
|
this._settings = new MapSettings();
|
|
475
|
+
registrator.up();
|
|
410
476
|
}
|
|
411
477
|
set settings(value) {
|
|
412
478
|
if (!value || this._settings.isSame(value))
|
|
@@ -433,26 +499,145 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
433
499
|
this.map.updateSize();
|
|
434
500
|
}
|
|
435
501
|
}
|
|
436
|
-
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token:
|
|
437
|
-
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
502
|
+
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
503
|
+
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], usesInheritance: true, ngImport: i0, template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
438
504
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
439
505
|
type: Component,
|
|
440
|
-
args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
441
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type:
|
|
506
|
+
args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService], template: "<ng-content></ng-content>\n<lib-osm-tile-layer *ngIf=\"osmUrl && map\" [map]=\"map\" [url]=\"osmUrl\"></lib-osm-tile-layer>\n", styles: ["lib-map-plate{position:relative;display:flex;flex-direction:column;height:100%}\n"] }]
|
|
507
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
442
508
|
type: Input
|
|
443
509
|
}] } });
|
|
444
510
|
|
|
445
|
-
class
|
|
511
|
+
class TileLayerSettings {
|
|
446
512
|
constructor() {
|
|
513
|
+
this.maxZoom = 19;
|
|
514
|
+
this.minZoom = 0;
|
|
515
|
+
this.opacity = 0.6;
|
|
516
|
+
this.url = '';
|
|
517
|
+
this.projection = 'EPSG:3857';
|
|
518
|
+
}
|
|
519
|
+
static copy(model) {
|
|
520
|
+
const result = new TileLayerSettings();
|
|
521
|
+
result.maxZoom = model.maxZoom;
|
|
522
|
+
result.minZoom = model.minZoom;
|
|
523
|
+
result.projection = model.projection;
|
|
524
|
+
result.opacity = model.opacity;
|
|
525
|
+
result.url = model.url;
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
setUrl(url) {
|
|
529
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
|
|
530
|
+
}
|
|
531
|
+
setMaxZoom(maxZoom) {
|
|
532
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
533
|
+
}
|
|
534
|
+
setMinZoom(minZoom) {
|
|
535
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
536
|
+
}
|
|
537
|
+
setOpacity(opacity) {
|
|
538
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity }));
|
|
539
|
+
}
|
|
540
|
+
setProjection(projection) {
|
|
541
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection }));
|
|
542
|
+
}
|
|
543
|
+
isSame(model) {
|
|
544
|
+
if (this.maxZoom !== model.maxZoom)
|
|
545
|
+
return false;
|
|
546
|
+
if (this.minZoom !== model.minZoom)
|
|
547
|
+
return false;
|
|
548
|
+
if (this.url !== model.url)
|
|
549
|
+
return false;
|
|
550
|
+
if (this.projection !== model.projection)
|
|
551
|
+
return false;
|
|
552
|
+
if (this.opacity !== model.opacity)
|
|
553
|
+
return false;
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
class TileLayerFactory {
|
|
559
|
+
build(settings) {
|
|
560
|
+
const source = new XYZ({
|
|
561
|
+
tileSize: 256,
|
|
562
|
+
maxZoom: settings.maxZoom || 14,
|
|
563
|
+
minZoom: settings.minZoom || 1,
|
|
564
|
+
projection: get(settings.projection),
|
|
565
|
+
tileUrlFunction: this.getTileFunc(settings),
|
|
566
|
+
crossOrigin: 'Anonymous',
|
|
567
|
+
});
|
|
568
|
+
return new TileLayer({ source, opacity: settings.opacity });
|
|
569
|
+
}
|
|
570
|
+
getTileFunc(settings) {
|
|
571
|
+
return (tileCoord) => {
|
|
572
|
+
const zoom = tileCoord[0];
|
|
573
|
+
const x = tileCoord[1];
|
|
574
|
+
const y = tileCoord[2];
|
|
575
|
+
const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
|
|
576
|
+
const bound = 1 << zoom;
|
|
577
|
+
return settings.url
|
|
578
|
+
.replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
|
|
579
|
+
.replace('{z}', String(zoom))
|
|
580
|
+
.replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
getNormalizedCoord(coord, zoom) {
|
|
584
|
+
const y = coord.y;
|
|
585
|
+
let x = coord.x;
|
|
586
|
+
const tileRange = 1 << zoom;
|
|
587
|
+
if (y < 0 || y >= tileRange)
|
|
588
|
+
return null;
|
|
589
|
+
if (x < 0 || x >= tileRange)
|
|
590
|
+
x = ((x % tileRange) + tileRange) % tileRange;
|
|
591
|
+
return { x: x, y: y };
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
TileLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
595
|
+
TileLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerFactory, providedIn: 'root' });
|
|
596
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerFactory, decorators: [{
|
|
597
|
+
type: Injectable,
|
|
598
|
+
args: [{
|
|
599
|
+
providedIn: 'root',
|
|
600
|
+
}]
|
|
601
|
+
}] });
|
|
602
|
+
|
|
603
|
+
class TileLayerComponent extends DestructibleComponent {
|
|
604
|
+
constructor(postboy, factory) {
|
|
447
605
|
super();
|
|
606
|
+
this.postboy = postboy;
|
|
607
|
+
this.factory = factory;
|
|
608
|
+
this._settings = new TileLayerSettings();
|
|
609
|
+
this.onDestroy = () => this.removeLayer();
|
|
610
|
+
}
|
|
611
|
+
ngOnInit() {
|
|
612
|
+
this.postboy
|
|
613
|
+
.subscribe(MapRenderedEvent.ID)
|
|
614
|
+
.pipe(filter((m) => !!m), first())
|
|
615
|
+
.subscribe((m) => this.initLayer());
|
|
616
|
+
}
|
|
617
|
+
set settings(value) {
|
|
618
|
+
if (!value || this._settings.isSame(value))
|
|
619
|
+
return;
|
|
620
|
+
this._settings = value;
|
|
621
|
+
this.initLayer();
|
|
622
|
+
}
|
|
623
|
+
initLayer() {
|
|
624
|
+
this.removeLayer();
|
|
625
|
+
this.layer = this.factory.build(this._settings);
|
|
626
|
+
this.postboy.fire(new AddTileCommand(this.layer));
|
|
627
|
+
}
|
|
628
|
+
removeLayer() {
|
|
629
|
+
if (this.layer)
|
|
630
|
+
this.postboy.fire(new RemoveTileCommand(this.layer));
|
|
448
631
|
}
|
|
449
632
|
}
|
|
450
|
-
TileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
451
|
-
TileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TileLayerComponent, selector: "lib-tile-layer", usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
633
|
+
TileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerComponent, deps: [{ token: MapPostboyService }, { token: TileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
634
|
+
TileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TileLayerComponent, selector: "lib-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
452
635
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TileLayerComponent, decorators: [{
|
|
453
636
|
type: Component,
|
|
454
637
|
args: [{ selector: 'lib-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
455
|
-
}], ctorParameters: function () { return []; }
|
|
638
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
|
|
639
|
+
type: Input
|
|
640
|
+
}] } });
|
|
456
641
|
|
|
457
642
|
class FeatureLayerSettings {
|
|
458
643
|
constructor() {
|
|
@@ -607,7 +792,7 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
|
607
792
|
TileLayerComponent,
|
|
608
793
|
OsmTileLayerComponent,
|
|
609
794
|
FeatureLayerComponent,
|
|
610
|
-
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent] });
|
|
795
|
+
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent] });
|
|
611
796
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
612
797
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
|
|
613
798
|
type: NgModule,
|
|
@@ -621,51 +806,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
621
806
|
FeatureLayerComponent,
|
|
622
807
|
MarkersComponent,
|
|
623
808
|
],
|
|
624
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent],
|
|
809
|
+
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
|
|
625
810
|
}]
|
|
626
811
|
}] });
|
|
627
812
|
|
|
628
|
-
class TileLayerSettings {
|
|
629
|
-
constructor() {
|
|
630
|
-
this.name = 'tiles';
|
|
631
|
-
this.maxZoom = 19;
|
|
632
|
-
this.minZoom = 0;
|
|
633
|
-
this.opacity = 1;
|
|
634
|
-
this.url = '';
|
|
635
|
-
}
|
|
636
|
-
static copy(model) {
|
|
637
|
-
const result = new TileLayerSettings();
|
|
638
|
-
result.name = model.name;
|
|
639
|
-
result.maxZoom = model.maxZoom;
|
|
640
|
-
result.minZoom = model.minZoom;
|
|
641
|
-
result.url = model.url;
|
|
642
|
-
return result;
|
|
643
|
-
}
|
|
644
|
-
setUrl(url) {
|
|
645
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
|
|
646
|
-
}
|
|
647
|
-
setName(name) {
|
|
648
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
|
|
649
|
-
}
|
|
650
|
-
setMaxZoom(maxZoom) {
|
|
651
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
652
|
-
}
|
|
653
|
-
setMinZoom(minZoom) {
|
|
654
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
655
|
-
}
|
|
656
|
-
isSame(model) {
|
|
657
|
-
if (this.maxZoom !== model.maxZoom)
|
|
658
|
-
return false;
|
|
659
|
-
if (this.minZoom !== model.minZoom)
|
|
660
|
-
return false;
|
|
661
|
-
if (this.url !== model.url)
|
|
662
|
-
return false;
|
|
663
|
-
if (this.name !== model.name)
|
|
664
|
-
return false;
|
|
665
|
-
return true;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
813
|
class MarkerStyleHelper {
|
|
670
814
|
static fromSvg(svg, size = [30, 30], zIndex = 400) {
|
|
671
815
|
let image = new Image();
|
|
@@ -701,5 +845,5 @@ class MarkerStyleHelper {
|
|
|
701
845
|
* Generated bundle index. Do not edit.
|
|
702
846
|
*/
|
|
703
847
|
|
|
704
|
-
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
848
|
+
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
705
849
|
//# sourceMappingURL=maps-components.mjs.map
|