我正在使用 iOS 版谷歌地图。我有一组坐标。其中我想将其中一个坐标设置为 map 的中心,与缩放级别无关。使用 GMSCameraUpdate fitBounds
,我能够同时适应框架中的所有坐标。但是我怎样才能一直将一个特定的坐标设置为中心,并且还适合框架中的其余坐标。
我尝试的是创建 GMSCoordinateBounds
,包括所有坐标并设置适合范围
[myMapview animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:20.0f]];
但我想要的是 map View 应该以这种方式缩放,即这个特定坐标应该是精确的中心,而所有其他坐标也包含在框架中。
最佳答案
您需要像这样将所有 map 点存储在 GMSCoordinateBounds 中
GMSCoordinateBounds* bounds = [[GMSCoordinateBounds alloc] init ];
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(26.00, 75.00);
bounds = [bounds includingCoordinate:position];
使用相同类型代码存储所有位置。添加所有 GMSCoordinateBounds 位置使用 map
[myMapview animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds]];
//myMapview = this is object of your google map.
关于ios - 设置 map 中心和缩放以适合所有坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32757245/