java 隐藏信息窗口android map api v2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14101439/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide infowindow android map api v2
提问by TheRedFox
I was trying to close the default infowindow in the android map.
I used .hideInfoWindow()
but nothing appends.
Thanks.
我试图关闭 android 地图中的默认信息窗口。我使用过.hideInfoWindow()
但没有附加任何内容。谢谢。
回答by Satheesh
Change the return statement
更改返回语句
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
(to)
@Override
public boolean onMarkerClick(Marker marker) {
return true;
}
回答by Delari Jesus
Use
利用
mapa.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
marker.hideInfoWindow();
}
});
I hope that helps.
我希望这有帮助。
回答by Edwin
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;
}
}
}