相关疑难解决方法(0)

如何在Android Google Maps API v2中将LatLng和半径转换为LatLngBounds?

我相信这是最近的Google Maps API v2的限制.他们最近添加了在地面上绘制圆圈的功能 - 但是如果你想要将摄像机定位为显示整个圆圈,则无法这样做.

可以调用CameraUpdateFactory#newLatLngBounds(bounds,padding),其中"bounds"是LatLngBounds,"padding"是以像素为单位的距离.问题是无法在LatLngBounds中创建LatLng和半径.

LatLngBounds的构造函数只接受2个LatLng实例并生成一个矩形,其中这些是NW和SE角.

android google-maps-android-api-2

45
推荐指数
3
解决办法
3万
查看次数

MKCoordinateRegionMakeWithDistance等效于Android

我们可以在iPhone中为地图上的特定位置设置周围区域,如下所示

CLLocationCoordinate2D coord = {latitude:37.09024, longitude:-95.712891};
CLLocationDistance latitudinalMeters;
latitudinalMeters =NoOfMiles * 1609.344;
CLLocationDistance longitudinalMeters;
longitudinalMeters = NoOfMiles * 1609.344;
mapViewHome.region = MKCoordinateRegionMakeWithDistance(coord, latitudinalMeters, longitudinalMeters); 
Run Code Online (Sandbox Code Playgroud)

有没有Android的等效方法?

android google-maps area

10
推荐指数
1
解决办法
4887
查看次数

在android中调整谷歌地图(api v2)缩放级别

maps api v2我正在使用我的应用程序.我必须在地图上显示我当前的位置和目标位置,以便两个位置在屏幕上可见(在最大可能的缩放级别).这是我到目前为止所尝试的......

googleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapFragment)).getMap();

 if(googleMap != null){

        googleMap.setMyLocationEnabled(true);
        LatLng targetLocationLatLng = new LatLng(modelObject.getLattitude(), modelObject.getLongitude());
        LatLng currentLocationLatLng = new LatLng(this.currentLocationLattitude, this.currentLocationLongitude);
        googleMap.addMarker(new MarkerOptions().position(targetLocationLatLng).title(modelObject.getLocationName()).icon(BitmapDescriptorFactory.fromResource(R.drawable.location_icon)));
        LatLngBounds bounds = new LatLngBounds(currentLocationLatLng, targetLocationLatLng);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 3));

    }
Run Code Online (Sandbox Code Playgroud)

应用程序因以下原因而关闭: java.lang.IllegalStateException: Map大小不应为0.很可能,layout地图视图尚未发生.

如何获得最大可能的缩放级别?请帮我.

android google-maps android-fragments

2
推荐指数
1
解决办法
8525
查看次数