2010-11-27 41 views
0

我的应用在地图上有很多叠加层,我如何让地图不会太慢?就像在地图上移动时延迟了5秒。看看我的代码如何添加人员,有人可以告诉我如何解决这个问题,以便它不那么慢,我在地图上覆盖了大约80个覆盖图,并且增加了第二个。添加了多个叠加层后,android地图移动缓慢

ArrayList<String> lstotherslocation = MyGlobalInfomation.getOthersLocation(); 
       List<Overlay> mapOverlays = gMapView.getOverlays(); 
       Drawable drawable = this.getResources().getDrawable(R.drawable.otherslocation); 
       OthersLocationOverlay otherslocation = new OthersLocationOverlay(drawable,this); 
       mapOverlays.clear(); 
       for(int i = 0; i < lstotherslocation.size();i++){ 
        number = number + 1; 
         OthersPoint = new GeoPoint((int) (Double.parseDouble(lstotherslocation.get(i).trim())), 
               (int) (Double.parseDouble(lstotherslocation.get(i + 1).trim()))); 
         OverlayItem overlayitem = new OverlayItem(OthersPoint, "Title", 
         "test: " + lstotherslocation.get(i+ 2) + "\n" + 
         "User: " + lstotherslocation.get(i+ 3) + "\n" + 
         "test: " + lstotherslocation.get(i+ 4) + "\n" + 
         "test: " + lstotherslocation.get(i+ 5)); 
        i = i + 5; 
        otherslocation.addOverlay(overlayitem); 
        mapOverlays.add(otherslocation); 

回答

1

是否有理由为什么mapOverlays.add(otherslocation)在for循环中?

你可以尝试用下面的代码:

OthersLocationOverlay otherslocation = new OthersLocationOverlay(drawable,this); 
mapOverlays.clear(); 
mapOverlays.add(otherslocation); 
for(int i = 0; i < lstotherslocation.size();i++){ 
    .... 
    otherslocation.addOverlay(overlayitem); 
} 

我假设你想对你的othersLocationOverlay 80点的标记?

+0

是的,我不确定你的代码与我的代码相比你要做什么。我的地图只是非常缓慢地翻转过来。 – user516883 2010-11-29 08:07:04