@artstesh/maps 5.0.0 → 5.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/esm2022/map/map-plate/layers/tile-layer/tile-layer.component.mjs +42 -7
- package/dist/esm2022/map/map-plate/layers/tile-layer/tile-layer.factory.mjs +50 -0
- package/dist/esm2022/map/map-plate/layers/tile-layer/tile-layer.settings.mjs +14 -8
- package/dist/esm2022/map/map-plate/map-plate.component.mjs +8 -7
- package/dist/esm2022/map/map.module.mjs +3 -3
- package/dist/esm2022/map/messages/commands/add-tile.command.mjs +13 -0
- package/dist/esm2022/map/messages/commands/remove-tile.command.mjs +13 -0
- package/dist/esm2022/map/messages/events/map-click.event.mjs +15 -0
- package/dist/esm2022/map/messages/index.mjs +2 -1
- package/dist/esm2022/map/models/marker-model.mjs +5 -8
- package/dist/esm2022/map/services/map-click.service.mjs +51 -0
- package/dist/esm2022/map/services/map-management.service.mjs +21 -8
- package/dist/esm2022/map/services/map-postboy.service.mjs +5 -17
- package/dist/esm2022/map/services/map-state.service.mjs +4 -2
- package/dist/esm2022/map/services/message-registrator.service.mjs +23 -12
- package/dist/esm2022/src/map/map-plate/layers/tile-layer/tile-layer.component.mjs +42 -7
- package/dist/esm2022/src/map/map-plate/layers/tile-layer/tile-layer.factory.mjs +50 -0
- package/dist/esm2022/src/map/map-plate/layers/tile-layer/tile-layer.settings.mjs +14 -8
- package/dist/esm2022/src/map/map-plate/map-plate.component.mjs +8 -7
- package/dist/esm2022/src/map/map.module.mjs +3 -3
- package/dist/esm2022/src/map/messages/commands/add-tile.command.mjs +13 -0
- package/dist/esm2022/src/map/messages/commands/remove-tile.command.mjs +13 -0
- package/dist/esm2022/src/map/messages/events/map-click.event.mjs +15 -0
- package/dist/esm2022/src/map/messages/index.mjs +2 -1
- package/dist/esm2022/src/map/models/marker-model.mjs +5 -8
- package/dist/esm2022/src/map/services/map-click.service.mjs +51 -0
- package/dist/esm2022/src/map/services/map-management.service.mjs +21 -8
- package/dist/esm2022/src/map/services/map-postboy.service.mjs +5 -17
- package/dist/esm2022/src/map/services/map-state.service.mjs +4 -2
- package/dist/esm2022/src/map/services/message-registrator.service.mjs +23 -12
- package/dist/fesm2022/maps-components-src-map.mjs +267 -119
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +267 -119
- package/dist/fesm2022/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/esm2022/map/messages/commands/clear-layer.command.mjs +0 -13
- package/dist/esm2022/map/services/service.collector.mjs +0 -14
- package/dist/esm2022/src/map/messages/commands/clear-layer.command.mjs +0 -13
- package/dist/esm2022/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';
|
|
@@ -118,15 +119,13 @@ class IdGenerator {
|
|
|
118
119
|
class MarkerModel {
|
|
119
120
|
lat;
|
|
120
121
|
lng;
|
|
121
|
-
id;
|
|
122
122
|
info;
|
|
123
|
+
id;
|
|
123
124
|
constructor(lat, lng, id, info) {
|
|
124
125
|
this.lat = lat;
|
|
125
126
|
this.lng = lng;
|
|
126
|
-
this.id = id;
|
|
127
127
|
this.info = info;
|
|
128
|
-
|
|
129
|
-
this.id = IdGenerator.get();
|
|
128
|
+
this.id = id == null ? IdGenerator.get() : id;
|
|
130
129
|
this._feature = this.getFeature();
|
|
131
130
|
}
|
|
132
131
|
_feature;
|
|
@@ -136,9 +135,8 @@ class MarkerModel {
|
|
|
136
135
|
getFeature() {
|
|
137
136
|
const feature = new Feature(new Point([this.lng, this.lat]));
|
|
138
137
|
feature.setId(this.id);
|
|
139
|
-
if (this.info)
|
|
140
|
-
|
|
141
|
-
}
|
|
138
|
+
if (this.info)
|
|
139
|
+
feature.set('info', this.info);
|
|
142
140
|
return feature;
|
|
143
141
|
}
|
|
144
142
|
}
|
|
@@ -166,6 +164,20 @@ class MapRenderedEvent extends GenericMessage {
|
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
|
|
167
|
+
class MapClickEvent extends GenericMessage {
|
|
168
|
+
coordinates;
|
|
169
|
+
entities;
|
|
170
|
+
static ID = '323df526-8d9c-49c6-83e8-6e9a1e7762f7';
|
|
171
|
+
constructor(coordinates, entities) {
|
|
172
|
+
super();
|
|
173
|
+
this.coordinates = coordinates;
|
|
174
|
+
this.entities = entities;
|
|
175
|
+
}
|
|
176
|
+
get id() {
|
|
177
|
+
return MapClickEvent.ID;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
169
181
|
class AddLayerCommand extends GenericMessage {
|
|
170
182
|
layer;
|
|
171
183
|
static ID = 'd93e250f-92bc-43ac-9c6a-46c521a1aaa5';
|
|
@@ -204,91 +216,73 @@ class RemoveLayerCommand extends GenericMessage {
|
|
|
204
216
|
}
|
|
205
217
|
}
|
|
206
218
|
|
|
207
|
-
class
|
|
219
|
+
class AddTileCommand extends GenericMessage {
|
|
208
220
|
layer;
|
|
209
|
-
static ID = '
|
|
221
|
+
static ID = '25b7df28-72ce-4453-9fe6-54285a2fdc57';
|
|
210
222
|
constructor(layer) {
|
|
211
223
|
super();
|
|
212
224
|
this.layer = layer;
|
|
213
225
|
}
|
|
214
226
|
get id() {
|
|
215
|
-
return
|
|
227
|
+
return AddTileCommand.ID;
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
230
|
|
|
219
|
-
class
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (!this.applications[id])
|
|
226
|
-
throw new Error(`There is no event with id ${id}`);
|
|
227
|
-
return this.applications[id].asObservable();
|
|
231
|
+
class RemoveTileCommand extends GenericMessage {
|
|
232
|
+
layer;
|
|
233
|
+
static ID = 'c36ccc0b-5638-4819-b148-2de57a59a5b7';
|
|
234
|
+
constructor(layer) {
|
|
235
|
+
super();
|
|
236
|
+
this.layer = layer;
|
|
228
237
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
throw new Error(`There is no event with id ${message.id}`);
|
|
232
|
-
this.applications[message.id].next(message);
|
|
238
|
+
get id() {
|
|
239
|
+
return RemoveTileCommand.ID;
|
|
233
240
|
}
|
|
234
|
-
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
class MapPostboyService extends PostboyService {
|
|
244
|
+
observe = (id) => this.subscribe(id);
|
|
245
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
235
246
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPostboyService });
|
|
236
247
|
}
|
|
237
248
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPostboyService, decorators: [{
|
|
238
249
|
type: Injectable
|
|
239
250
|
}] });
|
|
240
251
|
|
|
241
|
-
class MessageRegistratorService {
|
|
242
|
-
constructor(service) {
|
|
243
|
-
service.register(MapRenderedEvent.ID, new ReplaySubject(1));
|
|
244
|
-
service.register(AddLayerCommand.ID, new Subject());
|
|
245
|
-
service.register(PlaceLayerFeaturesCommand.ID, new ReplaySubject(1));
|
|
246
|
-
service.register(RemoveLayerCommand.ID, new Subject());
|
|
247
|
-
service.register(ClearLayerCommand.ID, new Subject());
|
|
248
|
-
}
|
|
249
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
250
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
251
|
-
}
|
|
252
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
253
|
-
type: Injectable
|
|
254
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
255
|
-
|
|
256
|
-
class MapStateService {
|
|
257
|
-
postboy;
|
|
258
|
-
map;
|
|
259
|
-
constructor(postboy) {
|
|
260
|
-
this.postboy = postboy;
|
|
261
|
-
postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
|
|
262
|
-
}
|
|
263
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
264
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService });
|
|
265
|
-
}
|
|
266
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService, decorators: [{
|
|
267
|
-
type: Injectable
|
|
268
|
-
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
269
|
-
|
|
270
252
|
class MapManagementService {
|
|
271
253
|
postboy;
|
|
272
254
|
map;
|
|
273
255
|
layers = {};
|
|
274
256
|
constructor(postboy) {
|
|
275
257
|
this.postboy = postboy;
|
|
258
|
+
}
|
|
259
|
+
up() {
|
|
276
260
|
this.observeMapRender();
|
|
277
261
|
this.observeAddLayer();
|
|
278
262
|
this.observeRemoveLayer();
|
|
279
263
|
this.observePlaceFeatures();
|
|
280
|
-
this.
|
|
264
|
+
this.observeAddTile();
|
|
265
|
+
this.observeRemoveTile();
|
|
266
|
+
}
|
|
267
|
+
observeRemoveTile() {
|
|
268
|
+
this.postboy.subscribe(RemoveTileCommand.ID).subscribe((c) => {
|
|
269
|
+
if (!this.map)
|
|
270
|
+
return;
|
|
271
|
+
this.map.removeLayer(c.layer);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
observeAddTile() {
|
|
275
|
+
this.postboy.subscribe(AddTileCommand.ID).subscribe((c) => {
|
|
276
|
+
if (!this.map)
|
|
277
|
+
return;
|
|
278
|
+
this.map.addLayer(c.layer);
|
|
279
|
+
});
|
|
281
280
|
}
|
|
282
281
|
observeMapRender() {
|
|
283
282
|
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
284
283
|
this.map = m.map;
|
|
285
284
|
});
|
|
286
285
|
}
|
|
287
|
-
observeClearLayer() {
|
|
288
|
-
this.postboy.subscribe(ClearLayerCommand.ID).subscribe((c) => {
|
|
289
|
-
this.layers[c.layer]?.getSource()?.clear();
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
286
|
observeAddLayer() {
|
|
293
287
|
this.postboy.subscribe(AddLayerCommand.ID).subscribe((c) => {
|
|
294
288
|
if (!this.map)
|
|
@@ -320,14 +314,88 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
320
314
|
type: Injectable
|
|
321
315
|
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
322
316
|
|
|
323
|
-
class
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
317
|
+
class MapStateService {
|
|
318
|
+
postboy;
|
|
319
|
+
map;
|
|
320
|
+
constructor(postboy) {
|
|
321
|
+
this.postboy = postboy;
|
|
322
|
+
}
|
|
323
|
+
up() {
|
|
324
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => (this.map = m));
|
|
325
|
+
}
|
|
326
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
327
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService });
|
|
327
328
|
}
|
|
328
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type:
|
|
329
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapStateService, decorators: [{
|
|
329
330
|
type: Injectable
|
|
330
|
-
}], ctorParameters: function () { return [{ type:
|
|
331
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
332
|
+
|
|
333
|
+
class MapClickService {
|
|
334
|
+
postboy;
|
|
335
|
+
map;
|
|
336
|
+
constructor(postboy) {
|
|
337
|
+
this.postboy = postboy;
|
|
338
|
+
}
|
|
339
|
+
up() {
|
|
340
|
+
this.observeMapRender();
|
|
341
|
+
}
|
|
342
|
+
observeMapRender() {
|
|
343
|
+
this.postboy.subscribe(MapRenderedEvent.ID).subscribe((m) => {
|
|
344
|
+
this.map = m.map;
|
|
345
|
+
this.map?.on('singleclick', (e) => {
|
|
346
|
+
this.postboy.fire(this.onClick(e));
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
onClick(ev) {
|
|
351
|
+
const model = new MapClickEvent(ev.coordinate, {});
|
|
352
|
+
this.map?.forEachFeatureAtPixel(ev.pixel, (f, l) => {
|
|
353
|
+
this.getFeatureCollectionWithInner([f])
|
|
354
|
+
.filter((f) => !!f.getId())
|
|
355
|
+
.forEach((fs) => {
|
|
356
|
+
let layerName = l.get('name');
|
|
357
|
+
if (!model.entities[layerName])
|
|
358
|
+
model.entities[layerName] = [];
|
|
359
|
+
model.entities[layerName].push(f.getId());
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return model;
|
|
363
|
+
}
|
|
364
|
+
getFeatureCollectionWithInner(features) {
|
|
365
|
+
const result = [];
|
|
366
|
+
features?.forEach((f) => {
|
|
367
|
+
const innerFeatures = f.get('features');
|
|
368
|
+
innerFeatures?.length ? result.push(...innerFeatures) : result.push(f);
|
|
369
|
+
});
|
|
370
|
+
return result;
|
|
371
|
+
}
|
|
372
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapClickService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
373
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapClickService });
|
|
374
|
+
}
|
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapClickService, decorators: [{
|
|
376
|
+
type: Injectable
|
|
377
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }]; } });
|
|
378
|
+
|
|
379
|
+
class MessageRegistratorService extends PostboyAbstractRegistrator {
|
|
380
|
+
constructor(service, management, state, interaction) {
|
|
381
|
+
super(service);
|
|
382
|
+
this.registerServices([management, state, interaction]);
|
|
383
|
+
}
|
|
384
|
+
_up() {
|
|
385
|
+
this.registerReplay(MapRenderedEvent.ID);
|
|
386
|
+
this.registerReplay(PlaceLayerFeaturesCommand.ID);
|
|
387
|
+
this.registerSubject(AddLayerCommand.ID);
|
|
388
|
+
this.registerSubject(RemoveLayerCommand.ID);
|
|
389
|
+
this.registerSubject(AddTileCommand.ID);
|
|
390
|
+
this.registerSubject(RemoveTileCommand.ID);
|
|
391
|
+
this.registerSubject(MapClickEvent.ID);
|
|
392
|
+
}
|
|
393
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }, { token: MapManagementService }, { token: MapStateService }, { token: MapClickService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
394
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService });
|
|
395
|
+
}
|
|
396
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageRegistratorService, decorators: [{
|
|
397
|
+
type: Injectable
|
|
398
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: MapManagementService }, { type: MapStateService }, { type: MapClickService }]; } });
|
|
331
399
|
|
|
332
400
|
class MapPlateFactory {
|
|
333
401
|
build(settings) {
|
|
@@ -417,6 +485,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
417
485
|
this.postboy = postboy;
|
|
418
486
|
this.mapFactory = mapFactory;
|
|
419
487
|
this.detector = detector;
|
|
488
|
+
registrator.up();
|
|
420
489
|
}
|
|
421
490
|
_settings = new MapSettings();
|
|
422
491
|
set settings(value) {
|
|
@@ -443,29 +512,147 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
443
512
|
this.detector.detectChanges();
|
|
444
513
|
this.map.updateSize();
|
|
445
514
|
}
|
|
446
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token:
|
|
447
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
515
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
516
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", 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 });
|
|
448
517
|
}
|
|
449
518
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
450
519
|
type: Component,
|
|
451
|
-
args: [{ selector: 'lib-map-plate', changeDetection: ChangeDetectionStrategy.OnPush, providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
452
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type:
|
|
520
|
+
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"] }]
|
|
521
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
453
522
|
type: Input
|
|
454
523
|
}] } });
|
|
455
524
|
|
|
525
|
+
class TileLayerSettings {
|
|
526
|
+
maxZoom = 19;
|
|
527
|
+
minZoom = 0;
|
|
528
|
+
opacity = 0.6;
|
|
529
|
+
url = '';
|
|
530
|
+
projection = 'EPSG:3857';
|
|
531
|
+
static copy(model) {
|
|
532
|
+
const result = new TileLayerSettings();
|
|
533
|
+
result.maxZoom = model.maxZoom;
|
|
534
|
+
result.minZoom = model.minZoom;
|
|
535
|
+
result.projection = model.projection;
|
|
536
|
+
result.opacity = model.opacity;
|
|
537
|
+
result.url = model.url;
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
setUrl(url) {
|
|
541
|
+
return TileLayerSettings.copy({ ...this, url });
|
|
542
|
+
}
|
|
543
|
+
setMaxZoom(maxZoom) {
|
|
544
|
+
return TileLayerSettings.copy({ ...this, maxZoom });
|
|
545
|
+
}
|
|
546
|
+
setMinZoom(minZoom) {
|
|
547
|
+
return TileLayerSettings.copy({ ...this, minZoom });
|
|
548
|
+
}
|
|
549
|
+
setOpacity(opacity) {
|
|
550
|
+
return TileLayerSettings.copy({ ...this, opacity });
|
|
551
|
+
}
|
|
552
|
+
setProjection(projection) {
|
|
553
|
+
return TileLayerSettings.copy({ ...this, projection });
|
|
554
|
+
}
|
|
555
|
+
isSame(model) {
|
|
556
|
+
if (this.maxZoom !== model.maxZoom)
|
|
557
|
+
return false;
|
|
558
|
+
if (this.minZoom !== model.minZoom)
|
|
559
|
+
return false;
|
|
560
|
+
if (this.url !== model.url)
|
|
561
|
+
return false;
|
|
562
|
+
if (this.projection !== model.projection)
|
|
563
|
+
return false;
|
|
564
|
+
if (this.opacity !== model.opacity)
|
|
565
|
+
return false;
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
class TileLayerFactory {
|
|
571
|
+
build(settings) {
|
|
572
|
+
const source = new XYZ({
|
|
573
|
+
tileSize: 256,
|
|
574
|
+
maxZoom: settings.maxZoom || 14,
|
|
575
|
+
minZoom: settings.minZoom || 1,
|
|
576
|
+
projection: get(settings.projection),
|
|
577
|
+
tileUrlFunction: this.getTileFunc(settings),
|
|
578
|
+
crossOrigin: 'Anonymous',
|
|
579
|
+
});
|
|
580
|
+
return new TileLayer({ source, opacity: settings.opacity });
|
|
581
|
+
}
|
|
582
|
+
getTileFunc(settings) {
|
|
583
|
+
return (tileCoord) => {
|
|
584
|
+
const zoom = tileCoord[0];
|
|
585
|
+
const x = tileCoord[1];
|
|
586
|
+
const y = tileCoord[2];
|
|
587
|
+
const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
|
|
588
|
+
const bound = 1 << zoom;
|
|
589
|
+
return settings.url
|
|
590
|
+
.replace('{x}', String(normalizedCoord?.x || x))
|
|
591
|
+
.replace('{z}', String(zoom))
|
|
592
|
+
.replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
getNormalizedCoord(coord, zoom) {
|
|
596
|
+
const y = coord.y;
|
|
597
|
+
let x = coord.x;
|
|
598
|
+
const tileRange = 1 << zoom;
|
|
599
|
+
if (y < 0 || y >= tileRange)
|
|
600
|
+
return null;
|
|
601
|
+
if (x < 0 || x >= tileRange)
|
|
602
|
+
x = ((x % tileRange) + tileRange) % tileRange;
|
|
603
|
+
return { x: x, y: y };
|
|
604
|
+
}
|
|
605
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
606
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TileLayerFactory, providedIn: 'root' });
|
|
607
|
+
}
|
|
608
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TileLayerFactory, decorators: [{
|
|
609
|
+
type: Injectable,
|
|
610
|
+
args: [{
|
|
611
|
+
providedIn: 'root',
|
|
612
|
+
}]
|
|
613
|
+
}] });
|
|
614
|
+
|
|
456
615
|
class TileLayerComponent extends DestructibleComponent {
|
|
457
|
-
|
|
616
|
+
postboy;
|
|
617
|
+
factory;
|
|
458
618
|
layer;
|
|
459
|
-
constructor() {
|
|
619
|
+
constructor(postboy, factory) {
|
|
460
620
|
super();
|
|
621
|
+
this.postboy = postboy;
|
|
622
|
+
this.factory = factory;
|
|
623
|
+
}
|
|
624
|
+
ngOnInit() {
|
|
625
|
+
this.postboy
|
|
626
|
+
.subscribe(MapRenderedEvent.ID)
|
|
627
|
+
.pipe(filter((m) => !!m), first())
|
|
628
|
+
.subscribe((m) => this.initLayer());
|
|
629
|
+
}
|
|
630
|
+
_settings = new TileLayerSettings();
|
|
631
|
+
set settings(value) {
|
|
632
|
+
if (!value || this._settings.isSame(value))
|
|
633
|
+
return;
|
|
634
|
+
this._settings = value;
|
|
635
|
+
this.initLayer();
|
|
461
636
|
}
|
|
462
|
-
|
|
463
|
-
|
|
637
|
+
onDestroy = () => this.removeLayer();
|
|
638
|
+
initLayer() {
|
|
639
|
+
this.removeLayer();
|
|
640
|
+
this.layer = this.factory.build(this._settings);
|
|
641
|
+
this.postboy.fire(new AddTileCommand(this.layer));
|
|
642
|
+
}
|
|
643
|
+
removeLayer() {
|
|
644
|
+
if (this.layer)
|
|
645
|
+
this.postboy.fire(new RemoveTileCommand(this.layer));
|
|
646
|
+
}
|
|
647
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TileLayerComponent, deps: [{ token: MapPostboyService }, { token: TileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
648
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TileLayerComponent, selector: "lib-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
464
649
|
}
|
|
465
650
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TileLayerComponent, decorators: [{
|
|
466
651
|
type: Component,
|
|
467
652
|
args: [{ selector: 'lib-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
|
|
468
|
-
}], ctorParameters: function () { return []; }
|
|
653
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
|
|
654
|
+
type: Input
|
|
655
|
+
}] } });
|
|
469
656
|
|
|
470
657
|
class FeatureLayerSettings {
|
|
471
658
|
name = IdGenerator.get();
|
|
@@ -620,7 +807,7 @@ class MapModule {
|
|
|
620
807
|
TileLayerComponent,
|
|
621
808
|
OsmTileLayerComponent,
|
|
622
809
|
FeatureLayerComponent,
|
|
623
|
-
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent] });
|
|
810
|
+
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent] });
|
|
624
811
|
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, imports: [CommonModule] });
|
|
625
812
|
}
|
|
626
813
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MapModule, decorators: [{
|
|
@@ -635,49 +822,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
635
822
|
FeatureLayerComponent,
|
|
636
823
|
MarkersComponent,
|
|
637
824
|
],
|
|
638
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent],
|
|
825
|
+
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
|
|
639
826
|
}]
|
|
640
827
|
}] });
|
|
641
828
|
|
|
642
|
-
class TileLayerSettings {
|
|
643
|
-
name = 'tiles';
|
|
644
|
-
maxZoom = 19;
|
|
645
|
-
minZoom = 0;
|
|
646
|
-
opacity = 1;
|
|
647
|
-
url = '';
|
|
648
|
-
static copy(model) {
|
|
649
|
-
const result = new TileLayerSettings();
|
|
650
|
-
result.name = model.name;
|
|
651
|
-
result.maxZoom = model.maxZoom;
|
|
652
|
-
result.minZoom = model.minZoom;
|
|
653
|
-
result.url = model.url;
|
|
654
|
-
return result;
|
|
655
|
-
}
|
|
656
|
-
setUrl(url) {
|
|
657
|
-
return TileLayerSettings.copy({ ...this, url });
|
|
658
|
-
}
|
|
659
|
-
setName(name) {
|
|
660
|
-
return TileLayerSettings.copy({ ...this, name });
|
|
661
|
-
}
|
|
662
|
-
setMaxZoom(maxZoom) {
|
|
663
|
-
return TileLayerSettings.copy({ ...this, maxZoom });
|
|
664
|
-
}
|
|
665
|
-
setMinZoom(minZoom) {
|
|
666
|
-
return TileLayerSettings.copy({ ...this, minZoom });
|
|
667
|
-
}
|
|
668
|
-
isSame(model) {
|
|
669
|
-
if (this.maxZoom !== model.maxZoom)
|
|
670
|
-
return false;
|
|
671
|
-
if (this.minZoom !== model.minZoom)
|
|
672
|
-
return false;
|
|
673
|
-
if (this.url !== model.url)
|
|
674
|
-
return false;
|
|
675
|
-
if (this.name !== model.name)
|
|
676
|
-
return false;
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
|
|
681
829
|
class MarkerStyleHelper {
|
|
682
830
|
static fromSvg(svg, size = [30, 30], zIndex = 400) {
|
|
683
831
|
let image = new Image();
|
|
@@ -713,5 +861,5 @@ class MarkerStyleHelper {
|
|
|
713
861
|
* Generated bundle index. Do not edit.
|
|
714
862
|
*/
|
|
715
863
|
|
|
716
|
-
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
864
|
+
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
717
865
|
//# sourceMappingURL=maps-components.mjs.map
|