我需要在地图上找出可见的坐标。拜托,检查一下。
CLLocationDegrees leftDegrees = mapView.region.center.longitude - (mapView.region.span.longitudeDelta / 2.0);
CLLocationDegrees rightdegrees = mapView.region.center.longitude + (mapView.region.span.longitudeDelta / 2.0);
CLLocationDegrees bottomDegrees = mapView.region.center.latitude - (mapView.region.span.latitudeDelta / 2.0);
CLLocationDegrees topDegrees = mapView.region.center.latitude + (mapView.region.span.latitudeDelta / 2.0);
if (leftDegrees > rightdegrees)
{
[self getAnnotationFromServer: mapView.region.center andLeftDegrees:leftDegrees andRightDegrees:180 andBottomDegrees:bottomDegrees andTopDegrees:topDegrees];
[self getAnnotationFromServer: mapView.region.center andLeftDegrees:rightdegrees andRightDegrees:-180 andBottomDegrees:bottomDegrees andTopDegrees:topDegrees];
}
else
{
[self getAnnotationFromServer: mapView.region.center andLeftDegrees:leftDegrees andRightDegrees:rightdegrees andBottomDegrees:bottomDegrees andTopDegrees:topDegrees];
}
答案 0 :(得分:1)
您的代码看起来不错,但是只为可见部分获取注释的简单方法是直接将中心和半径发送到服务器。你只需选择一个比屏幕对角线(latitudeDelta或longitudeDelta)大一点的半径乘以一个常数。
这也有助于服务器,因为您可以轻松找到计算点之间距离的函数,而不必关心180 / -180交汇点。