我正在尝试在Map ToolBar
上实施google maps
。我已经完成了以下编码,但toolbar
没有显示。我提到了link。谁能告诉我哪里出错了。我的代码如下:
if (isGooglePlayServicesIsInstalled(getActivity())) {
googleMap = mapFragment.getMap();
MarkerOptions marker = new MarkerOptions().position( new LatLng(15.4989, 15.4989)).title("title");
googleMap.addMarker(marker).showInfoWindow();
googleMap.getUiSettings().setMapToolbarEnabled(true);
}
@Override
public boolean onMarkerClick(final Marker marker) {
googleMap.getUiSettings().setMapToolbarEnabled(false);
googleMap.getUiSettings().setMapToolbarEnabled(true);
googleMap.getUiSettings().setCompassEnabled(true);
}
Google play gradle:compile 'com.google.android.gms:play-services:6.5.87'
答案 0 :(得分:3)
据我所知,您似乎忘记return false
让默认操作有效。查看guide。
这就是我的所作所为:
// add marker dynamically
lastScooterLocation = new LatLng(lastScooterLat, lastScooterLng);
lastScooterMarker = mMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.img_map_pin_normal))
.anchor(0.0f, 0.0f)
.position(lastScooterLocation)
.draggable(false)
.title(getString(R.string.strings_last_scooter_location)));
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
showBottomViewOf(BottomViewState.HIDE_ALL);
mMap.getUiSettings().setMapToolbarEnabled(true);
// return true will prevent any further map action from happening
return false;
}
});