设置google会将android版本2映射到特定区域(zoomtospan在版本2中的等价物?)

设置google会将android版本2映射到特定区域(zoomtospan在版本2中的等价物?),android,xamarin.android,google-maps-android-api-2,Android,Xamarin.android,Google Maps Android Api 2,在我的monodroid应用程序中,我使用此代码设置特定区域的google地图边界 mapView.Controller .ZoomToSpan (Math.Abs (maxLat - minLat), Math.Abs (maxLong - minLong)); mapView .Controller .AnimateTo (new GeoPoint ((maxLat + minLat) / 2, (maxLong + minLong) / 2)); 但是现在,通过更新到版本2找不到zoom

在我的monodroid应用程序中,我使用此代码设置特定区域的google地图边界

mapView.Controller .ZoomToSpan (Math.Abs (maxLat - minLat), Math.Abs (maxLong - minLong));
mapView .Controller .AnimateTo (new GeoPoint ((maxLat + minLat) / 2, (maxLong + minLong) / 2));
但是现在,通过更新到版本2找不到
zoomToSpan
方法。什么是替换机制?

这是您需要的

首先,获取所有要缩放的Latling点

让我们拿3个LatLng点

LatLngBounds bounds = new LatLngBounds.Builder().include(point1)
                    .include(point2).include(point3).build();

mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));

感谢@Basim Sherif,他的帖子让我对代码有了概念,但是在
iclude(latlng p0)
的谷歌文档上说:

<>将考虑在东部和东部扩展边界。 向西(其中一个可能环绕世界)和 从两者中选择较小的一个。如果两个方向都有结果 在相同大小的LatLngBounds中,这将在 向东方向

我猜如果它扩展了边界,那么我们就不能得到确切的面积。最后,我使用了以下代码:

LatLngBounds bounds= new LatLngBounds (new LatLng (minLat ,minLong ),new LatLng (maxLat ,maxLong ));
mapView .MoveCamera (CameraUpdateFactory .NewLatLngBounds (bounds ,0));

我认为它应该比其他方法更有效率

谢谢你的回复,但我想设置一个最大纬度、最小纬度、最大液化天然气和最小液化天然气的区域。不是目的地。