Android Google Maps API V2 Zoom to Current Location

前端 未结 9 1768
时光说笑
时光说笑 2020-11-28 04:37

I\'m trying to mess around with the Maps API V2 to get more familiar with it, and I\'m trying to start the map centered at the user\'s current location. Using the map.

9条回答
  •  天涯浪人
    2020-11-28 05:40

        mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location location) {
    
                    CameraUpdate center=CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()));
                    CameraUpdate zoom=CameraUpdateFactory.zoomTo(11);
                    mMap.moveCamera(center);
                    mMap.animateCamera(zoom);
    
            }
        });
    

提交回复
热议问题