如何根据Android上的缩放级别调整标记图标大小

时间:2014-05-17 11:55:27

标签: android google-maps map zoom google-maps-markers

我在地图上添加了几个标记,我希望他们在放大或缩小时调整图标大小。怎么做?

这是我的代码:

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        if (map!=null) {
            map.getUiSettings().setCompassEnabled(true);
            map.setTrafficEnabled(true);
            map.setMyLocationEnabled(true);

            map.moveCamera(CameraUpdateFactory.newLatLngZoom(defaultLatLng, zoomLevel));

            this.addMarkers(new MarkerOptions());

这是我的addMarkers方法:

public void addMarkers(MarkerOptions mo) {
    db = new Database(this);
    SQLiteDatabase dbRead = db.getReadableDatabase();
    String[] columns = {"title", "addr", "lat", "lon"};
    Cursor result = dbRead.query("people", columns, null, null, null, null, null);

while(result.moveToNext()){
    String person = result.getString(0);
    String address = result.getString(1);
    float lat = result.getFloat(2);
    float lon = result.getFloat(3);

    map.addMarker(mo.position(new LatLng(lat, lon))
            .title(person)
            .snippet(address)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)));;
}

}

0 个答案:

没有答案