[英]Hide infowindow android map api v2
I was trying to close the default infowindow in the android map.我试图关闭 android 地图中的默认信息窗口。 I used .hideInfoWindow()
but nothing appends.我使用了.hideInfoWindow()
但没有附加任何内容。 Thanks.谢谢。
Change the return statement更改返回语句
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
(to)
@Override
public boolean onMarkerClick(Marker marker) {
return true;
}
Use采用
mapa.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
marker.hideInfoWindow();
}
});
I hope that helps.我希望这有帮助。
I assume you want to close the infowindow when you click the marker for the second time.我假设您想在第二次单击标记时关闭信息窗口。 It seems you need to keep track of the last clicked marker.您似乎需要跟踪上次点击的标记。 I can't get it to work by simply checking if the clicked marker is currently shown and then close it, but this works nicely.我无法通过简单地检查单击的标记当前是否显示然后关闭它来使其工作,但这很好用。
private Marker lastClicked;
private class MyMarkerClickListener implements OnMarkerClickListener {
@Override
public boolean onMarkerClick(Marker marker) {
if (lastClicked != null && lastClicked.equals(marker)) {
lastClicked = null;
marker.hideInfoWindow();
return true;
} else {
lastClicked = marker;
return false;
}
}
}
Setting the pin title and snippet to null, will result in no info window being displayed.将 pin 标题和代码段设置为 null,将导致不显示信息窗口。 This shall cover both cases when selecting and clicking a pin.这将涵盖选择和单击图钉时的两种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.