Merge remote-tracking branch 'origin/feature/v1.0.2' into feature/v1.0.2
This commit is contained in:
@@ -93,70 +93,71 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
private void initMapView() {
|
||||
if ( mMapView != null ) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode( false );
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar( false );
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow( true );
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(),
|
||||
R.drawable.ic_amap_navi_cursor ) );
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled( false );
|
||||
// 黑夜模式
|
||||
options.setNaviNight( true );
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled( false );
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled( false );
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow( false );
|
||||
// 设置导航状态下屏幕是否一直开启。
|
||||
options.setScreenAlwaysBright( true );
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled( true );
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled( true );
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled( false );
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine( true );
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled( -1 );
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible( false );
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute( false );
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow( false );
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow( false );
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow( false );
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom( true );
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview( false );
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible( false );
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray( true );
|
||||
options.setZoom( 16 );
|
||||
options.setPointToCenter( 0.5D, 0.5D );
|
||||
// 2D模式
|
||||
options.setTilt( 0 );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
mMapView.setRouteOverlayVisible( false );
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
setUIMode( EnumMapUI.CarUp_2D, null );
|
||||
if ( mMapView == null ) {
|
||||
return;
|
||||
}
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode( false );
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar( false );
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow( true );
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(),
|
||||
R.drawable.ic_amap_navi_cursor ) );
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled( false );
|
||||
// 黑夜模式
|
||||
options.setNaviNight( true );
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled( false );
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled( false );
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow( false );
|
||||
// 设置导航状态下屏幕是否一直开启。
|
||||
options.setScreenAlwaysBright( true );
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled( true );
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled( true );
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled( false );
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine( true );
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled( -1 );
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible( false );
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute( false );
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow( false );
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow( false );
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow( false );
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom( true );
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview( false );
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible( false );
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray( true );
|
||||
options.setZoom( 16 );
|
||||
options.setPointToCenter( 0.5D, 0.5D );
|
||||
// 2D模式
|
||||
options.setTilt( 0 );
|
||||
mMapView.setViewOptions( options );
|
||||
}
|
||||
mMapView.setRouteOverlayVisible( false );
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
setUIMode( EnumMapUI.CarUp_2D, null );
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
@@ -654,6 +655,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( checkAMapView() ) {
|
||||
Logger.d( TAG, "setPointToCenter(%s, %s)", mapCenterX, mapCenterY );
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
options.setPointToCenter( mapCenterX, mapCenterY );
|
||||
mMapView.setViewOptions( options );
|
||||
|
||||
@@ -93,10 +93,30 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
return;
|
||||
}
|
||||
addEndPoints();
|
||||
showPathsBound( mCalculatePathItems.get( 0 ).getPath().getBoundsForPath() );
|
||||
showPathsBound( getBounds() );
|
||||
renderPathOverlay( mCalculatePathItems );
|
||||
}
|
||||
|
||||
private LatLngBounds getBounds(){
|
||||
if ( mCalculatePathItems == null ) {
|
||||
return null;
|
||||
}
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
for ( CalculatePathItem calculatePathItem : mCalculatePathItems ) {
|
||||
if ( calculatePathItem == null ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
LatLngBounds bounds = calculatePathItem.getPath().getBoundsForPath();
|
||||
builder.include( bounds.northeast );
|
||||
builder.include( bounds.southwest );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按pathId升序排序
|
||||
*
|
||||
@@ -148,6 +168,9 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
* 将规划好的路径显示在视野内
|
||||
*/
|
||||
private void showPathsBound( LatLngBounds bounds ) {
|
||||
if ( bounds == null ) {
|
||||
return;
|
||||
}
|
||||
checkAMapInstance();
|
||||
mAMap.animateCamera(
|
||||
CameraUpdateFactory.newLatLngBoundsRect( bounds, mBoundRect.left, mBoundRect.right,
|
||||
|
||||
@@ -2,17 +2,22 @@ package com.mogo.map.impl.amap.overlay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.model.NavigateArrowOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.navi.model.AMapNaviLocation;
|
||||
import com.amap.api.navi.model.AMapNaviPath;
|
||||
import com.amap.api.navi.model.NaviInfo;
|
||||
import com.amap.api.navi.model.RouteOverlayOptions;
|
||||
import com.amap.api.navi.view.RouteOverLay;
|
||||
import com.mogo.map.impl.amap.utils.MapStyleUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -36,6 +41,8 @@ public class RouteOverLayWrapper {
|
||||
private int mEndBitmapResId = 0;
|
||||
private int mZIndex = 0;
|
||||
|
||||
private static RouteOverlayOptions sOptions;
|
||||
|
||||
public RouteOverLayWrapper( Context context,
|
||||
AMap mAMap,
|
||||
AMapNaviPath mPath ) {
|
||||
@@ -49,7 +56,10 @@ public class RouteOverLayWrapper {
|
||||
return;
|
||||
}
|
||||
mRouteOverLay = new RouteOverLay( mAMap, mPath, mContextRef.get() );
|
||||
mRouteOverLay.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
if ( sOptions == null ) {
|
||||
sOptions = MapStyleUtils.getRouteOverlayOptions();
|
||||
}
|
||||
mRouteOverLay.setRouteOverlayOptions( sOptions );
|
||||
mRouteOverLay.setTrafficLine( true );
|
||||
mRouteOverLay.setRouteOverlayVisible( true );
|
||||
mRouteOverLay.setTrafficLightsVisible( true );
|
||||
@@ -58,6 +68,7 @@ public class RouteOverLayWrapper {
|
||||
mRouteOverLay.setNaviArrowVisible( true );
|
||||
mRouteOverLay.setLightsVisible( true );
|
||||
mRouteOverLay.setTrafficLightsVisible( mIsTrafficLightsVisible );
|
||||
hookRouteArrow();
|
||||
|
||||
if ( mStartBitmapResId != 0 ) {
|
||||
try {
|
||||
@@ -166,6 +177,19 @@ public class RouteOverLayWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private void hookRouteArrow() {
|
||||
if ( mRouteOverLay != null && sOptions != null ) {
|
||||
try {
|
||||
Field field = mRouteOverLay.getClass().getDeclaredField( "naviArrow" );
|
||||
field.setAccessible( true );
|
||||
field.set( mRouteOverLay, mAMap.addNavigateArrow( new NavigateArrowOptions().topColor( sOptions.getArrowColor() ).width( sOptions.getLineWidth() ).sideColor( sOptions.getArrowSideColor() ) ) );
|
||||
Logger.d( TAG, "hook 成功。" );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Polyline getTrafficColorfulPolyline() {
|
||||
if ( mRouteOverLay != null ) {
|
||||
return mRouteOverLay.mTrafficColorfulPolyline;
|
||||
|
||||
@@ -60,6 +60,8 @@ public class MapStyleUtils {
|
||||
options.setPassRoute( colorToBitmap( ColorEnum.light_gray.getColor() ) );
|
||||
// 设置路线虚线纹理
|
||||
options.setFairWayRes( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
|
||||
options.setArrowColor( Color.WHITE ); // 高德地图内部配置颜色
|
||||
options.setArrowSideColor( 1990523135 ); // 高德地图内部配置颜色
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
if ( size == 0 ) {
|
||||
showLayout();
|
||||
} else if ( size == 1 ) {
|
||||
|
||||
hideLayout();
|
||||
}
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user