如何自动获取当前地图视图的边界?我一直在寻找各地。 Google Maps API提供了它:http://www.w3schools.com/googleapi/ref_getbounds.asp
为React Native
做这件事会很好答案 0 :(得分:0)
如果您需要,那么您可以为 MKMapView 添加一个扩展名,如下所示。
extension MKMapView {
func getBounds() -> (southWestPoint: CLLocationCoordinate2D, northEastPoint: CLLocationCoordinate2D) {
let visibleMapRect = self.visibleMapRect
let neMapPoint = MKMapPointMake(MKMapRectGetMaxX(visibleMapRect), visibleMapRect.origin.y)
let swMapPoint = MKMapPointMake(visibleMapRect.origin.x, MKMapRectGetMaxY(visibleMapRect))
return (southWestPoint: MKCoordinateForMapPoint(swMapPoint), northEastPoint:MKCoordinateForMapPoint(neMapPoint))
}
}
每当你想要绑定时,只需调用 getBounds 方法。