Android Google Maps v2 - set zoom level for myLoca

2019-01-13 17:24发布

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 button on the map to find your location. If you click on it, the map will bring you to your location and zoom it in to some level. Can I change this zoom to be less or more?

10条回答
我想做一个坏孩纸
2楼-- · 2019-01-13 17:31

Even i recently had the same query....some how none of the above mentioned setmaxzoom or else map:cameraZoom="13" did not work So i found that the depenedency which i used was old please make sure your dependency for google maps is correct this is the newest use this

compile 'com.google.android.gms:play-services:11.8.0' 
查看更多
狗以群分
3楼-- · 2019-01-13 17:41

with location - in new GoogleMaps SDK:

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(chLocation,14));
查看更多
地球回转人心会变
4楼-- · 2019-01-13 17:41

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 :

 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))
查看更多
爷、活的狠高调
5楼-- · 2019-01-13 17:46

You can also use:

mMap.animateCamera( CameraUpdateFactory.zoomTo( 17.0f ) );    

To just change the zoom value to any desired value between minimum value=2.0 and maximum value=21.0.

The API warns that not all locations have tiles at values at or near maximum zoom.

See this for more information about zoom methods available in the CameraUpdateFactory.

查看更多
Melony?
6楼-- · 2019-01-13 17:46

Slightly different solution than HeatfanJohn's, where I change the zoom relatively to the current zoom level:

// Zoom out just a little
map.animateCamera(CameraUpdateFactory.zoomTo(map.getCameraPosition().zoom - 0.5f));
查看更多
爷、活的狠高调
7楼-- · 2019-01-13 17:48

In onMapReady() Method

change the zoomLevel to any desired value.

float zoomLevel = (float) 18.0;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel));
查看更多
登录 后发表回答