@@ -409,11 +409,49 @@ export class DashboardComponent
409409 this . countryCode . setValue (
410410 this . dashboard . page ?. geographicContext ?. country
411411 ) ;
412- } else {
412+ } else if ( this . dashboard . page . geographicContext . region ) {
413413 this . regionCode . setValue (
414414 this . dashboard . page ?. geographicContext ?. region
415415 ) ;
416416 }
417+ // Get related geographic context coordinates
418+ const geographicContextCoordinates = this . dashboard . page
419+ . geographicContext . country
420+ ? this . geographicContextCountries . find (
421+ ( country ) =>
422+ country . code ===
423+ this . dashboard ?. page ?. geographicContext ?. country
424+ )
425+ : this . dashboard . page . geographicContext . region
426+ ? this . geographicContextRegions . find (
427+ ( region ) =>
428+ region . code ===
429+ this . dashboard ?. page ?. geographicContext ?. region
430+ )
431+ : null ;
432+ if ( geographicContextCoordinates ) {
433+ // Map all map widgets to have as initial state in their coords the selected geographic context
434+ this . dashboard . structure = this . dashboard . structure . map (
435+ ( widget : any ) => {
436+ if ( widget . id === 'map' ) {
437+ // Update initial state with the geographic context coordinates if no initial state is set on top of it
438+ if (
439+ ! widget . settings . initialState . viewpoint . center . longitude
440+ ) {
441+ widget . settings . initialState . viewpoint . center . longitude =
442+ geographicContextCoordinates . centerlongitude ;
443+ }
444+ if (
445+ ! widget . settings . initialState . viewpoint . center . latitude
446+ ) {
447+ widget . settings . initialState . viewpoint . center . latitude =
448+ geographicContextCoordinates . centerlatitude ;
449+ }
450+ }
451+ return widget ;
452+ }
453+ ) ;
454+ }
417455 }
418456 this . initContext ( ) ;
419457 this . updateContextOptions ( ) ;
0 commit comments