iPhone开发 - 的引脚诠释可视地图区域 [英] iPhone Development - Is Pin Annotation in a viewable Map Region

查看:271
本文介绍了iPhone开发 - 的引脚诠释可视地图区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能检查是否引脚处于(的MKMapView)?在地图的可视区域


解决方案

一个引脚为 MKPinAnnotationView ,从 MKAnnotationView 并有一个属性注释(符合协议 MKAnnotation )。这样的注解有自己的另一个属性协调

就比较这样的纬度/经度坐标地图的区域。

这样的事情应该这样做:


双闽龙= myMap.region.center.longitude - myMap.region.span.longitudeDelta / 2.0;
双MAXLONG = myMap.region.center.longitude + myMap.region.span.longitudeDelta / 2.0;
双minL​​at = myMap.region.center.latitude - myMap.region.span.latitudeDelta / 2.0;
双maxLat = myMap.region.center.latitude + myMap.region.span.latitudeDelta / 2.0;

BOOL isPinInRegion = myPinCoordinates.longitude> =闽龙和放大器;&安培; myPinCoordinates.longitude< =&MAXLONG功放;&安培; myPinCoordinates.latitude> = minLat和放大器;&安培; myPinCoordinates.latitude< = maxLat;

How can i check if a pin is in viewable region of the map (MKMapView)?

解决方案

A pin is a MKPinAnnotationView, it extends from MKAnnotationView and has a property annotation (that conforms to the protocol MKAnnotation). Such annotation has itself another property coordinate.

Just compare the latitude / longitude of such coordinate to the region of your map.

something like this should do it :

double minLong = myMap.region.center.longitude - myMap.region.span.longitudeDelta/2.0;
double maxLong = myMap.region.center.longitude + myMap.region.span.longitudeDelta/2.0;
double minLat = myMap.region.center.latitude - myMap.region.span.latitudeDelta/2.0;
double maxLat = myMap.region.center.latitude + myMap.region.span.latitudeDelta/2.0;

BOOL isPinInRegion = myPinCoordinates.longitude>=minLong && myPinCoordinates.longitude<=maxLong && myPinCoordinates.latitude>=minLat && myPinCoordinates.latitude<=maxLat;

这篇关于iPhone开发 - 的引脚诠释可视地图区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆