Browse Source

Merge 7501ee473f into be70822bc6

pull/15906/merge
Maksym Tsymbarov 2 weeks ago
committed by GitHub
parent
commit
a179627b7e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 33
      ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts

33
ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts

@ -100,7 +100,8 @@ class TbTripDataItem extends TbDataLayerItem<TripsDataLayerSettings, TbTripsData
public updateAppearance() {
this.updatePathAppearance();
const dsData = this.dataLayer.getMap().getData();
if (this.settings.showMarker && this.settings.tooltip?.show) {
this.createMarker();
if (this.settings.showMarker && this.markerTooltip && this.settings.tooltip?.show) {
updateTooltip(this.dataLayer.getMap(), this.markerTooltip,
this.settings.tooltip, this.dataLayer.dataLayerTooltipProcessor, this.pointData, dsData);
}
@ -162,9 +163,12 @@ class TbTripDataItem extends TbDataLayerItem<TripsDataLayerSettings, TbTripsData
}
private createMarker() {
if (this.settings.showMarker) {
if (this.settings.showMarker && !this.marker) {
const dsData = this.dataLayer.getMap().getData();
const location = this.dataLayer.dataProcessor.extractLocation(this.pointData, dsData);
if (!location) {
return;
}
this.marker = L.marker(location, {
tbMarkerData: this.pointData,
snapIgnore: true
@ -188,6 +192,10 @@ class TbTripDataItem extends TbDataLayerItem<TripsDataLayerSettings, TbTripsData
private updateMarker() {
if (this.settings.showMarker) {
this.createMarker();
if (!this.marker) {
return;
}
const dsData = this.dataLayer.getMap().getData();
this.marker.options.tbMarkerData = this.pointData;
this.updateMarkerLocation(this.pointData, dsData);
@ -203,7 +211,7 @@ class TbTripDataItem extends TbDataLayerItem<TripsDataLayerSettings, TbTripsData
if (this.settings.showPath) {
const formattedRouteData = _.values(this.tripRouteData);
const dsData = this.dataLayer.getMap().getData();
const locations = formattedRouteData.map(data => 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<TripsDataLayerSettings, TbTripsData
if (this.settings.showPath) {
const formattedRouteData = _.values(this.tripRouteData);
const dsData = this.dataLayer.getMap().getData();
const locations = formattedRouteData.map(data => 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<TripsDataLayerSettings, TbTripsData
}
}
private extractValidLocations(data: FormattedData<TbMapDatasource>[], dsData: FormattedData<TbMapDatasource>[]):
{location: L.LatLng; data: FormattedData<TbMapDatasource>}[] {
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<TripsDataLayerSettings, TbTripsData
}
const formattedRouteData = _.values(this.tripRouteData);
const dsData = this.dataLayer.getMap().getData();
const pointsData = formattedRouteData.map(data => ({
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<TripsDataLayerSettings, TbTripsData
private updateMarkerLocation(data: FormattedData<TbMapDatasource>, dsData: FormattedData<TbMapDatasource>[]) {
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<TbMapDatasource>, dsData: FormattedData<TbMapDatasource>[]) {
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);

Loading…
Cancel
Save