How to adjust the size of marker icons to fit the zoom level on Android

I am adding several markers to my maps, and I want them to resize the icons when zooming or scaling. How to do it?

This is my code:

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()); 

This is my addMarkers method:

 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)));; } 

}

+6
source share

Source: https://habr.com/ru/post/969430/


All Articles