@artstesh/maps 1.0.0 → 1.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/bundles/maps-components-src-map.umd.js +307 -134
- package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
- package/dist/bundles/maps-components.umd.js +307 -134
- package/dist/bundles/maps-components.umd.js.map +1 -1
- package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.component.js +40 -6
- package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.factory.js +50 -0
- package/dist/esm2015/map/map-plate/layers/tile-layer/tile-layer.settings.js +14 -8
- package/dist/esm2015/map/map-plate/map-plate.component.js +8 -7
- package/dist/esm2015/map/map.module.js +3 -3
- package/dist/esm2015/map/messages/commands/add-tile.command.js +12 -0
- package/dist/esm2015/map/messages/commands/remove-tile.command.js +12 -0
- package/dist/esm2015/map/messages/events/map-click.event.js +13 -0
- package/dist/esm2015/map/messages/index.js +2 -1
- package/dist/esm2015/map/models/marker-model.js +4 -7
- package/dist/esm2015/map/services/map-click.service.js +51 -0
- package/dist/esm2015/map/services/map-management.service.js +21 -9
- package/dist/esm2015/map/services/map-postboy.service.js +6 -17
- package/dist/esm2015/map/services/map-state.service.js +4 -2
- package/dist/esm2015/map/services/message-registrator.service.js +23 -12
- package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.component.js +40 -6
- package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.factory.js +50 -0
- package/dist/esm2015/src/map/map-plate/layers/tile-layer/tile-layer.settings.js +14 -8
- package/dist/esm2015/src/map/map-plate/map-plate.component.js +8 -7
- package/dist/esm2015/src/map/map.module.js +3 -3
- package/dist/esm2015/src/map/messages/commands/add-tile.command.js +12 -0
- package/dist/esm2015/src/map/messages/commands/remove-tile.command.js +12 -0
- package/dist/esm2015/src/map/messages/events/map-click.event.js +13 -0
- package/dist/esm2015/src/map/messages/index.js +2 -1
- package/dist/esm2015/src/map/models/marker-model.js +4 -7
- package/dist/esm2015/src/map/services/map-click.service.js +51 -0
- package/dist/esm2015/src/map/services/map-management.service.js +21 -9
- package/dist/esm2015/src/map/services/map-postboy.service.js +6 -17
- package/dist/esm2015/src/map/services/map-state.service.js +4 -2
- package/dist/esm2015/src/map/services/message-registrator.service.js +23 -12
- package/dist/fesm2015/maps-components-src-map.js +263 -119
- package/dist/fesm2015/maps-components-src-map.js.map +1 -1
- package/dist/fesm2015/maps-components.js +263 -119
- package/dist/fesm2015/maps-components.js.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 +4 -3
- package/dist/esm2015/map/messages/commands/clear-layer.command.js +0 -12
- package/dist/esm2015/map/services/service.collector.js +0 -14
- package/dist/esm2015/src/map/messages/commands/clear-layer.command.js +0 -12
- package/dist/esm2015/src/map/services/service.collector.js +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 i5 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: "12.2.17", ngImport: i0, type: MapPostboyService, deps:
|
|
241
|
+
MapPostboyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
233
242
|
MapPostboyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPostboyService });
|
|
234
243
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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: "12.2.17", ngImport: i0, type: MessageRegistratorService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
248
|
-
MessageRegistratorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
249
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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: "12.2.17", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
260
|
-
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService });
|
|
261
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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: "12.2.17", 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: "12.2.17", ngImport: i0, type:
|
|
319
|
+
MapStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
320
|
+
MapStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapStateService });
|
|
321
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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: "12.2.17", ngImport: i0, type: MapClickService, deps: [{ token: MapPostboyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
366
|
+
MapClickService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapClickService });
|
|
367
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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: "12.2.17", 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: "12.2.17", ngImport: i0, type: MessageRegistratorService });
|
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", 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) {
|
|
@@ -412,6 +477,7 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
412
477
|
this.detector = detector;
|
|
413
478
|
this.osmUrl = '';
|
|
414
479
|
this._settings = new MapSettings();
|
|
480
|
+
registrator.up();
|
|
415
481
|
}
|
|
416
482
|
set settings(value) {
|
|
417
483
|
if (!value || this._settings.isSame(value))
|
|
@@ -438,8 +504,8 @@ class MapPlateComponent extends DestructibleComponent {
|
|
|
438
504
|
this.map.updateSize();
|
|
439
505
|
}
|
|
440
506
|
}
|
|
441
|
-
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token:
|
|
442
|
-
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: MapPlateComponent, selector: "lib-map-plate", inputs: { settings: "settings" }, providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
507
|
+
MapPlateComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, deps: [{ token: i0.ElementRef }, { token: MapPostboyService }, { token: MapPlateFactory }, { token: MessageRegistratorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
508
|
+
MapPlateComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", 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"], components: [{ type: OsmTileLayerComponent, selector: "lib-osm-tile-layer", inputs: ["url", "map"] }], directives: [{ type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
443
509
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapPlateComponent, decorators: [{
|
|
444
510
|
type: Component,
|
|
445
511
|
args: [{
|
|
@@ -447,19 +513,136 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
447
513
|
templateUrl: './map-plate.component.html',
|
|
448
514
|
styleUrls: ['./map-plate.component.scss'],
|
|
449
515
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
450
|
-
providers: [MessageRegistratorService, MapStateService, MapManagementService,
|
|
516
|
+
providers: [MessageRegistratorService, MapStateService, MapManagementService, MapClickService],
|
|
451
517
|
}]
|
|
452
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type:
|
|
518
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: MapPostboyService }, { type: MapPlateFactory }, { type: MessageRegistratorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { settings: [{
|
|
453
519
|
type: Input
|
|
454
520
|
}] } });
|
|
455
521
|
|
|
456
|
-
class
|
|
522
|
+
class TileLayerSettings {
|
|
457
523
|
constructor() {
|
|
524
|
+
this.maxZoom = 19;
|
|
525
|
+
this.minZoom = 0;
|
|
526
|
+
this.opacity = 0.6;
|
|
527
|
+
this.url = '';
|
|
528
|
+
this.projection = 'EPSG:3857';
|
|
529
|
+
}
|
|
530
|
+
static copy(model) {
|
|
531
|
+
const result = new TileLayerSettings();
|
|
532
|
+
result.maxZoom = model.maxZoom;
|
|
533
|
+
result.minZoom = model.minZoom;
|
|
534
|
+
result.projection = model.projection;
|
|
535
|
+
result.opacity = model.opacity;
|
|
536
|
+
result.url = model.url;
|
|
537
|
+
return result;
|
|
538
|
+
}
|
|
539
|
+
setUrl(url) {
|
|
540
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
|
|
541
|
+
}
|
|
542
|
+
setMaxZoom(maxZoom) {
|
|
543
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
544
|
+
}
|
|
545
|
+
setMinZoom(minZoom) {
|
|
546
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
547
|
+
}
|
|
548
|
+
setOpacity(opacity) {
|
|
549
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity }));
|
|
550
|
+
}
|
|
551
|
+
setProjection(projection) {
|
|
552
|
+
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection }));
|
|
553
|
+
}
|
|
554
|
+
isSame(model) {
|
|
555
|
+
if (this.maxZoom !== model.maxZoom)
|
|
556
|
+
return false;
|
|
557
|
+
if (this.minZoom !== model.minZoom)
|
|
558
|
+
return false;
|
|
559
|
+
if (this.url !== model.url)
|
|
560
|
+
return false;
|
|
561
|
+
if (this.projection !== model.projection)
|
|
562
|
+
return false;
|
|
563
|
+
if (this.opacity !== model.opacity)
|
|
564
|
+
return false;
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
class TileLayerFactory {
|
|
570
|
+
build(settings) {
|
|
571
|
+
const source = new XYZ({
|
|
572
|
+
tileSize: 256,
|
|
573
|
+
maxZoom: settings.maxZoom || 14,
|
|
574
|
+
minZoom: settings.minZoom || 1,
|
|
575
|
+
projection: get(settings.projection),
|
|
576
|
+
tileUrlFunction: this.getTileFunc(settings),
|
|
577
|
+
crossOrigin: 'Anonymous',
|
|
578
|
+
});
|
|
579
|
+
return new TileLayer({ source, opacity: settings.opacity });
|
|
580
|
+
}
|
|
581
|
+
getTileFunc(settings) {
|
|
582
|
+
return (tileCoord) => {
|
|
583
|
+
const zoom = tileCoord[0];
|
|
584
|
+
const x = tileCoord[1];
|
|
585
|
+
const y = tileCoord[2];
|
|
586
|
+
const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
|
|
587
|
+
const bound = 1 << zoom;
|
|
588
|
+
return settings.url
|
|
589
|
+
.replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
|
|
590
|
+
.replace('{z}', String(zoom))
|
|
591
|
+
.replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
getNormalizedCoord(coord, zoom) {
|
|
595
|
+
const y = coord.y;
|
|
596
|
+
let x = coord.x;
|
|
597
|
+
const tileRange = 1 << zoom;
|
|
598
|
+
if (y < 0 || y >= tileRange)
|
|
599
|
+
return null;
|
|
600
|
+
if (x < 0 || x >= tileRange)
|
|
601
|
+
x = ((x % tileRange) + tileRange) % tileRange;
|
|
602
|
+
return { x: x, y: y };
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
TileLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
606
|
+
TileLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerFactory, providedIn: 'root' });
|
|
607
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerFactory, decorators: [{
|
|
608
|
+
type: Injectable,
|
|
609
|
+
args: [{
|
|
610
|
+
providedIn: 'root',
|
|
611
|
+
}]
|
|
612
|
+
}] });
|
|
613
|
+
|
|
614
|
+
class TileLayerComponent extends DestructibleComponent {
|
|
615
|
+
constructor(postboy, factory) {
|
|
458
616
|
super();
|
|
617
|
+
this.postboy = postboy;
|
|
618
|
+
this.factory = factory;
|
|
619
|
+
this._settings = new TileLayerSettings();
|
|
620
|
+
this.onDestroy = () => this.removeLayer();
|
|
621
|
+
}
|
|
622
|
+
ngOnInit() {
|
|
623
|
+
this.postboy
|
|
624
|
+
.subscribe(MapRenderedEvent.ID)
|
|
625
|
+
.pipe(filter((m) => !!m), first())
|
|
626
|
+
.subscribe((m) => this.initLayer());
|
|
627
|
+
}
|
|
628
|
+
set settings(value) {
|
|
629
|
+
if (!value || this._settings.isSame(value))
|
|
630
|
+
return;
|
|
631
|
+
this._settings = value;
|
|
632
|
+
this.initLayer();
|
|
633
|
+
}
|
|
634
|
+
initLayer() {
|
|
635
|
+
this.removeLayer();
|
|
636
|
+
this.layer = this.factory.build(this._settings);
|
|
637
|
+
this.postboy.fire(new AddTileCommand(this.layer));
|
|
638
|
+
}
|
|
639
|
+
removeLayer() {
|
|
640
|
+
if (this.layer)
|
|
641
|
+
this.postboy.fire(new RemoveTileCommand(this.layer));
|
|
459
642
|
}
|
|
460
643
|
}
|
|
461
|
-
TileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
462
|
-
TileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TileLayerComponent, selector: "lib-tile-layer", usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
644
|
+
TileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerComponent, deps: [{ token: MapPostboyService }, { token: TileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
|
|
645
|
+
TileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TileLayerComponent, selector: "lib-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
463
646
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TileLayerComponent, decorators: [{
|
|
464
647
|
type: Component,
|
|
465
648
|
args: [{
|
|
@@ -468,7 +651,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
468
651
|
styleUrls: [],
|
|
469
652
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
470
653
|
}]
|
|
471
|
-
}], ctorParameters: function () { return []; }
|
|
654
|
+
}], ctorParameters: function () { return [{ type: MapPostboyService }, { type: TileLayerFactory }]; }, propDecorators: { settings: [{
|
|
655
|
+
type: Input
|
|
656
|
+
}] } });
|
|
472
657
|
|
|
473
658
|
class FeatureLayerSettings {
|
|
474
659
|
constructor() {
|
|
@@ -633,7 +818,7 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
|
|
|
633
818
|
TileLayerComponent,
|
|
634
819
|
OsmTileLayerComponent,
|
|
635
820
|
FeatureLayerComponent,
|
|
636
|
-
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent] });
|
|
821
|
+
MarkersComponent], imports: [CommonModule], exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent] });
|
|
637
822
|
MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
|
|
638
823
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
|
|
639
824
|
type: NgModule,
|
|
@@ -647,51 +832,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
647
832
|
FeatureLayerComponent,
|
|
648
833
|
MarkersComponent,
|
|
649
834
|
],
|
|
650
|
-
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent],
|
|
835
|
+
exports: [MapPlateComponent, FeatureLayerComponent, MarkersComponent, TileLayerComponent],
|
|
651
836
|
}]
|
|
652
837
|
}] });
|
|
653
838
|
|
|
654
|
-
class TileLayerSettings {
|
|
655
|
-
constructor() {
|
|
656
|
-
this.name = 'tiles';
|
|
657
|
-
this.maxZoom = 19;
|
|
658
|
-
this.minZoom = 0;
|
|
659
|
-
this.opacity = 1;
|
|
660
|
-
this.url = '';
|
|
661
|
-
}
|
|
662
|
-
static copy(model) {
|
|
663
|
-
const result = new TileLayerSettings();
|
|
664
|
-
result.name = model.name;
|
|
665
|
-
result.maxZoom = model.maxZoom;
|
|
666
|
-
result.minZoom = model.minZoom;
|
|
667
|
-
result.url = model.url;
|
|
668
|
-
return result;
|
|
669
|
-
}
|
|
670
|
-
setUrl(url) {
|
|
671
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
|
|
672
|
-
}
|
|
673
|
-
setName(name) {
|
|
674
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { name }));
|
|
675
|
-
}
|
|
676
|
-
setMaxZoom(maxZoom) {
|
|
677
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
|
|
678
|
-
}
|
|
679
|
-
setMinZoom(minZoom) {
|
|
680
|
-
return TileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
|
|
681
|
-
}
|
|
682
|
-
isSame(model) {
|
|
683
|
-
if (this.maxZoom !== model.maxZoom)
|
|
684
|
-
return false;
|
|
685
|
-
if (this.minZoom !== model.minZoom)
|
|
686
|
-
return false;
|
|
687
|
-
if (this.url !== model.url)
|
|
688
|
-
return false;
|
|
689
|
-
if (this.name !== model.name)
|
|
690
|
-
return false;
|
|
691
|
-
return true;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
839
|
class MarkerStyleHelper {
|
|
696
840
|
static fromSvg(svg, size = [30, 30], zIndex = 400) {
|
|
697
841
|
let image = new Image();
|
|
@@ -723,5 +867,5 @@ class MarkerStyleHelper {
|
|
|
723
867
|
* Generated bundle index. Do not edit.
|
|
724
868
|
*/
|
|
725
869
|
|
|
726
|
-
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
870
|
+
export { CallbackMessage, FeatureLayerComponent, FeatureLayerSettings, GenericMessage, MapClickEvent, MapLyrs, MapLyrsLabel, MapModule, MapPlateComponent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, OsmTileLayerComponent, TileLayerComponent, TileLayerSettings };
|
|
727
871
|
//# sourceMappingURL=maps-components-src-map.js.map
|