[英]Set region by distance between two points
I have the first point in center of MKMapView
and distance in meters to map's left border that the center should be. 我的第一个点位于
MKMapView
中心,距中心的地图左边框的距离以米为单位。
How do I set the region for that? 我该如何设置区域?
Given the center coordinate and the distance in meters from the center to the border, you can use the MKCoordinateRegionMakeWithDistance
function to create the region: 给定中心坐标以及从中心到边界的距离(以米为单位),可以使用
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.