【问题标题】:Adding an arrow over the polyline in mkmapkit?在 mkmapkit 的折线上添加箭头?
【发布时间】:2017-01-26 16:22:34
【问题描述】:

我有一个应用程序,我在 mkmapkit 中像这样显示折线 -

self.routeLine = [MKPolyline polylineWithCoordinates:coordinateArray count:4];
//[self.mapView setVisibleMapRect:[self.routeLine boundingMapRect]]; //If you want the route to be visible

[self.mapView addOverlay:self.routeLine];

-(MKPolylineRenderer *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
    if(overlay == self.routeLine)
    {
        if(nil == self.routeLineView)
        {
            self.routeLineView = [[MKPolylineRenderer alloc] initWithPolyline:self.routeLine];
            self.routeLineView.fillColor = [UIColor redColor];
            self.routeLineView.strokeColor = [UIColor redColor];
            self.routeLineView.lineWidth = 2;

        }

        return self.routeLineView;
    }

    return nil;
}

现在我想在多段线上添加一个箭头来显示这样的方向

How to draw an arrow on every polyline segment on Google Maps V3

。我用谷歌搜索了同样的结果,但到目前为止还没有运气。谁能指导我如何实现这一目标?

【问题讨论】:

    标签: iphone ipad mkmapview mkpolyline


    【解决方案1】:

    我建议自己使用 MKOverlayPathRenderer 实际绘制箭头,就像我在此示例中所做的那样:

    【讨论】:

    • 我不知道你想实现什么,但是MKOverlayPathRenderer的重点是它只是绘制一个CGPath。所以如果你能画出来,你就可以在地图上显示出来。
    • 好吧,你知道地图上的坐标(因为那是线的终点),所以在那个地方画箭头。
    • 我通过折线加入了 3 个点(在我们的例子中,不仅仅是直线,但我需要在每条折线的中间放置一个向前箭头。那条折线内是否可能)跨度>
    • 你能在这些线上添加一个带有箭头绘制代码的答案吗?
    猜你喜欢
    • 2016-01-22
    • 1970-01-01
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-18
    相关资源
    最近更新 更多