4

I've seen a few questions about this but no solid answers.

I have a MapView that can generate up to 1600 locations on the map, based on how far the user zooms in or out. As of now, I have my marker simply set to a drawable within my application. How can I detect if a user has zoomed in/out, then scale the marker accordingly. I'm not concerned with the scaling part, but with the zoom listening part. Has anyone developed a solution to this little issue, or can point me in the correct direction to create my own?

Also, as far as I know, there is not a default marker that Android supplies. Am I correct about this? It would be nice if Android had a built in marker that handles the scaling based on zoom levels for you.

bschultz
  • 4,244
  • 1
  • 25
  • 33

2 Answers2

0

Markers do not change size based on zoom. Use GroundOverlays if you desire this effect. src

 GoogleMap map = ...; // get a map.
 BitmapDescriptor image = ...; // get an image.
 LatLngBounds bounds = ...; // get a bounds
 // Adds a ground overlay with 50% transparency.
 GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
     .image(image)
     .positionFromBounds(bounds)
     .transparency(0.5));

A ground overlay is an image that is fixed to a map and scales with the map zoom. Please see the API for more info

See related post: Scale Map Markers by Zoom, Android

Community
  • 1
  • 1
Josh
  • 268
  • 2
  • 14
0

I'am use

LatLng latLng = new LatLng(-16.50881576338701,-68.13492067606603);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.raw.ic_car_1);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); 
        googleMap.addGroundOverlay(new GroundOverlayOptions()
             .image(bitmapDescriptor)
             .position(latLng,100));

The docs in google maps docs GroundOverlayOptions

Ronald Coarite
  • 4,460
  • 27
  • 31