我正在尝试在Google地图可见区域中适合两个地理位置点,但不适合。我使用下面的代码来实现这一点
let bounds = GMSCoordinateBounds(coordinate: source, coordinate: destination)
self.mapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 10))
答案 0 :(得分:1)
您可以为此使用includeCoordinate。它将适合所有坐标。
var bounds = GMSCoordinateBounds()
bounds = bounds.includingCoordinate(source)
bounds = bounds.includingCoordinate(destination)
self.mapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 10.0))
已更新!
let bounds = GMSCoordinateBounds(coordinate: source, coordinate: destination)
self.mapView.animate(with: GMSCameraUpdate.fit(bounds, withPadding: 100))
mapView.padding = UIEdgeInsets(top: 0, left: 0, bottom: self.bottomView.height, right: 0)