Merge branch 'dev2_aiSdk' into dev_hengyang_base
# Conflicts: # config.gradle # modules/mogo-module-v2x/build.gradle # modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java
This commit is contained in:
@@ -2,8 +2,8 @@ package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.location.Location;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.RelativeLayout;
|
||||
@@ -14,15 +14,18 @@ import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.view.RoundLayout;
|
||||
import com.mogo.utils.FileUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
@@ -30,13 +33,17 @@ import java.io.IOException;
|
||||
* @author donghongyu
|
||||
* @date 12/14/20 4:40 PM
|
||||
*/
|
||||
public class SmallMapDirectionView extends RelativeLayout {
|
||||
private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data";
|
||||
public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLocationChangedListener2 {
|
||||
/**
|
||||
* 小地图名称
|
||||
*/
|
||||
public static final String MODULE_NAME = "SmallMap";
|
||||
|
||||
private RoundLayout rlSmallMapBorder;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private AMapNavi mAMapNavi;
|
||||
private int zoomLevel = 15;
|
||||
private boolean mapIsLoaded = false;
|
||||
|
||||
public SmallMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
@@ -62,15 +69,63 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
rlSmallMapBorder.addView(mAMapNaviView);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
SmpServiceManager.getMogoRegisterCenter()
|
||||
.registerCarLocationChangedListener(MODULE_NAME, this);
|
||||
|
||||
setOnClickListener(view -> {
|
||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.changeMapMode(
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
.getCurrentSkinMode()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
// 车头朝上
|
||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
// 设置电子眼所在路线的可见性
|
||||
mAMapNaviView.setRouteOverlayVisible(false);
|
||||
AMap aMap = mAMapNaviView.getMap();
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 关闭地图文字标注
|
||||
aMap.showMapText(false);
|
||||
mAMap.showMapText(false);
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
mAMapNavi = AMapNavi.getInstance(getContext());
|
||||
mAMapNavi.setIsUseExtraGPSData(false);
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mAMap.setCustomMapStyle(
|
||||
new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext()))
|
||||
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext()))
|
||||
);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap.moveCamera(cameraUpdate);
|
||||
}).start();
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = aMap.getUiSettings();
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
@@ -137,95 +192,9 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
// 2D模式
|
||||
options.setTilt(0);
|
||||
// 黑夜模式
|
||||
//options.setNaviNight(true);
|
||||
// 自定义地图样式
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
options.setNaviNight(true);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
|
||||
try {
|
||||
// 判断是否有样式文件存在
|
||||
FileUtils.copy(
|
||||
context.getAssets().open("small_map_style.data"),
|
||||
styleFilePath,
|
||||
new FileUtils.FileCopyListener() {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
Log.w("FileCopyListener", "onStart=");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Exception e) {
|
||||
Log.w("FileCopyListener", "onFail=");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProcess(int process) {
|
||||
Log.w("FileCopyListener", "onProcess=" + process);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(String toPath) {
|
||||
Log.w("FileCopyListener", "onFinish toPath=" + toPath);
|
||||
|
||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
||||
if (options != null) {
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 高德地图有bug,所以需要多次调用设置皮肤才能成功
|
||||
if (options != null) {
|
||||
options.setCustomMapStylePath(styleFilePath);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
setOnClickListener(view -> {
|
||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.changeMapMode(
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
.getCurrentSkinMode()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -233,4 +202,17 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
|
||||
if (mAMapNavi != null) {
|
||||
mAMapNavi.setExtraGPSData(2, latLng);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged latLng:" + latLng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-2114:01
|
||||
* desc : V2X 服务
|
||||
* version: 1.0
|
||||
*/
|
||||
public class SmpServiceManager {
|
||||
private static final String TAG = "V2XServiceManager";
|
||||
private static boolean isInit;
|
||||
private static Context mContext;
|
||||
private static IMogoServiceApis mMogoServiceApis;
|
||||
private static IMogoRegisterCenter mMogoRegisterCenter;
|
||||
|
||||
private SmpServiceManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void init(final Context context) {
|
||||
if (!isInit) {
|
||||
isInit = true;
|
||||
mContext = context;
|
||||
mMogoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
mMogoRegisterCenter = mMogoServiceApis.getRegisterCenterApi();
|
||||
}
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public static IMogoRegisterCenter getMogoRegisterCenter() {
|
||||
return mMogoRegisterCenter;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user