在缩小并放大iOS后,闪烁的MapOverlay [英] Flickering MapOverlay after zoom out and zoom in-iOS
问题描述
NSArray * ants = [mapView overlay];
for(bb = 0; bb< [polygonArray count]; bb ++){
int attr = [[idArray objectAtIndex:bb] floatValue];
coords = malloc(sizeof(CLLocationCoordinate2D)* [[polygonArray objectAtIndex:bb] count]); (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];
下载苹果
应用程序。
使用此演示,您将看到推荐的技术来完成任务。
我在我的应用程序中使用了Demo,它的工作方式就像一个魅力。
MkPolygon的方法对于大多边形不起作用,或更改多边形。
I have two questions. First of all, once I allocate memory for the coordinates please see the code below, do I have to free memory free(coords)? Second, as you seen below code, I get overlay and add on the map. However, there is a different timestamps feeds coordinates and should update map. Like a radar map changing overlay shape with different time stamps.It is updating very well initially; however, once user zoom out and zoom in, it starts flashing or flickering. I wonder why this flickering happens? Anybody has experienced that problem before?
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];
Download Apples
App.
Using this Demo you see the recommended technic to do your task.
I have used that Demo in my App, and it worked like a charm.
The approach with MkPolygon does not work fine withn big polygons, or changing Polygons.
这篇关于在缩小并放大iOS后,闪烁的MapOverlay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!