How to zoom in/out in react-native-map?

后端 未结 2 1305
花落未央
花落未央 2020-12-08 10:24

I am using react-native to build a map application. The api I am using is from this link: https://github.com/lelandrichardson/react-native-maps. Below is the code I bring th

相关标签:
2条回答
  • 2020-12-08 11:10

    I was able to make this work using Dimensions.get('window');

                const window = Dimensions.get('window');
                const { width, height }  = window
                LONGITUDE_DELTA = LATITUD_DELTA + (width / height)
    

    and by default set LATITUD_DELTA = 0.0922. Then just update this values with the prop onRegionChangeComplete in the <MapView>

    0 讨论(0)
  • 2020-12-08 11:11

    You should use the animateToRegion method (see here)

    It takes a region object which has latitudeDelta and longitudeDelta. Use these to set the zoom level.

    Updated:

    in a Region object the latitude and longitude specify the center location and latitudeDelta and longitudeDelta specify the span of the viewable map area.

    This image from this blog post illustrates it well (LatΔ and LngΔ).

    0 讨论(0)
提交回复
热议问题