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],
|
time: el[0],
|
||||||
deviceType: null
|
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] = entity?.data[i][1];
|
||||||
obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0];
|
obj[entity?.dataKey?.label + '|ts'] = entity?.data[0][0];
|
||||||
if (entity?.dataKey?.label === 'type') {
|
if (entity?.dataKey?.label === 'type') {
|
||||||
@ -485,7 +485,7 @@ export function parseData(input: any[]): any[] {
|
|||||||
dsIndex: i,
|
dsIndex: i,
|
||||||
deviceType: null
|
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] = el?.data[0][1];
|
||||||
obj[el?.dataKey?.label + '|ts'] = el?.data[0][0];
|
obj[el?.dataKey?.label + '|ts'] = el?.data[0][0];
|
||||||
if (el?.dataKey?.label === 'type') {
|
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) {
|
export function parseTemplate(template: string, data: object, translateFn?: (key: string) => string) {
|
||||||
let res = '';
|
let res = '';
|
||||||
let variables = '';
|
|
||||||
try {
|
try {
|
||||||
if (template.match(/<link-act/g)) {
|
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'`);
|
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')) {
|
if (translateFn) {
|
||||||
const translateRegexp = /\{i18n:(.*?)\}/;
|
template = translateFn(template);
|
||||||
template.match(new RegExp(translateRegexp.source, translateRegexp.flags + 'g')).forEach(match => {
|
|
||||||
template = template.replace(match, translateFn(match.match(translateRegexp)[1]));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
const formatted = template.match(/\$\{([^}]*)\:\d*\}/g);
|
const formatted = template.match(/\$\{([^}]*)\:\d*\}/g);
|
||||||
if (formatted)
|
if (formatted)
|
||||||
formatted.forEach(value => {
|
formatted.forEach(value => {
|
||||||
const [variable, digits] = value.replace('${', '').replace('}', '').split(':');
|
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 + '}');
|
template = template.replace(value, '${' + variable + '}');
|
||||||
});
|
});
|
||||||
const variables = template.match(/\$\{.*?\}/g);
|
const variables = template.match(/\$\{.*?\}/g);
|
||||||
|
|||||||
@ -52,7 +52,9 @@ export type MapSettings = {
|
|||||||
animate: boolean,
|
animate: boolean,
|
||||||
maxClusterRadius: number,
|
maxClusterRadius: number,
|
||||||
chunkedLoading: boolean,
|
chunkedLoading: boolean,
|
||||||
removeOutsideVisibleBounds: boolean
|
removeOutsideVisibleBounds: boolean,
|
||||||
|
useCustomProvider: boolean,
|
||||||
|
customProviderTileUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MapProviders {
|
export enum MapProviders {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ export class MapWidgetController implements MapWidgetInterface {
|
|||||||
const timeseries = [];
|
const timeseries = [];
|
||||||
const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
|
const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
|
||||||
e.$datasource.dataKeys.forEach(key => {
|
e.$datasource.dataKeys.forEach(key => {
|
||||||
if (latLngProperties.includes(key)) {
|
if (latLngProperties.includes(key.name)) {
|
||||||
const value = {
|
const value = {
|
||||||
key: key.name,
|
key: key.name,
|
||||||
value: e[key.name]
|
value: e[key.name]
|
||||||
|
|||||||
@ -73,11 +73,14 @@ export class Polyline {
|
|||||||
getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
|
getPolyStyle(settings: PolylineSettings): L.PolylineOptions {
|
||||||
return {
|
return {
|
||||||
color: settings.useColorFunction ?
|
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 ?
|
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 ?
|
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) {
|
constructor($container, options: UnitedMapSettings) {
|
||||||
super($container, options);
|
super($container, options);
|
||||||
const map = L.map($container).setView(options?.defaultCenterPosition, options?.defaultZoomLevel);
|
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);
|
tileLayer.addTo(map);
|
||||||
super.setMap(map);
|
super.setMap(map);
|
||||||
super.initSettings(options);
|
super.initSettings(options);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user