Can someone tell me what does fitToCoordinates
do in React native (react-native-maps)?
react-native-maps have mentioned this in their docs
| `fitToCoordinates` | `coordinates: Array<LatLng>, options: { edgePadding: EdgePadding, animated: Boolean }` | If called in `ComponentDidMount` in android, it will cause an exception. It is recommended to call it from the MapView `onLayout` event.
Which I am unable to comprehend.
I have simple code in which marker is always centered in the screen
const updateLocationCordinate = (e:MapEvent) => { const {latitude, longitude} = e.nativeEvent.coordinate setLocationData({ ...locationData, latitude, longitude }) }return<MapView loadingEnabled={true} style={styles.map} provider="google" region={{ latitude, longitude, latitudeDelta: LATITUDE_DELTA, longitudeDelta: LONGITUDE_DELTA }}><Marker draggable coordinate={{ latitude, longitude }} title="Me" onDragEnd={updateLocationCordinate} /></MapView>
Why would I or people use fitToCoordinates
and what does this exactly.
Super helpful if someone can explain with some examples.