diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts index b3e03dfe47..5267238297 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts @@ -100,7 +100,8 @@ class TbTripDataItem extends TbDataLayerItem this.dataLayer.dataProcessor.extractLocation(data, dsData)); + const locations = this.extractValidLocations(formattedRouteData, dsData).map(entry => entry.location); const pathStyle = this.dataLayer.getPathStyle(this.pointData, dsData); this.polyline = L.polyline(locations, pathStyle); this.polyline.addTo(this.layer); @@ -218,7 +226,7 @@ class TbTripDataItem extends TbDataLayerItem this.dataLayer.dataProcessor.extractLocation(data, dsData)); + const locations = this.extractValidLocations(formattedRouteData, dsData).map(entry => entry.location); this.polyline.setLatLngs(locations); if (this.settings.usePathDecorator) { this.polylineDecorator.setPaths(this.polyline); @@ -227,6 +235,14 @@ class TbTripDataItem extends TbDataLayerItem[], dsData: FormattedData[]): + {location: L.LatLng; data: FormattedData}[] { + return data.map(item => ({ + location: this.dataLayer.dataProcessor.extractLocation(item, dsData), + data: item + })).filter(entry => !!entry.location); + } + private updatePoints() { if (this.settings.showPoints) { if (!this.pointsContainer) { @@ -235,10 +251,7 @@ class TbTripDataItem extends TbDataLayerItem ({ - location: this.dataLayer.dataProcessor.extractLocation(data, dsData), - data - })).filter(pData => !!pData.location); + const pointsData = this.extractValidLocations(formattedRouteData, dsData); const toDelete = new Set(Array.from(this.points.keys())); for (const pData of pointsData) { let pointData = pData.data; @@ -300,13 +313,13 @@ class TbTripDataItem extends TbDataLayerItem, dsData: FormattedData[]) { const location = this.dataLayer.dataProcessor.extractLocation(data, dsData); - if (!this.marker.getLatLng().equals(location)) { + if (location && !this.marker.getLatLng().equals(location)) { this.marker.setLatLng(location); } } private updateMarkerIcon(data: FormattedData, dsData: FormattedData[]) { - if (this.settings.showMarker) { + if (this.settings.showMarker && this.marker) { this.dataLayer.dataProcessor.createMarkerIcon(data, dsData, data.rotationAngle).subscribe( (iconInfo) => { const options = deepClone(iconInfo.icon.options);