简体   繁体   中英

Zoom into current location android

How can I zoom in and move to my current location when I click on the My Location button?

I have the following implementation for this:

 googleMap.setMyLocationEnabled(true);

This shows the button but nothing happens when I press on this. How can I move to my current location?

用这个

googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 8.0f));
 googleMap.setMyLocationEnabled(true);

Only displays your location.

Use this for the zoom to your location button:

 googleMap.getUiSettings().setMyLocationButtonEnabled(true);


Here is a pretty good tutorial.

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