Android Google Maps v2 - set zoom level for myLocation

前端 未结 13 1153
孤城傲影
孤城傲影 2020-12-05 01:39

Is it possible to change the zoom level for myLocation with the new Google Maps API v2?

If you set GoogleMap.setEnableMyLocation(true);, you get a butto

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 02:09

    Here are the approximate zoom levels and what they do :

    1: World
    5: Landmass/continent
    10: City
    15: Streets
    20: Buildings
    

    so you could do something like this to zoom to street level for example (note the "15f" below is street level) :

     override fun onMapReady(googleMap: GoogleMap?) {
        googleMap?.mapType = GoogleMap.MAP_TYPE_NORMAL
        googleMap?.addMarker(MarkerOptions()
                .position(LatLng(37.4233438, -122.0728817))
                .title("cool place")
    
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)))
    
        googleMap?.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(37.4233438, -122.0728817), 15f))
    

    note: just so you know different locations can have different max zoom levels. try to use googleMap.maxZoomLevel if you want to get the max or min zoom levels.

提交回复
热议问题