Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Maps - custom background behind all markers

I try to put a background between the map and my marker; this image should always (!) stay behind all markers.

I tried several way, e.g. showInfoWindow() on all my markers except the background image, but it seems as this would only help for the last one.

Then I tried a solution using GroundOverlay, but I need my image to always stay the same size (e.g. half the device size), independent of zoom factor.

Is there a solution on Android for this?

like image 991
swalkner Avatar asked Nov 02 '15 12:11

swalkner


People also ask

Can you change the background on Google Maps?

You can change the color theme of Google Maps on your mobile device. Dark theme can make your screen easier to read and reduce battery usage.

How do I start a custom image on Google Maps marker for mobile app?

For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New > Vector Assets and select the icon which we have to show on your Map. You can change the color according to our requirements.


1 Answers

This is easy to do.

Add two markers instead of one. First add the background as a bitmap at lat_lng.

Something like this:

map.addMarker(new MarkerOptions()
      .position(lat_lng)
      .anchor(0.5f, 0.5f)
      .icon(BitmapDescriptorFactory.fromBitmap(bitmap)));

Then add your marker like you normally do at the same lat_lng.

Do the above for each of your markers.

like image 153
Capstone Avatar answered Oct 06 '22 01:10

Capstone