我正在尝试为CLLocation编写一个类别,以将轴承返回到另一个CLLocation.
我相信我对公式做错了(计算不是我的强项).返回的轴承始终关闭.
我一直在看这个问题并尝试应用被接受为正确答案的更改及其引用的网页:
计算两个CLLocationCoordinate2D之间的方位
http://www.movable-type.co.uk/scripts/latlong.html
谢谢你的任何指示.我已经尝试将其他问题的反馈结合起来,而我仍然没有得到任何东西.
谢谢
这是我的类别 -
----- CLLocation + Bearing.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface CLLocation (Bearing)
-(double) bearingToLocation:(CLLocation *) destinationLocation;
-(NSString *) compassOrdinalToLocation:(CLLocation *) nwEndPoint;
@end
Run Code Online (Sandbox Code Playgroud)
--------- CLLocation + Bearing.m
#import "CLLocation+Bearing.h"
double DegreesToRadians(double degrees) {return degrees * M_PI / 180;};
double RadiansToDegrees(double radians) {return radians * 180/M_PI;};
@implementation CLLocation (Bearing)
-(double) bearingToLocation:(CLLocation *) destinationLocation {
double lat1 = DegreesToRadians(self.coordinate.latitude);
double lon1 = DegreesToRadians(self.coordinate.longitude);
double lat2 = DegreesToRadians(destinationLocation.coordinate.latitude);
double lon2 = DegreesToRadians(destinationLocation.coordinate.longitude);
double dLon = lon2 …Run Code Online (Sandbox Code Playgroud) 我想自定义在MKMapView上绘制的线条以显示路线,以便线条具有边框颜色和填充颜色.与此类似,它有一个黑色边框,并填充另一种颜色:

我目前只是返回MKPolyLineView对象,mapView:viewForOverlay:从中可以很好地处理普通线条.文档说MKPolyLineView不是子类,所以我应该继承MKOverlayView并实现我自己的drawMapRect?或者我应该继承MKOverlayPathView?或者创建MKPolylineView的替代品?
编辑 - 我要问的是:在哪里放置自己的Quartz绘图代码以绘制自己的注释/叠加?目前我已经创建了MKOverlayView的子类并实现了我自己的drawMapRect:zoomScale:inContext:以这种方式绘制叠加层非常容易,但这是最好的解决方案吗?
iphone ×3
cllocation ×1
cocoa-touch ×1
haversine ×1
ios ×1
map ×1
mapkit ×1
mkmapview ×1
overlay ×1