Skip to content

Commit 1cae632

Browse files
feat/AB#80878_limit-zoom-of-map-widgets-for-the-given-geographic-context-in-the-page fix: prevent automatic update of map widgets initial state for geographic context dashboard if there is already an initial state set different that the default one for that map widget
1 parent 35e2a8d commit 1cae632

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,23 @@ export class DashboardComponent
416416
this.dashboard.structure = this.dashboard.structure.map(
417417
(widget: any) => {
418418
if (widget.id === 'map') {
419+
// Update initial state with the country coordinates if no initial state is set on top of it
419420
// Increase the zoom to have a clear target of the selected country in the map
420-
widget.settings.initialState.viewpoint.zoom = 4;
421-
widget.settings.initialState.viewpoint.center.longitude =
422-
countryCoordinates.centerlongitude;
423-
widget.settings.initialState.viewpoint.center.latitude =
424-
countryCoordinates.centerlatitude;
421+
if (widget.settings.initialState.viewpoint.zoom === 2) {
422+
widget.settings.initialState.viewpoint.zoom = 4;
423+
}
424+
if (
425+
!widget.settings.initialState.viewpoint.center.longitude
426+
) {
427+
widget.settings.initialState.viewpoint.center.longitude =
428+
countryCoordinates.centerlongitude;
429+
}
430+
if (
431+
!widget.settings.initialState.viewpoint.center.latitude
432+
) {
433+
widget.settings.initialState.viewpoint.center.latitude =
434+
countryCoordinates.centerlatitude;
435+
}
425436
}
426437
return widget;
427438
}

0 commit comments

Comments
 (0)