/** * 缩放地图,使所有Overlay都在合适的视野内 * <p> * 注: 该方法只对Marker类型的overlay有效 * </p> * */ public void zoomToSpan() { if (mBaiduMap == null) { return; } if (mOverlayList.size() > 0) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Overlay overlay : mOverlayList) { // polyline 中的点可能太多,只按marker 缩放 if (overlay instanceof Marker) { builder.include(((Marker) overlay).getPosition()); } } mBaiduMap.setMapStatus(MapStatusUpdateFactory .newLatLngBounds(builder.build())); } }
/** * 缩放地图,使所有Overlay都在合适的视野内 * <p> * 注: 该方法只对Marker类型的overlay有效 * </p> */ public void zoomToSpan() { if (mBaiduMap == null) { return; } if (mOverlayList.size() > 0) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Overlay overlay : mOverlayList) { // polyline 中的点可能太多,只按marker 缩放 if (overlay instanceof Marker) { builder.include(((Marker) overlay).getPosition()); } } mBaiduMap.setMapStatus(MapStatusUpdateFactory .newLatLngBounds(builder.build())); } }
/** * ���ŵ�ͼ��ʹ����Overlay���ں��ʵ���Ұ�� * <p> * ע�� �÷���ֻ��Marker���͵�overlay��Ч * </p> * */ public void zoomToSpan() { if (mBaiduMap == null) { return; } if (mOverlayList.size() > 0) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Overlay overlay : mOverlayList) { // polyline �еĵ����̫�ֻ࣬��marker ���� if (overlay instanceof Marker) { builder.include(((Marker) overlay).getPosition()); } } mBaiduMap.setMapStatus(MapStatusUpdateFactory .newLatLngBounds(builder.build())); } }
@Override public final boolean onMarkerClick(Marker marker) { for (Overlay mMarker : mOverlayList) { if (mMarker instanceof Marker && mMarker.equals(marker)) { if (marker.getExtraInfo() != null) { onRouteNodeClick(marker.getExtraInfo().getInt("index")); } } } return true; }
/** * 通过一个BaiduMap 对象构造 * * @param baiduMap */ public OverlayManager(BaiduMap baiduMap) { mBaiduMap = baiduMap; // mBaiduMap.setOnMarkerClickListener(this); if (mOverlayOptionList == null) { mOverlayOptionList = new ArrayList<OverlayOptions>(); } if (mOverlayList == null) { mOverlayList = new ArrayList<Overlay>(); } }
/** * 将所有Overlay 从 地图上消除 */ public final void removeFromMap() { if (mBaiduMap == null) { return; } for (Overlay marker : mOverlayList) { marker.remove(); } mOverlayOptionList.clear(); mOverlayList.clear(); }
@Override public boolean onPolylineClick(Polyline polyline) { boolean flag = false; for (Overlay mPolyline : mOverlayList) { if (mPolyline instanceof Polyline && mPolyline.equals(polyline)) { // 选中 flag = true; break; } } setFocus(flag); return true; }
public void setFocus(boolean flag) { focus = flag; for (Overlay mPolyline : mOverlayList) { if (mPolyline instanceof Polyline) { // 选中 ((Polyline) mPolyline).setFocus(flag); break; } } }