Commit 507bd43a37512597aeab47b17b1e71a4b525a74a

Authored by Igor Kulikov
Committed by GitHub
2 parents 5071ce84 c9392ab0

Merge pull request #2819 from ArtemHalushko/map/3.0

Map/3.0
... ... @@ -14,7 +14,7 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import L, { FeatureGroup, LatLngBounds, LatLngTuple, markerClusterGroup, MarkerClusterGroupOptions } from 'leaflet';
  17 +import L, { FeatureGroup, LatLngBounds, LatLngTuple, markerClusterGroup, MarkerClusterGroupOptions, MarkerClusterGroup } from 'leaflet';
18 18
19 19 import 'leaflet-providers';
20 20 import 'leaflet.markercluster/dist/leaflet.markercluster';
... ... @@ -45,9 +45,9 @@ export default abstract class LeafletMap {
45 45 options: UnitedMapSettings;
46 46 bounds: L.LatLngBounds;
47 47 datasources: FormattedData[];
48   - markersCluster;
  48 + markersCluster: MarkerClusterGroup;
49 49 points: FeatureGroup;
50   - markersData = [];
  50 + markersData: FormattedData[] = [];
51 51
52 52 protected constructor(public $container: HTMLElement, options: UnitedMapSettings) {
53 53 this.options = options;
... ... @@ -222,6 +222,7 @@ export default abstract class LeafletMap {
222 222 this.bounds = this.bounds.extend(this.options.defaultCenterPosition);
223 223 }
224 224 this.map.fitBounds(this.bounds, { padding: padding || [50, 50], animate: false });
  225 + this.map.invalidateSize();
225 226 }
226 227 }
227 228 }
... ... @@ -244,7 +245,7 @@ export default abstract class LeafletMap {
244 245 }
245 246
246 247 // Markers
247   - updateMarkers(markersData, callback?) {
  248 + updateMarkers(markersData: FormattedData[], callback?) {
248 249 markersData.filter(mdata => !!this.convertPosition(mdata)).forEach(data => {
249 250 if (data.rotationAngle || data.rotationAngle === 0) {
250 251 const currentImage = this.options.useMarkerImageFunction ?
... ... @@ -271,7 +272,7 @@ export default abstract class LeafletMap {
271 272 this.markersData = markersData;
272 273 }
273 274
274   - dragMarker = (e, data?) => {
  275 + dragMarker = (e, data = {}) => {
275 276 if (e.type !== 'dragend') return;
276 277 this.saveMarkerLocation({ ...data, ...this.convertToCustomFormat(e.target._latlng) });
277 278 }
... ...
... ... @@ -34,7 +34,8 @@ import {
34 34 DatasourceType,
35 35 JsonSettingsSchema,
36 36 WidgetActionDescriptor,
37   - widgetType
  37 + widgetType,
  38 + DatasourceData
38 39 } from '@shared/models/widget.models';
39 40 import { EntityId } from '@shared/models/id/entity-id';
40 41 import { AttributeScope, DataKeyType, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
... ... @@ -83,7 +84,7 @@ export class MapWidgetController implements MapWidgetInterface {
83 84 map: LeafletMap;
84 85 provider: MapProviders;
85 86 schema: JsonSettingsSchema;
86   - data;
  87 + data: DatasourceData[];
87 88 settings: UnitedMapSettings;
88 89
89 90 public static dataKeySettingsSchema(): object {
... ...
... ... @@ -22,8 +22,8 @@ import { isDefined } from '@core/utils';
22 22
23 23 export class Marker {
24 24 leafletMarker: L.Marker;
25   - tooltipOffset: [number, number];
26   - markerOffset: [number, number];
  25 + tooltipOffset: L.LatLngTuple;
  26 + markerOffset: L.LatLngTuple;
27 27 tooltip: L.Popup;
28 28 location: L.LatLngExpression;
29 29 data: FormattedData;
... ...
... ... @@ -409,7 +409,10 @@ export const commonMapSettingsSchema =
409 409 condition: 'model.provider !== "image-map"'
410 410 },
411 411 'draggableMarker',
412   - 'disableScrollZooming',
  412 + {
  413 + key: 'disableScrollZooming',
  414 + condition: 'model.provider !== "image-map"'
  415 + },
413 416 {
414 417 key: 'latKeyName',
415 418 condition: 'model.provider !== "image-map"'
... ...
... ... @@ -159,10 +159,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
159 159 calculateIntervals() {
160 160 this.historicalData.forEach((dataSource, index) => {
161 161 this.minTime = dataSource[0]?.time || Infinity;
162   - const minTimeFormat = this.minTime !== Infinity ? moment(this.minTime).format('YYYY-MM-DD HH:mm:ss') : '';
163 162 this.maxTime = dataSource[dataSource.length - 1]?.time || -Infinity;
164   - const maxTimeFormat = this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '';
165   - this.interpolatedTimeData[index] = this.interpolateArray(dataSource, minTimeFormat, maxTimeFormat);
  163 + this.interpolatedTimeData[index] = this.interpolateArray(dataSource);
166 164 });
167 165 if(!this.activeTrip){
168 166 this.activeTrip = this.interpolatedTimeData.map(dataSource => dataSource[this.minTime]).filter(ds => ds)[0];
... ... @@ -194,7 +192,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
194 192 this.label = (parseWithTranslation.parseTemplate(labelText, data, true));
195 193 }
196 194
197   - interpolateArray(originData: FormattedData[], minTimeFormat?: string, maxTimeFormat?: string) {
  195 + interpolateArray(originData: FormattedData[]) {
198 196 const result = {};
199 197 const latKeyName = this.settings.latKeyName;
200 198 const lngKeyName = this.settings.lngKeyName;
... ... @@ -203,8 +201,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
203 201 const normalizeTime = this.minTime + Math.ceil((currentTime - this.minTime) / this.normalizationStep) * this.normalizationStep;
204 202 result[normalizeTime] = {
205 203 ...data,
206   - minTime: minTimeFormat,
207   - maxTime: maxTimeFormat,
  204 + minTime: this.minTime !== Infinity ? moment(this.minTime).format('YYYY-MM-DD HH:mm:ss') : '',
  205 + maxTime: this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '',
208 206 rotationAngle: this.settings.rotationAngle
209 207 };
210 208 }
... ...
... ... @@ -37,19 +37,18 @@
37 37 <button mat-icon-button class="mat-icon-button" aria-label="End" (click)="moveEnd()">
38 38 <mat-icon class="material-icons" [ngStyle]="{'color': settings.buttonColor}">fast_forward</mat-icon>
39 39 </button>
40   - <button mat-icon-button class="mat-icon-button" aria-label="Play">
41   - <mat-icon (click)="play()" *ngIf="!playing" class="material-icons"
42   - [ngStyle]="{'color': settings.buttonColor}">
  40 + <button mat-icon-button class="mat-icon-button" *ngIf="!playing" (click)="play()" aria-label="Play">
  41 + <mat-icon class="material-icons" [ngStyle]="{'color': settings.buttonColor}">
43 42 play_circle_outline
44 43 </mat-icon>
45   - <mat-icon (click)="pause()" *ngIf="playing" class="material-icons"
46   - [ngStyle]="{'color': settings.buttonColor}">
  44 + </button>
  45 + <button mat-icon-button class="mat-icon-button" *ngIf="playing" (click)="pause()" aria-label="Stop">
  46 + <mat-icon class="material-icons" [ngStyle]="{'color': settings.buttonColor}">
47 47 pause_circle_outline
48 48 </mat-icon>
49 49 </button>
50   - <mat-select [(ngModel)]="speed" (selectionChange)="reeneble()" class="speed-select"
51   - aria-label="Speed selector">
  50 + <mat-select [(ngModel)]="speed" (selectionChange)="reeneble()" class="speed-select" aria-label="Speed selector">
52 51 <mat-option [value]="speedValue" *ngFor="let speedValue of speeds">{{speedValue}} </mat-option>
53 52 </mat-select>
54 53 </div>
55   -</div>
  54 +</div>
\ No newline at end of file
... ...