user2251725
user2251725

Reputation: 406

How perform click operation on marker custom info window on google map V2 in android

I am implementing google map V2 in my app.I have added custom info window to marker.There are three images cancel,delete & edit.

onclick, cancel image window hide. delete data delete & on edit dialog open for editing.

My problem is, how perform click operation on on these images?

Image

Upvotes: 15

Views: 27717

Answers (3)

Deyan Genovski
Deyan Genovski

Reputation: 412

Even though this is an old question I still think people are interested in having info windows with buttons, list etc.

You can check the following library - https://github.com/Appolica/InteractiveInfoWindowAndroid

You can basically add your own fragment as an info window using the manager provided by this library. The following is a snippet of how easily the library can be used. Check the link above for more information

 final MapInfoWindowFragment mapInfoWindowFragment =
    (MapInfoWindowFragment) getSupportFragmentManager().findFragmentById(R.id.infoWindowMap);
 final InfoWindow infoWindow = new InfoWindow(marker, markerSpec, fragment);
// Shows the InfoWindow or hides it if it is already opened.
 mapInfoWindowFragment.infoWindowManager().toggle(infoWindow, true); 

Upvotes: -1

MaciejGórski
MaciejGórski

Reputation: 22232

There is no direct way to do it, but there seems to be workaround for this (which I haven't tested myself yet). You may see a long description in this answer: https://stackoverflow.com/a/15040761/2183804.

Upvotes: 9

Raghunandan
Raghunandan

Reputation: 133560

https://developers.google.com/maps/documentation/android/marker

Quoting form the docs

Info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described below.

Info window is not a live View, rather the view is rendered as an image onto the map. As a result, any listeners you set on the view are disregarded and you cannot distinguish between click events on various parts of the view. You are advised not to place interactive components — such as buttons, checkboxes, or text inputs — within your custom info window.

You can use an OnInfoWindowClickListener to listen to click events on an info window. To set this listener on the map, call GoogleMap.setOnInfoWindowClickListener(OnInfoWindowClickListener). When a user clicks on an info window, onInfoWindowClick(Marker) will be called and the info window will be highlighted in the default highlight color (Holo Blue for devices running Ice Cream Sandwich and newer, orange for earlier versions of Android).

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.OnInfoWindowClickListener

Upvotes: 8

Related Questions