Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale Map Markers by Zoom, Android

I have lot of markers on my map. Zooming in each marker shows me a position. but zooming out the markers are overlapping each other and it is more difficult do determine the position of a marker.

Is there a way to scale the marker image depending on the zoom factor?

like image 520
UpCat Avatar asked Aug 19 '10 07:08

UpCat


People also ask

How do I zoom in smaller increments on Google Maps?

You can change the zoom level of the map using simple steps. Step 1 Go to Add or Edit Map page . Step 2 Select 'Default zoom level' in the 'Map Information section'. Step 3 click save map and see the changes.

How do I zoom in and out on a map?

The shortcut is simple: just double-tap the maps interface, but instead of lifting your finger after the second tap (the shortcut for zooming in), you leave it touching the screen. Then a swipe up zooms out, and a swipe down zooms in.


2 Answers

Depends on how you draw your marker. If your marker is just a bitmap/drawable, simply use matrix.postScale()

Matrix matrix = new Matrix();
matrix.postScale(2f, 2f); // douple the size
canvas.drawBitmap(mBitmap, matrix, mPaint);
like image 148
WarrenFaith Avatar answered Oct 12 '22 04:10

WarrenFaith


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

like image 35
Josh Avatar answered Oct 12 '22 05:10

Josh