简体   繁体   中英

How to show markers with coloured circles?

i have created this 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))
                    );;
        }
    }
}

Since there are more than 5000 markers i get something like this:

在此处输入图片说明

I would like to get something like this:

在此处输入图片说明

that shows circles for markers that are closer to eachother and if you zoom it shows smaller circles or unique markers. How to obtain this feature?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM