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:49

you have to write only one line in maps_activity.xml

map:cameraZoom="13"

I hope this will solve your problem...

查看更多
相关推荐>>
3楼-- · 2019-01-13 17:52
Location locaton;
double latitude = location.getlatitude;
double longitude = location.getlongitude;

If you want to save the zoom or get it all the time,you just need to call the following

int zoom = mMap.getCameraPosition().zoom;

//To set that just use

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(getlatitude(), getlongitude),zoom);
查看更多
beautiful°
4楼-- · 2019-01-13 17:52

You can use

    CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()));
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(12);
查看更多
We Are One
5楼-- · 2019-01-13 17:54

It's doubtful you can change it on click with the default myLocation Marker. However, if you would like the app to automatically zoom in on your location once it is found, I would check out my answer to this question

Note that the answer I provided does not zoom in, but if you modify the onLocationChanged method to be like the one below, you can choose whatever zoom level you like:

@Override
public void onLocationChanged(Location location) 
{
    if( mListener != null )
    {
        mListener.onLocationChanged( location );

        //Move the camera to the user's location and zoom in!
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 12.0f));
    }
}
查看更多
登录 后发表回答