Showing
7 changed files
with
24 additions
and
21 deletions
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | import L, { | 17 | import L, { |
18 | FeatureGroup, | 18 | FeatureGroup, |
19 | Icon, | 19 | Icon, |
20 | - LatLngBounds, LatLngExpression, | 20 | + LatLngBounds, |
21 | LatLngTuple, | 21 | LatLngTuple, |
22 | markerClusterGroup, | 22 | markerClusterGroup, |
23 | MarkerClusterGroup, | 23 | MarkerClusterGroup, |
@@ -50,8 +50,6 @@ import { | @@ -50,8 +50,6 @@ import { | ||
50 | } from '@home/components/widget/lib/maps/maps-utils'; | 50 | } from '@home/components/widget/lib/maps/maps-utils'; |
51 | import { WidgetContext } from '@home/models/widget-component.models'; | 51 | import { WidgetContext } from '@home/models/widget-component.models'; |
52 | import { deepClone, isDefinedAndNotEmptyStr } from '@core/utils'; | 52 | import { deepClone, isDefinedAndNotEmptyStr } from '@core/utils'; |
53 | -import {newArray} from "@angular/compiler/src/util"; | ||
54 | -import {isArray} from "rxjs/internal-compatibility"; | ||
55 | 53 | ||
56 | export default abstract class LeafletMap { | 54 | export default abstract class LeafletMap { |
57 | 55 | ||
@@ -186,9 +184,9 @@ export default abstract class LeafletMap { | @@ -186,9 +184,9 @@ export default abstract class LeafletMap { | ||
186 | let mousePositionOnMap: L.LatLng[]; | 184 | let mousePositionOnMap: L.LatLng[]; |
187 | let addPolygon: L.Control; | 185 | let addPolygon: L.Control; |
188 | this.map.on('mousemove', (e: L.LeafletMouseEvent) => { | 186 | this.map.on('mousemove', (e: L.LeafletMouseEvent) => { |
189 | - let latlng1 = e.latlng; | ||
190 | - let latlng2 = L.latLng(e.latlng.lat, e.latlng.lng + 10); | ||
191 | - let latlng3 = L.latLng(e.latlng.lat-10, e.latlng.lng); | 187 | + const latlng1 = e.latlng; |
188 | + const latlng2 = L.latLng(e.latlng.lat, e.latlng.lng + 10); | ||
189 | + const latlng3 = L.latLng(e.latlng.lat-10, e.latlng.lng); | ||
192 | mousePositionOnMap = [latlng1,latlng2, latlng3 ]; | 190 | mousePositionOnMap = [latlng1,latlng2, latlng3 ]; |
193 | }); | 191 | }); |
194 | const dragListener = (e: L.DragEndEvent) => { | 192 | const dragListener = (e: L.DragEndEvent) => { |
@@ -207,7 +205,6 @@ export default abstract class LeafletMap { | @@ -207,7 +205,6 @@ export default abstract class LeafletMap { | ||
207 | this.savePolygonLocation(updatedEnttity).subscribe(() => { | 205 | this.savePolygonLocation(updatedEnttity).subscribe(() => { |
208 | this.map.removeLayer(newPolygon); | 206 | this.map.removeLayer(newPolygon); |
209 | this.deletePolygon(ds.entityName); | 207 | this.deletePolygon(ds.entityName); |
210 | - // this.createPolygon(ds, this.datasources, this.options); | ||
211 | }); | 208 | }); |
212 | } | 209 | } |
213 | datasourcesList.append(dsItem); | 210 | datasourcesList.append(dsItem); |
@@ -673,7 +670,7 @@ export default abstract class LeafletMap { | @@ -673,7 +670,7 @@ export default abstract class LeafletMap { | ||
673 | } | 670 | } |
674 | 671 | ||
675 | dragPolygonVertex = (e?, data = {} as FormattedData) => { | 672 | dragPolygonVertex = (e?, data = {} as FormattedData) => { |
676 | - if (e == undefined || (e.type !== 'editable:vertex:dragend' && e.type !== 'editable:vertex:deleted')) return; | 673 | + if (e === undefined || (e.type !== 'editable:vertex:dragend' && e.type !== 'editable:vertex:deleted')) return; |
677 | this.savePolygonLocation({ ...data, ...this.convertPolygonToCustomFormat(e.layer._latlngs) }).subscribe(); | 674 | this.savePolygonLocation({ ...data, ...this.convertPolygonToCustomFormat(e.layer._latlngs) }).subscribe(); |
678 | } | 675 | } |
679 | 676 |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | 16 | ||
17 | import L, { LatLngExpression, LeafletMouseEvent } from 'leaflet'; | 17 | import L, { LatLngExpression, LeafletMouseEvent } from 'leaflet'; |
18 | import { createTooltip, functionValueCalculator, parseWithTranslation, safeExecute } from './maps-utils'; | 18 | import { createTooltip, functionValueCalculator, parseWithTranslation, safeExecute } from './maps-utils'; |
19 | -import "leaflet-editable/src/Leaflet.Editable"; | 19 | +import 'leaflet-editable/src/Leaflet.Editable'; |
20 | import { FormattedData, PolygonSettings } from './map-models'; | 20 | import { FormattedData, PolygonSettings } from './map-models'; |
21 | 21 | ||
22 | export class Polygon { | 22 | export class Polygon { |
@@ -41,8 +41,8 @@ export class Polygon { | @@ -41,8 +41,8 @@ export class Polygon { | ||
41 | if (settings.editablePolygon) { | 41 | if (settings.editablePolygon) { |
42 | this.leafletPoly.enableEdit(this.map); | 42 | this.leafletPoly.enableEdit(this.map); |
43 | if (onDragendListener) { | 43 | if (onDragendListener) { |
44 | - this.leafletPoly.on("editable:vertex:dragend", e => onDragendListener(e, this.data)); | ||
45 | - this.leafletPoly.on("editable:vertex:deleted", e => onDragendListener(e, this.data)); | 44 | + this.leafletPoly.on('editable:vertex:dragend', e => onDragendListener(e, this.data)); |
45 | + this.leafletPoly.on('editable:vertex:deleted', e => onDragendListener(e, this.data)); | ||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 |
@@ -20,7 +20,6 @@ import LeafletMap from '../leaflet-map'; | @@ -20,7 +20,6 @@ import LeafletMap from '../leaflet-map'; | ||
20 | import { UnitedMapSettings } from '../map-models'; | 20 | import { UnitedMapSettings } from '../map-models'; |
21 | import 'leaflet.gridlayer.googlemutant'; | 21 | import 'leaflet.gridlayer.googlemutant'; |
22 | import { ResourcesService } from '@core/services/resources.service'; | 22 | import { ResourcesService } from '@core/services/resources.service'; |
23 | -import { Injector } from '@angular/core'; | ||
24 | import { WidgetContext } from '@home/models/widget-component.models'; | 23 | import { WidgetContext } from '@home/models/widget-component.models'; |
25 | 24 | ||
26 | const gmGlobals: GmGlobal = {}; | 25 | const gmGlobals: GmGlobal = {}; |
@@ -37,7 +36,10 @@ export class GoogleMap extends LeafletMap { | @@ -37,7 +36,10 @@ export class GoogleMap extends LeafletMap { | ||
37 | this.resource = ctx.$injector.get(ResourcesService); | 36 | this.resource = ctx.$injector.get(ResourcesService); |
38 | super.initSettings(options); | 37 | super.initSettings(options); |
39 | this.loadGoogle(() => { | 38 | this.loadGoogle(() => { |
40 | - const map = L.map($container, {attributionControl: false, editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | 39 | + const map = L.map($container, { |
40 | + attributionControl: false, | ||
41 | + editable: !!options.editablePolygon | ||
42 | + }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | ||
41 | (L.gridLayer as any).googleMutant({ | 43 | (L.gridLayer as any).googleMutant({ |
42 | type: options?.gmDefaultMapType || 'roadmap' | 44 | type: options?.gmDefaultMapType || 'roadmap' |
43 | }).addTo(map); | 45 | }).addTo(map); |
@@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models'; | @@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models'; | ||
22 | export class HEREMap extends LeafletMap { | 22 | export class HEREMap extends LeafletMap { |
23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { | 23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { |
24 | super(ctx, $container, options); | 24 | super(ctx, $container, options); |
25 | - const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | 25 | + const map = L.map($container, { |
26 | + editable: !!options.editablePolygon | ||
27 | + }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | ||
26 | const tileLayer = (L.tileLayer as any).provider(options.mapProviderHere || 'HERE.normalDay', options.credentials); | 28 | const tileLayer = (L.tileLayer as any).provider(options.mapProviderHere || 'HERE.normalDay', options.credentials); |
27 | tileLayer.addTo(map); | 29 | tileLayer.addTo(map); |
28 | super.initSettings(options); | 30 | super.initSettings(options); |
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | /// limitations under the License. | 14 | /// limitations under the License. |
15 | /// | 15 | /// |
16 | 16 | ||
17 | -import L, {LatLngBounds, LatLngExpression, LatLngLiteral, LatLngTuple} from 'leaflet'; | 17 | +import L, { LatLngBounds, LatLngLiteral, LatLngTuple } from 'leaflet'; |
18 | import LeafletMap from '../leaflet-map'; | 18 | import LeafletMap from '../leaflet-map'; |
19 | import { MapImage, PosFuncton, UnitedMapSettings } from '../map-models'; | 19 | import { MapImage, PosFuncton, UnitedMapSettings } from '../map-models'; |
20 | import { Observable, ReplaySubject } from 'rxjs'; | 20 | import { Observable, ReplaySubject } from 'rxjs'; |
@@ -24,9 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; | @@ -24,9 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; | ||
24 | import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models'; | 24 | import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models'; |
25 | import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; | 25 | import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; |
26 | import { WidgetSubscriptionOptions } from '@core/api/widget-api.models'; | 26 | import { WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
27 | -import { isDefinedAndNotNull, isDefinedAndNotEmptyStr, isNumber } from '@core/utils'; | ||
28 | -import "leaflet-editable/src/Leaflet.Editable"; | ||
29 | -import {isArray} from "rxjs/internal-compatibility"; | 27 | +import { isDefinedAndNotEmptyStr } from '@core/utils'; |
30 | 28 | ||
31 | const maxZoom = 4;// ? | 29 | const maxZoom = 4;// ? |
32 | 30 | ||
@@ -260,7 +258,7 @@ export class ImageMap extends LeafletMap { | @@ -260,7 +258,7 @@ export class ImageMap extends LeafletMap { | ||
260 | if (point.length) { | 258 | if (point.length) { |
261 | return this.convertToPolygonFormat(point); | 259 | return this.convertToPolygonFormat(point); |
262 | } else { | 260 | } else { |
263 | - let pos = this.latLngToPoint(point); | 261 | + const pos = this.latLngToPoint(point); |
264 | return [calculateNewPointCoordinate(pos.x, this.width), calculateNewPointCoordinate(pos.y, this.height)]; | 262 | return [calculateNewPointCoordinate(pos.x, this.width), calculateNewPointCoordinate(pos.y, this.height)]; |
265 | } | 263 | } |
266 | }) | 264 | }) |
@@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models'; | @@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models'; | ||
22 | export class OpenStreetMap extends LeafletMap { | 22 | export class OpenStreetMap extends LeafletMap { |
23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { | 23 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { |
24 | super(ctx, $container, options); | 24 | super(ctx, $container, options); |
25 | - const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | 25 | + const map = L.map($container, { |
26 | + editable: !!options.editablePolygon | ||
27 | + }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | ||
26 | let tileLayer; | 28 | let tileLayer; |
27 | if (options.useCustomProvider) | 29 | if (options.useCustomProvider) |
28 | tileLayer = L.tileLayer(options.customProviderTileUrl); | 30 | tileLayer = L.tileLayer(options.customProviderTileUrl); |
@@ -24,7 +24,9 @@ export class TencentMap extends LeafletMap { | @@ -24,7 +24,9 @@ export class TencentMap extends LeafletMap { | ||
24 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { | 24 | constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) { |
25 | super(ctx, $container, options); | 25 | super(ctx, $container, options); |
26 | const txUrl = 'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0'; | 26 | const txUrl = 'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0'; |
27 | - const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | 27 | + const map = L.map($container, { |
28 | + editable: !!options.editablePolygon | ||
29 | + }).setView(options?.defaultCenterPosition, options?.defaultZoomLevel); | ||
28 | const txLayer = L.tileLayer(txUrl, { | 30 | const txLayer = L.tileLayer(txUrl, { |
29 | subdomains: '0123', | 31 | subdomains: '0123', |
30 | tms: true, | 32 | tms: true, |