Commit 73b03394f0d056ac64a1f1522dd929ad5e3819bb

Authored by Artem Halushko
1 parent 1e0e1bd5

tile layers and locations set fixes

... ... @@ -464,7 +464,7 @@ export function parseArray(input: any[]): any[] {
464 464 time: el[0],
465 465 deviceType: null
466 466 };
467   - entityArray.filter(el=>el.data.length).forEach(entity => {
  467 + entityArray.filter(el => el.data.length).forEach(entity => {
468 468 obj[entity?.dataKey?.label] = entity?.data[i][1];
469 469 obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0];
470 470 if (entity?.dataKey?.label === 'type') {
... ... @@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] {
485 485 dsIndex: i,
486 486 deviceType: null
487 487 };
488   - entityArray.filter(el=>el.data.length).forEach(el => {
  488 + entityArray.filter(el => el.data.length).forEach(el => {
489 489 obj[el?.dataKey?.label] = el?.data[0][1];
490 490 obj[el?.dataKey?.label + '|ts'] = el?.data[0][0];
491 491 if (el?.dataKey?.label === 'type') {
... ... @@ -525,22 +525,19 @@ export function parseFunction(source: any, params: string[] = ['def']): Function
525 525
526 526 export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) {
527 527 let res = '';
528   - let variables = '';
529 528 try {
530 529 if (template.match(/<link-act/g)) {
531 530 template = template.replace(/<link-act/g, '<a').replace(/link-act>/g, 'a>').replace(/name=(\'|")(.*?)(\'|")/g, `class='tb-custom-action' id='$2'`);
532 531 }
533   - if (template.includes('i18n')) {
534   - const translateRegexp = /\{i18n:(.*?)\}/;
535   - template.match(new RegExp(translateRegexp.source, translateRegexp.flags + 'g')).forEach(match => {
536   - template = template.replace(match, translateFn(match.match(translateRegexp)[1]));
537   - });
  532 + if (translateFn) {
  533 + template = translateFn(template);
538 534 }
539 535 const formatted = template.match(/\$\{([^}]*)\:\d*\}/g);
540 536 if (formatted)
541 537 formatted.forEach(value => {
542 538 const [variable, digits] = value.replace('${', '').replace('}', '').split(':');
543   - data[variable] = padValue(data[variable], +digits)
  539 + data[variable] = padValue(data[variable], +digits);
  540 + if (isNaN(data[variable])) data[value] = '';
544 541 template = template.replace(value, '${' + variable + '}');
545 542 });
546 543 const variables = template.match(/\$\{.*?\}/g);
... ...
... ... @@ -52,7 +52,9 @@ export type MapSettings = {
52 52 animate: boolean,
53 53 maxClusterRadius: number,
54 54 chunkedLoading: boolean,
55   - removeOutsideVisibleBounds: boolean
  55 + removeOutsideVisibleBounds: boolean,
  56 + useCustomProvider: boolean,
  57 + customProviderTileUrl: string;
56 58 }
57 59
58 60 export enum MapProviders {
... ...
... ... @@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface {
170 170 const timeseries = [];
171 171 const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
172 172 e.$datasource.dataKeys.forEach(key => {
173   - if (latLngProperties.includes(key)) {
  173 + if (latLngProperties.includes(key.name)) {
174 174 const value = {
175 175 key: key.name,
176 176 value: e[key.name]
... ...
... ... @@ -73,11 +73,14 @@ export class Polyline {
73 73 getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
74 74 return {
75 75 color: settings.useColorFunction ?
76   - safeExecute(settings.colorFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.color,
  76 + safeExecute(settings.colorFunction,
  77 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.color,
77 78 opacity: settings.useStrokeOpacityFunction ?
78   - safeExecute(settings.strokeOpacityFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeOpacity,
  79 + safeExecute(settings.strokeOpacityFunction,
  80 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeOpacity,
79 81 weight: settings.useStrokeWeightFunction ?
80   - safeExecute(settings.strokeWeightFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeWeight,
  82 + safeExecute(settings.strokeWeightFunction,
  83 + [this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeWeight,
81 84 }
82 85 }
83 86
... ...
... ... @@ -22,7 +22,11 @@ export class OpenStreetMap extends LeafletMap {
22 22 constructor($container, options: UnitedMapSettings) {
23 23 super($container, options);
24 24 const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
25   - const tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik');
  25 + let tileLayer;
  26 + if (options.useCustomProvider)
  27 + tileLayer = L.tileLayer(options.customProviderTileUrl);
  28 + else
  29 + tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik');
26 30 tileLayer.addTo(map);
27 31 super.setMap(map);
28 32 super.initSettings(options);
... ...