Reputation: 1231
I'm using react-native-maps and I want to zoom to a specific lat lon location when i init my maps in my react native project. I heard that it is called as camera zoom but couldn't find anything that could help me with this problem. and also it must fit to all the markers on the map.
Any lead would be greatly appreciated...
Upvotes: 0
Views: 5820
Reputation: 6857
Use the following code:
componentDidMount() {
var newRegion = {
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA,
};
this.mapView.animateToRegion(newRegion, 1000);
}
MapView:
<MapView
provider={PROVIDER_GOOGLE}
style={styles.map}
initialRegion={this.state.region}
zoomEnabled={true}
minZoomLevel={10}
ref={ref => { this.mapView = ref }}>
</MapView>
Upvotes: 2
Reputation: 11
By specifying latitudeDelta , longitudeDelta and marker array, you can zoom in. see props of react native maps for more information.
Upvotes: 1