如何将MKMapView的距离(例如400米)转换为UIView的距离? 我想显示MKAnnotationView取决于MKMapView上的当前缩放级别。将MKMapView的距离转换为UIView的距离
2
A
回答
9
首先,创建一个区域400米定尺:
MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate, 400, 0);
使用后转换区域方法得到真正的矩形:
CGRect myRect = [mapView convertRegion: myRegion toRectToView: nil];
NSLog(@"width for 400m is %f", myRect.size.width);
希望,这会有所帮助。
5
您有几种选择在MKMapView转换的UIView屏幕地理坐标上的坐标(和地理 - >屏幕以及):
- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(UIView *)view
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view
我认为400米,2个坐标之间的距离,所以要您有2 CLLocationCoordinate2D
结构的参考。
只需使用- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(UIView *)view
即可获得相应的CGPoint
(=屏幕坐标),然后您就可以计算屏幕距离。
相关问题
- 1. 将RSSI转换为距离
- 2. 将距离转换为WP8中的GeoCoordinate
- 3. 将成对距离转换成距离矩阵R
- 4. iphone - 将MKMapPoint距离转换为米
- 5. 从欧几里得距离转换为曼哈顿距离c#
- 6. 距离Cell塔的距离
- 7. 转换(起源,目的地,距离)到距离矩阵
- 8. 将gps坐标转换为距离并将距离转换为以十进制度表示的半径
- 9. 反转距离
- 10. MongoDB geonear和距离转换
- 11. PHP - 邮编距离函数转换距离到英里
- 12. google api距离矩阵转换为R
- 13. 计算距离位置的距离 - iPhone
- 14. 如何计算距离cellID的距离?
- 15. 获取距离边缘的距离3
- 16. Levenstein转置距离
- 17. 距离变换.NET
- 18. 如何设置mkmapview以显示距离我当前位置100米的距离?
- 19. Python中的广义距离转换
- 20. 转换Levenshtein错误率的距离
- 21. 距离
- 22. 如何将点转换为指定角度的指定距离?
- 23. 如何将平面转换为X距离的点?
- 24. FetchXML - GeoCode距离按距离搜索
- 25. Python中的Levenshtein距离只给出1作为编辑距离
- 26. Vincenty距离转换成阵列
- 27. opencv C++到java距离转换
- 28. 转换时间:[距离,速度]数据距离:[时间,速度]数据
- 29. AS3:查找旋转距离
- 30. 单点的距离
如果您将距离设置为'MKCoordinateRegionMakeWithDistance'的'latitudinalMeters'属性,就像在您的示例中一样,您应该确实读取高度而不是生成的CGRect的宽度。请参阅http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MapKitFunctionsReference/Reference/reference.html#//apple_ref/c/func/MKCoordinateRegionMakeWithDistance –