加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 从地图Xcode上删除折线

发布时间:2020-12-14 18:06:13 所属栏目:百科 来源:网络整理
导读:我正在实施一个iPhone应用程序.我有一个地图和对象数组,其中包含要在地图上绘制的坐标.并且在这些点之间绘制折线.所以我想知道如何删除这条折线.不显示/隐藏,但删除. 这是我如何绘制它的代码 int pointCount = [routeLatitudes count] / 2; //routeLatitudes
我正在实施一个iPhone应用程序.我有一个地图和对象数组,其中包含要在地图上绘制的坐标.并且在这些点之间绘制折线.所以我想知道如何删除这条折线.不显示/隐藏,但删除.

这是我如何绘制它的代码

int pointCount = [routeLatitudes count] / 2; //routeLatitudes is the array that contains the coordinates latitude followed by longitude.

MKMapPoint* pointArr = malloc(sizeof(MKMapPoint) * pointCount);

    int pointArrIndex = 0;  
    for (int idx = 0; idx < [routeLatitudes count]; idx=idx+2)
    {
        CLLocationCoordinate2D workingCoordinate;       
        workingCoordinate.latitude=[[routeLatitudes objectAtIndex:idx] doubleValue];
        workingCoordinate.longitude=[[routeLatitudes objectAtIndex:idx+1] doubleValue];  
        MKMapPoint point = MKMapPointForCoordinate(workingCoordinate);
        pointArr[pointArrIndex] = point;
        pointArrIndex++;
    }   

    // create the polyline based on the array of points. 
    routeLine = [MKPolyline polylineWithPoints:pointArr count:pointCount];

    [mapView addOverlay:routeLine];
    free(pointArr);

并显示/隐藏折线我创建了一个参考MKOverlayView * overlayView = nil;

overlayView.hidden=false/true;

现在我需要知道如何删除/删除绘制的折线.

预先感谢.

解决方法

试试这个

[mapView removeOverlays:mapView.overlays];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读