Browse Source

Added setting pageSize for a map, deleted deprecated map provider and fix creating a markers

pull/3198/head
Vladyslav_Prykhodko 6 years ago
committed by Andrew Shvayka
parent
commit
557b0642b8
  1. 7
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 6
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  4. 15
      ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts
  5. 12
      ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts

7
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -42,7 +42,7 @@ import { Polygon } from './polygon';
import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils';
import { WidgetContext } from '@home/models/widget-component.models';
import { DatasourceData } from '@shared/models/widget.models';
import { deepClone } from '@core/utils';
import { deepClone, isDefinedAndNotNull } from '@core/utils';
export default abstract class LeafletMap {
@ -249,8 +249,9 @@ export default abstract class LeafletMap {
if (!expression) return null;
const lat = expression[this.options.latKeyName];
const lng = expression[this.options.lngKeyName];
if (isNaN(lat) || isNaN(lng))
return null;
if (!isDefinedAndNotNull(lat) || isNaN(lat) || !isDefinedAndNotNull(lng) || isNaN(lng)){
return null;
}
else
return L.latLng(lat, lng) as L.LatLng;
}

6
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts

@ -25,7 +25,7 @@ import {
} from './schemes';
import { EntityType } from '@shared/models/entity-type.models';
export const DEFAULT_MAP_PAGE_SIZE = 1024;
export const DEFAULT_MAP_PAGE_SIZE = 2 ** 14;
export type GenericFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string;
export type MarkerImageFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string;
@ -68,6 +68,7 @@ export type MapSettings = {
removeOutsideVisibleBounds: boolean,
useCustomProvider: boolean,
customProviderTileUrl: string;
mapPageSize: number;
}
export enum MapProviders {
@ -267,7 +268,8 @@ export const defaultSettings: any = {
credentials: '',
markerClusteringSetting: null,
draggableMarker: false,
fitMapBounds: true
fitMapBounds: true,
mapPageSize: DEFAULT_MAP_PAGE_SIZE
};
export const hereProviders = [

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts

@ -81,7 +81,7 @@ export class MapWidgetController implements MapWidgetInterface {
this.map.saveMarkerLocation = this.setMarkerLocation;
this.pageLink = {
page: 0,
pageSize: DEFAULT_MAP_PAGE_SIZE,
pageSize: this.settings.mapPageSize,
textSearch: null,
dynamic: true
};

15
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts

@ -24,6 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models';
import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { WidgetSubscriptionOptions } from '@core/api/widget-api.models';
import { isDefinedAndNotNull } from '@core/utils';
const maxZoom = 4;// ?
@ -209,11 +210,15 @@ export class ImageMap extends LeafletMap {
}
convertPosition(expression): L.LatLng {
if (isNaN(expression[this.options.xPosKeyName]) || isNaN(expression[this.options.yPosKeyName])) return null;
Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName]));
return this.pointToLatLng(
expression.x * this.width,
expression.y * this.height);
const xPos = expression[this.options.xPosKeyName];
const yPos = expression[this.options.yPosKeyName];
if (!isDefinedAndNotNull(xPos) || isNaN(xPos) || !isDefinedAndNotNull(yPos) || isNaN(yPos)) {
return null;
}
Object.assign(expression, this.posFunction(xPos, yPos));
return this.pointToLatLng(
expression.x * this.width,
expression.y * this.height);
}
convertPositionPolygon(expression: Array<[number, number]>): L.LatLngExpression[] {

12
ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts

@ -14,6 +14,8 @@
/// limitations under the License.
///
import { DEFAULT_MAP_PAGE_SIZE } from '@home/components/widget/lib/maps/map-models';
export const googleMapSettingsSchema =
{
schema: {
@ -197,10 +199,6 @@ export const openstreetMapSettingsSchema =
value: 'OpenStreetMap.Mapnik',
label: 'OpenStreetMap.Mapnik (Default)'
},
{
value: 'OpenStreetMap.BlackAndWhite',
label: 'OpenStreetMap.BlackAndWhite'
},
{
value: 'OpenStreetMap.HOT',
label: 'OpenStreetMap.HOT'
@ -246,6 +244,11 @@ export const commonMapSettingsSchema =
type: 'boolean',
default: false
},
mapPageSize: {
title: 'Map page size load entities',
type: 'number',
default: DEFAULT_MAP_PAGE_SIZE
},
defaultCenterPosition: {
title: 'Default map center position (0,0)',
type: 'string',
@ -408,6 +411,7 @@ export const commonMapSettingsSchema =
key: 'fitMapBounds',
condition: 'model.provider !== "image-map"'
},
'mapPageSize',
'draggableMarker',
{
key: 'disableScrollZooming',

Loading…
Cancel
Save