简体   繁体   中英

how to Zoom to specific markers react-native-maps

how to Zoom to specific markers react-native-maps

like this image地图图像

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM