I am new in react native and I want to animate map on particular position i'll use animateToCoordinates that deprecated and not working sometimes.
new Method for that is animateCamera but i don't get how to use that na d how to create camera object to pass in that.
thanks
You can use animateToRegion(region,duration) by simply passing the region as
let region={latitude:<Target_latitude>,longitude:<Targeted_longitude>,latitudeDelta: LATITUDE_DELTA,longitudeDelta:LONGITUDE_DELTA}
keeping Deltas fixed you can have your animation in map.
For animateToCamera you can use
this.mapRef.animateCamera({center: temp_cordinate,pitch: 2, heading: 20,altitude: 200, zoom: 40},duration)
where type of temp_cordinate is {latitude:latitude,longitude:longitude}
set ref to your mapView like this;
<MapView
ref={(map) => { this.map = map; }}
initialRegion={this.state.region}
/>
then,
this.map.animateToRegion(region,1000)
call this whenever you need to update your region value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With