Marker scaling

There is a section in the react-native-maps document for scaling the marker array, however there are no code examples on how to do this either in the documents or in the examples folder (from which I can find)

Can someone provide an example of how to do this?

+6
source share
1 answer

There are several methods in MapView component documents: fitToElements , fitToSuppliedMarkers and fitToCoordinates . https://github.com/airbnb/react-native-maps/blob/master/docs/mapview.md#methods

If you want to enlarge the map in some collection of markers at loading, you can use componentDidMount to increase after the initial render:

 class SomeView extends Component { constructor() { this.mapRef = null; } componentDidMount() { this.mapRef.fitToSuppliedMarkers( someArrayOfMarkers, false, // not animated ); } render() { <MapView ref={(ref) => { this.mapRef = ref }} > { someArrayOfMarkers } </MapView> } } 
+13
source

All Articles