方法
BaiduMap.Marker.setVisible(boolean)
实现
List<Marker> list_marker = new ArrayList<>();
boolean isShowMarker = true;@Override
public boolean onCreateOptionsMenu(Menu menu) {String[] sm = { "显隐信息", "显隐照片", "截图", "分享", "重命名", "删除", "退出" };for (int i=0; i<sm.length; i++) {menu.add(0, i, i, sm[i]);}return true;
}@Override
public boolean onPrepareOptionsMenu(Menu menu) {MenuItem item = menu.findItem(1);if (isShowMarker)item.setTitle("隐藏照片");elseitem.setTitle("显示照片");return true;
}@Override
public boolean onOptionsItemSelected(MenuItem item) {int item_id = item.getItemId();switch (item_id) {...case 1:isShowMarker = !isShowMarker;for (int i=0; i<list_marker.size(); i++) {Marker marker = list_marker.get(i);marker.setVisible(isShowMarker);}break;...}
}void addPhotoMarker() {...list_marker.clear();for (int i = 0; i < list_photo_LatLng.size(); i++) {...OverlayOptions overlay = new MarkerOptions().position(list_photo_LatLng.get(i)).icon(bitmap4).extraInfo(bundle);Marker marker = (Marker) mBaiduMap.addOverlay(overlay);list_marker.add(marker);}...
}