【问题标题】:Remove Polylines from over the map Xcode从地图 Xcode 上删除折线
【发布时间】:2023-03-22 20:30:01
【问题描述】:

我正在实施一个 iphone 应用程序。我有一个地图和对象数组,其中包含要在地图上绘制的坐标。并在这些点之间绘制一条折线。所以我想知道如何删除这条折线。不是显示/隐藏,而是删除。

这是我如何绘制它的代码

int pointCount = [routeLatitudes count] / 2; //routeLatitudes 是包含坐标纬度后跟经度的数组。

    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;

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

提前致谢。

【问题讨论】:

    标签: iphone objective-c ios xcode ipad


    【解决方案1】:

    试试这个

     [mapView removeOverlays:mapView.overlays];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-28
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多