0
私のアプリは地図上にオーバーレイがたくさんあるので、マップの速度が遅くならないようにするにはどうすればよいですか?地図上を移動すると5秒間遅れます。以下のコードを見て、私は人を追加しています。誰かが私にこの問題を解決する方法を教えてもらえないので、地図上に約80のオーバーレイがあり、2番目に成長しています。多くのオーバーレイが追加された後、アンドロイドマップの移動が遅くなる
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);
はい、あなたのコードで自分のコードと比べて何が起こっているのか分かりません。私の地図はそれだけで非常に遅いです。 – user516883
forループ内にmapOverlays.add(他の場所)がありませんか? forループから外して、ループ内のotherslocation.addOverlay(overlayitem)のみを含める – ddewaele
こんにちは。この問題を解決しましたか、同じことに直面しています。解決策があれば教えてください。 –