@@ -12,6 +12,7 @@ import android.view.View;
import android.widget.RelativeLayout ;
import android.widget.TextView ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import com.amap.api.maps.AMap ;
@@ -77,6 +78,7 @@ import java.util.Map;
import ch.hsr.geohash.GeoHash ;
import mogo.telematics.pad.MessagePad ;
import mogo_msg.MogoReportMsg ;
import system_master.SystemStatusInfo ;
/**
* 小地图的方向View
@@ -201,7 +203,7 @@ public class AMapCustomView
// options.setTilt((int) tilt);
//自车车标
options . setCarBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_my_location_logo ) ) ;
options. setFourCornersBitmap( BitmapFactory. decodeResource( this . getResources ( ) , R . drawable. amap_custom_corner) ) ;
// options. setFourCornersBitmap( BitmapFactory. decodeResource(this.getResources(), R. drawable. amap_custom_corner)) ;
options . setStartPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_dir_start ) ) ;
options . setWayPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . icon_module_small_map_four_corners ) ) ;
options . setEndPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_dir_end ) ) ;
@@ -210,17 +212,22 @@ public class AMapCustomView
//路线纹理自定义
RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions ( ) ;
routeOverlayOptions . setTurnArrowIs3D ( false ) ;
routeOverlayOptions. setUnknownTraffic( BitmapFactory. decodeResource( getResources( ) , R . drawable. custtexture_no) ) ; //未知路段
routeOverlayOptions. setSmoothTraffic( BitmapFactory. decodeResource( getResources( ) , R . drawable. amap_custom_smooth_route) ) ;
routeOverlayOptions. setJamTraffic( BitmapFactory. decodeResource( getResources( ) , R . drawable. custtexture_bad) ) ; //拥堵路段
routeOverlayOptions. setVeryJamTraffic( BitmapFactory. decodeResource( getResources( ) , R . drawable. custtexture_grayred) ) ; //超级拥堵路段
routeOverlayOptions. setPassRoute( BitmapFactory. decodeResource( getResources( ) , R . drawable. amap_custom_pass_route) ) ; //走过的路段
// routeOverlayOptions. setUnknownTraffic( BitmapFactory. decodeResource( getResources(), R. drawable. custtexture_no)); //未知路段
// routeOverlayOptions. setSmoothTraffic( BitmapFactory. decodeResource( getResources(), R. drawable. amap_custom_smooth_route)) ;
// routeOverlayOptions. setJamTraffic( BitmapFactory. decodeResource( getResources(), R. drawable. custtexture_bad)); //拥堵路段
// routeOverlayOptions. setVeryJamTraffic( BitmapFactory. decodeResource( getResources(), R. drawable. custtexture_grayred)); //超级拥堵路段
// routeOverlayOptions. setPassRoute( BitmapFactory. decodeResource( getResources(), R. drawable. amap_custom_pass_route)); //走过的路段
options . setRouteOverlayOptions ( routeOverlayOptions ) ;
mAMapNaviView . setViewOptions ( options ) ;
}
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener ( ) {
@Override
public void onAutopilotStatusRespByQuery ( @NonNull SystemStatusInfo . StatusInfo status ) {
}
@Override
public void onAutopilotIpcConnectStatusChanged ( int status , @org.jetbrains.annotations.Nullable String reason ) {
@@ -330,72 +337,6 @@ public class AMapCustomView
CallerAutopilotPlanningListenerManager . INSTANCE . removeListener ( TAG ) ;
}
private void initAMapView ( Context context ) {
mCameraUpdate = CameraUpdateFactory . zoomTo ( zoomLevel ) ;
AMapNaviViewOptions options = mAMapNaviView . getViewOptions ( ) ;
//关闭自动绘制路线,自行绘制路线
// options.setAutoDrawRoute(false);
//不显示导航界面
options . setLayoutVisible ( false ) ;
//黑夜模式
options . setNaviNight ( true ) ;
//导航全程光柱
options . setTrafficBarEnabled ( false ) ;
//指南针
// options.setCompassEnabled(false);
options . setTilt ( ( int ) tilt ) ;
//自车车标
options . setCarBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_my_location_logo ) ) ;
options . setFourCornersBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . amap_custom_corner ) ) ;
options . setStartPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_dir_start ) ) ;
options . setWayPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . icon_module_small_map_four_corners ) ) ;
options . setEndPointBitmap ( BitmapFactory . decodeResource ( this . getResources ( ) , R . drawable . module_small_map_view_dir_end ) ) ;
//与走过的路线
options . setAfterRouteAutoGray ( true ) ;
//路线纹理自定义
RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions ( ) ;
routeOverlayOptions . setTurnArrowIs3D ( false ) ;
routeOverlayOptions . setUnknownTraffic ( BitmapFactory . decodeResource ( getResources ( ) , R . drawable . custtexture_no ) ) ; //未知路段
routeOverlayOptions . setSmoothTraffic ( BitmapFactory . decodeResource ( getResources ( ) , R . drawable . amap_custom_smooth_route ) ) ;
routeOverlayOptions . setJamTraffic ( BitmapFactory . decodeResource ( getResources ( ) , R . drawable . custtexture_bad ) ) ; //拥堵路段
routeOverlayOptions . setVeryJamTraffic ( BitmapFactory . decodeResource ( getResources ( ) , R . drawable . custtexture_grayred ) ) ; //超级拥堵路段
routeOverlayOptions . setPassRoute ( BitmapFactory . decodeResource ( getResources ( ) , R . drawable . custtexture_slow ) ) ; //走过的路段
options . setRouteOverlayOptions ( routeOverlayOptions ) ;
mAMapNaviView . setViewOptions ( options ) ;
mAMap = mAMapNaviView . getMap ( ) ;
// 地图文字标注
mAMap . showMapText ( true ) ;
// 显示实时路况图层, aMap是地图控制器对象。
mAMap . setTrafficEnabled ( true ) ;
//设置希望展示的地图缩放级别
mAMap . moveCamera ( mCameraUpdate ) ;
//设置地图的样式
UiSettings uiSettings = mAMap . getUiSettings ( ) ;
//地图缩放级别的交换按钮
uiSettings . setZoomControlsEnabled ( false ) ;
//所有手势
uiSettings . setAllGesturesEnabled ( true ) ;
//隐藏指南针
uiSettings . setCompassEnabled ( false ) ;
//设置倾斜手势是否可用。
uiSettings . setTiltGesturesEnabled ( true ) ;
//隐藏默认的定位按钮
uiSettings . setMyLocationButtonEnabled ( false ) ;
//设置Logo下边界距离屏幕底部的边距,设置为负值即可
uiSettings . setLogoBottomMargin ( - 150 ) ;
int strategy = 0 ;
try {
//再次强调, 最后一个参数为true时代表多路径, 否则代表单路径
strategy = mAMapNavi . strategyConvert ( true , false , false , false , false ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
//指定路径绘制导航路线
mAMapNavi . calculateDriveRoute ( sList , eList , mWayPointList , strategy ) ;
}
@Override
public boolean onInterceptTouchEvent ( MotionEvent ev ) {
return false ;
@@ -750,8 +691,8 @@ public class AMapCustomView
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions ( )
. setEnable ( true )
. setStyleData ( MapAssetStyleUtils . getAssetsStyle ( getContext ( ) , " over_view_style.data " ))
. setStyleExtraData ( MapAssetStyleUtils . getAssetsExtraStyle ( getContext ( ) , " over_view_style_extra.data " )) ;
. setStyleData ( MapAssetStyleUtils . getAssetsStyle ( getContext ( ) ) )
. setStyleExtraData ( MapAssetStyleUtils . getAssetsExtraStyle ( getContext ( ) ) ) ;
// 设置自定义样式
mAMap . setCustomMapStyle ( customMapStyleOptions ) ;
}