我的应用程序在地图上有很多叠加层,如何让地图保持这么慢?它就像在地图上移动时的5秒延迟。看看我下面的代码,我将如何添加人员,有人可以告诉我如何解决这个问题,以便它不会那么慢,我在地图上有大约80个叠加层,并且在第二个区域内增长。
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);
答案 0 :(得分: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个标记?