有什么方法可以从 Google Maps SDK for iOS 的 lat/long delta 值计算 Google Maps 缩放级别?
或者也许通过 Objective C 计算它?
谢谢
有什么方法可以从 Google Maps SDK for iOS 的 lat/long delta 值计算 Google Maps 缩放级别?
或者也许通过 Objective C 计算它?
谢谢
也许这就是您正在寻找的。
来自 GMSCoordinateBounds.h:
/**
* Inits the northEast and southWest bounds corresponding
* to the rectangular region defined by the two corners.
*
* It is ambiguous whether the longitude of the box
* extends from |coord1| to |coord2| or vice-versa;
* the box is constructed as the smaller of the two variants, eliminating the
* ambiguity.
*/
- (id)initWithCoordinate:(CLLocationCoordinate2D)coord1
coordinate:(CLLocationCoordinate2D)coord2;
它可用于设置相机以适应具有适当缩放级别的边界。
CLLocationCoordinate2D coord1 = CLLocationCoordinate2DMake(-45.43563456, -23.32543646);
CLLocationCoordinate2D coord2 = CLLocationCoordinate2DMake(-21.32145323, -12.32455435);
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:coord1 coordinate:coord2];
[mapView moveCamera: [GMSCameraUpdate fitBounds:bounds]];
如果有人正在快速搜索它,我还需要它来自动完成,您可以设置边界(例如德国西南部靠近弗赖堡和斯图加特):
let coord1 : CLLocationCoordinate2D = CLLocationCoordinate2DMake(48.10009, 8.206787);
let coord2 : CLLocationCoordinate2D = CLLocationCoordinate2DMake(48.10009, 8.206787);
let bounds = GMSCoordinateBounds(coordinate: (coord1), coordinate: (coord2))
placesClient?.autocompleteQuery(autoQuery, bounds: bounds, filter: filter, callback: { (results, error: NSError?) -> Void in and so on.......