diff --git a/ui-ngx/src/app/core/utils.ts b/ui-ngx/src/app/core/utils.ts
index 9f21791ecd..ffd69b85c1 100644
--- a/ui-ngx/src/app/core/utils.ts
+++ b/ui-ngx/src/app/core/utils.ts
@@ -498,7 +498,7 @@ export function safeExecute(func: Function, params = []) {
res = func(...params);
}
catch (err) {
- console.log(err);
+ console.log('error in external function:', err);
res = null;
}
}
@@ -519,7 +519,7 @@ export function parseFunction(source: string, params: string[] = []): Function {
return res;
}
-export function parseTemplate(template, data) {
+export function parseTemplate(template: string, data: object) {
let res = '';
try {
let variables = '';
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
index b2bc4951f5..0eee7e9caa 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
@@ -27,7 +27,6 @@ import { Observable, of, BehaviorSubject, Subject } from 'rxjs';
import { filter } from 'rxjs/operators';
import { Polyline } from './polyline';
import { Polygon } from './polygon';
-import { string } from 'prop-types';
export default abstract class LeafletMap {
@@ -43,7 +42,6 @@ export default abstract class LeafletMap {
isMarketCluster;
bounds: L.LatLngBounds;
-
constructor($container: HTMLElement, options: MapOptions) {
this.options = options;
}
@@ -138,7 +136,7 @@ export default abstract class LeafletMap {
}
invalidateSize() {
- this.map.invalidateSize(true);
+ this.map?.invalidateSize(true);
}
onResize() {
@@ -160,7 +158,7 @@ export default abstract class LeafletMap {
}
}
- ////Markers
+ //Markers
updateMarkers(markersData) {
markersData.forEach(data => {
if (data.rotationAngle) {
@@ -259,7 +257,6 @@ export default abstract class LeafletMap {
createPolygon(data, dataSources, settings) {
this.ready$.subscribe(() => {
- //public map, coordinates, dataSources, settings, onClickListener?
this.polygon = new Polygon(this.map, data, dataSources, settings);
const bounds = this.bounds.extend(this.polygon.leafletPoly.getBounds());
if (bounds.isValid()) {
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
index 3feaad9af6..e44d9d3c99 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
@@ -91,6 +91,15 @@ export class MapWidgetController implements MapWidgetInterface {
initSettings(settings: any) {
const functionParams = ['data', 'dsData', 'dsIndex'];
this.provider = settings.provider ? settings.provider : this.mapProvider;
+
+ function getDefCenterPosition(position) {
+ if (typeof (position) === 'string')
+ return position.split(',');
+ if (typeof (position) === 'object')
+ return position;
+ return [0, 0];
+ }
+
const customOptions = {
provider: this.provider,
mapUrl: settings?.mapImageUrl,
@@ -102,7 +111,7 @@ export class MapWidgetController implements MapWidgetInterface {
labelColor: this.ctx.widgetConfig.color,
tooltipPattern: settings.tooltipPattern ||
"${entityName}
Latitude: ${" + settings.latKeyName + ":7}
Longitude: ${" + settings.lngKeyName + ":7}",
- defaultCenterPosition: settings?.defaultCenterPosition?.split(',') || [0, 0],
+ defaultCenterPosition: getDefCenterPosition(settings?.defaultCenterPosition),
useDraggableMarker: true,
currentImage: (settings.useMarkerImage && settings.markerImage?.length) ? {
url: settings.markerImage,
@@ -137,7 +146,7 @@ export class MapWidgetController implements MapWidgetInterface {
return {};
}
- public static getProvidersSchema() {
+ public static getProvidersSchema() {
return mergeSchemes([mapProviderSchema,
...Object.values(providerSets)?.map(
setting => addCondition(setting?.schema, `model.provider === '${setting.name}'`))]);
@@ -246,5 +255,5 @@ const defaultSettings = {
minZoomLevel: 16,
credentials: '',
markerClusteringSetting: null,
- draggebleMarker: true
+ draggebleMarker: false
}
\ No newline at end of file
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
index ac1c756dbb..9bcdf758e8 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts
@@ -15,7 +15,6 @@
///
import L from 'leaflet';
-import { interpolateOnPointSegment } from 'leaflet-geometryutil';
import _ from 'lodash';
export function createTooltip(target, settings) {
@@ -34,38 +33,3 @@ export function createTooltip(target, settings) {
return popup;
}
-
-export function interpolateArray(originData, interpolatedIntervals) {
-
- const getRatio = (firsMoment, secondMoment, intermediateMoment) => {
- return (intermediateMoment - firsMoment) / (secondMoment - firsMoment);
- };
-
- function findAngle(startPoint, endPoint) {
- let angle = -Math.atan2(endPoint.latitude - startPoint.latitude, endPoint.longitude - startPoint.longitude);
- angle = angle * 180 / Math.PI;
- return parseInt(angle.toFixed(2));
- }
-
- const result = {};
-
- for (let i = 1, j = 0; i < originData.length, j < interpolatedIntervals.length;) {
- const currentTime = interpolatedIntervals[j];
- while (originData[i].time < currentTime) i++;
- const before = originData[i - 1];
- const after = originData[i];
- const interpolation = interpolateOnPointSegment(
- new L.Point(before.latitude, before.longitude),
- new L.Point(after.latitude, after.longitude),
- getRatio(before.time, after.time, currentTime));
- result[currentTime] = ({
- ...originData[i],
- rotationAngle: findAngle(before, after),
- latitude: interpolation.x,
- longitude: interpolation.y
- });
- j++;
- }
-
- return result;
-};
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts
index 4f1dd78a50..0fef1a1046 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts
@@ -56,7 +56,6 @@ export class Marker {
if (onDragendListener) {
this.leafletMarker.on('dragend', onDragendListener);
}
-
}
setDataSources(data, dataSources) {
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts
index 6bbdfe1a54..29032c195f 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/polyline.ts
@@ -24,7 +24,6 @@ export class Polyline {
data;
constructor(private map: L.Map, locations, data, dataSources, settings) {
- console.log("Polyline -> constructor -> data", data)
this.dataSources = dataSources;
this.data = data;
this.leafletPoly = L.polyline(locations,
@@ -34,7 +33,6 @@ export class Polyline {
updatePolyline(settings, data, dataSources) {
this.leafletPoly.setStyle(this.getPolyStyle(settings, data, dataSources));
-
}
getPolyStyle(settings, data, dataSources): L.PolylineOptions {
diff --git a/ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.html b/ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.html
index 75f9a4017c..516c01d169 100644
--- a/ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.html
+++ b/ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.html
@@ -15,6 +15,23 @@
limitations under the License.
-->
-