您当前的位置: Android HUD SDK > 开发指南 > 路口放大图
路口放大图

概述

路口放大图主要包括放大图数据、路名、剩余距离等信息。

关键代码

@Override
public void onEnlargeRoad(BNEnlargeRoad enlargeRoad) {
	Log.d(BNRemoteConstants.MODULE_TAG, "onEnlargeRoad......enlargeRoad = " + enlargeRoad);
 
	final BNEnlargeRoad enlargeInfo = enlargeRoad;
	mMainHandler.post(new Runnable() {
		@Override
		public void run() {
			handleEnlargeRoad(enlargeInfo);
		}
	});
}
 
private void handleEnlargeRoad(BNEnlargeRoad enlargeRoad) {
	int enlargeType = enlargeRoad.getEnlargeRoadType();
	int enlargeState = enlargeRoad.getEnlargeRoadState();
 
	if (enlargeState == HUDConstants.EnlargeMapState.EXPAND_MAP_STATE_HIDE) {
		if (mEnlargeRoadMapView != null) {
			mEnlargeRoadMapView.setVisibility(View.GONE);
		}
	} else {
 
		if (mEnlargeRoadMapView != null) {
			if (enlargeState == HUDConstants.EnlargeMapState.EXPAND_MAP_STATE_UPDATE && 
				mEnlargeRoadMapView.getVisibility() != View.VISIBLE) {
				return;
			}
			mEnlargeRoadMapView.setVisibility(View.VISIBLE);	
		}
 
		mEnlargeType = enlargeType;
		if (enlargeState == HUDConstants.EnlargeMapState.EXPAND_MAP_STATE_SHOW) {
			mbUpdateRasterInfo = false;
		} else {
			mbUpdateRasterInfo = true;
		}
 
		Bitmap basicImage = enlargeRoad.getBasicImage();
		Bitmap arrowImage = enlargeRoad.getArrowImage();
 
		String roadName = enlargeRoad.getRoadName();
		mTotalDist = enlargeRoad.getTotalDist();
		mRemDist = enlargeRoad.getRemainDist();
		if (!TextUtils.isEmpty(roadName)) {
			mRoadName = roadName;
		}
 
		mProgress = 0;
		if (mRemDist <= 0 || mTotalDist <= 0) {
			mProgress = 100;
		} else {
			mProgress = (int) (mTotalDist - mRemDist) * 100 / mTotalDist;
		}
 
		if (enlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_VECTOR) {	            
	        mCarPosX = enlargeRoad.getCarPosX();
	        mCarPosY = enlargeRoad.getCarPosY();
	        mCarRotate = enlargeRoad.getCarPosRotate();
	        mCarRotate = - mCarRotate;
	    } else if ( null != mCarPosImgView ) {
	        mCarPosImgView.setVisibility(View.INVISIBLE);
	    }
 
	    if (enlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_DEST_STREET_VIEW) {
 
	    	if ( null != bnav_rg_enlarge_image_mask ) {
	    		bnav_rg_enlarge_image_mask.setVisibility(View.INVISIBLE);
	    	}
		}
 
	     updateEnlargeRoadView(basicImage, arrowImage);
	}
}
 
	private void updateEnlargeRoadView(Bitmap baseicImage, Bitmap arrawImage) {
		if (!mbUpdateRasterInfo || mForceRefreshImage ) {
        	mForceRefreshImage = false;
            if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_DIRECT_BOARD) {           	
                updateDirectBoardView(baseicImage, arrawImage);
 
            } else if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_RASTER) {
                updateSimpleModelView(baseicImage, arrawImage);
 
            } else if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_VECTOR) {
                updateVectorMapView(baseicImage, arrawImage);
 
            } else if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_DEST_STREET_VIEW) {
                updateStreetView(baseicImage, arrawImage);
            }
        }
        updateProgress(baseicImage, arrawImage);
    }
 
	private void updateProgress(Bitmap baseicImage, Bitmap arrawImage){
        // 更新剩余距离和进度条
        StringBuffer distance = new StringBuffer();
        StringUtils.formatDistance(mRemDist, UnitLangEnum.ZH, distance);
        mRemainDistTV.setText(distance.toString());
        mProgressBar.setProgress(mProgress);
 
        if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_VECTOR) {
            updateVectorMapCarPos(baseicImage, arrawImage);
        } else if (mEnlargeType == HUDConstants.EnlargeMapType.EXPAND_MAP_DEST_STREET_VIEW) {
        	if ( null != mCarPosImgView ) {
            	mCarPosImgView.setVisibility(View.INVISIBLE);
            }
        } else if ( null != mCarPosImgView ) {
        	mCarPosImgView.setVisibility(View.INVISIBLE);
        }
    }