Clear code
This commit is contained in:
parent
a088221c25
commit
a1fb61ff4c
@ -17,7 +17,7 @@
|
||||
import L, {
|
||||
FeatureGroup,
|
||||
Icon,
|
||||
LatLngBounds, LatLngExpression,
|
||||
LatLngBounds,
|
||||
LatLngTuple,
|
||||
markerClusterGroup,
|
||||
MarkerClusterGroup,
|
||||
@ -50,8 +50,6 @@ import {
|
||||
} from '@home/components/widget/lib/maps/maps-utils';
|
||||
import { WidgetContext } from '@home/models/widget-component.models';
|
||||
import { deepClone, isDefinedAndNotEmptyStr } from '@core/utils';
|
||||
import {newArray} from "@angular/compiler/src/util";
|
||||
import {isArray} from "rxjs/internal-compatibility";
|
||||
|
||||
export default abstract class LeafletMap {
|
||||
|
||||
@ -186,9 +184,9 @@ export default abstract class LeafletMap {
|
||||
let mousePositionOnMap: L.LatLng[];
|
||||
let addPolygon: L.Control;
|
||||
this.map.on('mousemove', (e: L.LeafletMouseEvent) => {
|
||||
let latlng1 = e.latlng;
|
||||
let latlng2 = L.latLng(e.latlng.lat, e.latlng.lng + 10);
|
||||
let latlng3 = L.latLng(e.latlng.lat-10, e.latlng.lng);
|
||||
const latlng1 = e.latlng;
|
||||
const latlng2 = L.latLng(e.latlng.lat, e.latlng.lng + 10);
|
||||
const latlng3 = L.latLng(e.latlng.lat-10, e.latlng.lng);
|
||||
mousePositionOnMap = [latlng1,latlng2, latlng3 ];
|
||||
});
|
||||
const dragListener = (e: L.DragEndEvent) => {
|
||||
@ -207,7 +205,6 @@ export default abstract class LeafletMap {
|
||||
this.savePolygonLocation(updatedEnttity).subscribe(() => {
|
||||
this.map.removeLayer(newPolygon);
|
||||
this.deletePolygon(ds.entityName);
|
||||
// this.createPolygon(ds, this.datasources, this.options);
|
||||
});
|
||||
}
|
||||
datasourcesList.append(dsItem);
|
||||
@ -673,7 +670,7 @@ export default abstract class LeafletMap {
|
||||
}
|
||||
|
||||
dragPolygonVertex = (e?, data = {} as FormattedData) => {
|
||||
if (e == undefined || (e.type !== 'editable:vertex:dragend' && e.type !== 'editable:vertex:deleted')) return;
|
||||
if (e === undefined || (e.type !== 'editable:vertex:dragend' && e.type !== 'editable:vertex:deleted')) return;
|
||||
this.savePolygonLocation({ ...data, ...this.convertPolygonToCustomFormat(e.layer._latlngs) }).subscribe();
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
import L, { LatLngExpression, LeafletMouseEvent } from 'leaflet';
|
||||
import { createTooltip, functionValueCalculator, parseWithTranslation, safeExecute } from './maps-utils';
|
||||
import "leaflet-editable/src/Leaflet.Editable";
|
||||
import 'leaflet-editable/src/Leaflet.Editable';
|
||||
import { FormattedData, PolygonSettings } from './map-models';
|
||||
|
||||
export class Polygon {
|
||||
@ -41,8 +41,8 @@ export class Polygon {
|
||||
if (settings.editablePolygon) {
|
||||
this.leafletPoly.enableEdit(this.map);
|
||||
if (onDragendListener) {
|
||||
this.leafletPoly.on("editable:vertex:dragend", e => onDragendListener(e, this.data));
|
||||
this.leafletPoly.on("editable:vertex:deleted", e => onDragendListener(e, this.data));
|
||||
this.leafletPoly.on('editable:vertex:dragend', e => onDragendListener(e, this.data));
|
||||
this.leafletPoly.on('editable:vertex:deleted', e => onDragendListener(e, this.data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import LeafletMap from '../leaflet-map';
|
||||
import { UnitedMapSettings } from '../map-models';
|
||||
import 'leaflet.gridlayer.googlemutant';
|
||||
import { ResourcesService } from '@core/services/resources.service';
|
||||
import { Injector } from '@angular/core';
|
||||
import { WidgetContext } from '@home/models/widget-component.models';
|
||||
|
||||
const gmGlobals: GmGlobal = {};
|
||||
@ -37,7 +36,10 @@ export class GoogleMap extends LeafletMap {
|
||||
this.resource = ctx.$injector.get(ResourcesService);
|
||||
super.initSettings(options);
|
||||
this.loadGoogle(() => {
|
||||
const map = L.map($container, {attributionControl: false, editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const map = L.map($container, {
|
||||
attributionControl: false,
|
||||
editable: !!options.editablePolygon
|
||||
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
(L.gridLayer as any).googleMutant({
|
||||
type: options?.gmDefaultMapType || 'roadmap'
|
||||
}).addTo(map);
|
||||
|
||||
@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models';
|
||||
export class HEREMap extends LeafletMap {
|
||||
constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) {
|
||||
super(ctx, $container, options);
|
||||
const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const map = L.map($container, {
|
||||
editable: !!options.editablePolygon
|
||||
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const tileLayer = (L.tileLayer as any).provider(options.mapProviderHere || 'HERE.normalDay', options.credentials);
|
||||
tileLayer.addTo(map);
|
||||
super.initSettings(options);
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
/// limitations under the License.
|
||||
///
|
||||
|
||||
import L, {LatLngBounds, LatLngExpression, LatLngLiteral, LatLngTuple} from 'leaflet';
|
||||
import L, { LatLngBounds, LatLngLiteral, LatLngTuple } from 'leaflet';
|
||||
import LeafletMap from '../leaflet-map';
|
||||
import { MapImage, PosFuncton, UnitedMapSettings } from '../map-models';
|
||||
import { Observable, ReplaySubject } from 'rxjs';
|
||||
@ -24,9 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
|
||||
import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models';
|
||||
import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
|
||||
import { WidgetSubscriptionOptions } from '@core/api/widget-api.models';
|
||||
import { isDefinedAndNotNull, isDefinedAndNotEmptyStr, isNumber } from '@core/utils';
|
||||
import "leaflet-editable/src/Leaflet.Editable";
|
||||
import {isArray} from "rxjs/internal-compatibility";
|
||||
import { isDefinedAndNotEmptyStr } from '@core/utils';
|
||||
|
||||
const maxZoom = 4;// ?
|
||||
|
||||
@ -260,7 +258,7 @@ export class ImageMap extends LeafletMap {
|
||||
if (point.length) {
|
||||
return this.convertToPolygonFormat(point);
|
||||
} else {
|
||||
let pos = this.latLngToPoint(point);
|
||||
const pos = this.latLngToPoint(point);
|
||||
return [calculateNewPointCoordinate(pos.x, this.width), calculateNewPointCoordinate(pos.y, this.height)];
|
||||
}
|
||||
})
|
||||
|
||||
@ -22,7 +22,9 @@ import { WidgetContext } from '@home/models/widget-component.models';
|
||||
export class OpenStreetMap extends LeafletMap {
|
||||
constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) {
|
||||
super(ctx, $container, options);
|
||||
const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const map = L.map($container, {
|
||||
editable: !!options.editablePolygon
|
||||
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
let tileLayer;
|
||||
if (options.useCustomProvider)
|
||||
tileLayer = L.tileLayer(options.customProviderTileUrl);
|
||||
|
||||
@ -24,7 +24,9 @@ export class TencentMap extends LeafletMap {
|
||||
constructor(ctx: WidgetContext, $container, options: UnitedMapSettings) {
|
||||
super(ctx, $container, options);
|
||||
const txUrl = 'http://rt{s}.map.gtimg.com/realtimerender?z={z}&x={x}&y={y}&type=vector&style=0';
|
||||
const map = L.map($container, {editable: !!options.editablePolygon}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const map = L.map($container, {
|
||||
editable: !!options.editablePolygon
|
||||
}).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const txLayer = L.tileLayer(txUrl, {
|
||||
subdomains: '0123',
|
||||
tms: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user