为了设置外部服务器的查询,我想在我正在构建的iPhone应用程序中获取当前Map View的边界.UIView应该响应边界,但似乎MKMapView没有.设置区域并放大地图后,我尝试获取边界.我坚持第一步,试图获得代表地图SE和NW角落的CGPoints.之后我打算用:
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view
Run Code Online (Sandbox Code Playgroud)
将点转换为地图坐标.但我甚至无法做到那么远......
//Recenter and zoom map in on search location
MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
region.center = mySearchLocation.searchLocation.coordinate;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[self.mapView setRegion:region animated:YES];
//After the new search location has been added to the map, and the map zoomed, we need to update the search bounds
//First we need to calculate the corners of the map
CGPoint se = CGPointMake(self.mapView.bounds.origin.x, mapView.bounds.origin.y);
CGPoint nw = CGPointMake((self.mapView.bounds.origin.x + mapView.bounds.size.width), (mapView.bounds.origin.y + mapView.bounds.size.height)); …Run Code Online (Sandbox Code Playgroud)