Commit 557b0642b89fa5ae0188fbb8843a13ccd53ca445
Committed by
Andrew Shvayka
1 parent
56275a5c
Added setting pageSize for a map, deleted deprecated map provider and fix creating a markers
Showing
5 changed files
with
27 additions
and
15 deletions
... | ... | @@ -42,7 +42,7 @@ import { Polygon } from './polygon'; |
42 | 42 | import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils'; |
43 | 43 | import { WidgetContext } from '@home/models/widget-component.models'; |
44 | 44 | import { DatasourceData } from '@shared/models/widget.models'; |
45 | -import { deepClone } from '@core/utils'; | |
45 | +import { deepClone, isDefinedAndNotNull } from '@core/utils'; | |
46 | 46 | |
47 | 47 | export default abstract class LeafletMap { |
48 | 48 | |
... | ... | @@ -249,8 +249,9 @@ export default abstract class LeafletMap { |
249 | 249 | if (!expression) return null; |
250 | 250 | const lat = expression[this.options.latKeyName]; |
251 | 251 | const lng = expression[this.options.lngKeyName]; |
252 | - if (isNaN(lat) || isNaN(lng)) | |
253 | - return null; | |
252 | + if (!isDefinedAndNotNull(lat) || isNaN(lat) || !isDefinedAndNotNull(lng) || isNaN(lng)){ | |
253 | + return null; | |
254 | + } | |
254 | 255 | else |
255 | 256 | return L.latLng(lat, lng) as L.LatLng; |
256 | 257 | } | ... | ... |
... | ... | @@ -25,7 +25,7 @@ import { |
25 | 25 | } from './schemes'; |
26 | 26 | import { EntityType } from '@shared/models/entity-type.models'; |
27 | 27 | |
28 | -export const DEFAULT_MAP_PAGE_SIZE = 1024; | |
28 | +export const DEFAULT_MAP_PAGE_SIZE = 2 ** 14; | |
29 | 29 | |
30 | 30 | export type GenericFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string; |
31 | 31 | export type MarkerImageFunction = (data: FormattedData, dsData: FormattedData[], dsIndex: number) => string; |
... | ... | @@ -68,6 +68,7 @@ export type MapSettings = { |
68 | 68 | removeOutsideVisibleBounds: boolean, |
69 | 69 | useCustomProvider: boolean, |
70 | 70 | customProviderTileUrl: string; |
71 | + mapPageSize: number; | |
71 | 72 | } |
72 | 73 | |
73 | 74 | export enum MapProviders { |
... | ... | @@ -267,7 +268,8 @@ export const defaultSettings: any = { |
267 | 268 | credentials: '', |
268 | 269 | markerClusteringSetting: null, |
269 | 270 | draggableMarker: false, |
270 | - fitMapBounds: true | |
271 | + fitMapBounds: true, | |
272 | + mapPageSize: DEFAULT_MAP_PAGE_SIZE | |
271 | 273 | }; |
272 | 274 | |
273 | 275 | export const hereProviders = [ | ... | ... |
... | ... | @@ -81,7 +81,7 @@ export class MapWidgetController implements MapWidgetInterface { |
81 | 81 | this.map.saveMarkerLocation = this.setMarkerLocation; |
82 | 82 | this.pageLink = { |
83 | 83 | page: 0, |
84 | - pageSize: DEFAULT_MAP_PAGE_SIZE, | |
84 | + pageSize: this.settings.mapPageSize, | |
85 | 85 | textSearch: null, |
86 | 86 | dynamic: true |
87 | 87 | }; | ... | ... |
... | ... | @@ -24,6 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; |
24 | 24 | import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models'; |
25 | 25 | import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; |
26 | 26 | import { WidgetSubscriptionOptions } from '@core/api/widget-api.models'; |
27 | +import { isDefinedAndNotNull } from '@core/utils'; | |
27 | 28 | |
28 | 29 | const maxZoom = 4;// ? |
29 | 30 | |
... | ... | @@ -209,11 +210,15 @@ export class ImageMap extends LeafletMap { |
209 | 210 | } |
210 | 211 | |
211 | 212 | convertPosition(expression): L.LatLng { |
212 | - if (isNaN(expression[this.options.xPosKeyName]) || isNaN(expression[this.options.yPosKeyName])) return null; | |
213 | - Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName])); | |
214 | - return this.pointToLatLng( | |
215 | - expression.x * this.width, | |
216 | - expression.y * this.height); | |
213 | + const xPos = expression[this.options.xPosKeyName]; | |
214 | + const yPos = expression[this.options.yPosKeyName]; | |
215 | + if (!isDefinedAndNotNull(xPos) || isNaN(xPos) || !isDefinedAndNotNull(yPos) || isNaN(yPos)) { | |
216 | + return null; | |
217 | + } | |
218 | + Object.assign(expression, this.posFunction(xPos, yPos)); | |
219 | + return this.pointToLatLng( | |
220 | + expression.x * this.width, | |
221 | + expression.y * this.height); | |
217 | 222 | } |
218 | 223 | |
219 | 224 | convertPositionPolygon(expression: Array<[number, number]>): L.LatLngExpression[] { | ... | ... |
... | ... | @@ -14,6 +14,8 @@ |
14 | 14 | /// limitations under the License. |
15 | 15 | /// |
16 | 16 | |
17 | +import { DEFAULT_MAP_PAGE_SIZE } from '@home/components/widget/lib/maps/map-models'; | |
18 | + | |
17 | 19 | export const googleMapSettingsSchema = |
18 | 20 | { |
19 | 21 | schema: { |
... | ... | @@ -198,10 +200,6 @@ export const openstreetMapSettingsSchema = |
198 | 200 | label: 'OpenStreetMap.Mapnik (Default)' |
199 | 201 | }, |
200 | 202 | { |
201 | - value: 'OpenStreetMap.BlackAndWhite', | |
202 | - label: 'OpenStreetMap.BlackAndWhite' | |
203 | - }, | |
204 | - { | |
205 | 203 | value: 'OpenStreetMap.HOT', |
206 | 204 | label: 'OpenStreetMap.HOT' |
207 | 205 | }, |
... | ... | @@ -246,6 +244,11 @@ export const commonMapSettingsSchema = |
246 | 244 | type: 'boolean', |
247 | 245 | default: false |
248 | 246 | }, |
247 | + mapPageSize: { | |
248 | + title: 'Map page size load entities', | |
249 | + type: 'number', | |
250 | + default: DEFAULT_MAP_PAGE_SIZE | |
251 | + }, | |
249 | 252 | defaultCenterPosition: { |
250 | 253 | title: 'Default map center position (0,0)', |
251 | 254 | type: 'string', |
... | ... | @@ -408,6 +411,7 @@ export const commonMapSettingsSchema = |
408 | 411 | key: 'fitMapBounds', |
409 | 412 | condition: 'model.provider !== "image-map"' |
410 | 413 | }, |
414 | + 'mapPageSize', | |
411 | 415 | 'draggableMarker', |
412 | 416 | { |
413 | 417 | key: 'disableScrollZooming', | ... | ... |