【发布时间】:2016-04-19 00:54:15
【问题描述】:
我正在尝试在 android 上使用 GoogleMap API,但我想在用户单击掉落的图钉时隐藏 infoWindow。但是,我仍然希望显示路线和 latlog 图标。
也就是说,图片应该能说明我需要什么:
我尝试为我丢弃的图钉添加一个监听器,但这会杀死整个 infoWindow 和方向图标,如下所示:
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng location1 = new LatLng(32.75613, -117.11648);
mMap.addMarker(new MarkerOptions().position(location1).title("Hello"));
LatLng location2 = new LatLng(32.754978528015876, -117.12977170944214);
mMap.addMarker(new MarkerOptions().position(location2).title("World"));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location1, 12.0f)); //zoom out
// This does not work, if I turn it to true, I loose the directions icon
// I don't want a custom info window, I just want to hide it and have the directions
// icon still showing up
if (false) {
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
Log.d("zzz", "marker = " + marker.getTitle());
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 14.0f)); //zoom out
return true;
}
});
}
}
是否可以在不重写路线图标的整个逻辑的情况下做到这一点?
谢谢!
【问题讨论】:
标签: android google-maps google-maps-api-2