adeamos83
6/21/2018 - 7:04 PM

React-native-Maps - fitToElements

let markers = [];
		for (let i = 0; i < this.props.locations.length; i++) {
			let placeMarker = {
				latitude: this.props.locations[i].latitude,
				longitude: this.props.locations[i].longitude
				title: this.props.locations[i].name,
				key: i + 1
			};
			markers.push(placeMarker);
		};
<MapView
 ref={(ref) => { this.mapRef = ref; }}
onLayout={() => this.mapRef.fitToCoordinates(this.markers, { edgePadding: { top: 50, right: 10, bottom: 10, left: 10 }, animated: false })} >