3

If you add a marker to your map and you try to click it, the current default behavior is the infoWindow will popup. If you notice carefully, there is an additional control with two buttons will appear at the bottom right corner.

Here's my question: I would like to simulate this "marker selected" behavior when the activity is loaded. I managed to show the infoWindow by calling marker.showInfoWindow();, But how do I make this routing buttons appear at the bottom corner of the screen?

I have tried to look into map.getUiSettings() but I found no relevant methods there.

Thanks in advance!

route button

You Qi
  • 8,353
  • 8
  • 50
  • 68

2 Answers2

3

Unfortunately, no, this feature isn't available in the current version of Google Maps. Here is the feature request for developers team created https://code.google.com/p/gmaps-api-issues/issues/detail?id=7652.

You can also try to create your own layout with 2 ImageButtons. Check this answer for logic that needed to be implemented.

Community
  • 1
  • 1
romtsn
  • 11,704
  • 2
  • 31
  • 49
  • Hm, sadly the answer isn't complete enough for me (doesn't set up the views and transparent graphics) – xjcl Jun 29 '20 at 21:15
0

I don't understand what do you means - show or hide this 2 buttons? So both actions you can do only with one boolean: you should override standard behavior of (GoogleMap.OnMarkerClickListener

public abstract boolean onMarkerClick (Marker marker) 

So, your code in Kotlin, for example, will be like this:

googleMap.setOnMarkerClickListener { marker ->
         // your logic to show info panel or smth else
                  ...
         // and then - return value
          true
}

If you want to HIDE this buttons - return true, if you want to show this buttons - return false.

It's help for my to write my own Info Panel logic and hide buttons, for example.

alena_fox_spb
  • 697
  • 1
  • 8
  • 24
  • I want to do something different but still show the buttons, so just returning `true` won't cut it – xjcl Jun 29 '20 at 20:58