How to add a button to the marker info window?

I would like to implement this in my application, but I have no idea how to make a marker with a button, or how to get OnMarkerClickListener to indicate which part it clicked on.

As an example, here is the official Maps application, where the directions icon is a separate part / button and the reviews are shown on the right side.

Example

+7
source share
4 answers

I assume that you are using the new version of the Google Maps API for Android

While you can set the info window as an arbitrary view using GoogleMap.setInfoWindowAdapter() , the info window displayed on the map is not a live view. Instead, it is a snapshot of the view when the adapter returns the view. Thus, unfortunately, there is currently no way to distinguish between click events in the info window.

+4
source

See my answer here minutes ago: nstead, listen for marker click events using OnMarkerClickListener and immediately show your own full view. However, there may be a bit more work to snap it to the location of the marker. Try PopupWindow with showAtLocation (View parent, int gravity, int x, int y)

+3
source

You can basically click on the desired html code in the InfoWindow content property.

as a link: https://developers.google.com/maps/documentation/javascript/overlays#InfoWindows

+1
source

A bubble is just another representation that is placed on top of a map. This way your OnMarkerClickedListener will tell you which contact was clicked. From there, you can get the actual pin position on the screen and use this to position the look of the bubble that will contain the usual Android widgets.

0
source

All Articles