@@ -14,7 +14,7 @@ interface FitBoundsProps {
1414 disableAnimation ?: boolean ;
1515 fitBounds ?: boolean ;
1616 animationKey ?: unknown ;
17- offset ?: [ number , number ] ;
17+ openPopup ?: boolean ;
1818}
1919
2020const serializeKey = ( key : unknown ) : string => {
@@ -57,10 +57,10 @@ const FitBounds = ({
5757 features,
5858 padding = 50 ,
5959 duration = 1000 ,
60- disableAnimation = false ,
60+ disableAnimation,
6161 fitBounds = true ,
6262 animationKey,
63- offset = [ 0 , 0 ] ,
63+ openPopup ,
6464} : FitBoundsProps ) => {
6565 const { current : map } = useMap ( ) ;
6666 const previousKey = useRef < string > ( "" ) ;
@@ -79,6 +79,10 @@ const FitBounds = ({
7979 } , [ validMarkers , featureCoords ] ) ;
8080
8181 useEffect ( ( ) => {
82+ if ( openPopup ) {
83+ return ;
84+ }
85+
8286 if ( ! ( map && fitBounds && bounds ) ) {
8387 return ;
8488 }
@@ -100,18 +104,16 @@ const FitBounds = ({
100104 map . flyTo ( {
101105 center : [ m . lng , m . lat ] ,
102106 duration : disableAnimation ? 0 : duration ,
103- offset,
104107 zoom : 14 ,
105108 } ) ;
106109 return ;
107110 }
108111
109112 map . fitBounds ( [ bounds . getSouthWest ( ) . toArray ( ) , bounds . getNorthEast ( ) . toArray ( ) ] , {
110113 duration : disableAnimation ? 0 : duration ,
111- offset,
112114 padding,
113115 } ) ;
114- } , [ map , bounds , padding , duration , disableAnimation , animationKey , fitBounds , validMarkers , featureCoords , offset ] ) ;
116+ } , [ map , bounds , padding , duration , disableAnimation , animationKey , fitBounds , validMarkers , featureCoords , openPopup ] ) ;
115117
116118 return null ;
117119} ;
0 commit comments