0

我在 MkMapView 中的 MKPolyLineView 上的 2 组坐标之间绘制 MKPolyLines。一条线是从一个点到另一点的实际路线,而另一条线是两点之间的最短距离。我已经成功绘制了 2 组线。现在我需要找到两条线之间的方向角度。尽管我付出了很多努力,但我还是没有找到任何有用的东西。需要帮助。

这就是我绘制折线的方式。

self.routeLine = [MKPolyline polylineWithCoordinates:pointsToUse count:[array count]];
self.straightLine = [MKPolyline polylineWithCoordinates:straightLinePoints count:2];

[self.map addOverlay:self.routeLine];
[self.map addOverlay:self.straightLine];

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
if(overlay == self.routeLine){
// ylineView *polyLineView = [[MKPolylineView alloc] initWithPolyline:self.polyLine];
polyLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
polyLineView.lineWidth = 2;
polyLineView.strokeColor = [UIColor lightGrayColor];
polyLineView.backgroundColor = [UIColor grayColor];
return polyLineView;
}
else{
    polyLineView = [[MKPolylineView alloc] initWithPolyline:self.straightRouteLine];
    polyLineView.lineWidth = 2;
    polyLineView.strokeColor = [UIColor redColor];
    polyLineView.backgroundColor = [UIColor redColor];
    return polyLineView;
}
}
4

1 回答 1

0

我写了一些在 Python 中执行此操作的代码。我可以稍后回家后发布代码,但它看起来像这样:

angle = atan2(y2 - y1, x2 - x1) * 180 / PI;
于 2013-09-04T08:20:16.167 回答