Flickering MapOverlay after zoom out and zoom in-iOS

删除回忆录丶 提交于 2019-12-10 12:59:25

问题


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];

回答1:


Download Apples

BreadCrumbs Demo

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.




回答2:


I have tested BreadCrumbs Demo on iOS 6.1 (iPad 3) and it flicker. It's a bug of the new MKMapView (sad). I have submitted the bug to Apple.



来源:https://stackoverflow.com/questions/13364758/flickering-mapoverlay-after-zoom-out-and-zoom-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!