简体   繁体   English

Google地图放大相机无法在Android上使用

[英]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. 我只有一个基本的Google Maps项目,并且地图运行正常,问题是,当我选择纬度和经度时,即使添加注释以添加标记来移动相机,它也不会显示“缩放动画”,并且我不知道为什么不起作用。

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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM