tile layers and locations set fixes
This commit is contained in:
parent
1e0e1bd542
commit
73b03394f0
@ -464,7 +464,7 @@ export function parseArray(input: any[]): any[] {
|
||||
time: el[0],
|
||||
deviceType: null
|
||||
};
|
||||
entityArray.filter(el=>el.data.length).forEach(entity => {
|
||||
entityArray.filter(el => el.data.length).forEach(entity => {
|
||||
obj[entity?.dataKey?.label] = entity?.data[i][1];
|
||||
obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0];
|
||||
if (entity?.dataKey?.label === 'type') {
|
||||
@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] {
|
||||
dsIndex: i,
|
||||
deviceType: null
|
||||
};
|
||||
entityArray.filter(el=>el.data.length).forEach(el => {
|
||||
entityArray.filter(el => el.data.length).forEach(el => {
|
||||
obj[el?.dataKey?.label] = el?.data[0][1];
|
||||
obj[el?.dataKey?.label + '|ts'] = el?.data[0][0];
|
||||
if (el?.dataKey?.label === 'type') {
|
||||
@ -525,22 +525,19 @@ export function parseFunction(source: any, params: string[] = ['def']): Function
|
||||
|
||||
export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) {
|
||||
let res = '';
|
||||
let variables = '';
|
||||
try {
|
||||
if (template.match(/<link-act/g)) {
|
||||
template = template.replace(/<link-act/g, '<a').replace(/link-act>/g, 'a>').replace(/name=(\'|")(.*?)(\'|")/g, `class='tb-custom-action' id='$2'`);
|
||||
}
|
||||
if (template.includes('i18n')) {
|
||||
const translateRegexp = /\{i18n:(.*?)\}/;
|
||||
template.match(new RegExp(translateRegexp.source, translateRegexp.flags + 'g')).forEach(match => {
|
||||
template = template.replace(match, translateFn(match.match(translateRegexp)[1]));
|
||||
});
|
||||
if (translateFn) {
|
||||
template = translateFn(template);
|
||||
}
|
||||
const formatted = template.match(/\$\{([^}]*)\:\d*\}/g);
|
||||
if (formatted)
|
||||
formatted.forEach(value => {
|
||||
const [variable, digits] = value.replace('${', '').replace('}', '').split(':');
|
||||
data[variable] = padValue(data[variable], +digits)
|
||||
data[variable] = padValue(data[variable], +digits);
|
||||
if (isNaN(data[variable])) data[value] = '';
|
||||
template = template.replace(value, '${' + variable + '}');
|
||||
});
|
||||
const variables = template.match(/\$\{.*?\}/g);
|
||||
|
||||
@ -52,7 +52,9 @@ export type MapSettings = {
|
||||
animate: boolean,
|
||||
maxClusterRadius: number,
|
||||
chunkedLoading: boolean,
|
||||
removeOutsideVisibleBounds: boolean
|
||||
removeOutsideVisibleBounds: boolean,
|
||||
useCustomProvider: boolean,
|
||||
customProviderTileUrl: string;
|
||||
}
|
||||
|
||||
export enum MapProviders {
|
||||
|
||||
@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface {
|
||||
const timeseries = [];
|
||||
const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
|
||||
e.$datasource.dataKeys.forEach(key => {
|
||||
if (latLngProperties.includes(key)) {
|
||||
if (latLngProperties.includes(key.name)) {
|
||||
const value = {
|
||||
key: key.name,
|
||||
value: e[key.name]
|
||||
|
||||
@ -73,11 +73,14 @@ export class Polyline {
|
||||
getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
|
||||
return {
|
||||
color: settings.useColorFunction ?
|
||||
safeExecute(settings.colorFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.color,
|
||||
safeExecute(settings.colorFunction,
|
||||
[this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.color,
|
||||
opacity: settings.useStrokeOpacityFunction ?
|
||||
safeExecute(settings.strokeOpacityFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeOpacity,
|
||||
safeExecute(settings.strokeOpacityFunction,
|
||||
[this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeOpacity,
|
||||
weight: settings.useStrokeWeightFunction ?
|
||||
safeExecute(settings.strokeWeightFunction, [this.data, this.dataSources, this.data[0]?.dsIndex]) : settings.strokeWeight,
|
||||
safeExecute(settings.strokeWeightFunction,
|
||||
[this.data, this.dataSources, this.dataSources[0]?.dsIndex]) : settings.strokeWeight,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,11 @@ export class OpenStreetMap extends LeafletMap {
|
||||
constructor($container, options: UnitedMapSettings) {
|
||||
super($container, options);
|
||||
const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
||||
const tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik');
|
||||
let tileLayer;
|
||||
if (options.useCustomProvider)
|
||||
tileLayer = L.tileLayer(options.customProviderTileUrl);
|
||||
else
|
||||
tileLayer = (L.tileLayer as any).provider(options.mapProvider || 'OpenStreetMap.Mapnik');
|
||||
tileLayer.addTo(map);
|
||||
super.setMap(map);
|
||||
super.initSettings(options);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user