Skip to content

Commit 35e2a8d

Browse files
feat/AB#80878_limit-zoom-of-map-widgets-for-the-given-geographic-context-in-the-page feat: update countries data with the coordinates feat: set all map widgets initial state coordinates as the one selected for the country context if exists
1 parent c671f45 commit 35e2a8d

File tree

2 files changed

+1533
-520
lines changed

2 files changed

+1533
-520
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,27 @@ export class DashboardComponent
406406
};
407407
if (this.dashboard.page?.geographicContext?.enabled) {
408408
if (this.dashboard.page.geographicContext.country) {
409+
const countryCoordinates = this.geographicContextCountries.find(
410+
(country) =>
411+
country.code ===
412+
this.dashboard?.page?.geographicContext?.country
413+
);
414+
if (countryCoordinates) {
415+
// Map all map widgets to have as initial state in their coords the selected country
416+
this.dashboard.structure = this.dashboard.structure.map(
417+
(widget: any) => {
418+
if (widget.id === 'map') {
419+
// 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;
425+
}
426+
return widget;
427+
}
428+
);
429+
}
409430
this.countryCode.setValue(
410431
this.dashboard.page?.geographicContext?.country
411432
);

0 commit comments

Comments
 (0)