@@ -426,7 +426,7 @@ namespace Provider.Maps.Google.OSMap {
426426 this . _provider = undefined ;
427427 }
428428
429- public refresh ( ) : void {
429+ public refresh ( centerChanged ?: boolean ) : void {
430430 //Let's stop listening to the zoom event be caused by the refreshZoom
431431 this . _removeMapZoomHandler ( ) ;
432432
@@ -439,35 +439,35 @@ namespace Provider.Maps.Google.OSMap {
439439 //If there are markers, let's choose the map center accordingly.
440440 //Otherwise, the map center will be the one defined in the configs.
441441 if ( this . markers . length > 0 ) {
442+ // The TS definitions appear to be outdated.
443+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
444+ const markerProvider : any = this . markers [ 0 ] . provider ;
442445 if ( this . markers . length > 1 ) {
443446 //As the map has more than one marker, let's see if the map
444447 //center should be changed.
445448 //If the user hasn't change zoom, or the developer is ignoring it (current behavior).
446449 if ( this . allowRefreshZoom ) {
447- const markerProvider = this . markers [ 0 ] . provider ;
448450 //Let's check if the marker provider is ready to be used.
449451 if ( markerProvider !== undefined ) {
450452 //If the map center, is the same as the default, then the map will ignore it.
451453 //Otherwise, the isAutofit config will be checked, and if false, then the current
452454 //center will not be changed.
453455 if ( isDefault || this . features . zoom . isAutofit ) {
454456 //Let's use the first marker as the center of the map.
455- // The TS definitions appear to be outdated.
456- // eslint-disable-next-line @typescript-eslint/no-explicit-any
457- position = ( markerProvider as any ) . position . toJSON ( ) ;
457+ position = markerProvider . position . toJSON ( ) ;
458458 }
459459 }
460460 } else {
461461 //If the user has zoomed and the developer intends to respect user zoom
462462 //then the current map center will be used.
463- position = this . provider . getCenter ( ) . toJSON ( ) ;
463+ position = centerChanged
464+ ? ( this . config . center as OSFramework . Maps . OSStructures . OSMap . Coordinates )
465+ : this . provider . getCenter ( ) . toJSON ( ) ;
464466 }
465- } else if ( this . markers [ 0 ] . provider !== undefined ) {
467+ } else if ( markerProvider !== undefined ) {
466468 //If there's only one marker, and is already created, its location will be
467469 //used as the map center.
468- // The TS definitions appear to be outdated.
469- // eslint-disable-next-line @typescript-eslint/no-explicit-any
470- position = ( this . markers [ 0 ] . provider as any ) . position . toJSON ( ) ;
470+ position = markerProvider . position . toJSON ( ) ;
471471 }
472472 }
473473
0 commit comments