15

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

4

3 回答 3

9

没有直接的方法可以做到这一点,但似乎有解决方法(我还没有测试过自己)。您可能会在此答案中看到很长的描述:https ://stackoverflow.com/a/15040761/2183804 。

于 2013-05-17T10:48:37.130 回答
8

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

于 2013-05-17T07:51:03.380 回答
-1

尽管这是一个老问题,但我仍然认为人们对拥有带有按钮、列表等的信息窗口感兴趣。

您可以检查以下库 - https://github.com/Appolica/InteractiveInfoWindowAndroid

您基本上可以使用此库提供的管理器将您自己的片段添加为信息窗口。以下是该库的使用方便程度的片段。检查上面的链接以获取更多信息

 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); 
于 2016-11-21T21:30:44.917 回答