谷歌地图:放大和缩小不工作的Android应用程序

时间:2018-04-17 21:18:46

标签: android google-maps zooming

我正在开发一款Android游戏,我必须绘制矩形码[足球场]。我使用多边形在谷歌地图上绘制矩形。代码在这里:

    PolygonOptions polygonOptions =  new PolygonOptions()
            .add(new LatLng(bounds.northeast.latitude, bounds.northeast.longitude))
            .add(new LatLng(bounds.southwest.latitude, bounds.northeast.longitude))
            .add(new LatLng(bounds.southwest.latitude, bounds.southwest.longitude))
            .add(new LatLng(bounds.northeast.latitude, bounds.southwest.longitude))
            .strokeColor(color);
    mMap.addPolygon(polygonOptions);

我尝试了各种代码供谷歌地图放大:

代码1:

 map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

代码2:

 CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(Latitude, Longitude))      // Sets the center of the map to Mountain View
            .zoom(30)                   // Sets the zoom
            .bearing(90)                // Sets the orientation of the camera to east
            .tilt(30)                   // Sets the tilt of the camera to 30 degrees
            .build();                   // Creates a CameraPosition from the builder
    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

代码3:

map.animateCamera(CameraUpdateFactory.zoomIn());

这些代码都不适合我。欢迎任何帮助!!!

1 个答案:

答案 0 :(得分:0)

您可以使用以下选项将缩放控件(按钮)添加到UI:

map.getUiSettings().setZoomControlsEnabled(true);
相关问题