从经度/经度增量获取/计算缩放级别



有没有办法让谷歌地图缩放级别从谷歌地图SDK的iOS版的经度/经度增量值计算?

或者也许通过目标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]];

如果有人正在搜索 swift,我也需要它来进行自动完成,您可以设置边界(例如弗莱堡和斯图加特附近的德国西南部):

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.......

最新更新