我有两个问题。首先,一旦我为坐标分配内存,请参阅下面的代码,我是否必须释放内存(坐标)?其次,正如您在下面的代码中看到的,我得到了叠加层并添加到地图上。但是,有不同的时间戳提要坐标,应该更新地图。就像雷达地图用不同的时间戳改变叠加形状一样。它最初更新得很好;然而,一旦用户缩小和放大,它就会开始闪烁。我想知道为什么会出现这种闪烁?以前有人遇到过这个问题吗?
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];
下载苹果
面包屑演示 http://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html
App.
使用此演示,您可以看到完成任务的推荐技术。
我已经在我的应用程序中使用了该演示,它的效果非常好。
MkPolygon 的方法不适用于大多边形或更改多边形。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)