探索地图工具包:功能与应用实践
地图区域坐标判断
在地图开发中,有时需要判断某个坐标是否在地图视图的显示区域内。可以通过以下代码实现:
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 = self.region.center.latitude + (mapView.region.span.latitudeDelta / 2.0);
if (leftDegrees > rightDegrees) { // 国际日期变更线在视图内
leftDegrees = -180.0 - leftDegrees;
}
if (coords.longitude > 0) // 坐标在日期变更线以西
coords.longitude = -180.0 - coords.longitude;
if (leftDegrees <= coords.longitude &
超级会员免费看
订阅专栏 解锁全文
5万+

被折叠的 条评论
为什么被折叠?



