我有MKMapView
中心的第一个点和以米为单位的距离来映射中心应该是的左边界。
如何为此设置区域?
答案 0 :(得分:1)
给定中心坐标和从中心到边界的距离(以米为单位),您可以使用MKCoordinateRegionMakeWithDistance
功能创建区域:
CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(lat, lng);
CLLocationDistance centerToBorderMeters = 5000;
MKCoordinateRegion rgn = MKCoordinateRegionMakeWithDistance
(centerCoord,
centerToBorderMeters * 2, //vertical span
centerToBorderMeters * 2); //horizontal span
[mapView setRegion:rgn animated:YES];