如何用彩色圆圈显示标记?

时间:2015-01-02 11:16:03

标签: android google-maps geometry icons marker

我创建了这项活动:

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个标记我得到这样的东西:

enter image description here

我想得到这样的东西:

enter image description here

显示距离彼此较近的标记的圆圈,如果缩放则显示较小的圆圈或唯一标记。 如何获得此功能?

1 个答案:

答案 0 :(得分:1)