Android 添加500多个标记会使应用程序挂起
我正在开发一个地点/商店的应用程序,在谷歌地图上有500多个DB标记 我添加了两种场所和一种商店,如下所示:Android 添加500多个标记会使应用程序挂起,android,performance,google-maps,Android,Performance,Google Maps,我正在开发一个地点/商店的应用程序,在谷歌地图上有500多个DB标记 我添加了两种场所和一种商店,如下所示: Cursor places = db.getAllPlaces(); this.placeMarker0 = new ItemizedMarker(this.getResources().getDrawable( R.drawable.place0), this); this.placeMarker1 = new ItemizedMarke
Cursor places = db.getAllPlaces();
this.placeMarker0 = new ItemizedMarker(this.getResources().getDrawable(
R.drawable.place0), this);
this.placeMarker1 = new ItemizedMarker(this.getResources().getDrawable(
R.drawable.place1), this);
this.shopMarker = new ItemizedMarker(this.getResources().getDrawable(
R.drawable.shop), this);
if (places.moveToFirst()) {
do {
String[] coordinates = places.getString(11).split(",");
if (coordinates.length > 0) {
GeoPoint point = new GeoPoint((int) (Double
.parseDouble(coordinates[0]) * 1E6), (int) (Double
.parseDouble(coordinates[1]) * 1E6));
OverlayItem overlayitem = new OverlayItem(point, places
.getString(1), Integer.toString(places.getInt(0)));
if (places.getInt(12) == 0) {
placeMarker0.addMarker(overlayitem);
} else if (places.getInt(12) == 1) {
placeMarker1.addMarker(overlayitem);
} else {
shopMarker.addMarker(overlayitem);
}
} else {
Log.w("GMaps", "Place not located - " + places.getString(1));
}
} while (places.moveToNext());
this.placeMarker0.populateNow();
this.mapOverlays.add(placeMarker0);
this.placeMarker1.populateNow();
this.mapOverlays.add(placeMarker1);
this.shopMarker.populateNow();
}
这很好,默认情况下,所有标记都不会显示在商店中:-
问题是,在添加所有标记后,应用程序通常会冻结,并且您暂时无法单击任何标记或收缩缩放/移动地图。我添加了ZoomControl,它们可以工作,但不能直接与地图交互
是Android Google Map API不擅长处理许多标记,还是我应该使用另一种方法
如果你需要更多的细节,请让我现在 您是否考虑过使用而不是创建500多个单独的标记?除了性能开销之外,您当前的设置可能会让用户不知所措。似乎是一个很酷的库。谢谢我会在不久的将来尝试!