Ah Bu
Ah Bu

Reputation: 11

how to Zoom to specific markers react-native-maps

how to Zoom to specific markers react-native-maps

like this image map image

Upvotes: 1

Views: 1411

Answers (2)

Alok Singh
Alok Singh

Reputation: 181

You can use onPress or onSelect props of marker which accepts a callback function where you can pass the zooom size of marker. I hope it is useful

Upvotes: 0

First create a ref to the MapView component:

        <MapView
          ref={ref => {
            this.map = ref;
          }}
          ...
        >
          ...
        </MapView>

Then use one of the following three methods:

  • fitToElements - focus on all markers
  • fitToSuppliedMarkers - focus on specific markers by ID - example from docs.
  • fitToCoordinates - focus on a set of coordinates - example from docs.

You can find more details on these methods and parameters in the MapView docs.

Upvotes: 2

Related Questions