简体   繁体   中英

Google maps zoom in camera is not working Android

I just have a basic Google Maps project and the maps works fine, the thing is, when I Choose the Lat and Long, it doesn't shows the "Zoom Animation" even that are comment to add a marker to move the camera, and I don't know why is not working.

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);

@Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        // Add a marker in Sydney and move the camera
        LatLng location = new LatLng(DB_LAT, DB_LONG);
        mMap.addMarker(new MarkerOptions().position(location).title("CEP"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
    }

Use the following code:

Remove the line:

mMap.moveCamera(CameraUpdateFactory.newLatLng(location));

Add this

mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 15));

Hope this helps.

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