【问题标题】:Overlaying multiple polygons on the mapView-iOS在 mapView-iOS 上叠加多个多边形
【发布时间】:2012-11-08 00:04:32
【问题描述】:

如图所示,mapView 顶部有许多多边形。每个多边形都覆盖在其他多边形的顶部。这会导致不透明度问题,并误导用户通过参考颜色图来解释颜色。

在放置任何多边形之前,首先我要删除/清除新的多边形区域,然后添加多边形。

我希望我的问题清楚!如果没有,请告诉我。提前赞赏。

我还在下面添加了部分代码作为参考!多边形数据来自 JSON 格式的服务器,我从这些数据中获取坐标并将它们添加为每个时间戳的多边形。

for(bb = 0; bb < [polygonArray count]; bb++){
        coords = malloc(sizeof(CLLocationCoordinate2D) * [[polygonArray objectAtIndex:bb] count]);
        for (int a = 0;a < [[polygonArray objectAtIndex:bb] count]; a++){
            coords[a].latitude = [[[[polygonArray objectAtIndex:bb]objectAtIndex:a]objectAtIndex:0]doubleValue];
            coords[a].longitude = [[[[polygonArray objectAtIndex:bb]objectAtIndex:a]objectAtIndex:1]doubleValue];
        }
        polygon = [[MKPolygon alloc]init];
        polygon = [MKPolygon polygonWithCoordinates:coords count:[[polygonArray objectAtIndex:bb]count]];
        [previousPolygons addObject:polygon];
        [mapView addOverlay:polygon];
        }

    }

【问题讨论】:

    标签: ios ios6 mkmapview mkoverlay ios6-maps


    【解决方案1】:

    嗯。我有点不清楚你想做什么。如果你只是想删除一个多边形,你必须知道如何找到你想要删除的多边形并运行

    [mapView removeOverlay:polygon]
    

    如果要删除所有多边形,则可以运行

    [mapView removeOverlays:mapView.overlays]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多