Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a button to a API v2 Google Maps marker


I am working on an android Google Maps app, and am having trouble with map markers.

This question might have a trivial solution but after searching, I have only found links on how to add a marker with a button. What I want is different: I want a marker whose respective dialog box has a button.

Has anyone done anything similar to this?

like image 232
jhc Avatar asked Jan 15 '23 10:01

jhc


1 Answers

While you can create an InfoWindowAdapter, and attach it to your GoogleMap via setInfoWindowAdapter(), to tailor the contents of an info window to contain a Button, the Button will not be clickable. The View you return from getInfoContents() in InfoWindowAdapter is not displayed. Rather, it is converted into a Bitmap, and that image is what is displayed.

However, you can find out when the user taps on the info window via an OnInfoWindowClickListener registered via setOnInfoWindowClickListener() on your GoogleMap.

like image 85
CommonsWare Avatar answered Jan 21 '23 09:01

CommonsWare