如何用彩色圆圈显示标记?
How to show markers with coloured circles?
我创建了这个 activity:
public class MapViewer extends Activity {
private GoogleMap map;
private Database db = new Database(this);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapviewer);
try {
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map != null) {
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.getUiSettings().setRotateGesturesEnabled(false);
this.addMerchantMarkers(new MarkerOptions());
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onPause() {
if (map != null) {
map.setMyLocationEnabled(false);
map.setTrafficEnabled(false);
}
super.onPause();
}
public void addMerchantMarkers(MarkerOptions mo) {
SQLiteDatabase dbRead = db.getReadableDatabase();
Cursor result = dbRead.rawQuery("SELECT title, addr, lat, lon FROM users", null);
while(result.moveToNext()) {
map.addMarker(mo.position(new LatLng(result.getFloat(2), result.getFloat(3)))
.title(result.getString(0))
.snippet(result.getString(1))
);;
}
}
}
因为有超过 5000 个标记,我得到这样的结果:
我想得到这样的东西:
显示彼此更接近的标记的圆圈,如果缩放,它会显示更小的圆圈或独特的标记。
如何获得此功能?
我创建了这个 activity:
public class MapViewer extends Activity {
private GoogleMap map;
private Database db = new Database(this);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapviewer);
try {
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map != null) {
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.getUiSettings().setRotateGesturesEnabled(false);
this.addMerchantMarkers(new MarkerOptions());
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onPause() {
if (map != null) {
map.setMyLocationEnabled(false);
map.setTrafficEnabled(false);
}
super.onPause();
}
public void addMerchantMarkers(MarkerOptions mo) {
SQLiteDatabase dbRead = db.getReadableDatabase();
Cursor result = dbRead.rawQuery("SELECT title, addr, lat, lon FROM users", null);
while(result.moveToNext()) {
map.addMarker(mo.position(new LatLng(result.getFloat(2), result.getFloat(3)))
.title(result.getString(0))
.snippet(result.getString(1))
);;
}
}
}
因为有超过 5000 个标记,我得到这样的结果:
我想得到这样的东西:
显示彼此更接近的标记的圆圈,如果缩放,它会显示更小的圆圈或独特的标记。 如何获得此功能?