From cd88afea005b6fcec3cde05f97d20798a95c840a Mon Sep 17 00:00:00 2001 From: Artem Halushko Date: Mon, 4 May 2020 18:04:35 +0300 Subject: [PATCH] fix empty center position & fix entity id --- .../home/components/widget/lib/maps/leaflet-map.ts | 11 ++++++++--- .../home/components/widget/lib/maps/map-widget2.ts | 9 ++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts index d98b564c2f..64a8621920 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts @@ -198,9 +198,15 @@ export default abstract class LeafletMap { fitBounds(bounds: LatLngBounds, useDefaultZoom = false, padding?: LatLngTuple) { if (bounds.isValid()) { - if ((!this.options.fitMapBounds || this.options.useDefaultCenterPosition) && this.options.defaultZoomLevel) { + this.bounds = this.bounds.extend(bounds); + if (!this.options.fitMapBounds && this.options.defaultZoomLevel) { this.map.setZoom(this.options.defaultZoomLevel, { animate: false }); - this.map.panTo(this.options.defaultCenterPosition, { animate: false }); + if (this.options.useDefaultCenterPosition) { + this.map.panTo(this.options.defaultCenterPosition, { animate: false }); + } + else { + this.map.panTo(this.bounds.getCenter()); + } } else { this.map.once('zoomend', () => { if (!this.options.defaultZoomLevel && this.map.getZoom() > this.options.minZoomLevel) { @@ -212,7 +218,6 @@ export default abstract class LeafletMap { } this.map.fitBounds(bounds, { padding: padding || [50, 50], animate: false }); } - this.bounds = bounds; } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts index 82db9c2b29..330e739c31 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts @@ -154,12 +154,11 @@ export class MapWidgetController implements MapWidgetInterface { if ($event && $event.stopPropagation) { $event?.stopPropagation(); } - const { id, entityName, entityLabel, entityType } = entityInfo; - const entityId: EntityId = { + const { entityId, entityName, entityLabel, entityType } = entityInfo; + this.ctx.actionsApi.handleWidgetAction($event, descriptor, { entityType, - id - }; - this.ctx.actionsApi.handleWidgetAction($event, descriptor, entityId, entityName, null, entityLabel); + id: entityId + }, entityName, null, entityLabel); } setMarkerLocation = (e) => {