每当相机移动时,我需要知道Google map 中的右上角和左下角坐标。 API为我提供了相机的中心点。有没有一种方法可以通过API或某种算法知道中心点(目标),缩放和方位角,从而得到我想要的东西?
func mapView(mapView: GMSMapView, didChangeCameraPosition position: GMSCameraPosition) {
position.target
position.zoom
position.bearing
}
最佳答案
swift 3
使用GMSProjection的visibleRegion方法。
let projection = mapView.projection.visibleRegion()
let topLeftCorner: CLLocationCoordinate2D = projection.farLeft
let topRightCorner: CLLocationCoordinate2D = projection.farRight
let bottomLeftCorner: CLLocationCoordinate2D = projection.nearLeft
let bottomRightCorner: CLLocationCoordinate2D = projection.nearRight
也看看this question。
关于ios - Swift:如何知道Google map 的右上角和左下角坐标,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37861920/