在缩小并放大iOS后,闪烁的MapOverlay [英] Flickering MapOverlay after zoom out and zoom in-iOS

查看:113
本文介绍了在缩小并放大iOS后,闪烁的MapOverlay的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题。首先,一旦我分配内存的坐标,请看下面的代码,我必须释放内存空闲(coords)?其次,如下面的代码所示,我得到覆盖并添加到地图上。但是,有不同的时间戳馈送坐标并且应该更新地图。像雷达地图改变覆盖形状与不同的时间戳。它最初更新很好;然而,一旦用户缩小并放大,它将开始闪烁或闪烁。我不知道为什么这个闪烁发生了?任何人以前都经历过这个问题?

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


解决方案

下载苹果


BreadCrumbs演示


应用程序。

使用此演示,您将看到推荐的技术来完成任务。

我在我的应用程序中使用了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

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.

这篇关于在缩小并放大iOS后,闪烁的MapOverlay的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆