Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

What does fit to coordinate do in react-native-maps

$
0
0

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.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>