我有两个问题。首先,一旦我为坐标分配了内存请看下面的代码,我是否必须释放内存 free(coords)?其次,正如您在下面的代码中看到的那样,我获得了叠加层并添加到 map 上。但是,有一个不同的时间戳提要坐标并且应该更新 map 。就像雷达 map 随着不同的时间戳改变叠加形状。它最初更新得很好;但是,一旦用户缩小和放大,它就会开始闪烁或闪烁。我想知道为什么会出现这种闪烁?以前有人遇到过这个问题吗?
NSArray *ants = [mapView overlays];
for(bb = 0; bb < [polygonArray count]; bb++){
int attr=[[idArray objectAtIndex:bb]floatValue];
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]];
//free(coords);
[previousPolygons addObject:polygon];
}
[mapView addOverlay:polygon];
}
}
[mapView removeOverlays:ants];
最佳答案
下载苹果
应用程序。
使用此演示,您会看到推荐的技术来完成您的任务。
我在我的应用程序中使用了该演示,它非常有效。
MkPolygon 的方法不适用于大多边形或更改多边形。
关于ios - 缩小和放大后 MapOverlay 闪烁-iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13364758/