[3.4.0-map-sdk] code tyle

This commit is contained in:
zhongchao
2023-09-13 18:31:16 +08:00
parent 1f1a28a975
commit 4932c1d8a7
38 changed files with 657 additions and 822 deletions

View File

@@ -1,115 +0,0 @@
package com.mogo.map;
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
import java.lang.reflect.Method;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 代理自研地图UiSettings
*/
public class AMapUiSettingsWrapper implements IMogoUiSettings {
private final MapAutoViewHelper mUiSettings;
public AMapUiSettingsWrapper( MapAutoViewHelper mUiSettings ) {
this.mUiSettings = mUiSettings;
}
@Override
public void setScaleControlsEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showScale();
}else{
mUiSettings.hiddenScale();
}
}
}
@Override
public void setZoomControlsEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setZoomGesturesEnabled( enabled );
}
}
@Override
public void setCompassEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showDirection();
}else{
mUiSettings.hiddenDirection();
}
}
}
@Override
public void setMyLocationButtonEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showLocation();
}else{
mUiSettings.hiddenLocation();
}
}
}
@Override
public void setScrollGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setScrollGesturesEnabled( enabled );
}
}
@Override
public void setZoomGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setZoomGesturesEnabled( enabled );
}
}
@Override
public void setTiltGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setTiltGesturesEnabled( enabled );
}
}
@Override
public void setRotateGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setRotateGesturesEnabled( enabled );
}
}
@Override
public void setAllGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setAllGesturesEnabled( enabled );
}
}
@Override
public void setIndoorSwitchEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
// mUiSettings.setIndoorSwitchEnabled( enabled );
}
}
@Override
public void setLogoEnable( boolean enabled ) {
if ( mUiSettings != null ) {
try {
Method method = mUiSettings.getClass().getMethod( "setLogoEnable", boolean.class );
method.setAccessible( true );
method.invoke( mUiSettings, enabled );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,76 @@
package com.mogo.map
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper
/**
* 代理自研地图UiSettings
*/
class AMapUiSettingsWrapper(private val mUiSettings: MapAutoViewHelper?) : IMogoUiSettings {
override fun setScaleControlsEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showScale()
} else {
mUiSettings?.hiddenScale()
}
}
override fun setZoomControlsEnabled(enabled: Boolean) {
mUiSettings?.setZoomGesturesEnabled(enabled)
}
override fun setCompassEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showDirection()
} else {
mUiSettings?.hiddenDirection()
}
}
override fun setMyLocationButtonEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showLocation()
} else {
mUiSettings?.hiddenLocation()
}
}
override fun setScrollGesturesEnabled(enabled: Boolean) {
mUiSettings?.setScrollGesturesEnabled(enabled)
}
override fun setZoomGesturesEnabled(enabled: Boolean) {
mUiSettings?.setZoomGesturesEnabled(enabled)
}
override fun setTiltGesturesEnabled(enabled: Boolean) {
mUiSettings?.setTiltGesturesEnabled(enabled)
}
override fun setRotateGesturesEnabled(enabled: Boolean) {
mUiSettings?.setRotateGesturesEnabled(enabled)
}
override fun setAllGesturesEnabled(enabled: Boolean) {
mUiSettings?.setAllGesturesEnabled(enabled)
}
override fun setIndoorSwitchEnabled(enabled: Boolean) {
// mUiSettings.setIndoorSwitchEnabled( enabled )
}
override fun setLogoEnable(enabled: Boolean) {
if (mUiSettings != null) {
try {
val method = mUiSettings.javaClass.getMethod(
"setLogoEnable",
Boolean::class.javaPrimitiveType
)
method.isAccessible = true
method.invoke(mUiSettings, enabled)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}

View File

@@ -122,7 +122,7 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
return mIMap
}
override fun onCreate(bundle: Bundle?) {
override fun onCreate(bundle: Bundle) {
mMapView.onCreate(bundle)
d(SceneConstant.M_MAP + TAG, "map onCreate")
}
@@ -258,11 +258,10 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
return ret
}
override fun changeZoom(zoom: Float): MapControlResult {
override fun changeZoom(zoom: Float) {
if (checkAMapView()) {
mMapView.getMapAutoViewHelper()!!.setZoom(zoom.toInt())
}
return MapControlResult.SUCCESS
}
override fun changeZoom2(zoom: Float) {
@@ -792,10 +791,10 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
//更新点云
override fun updatePointCloud(
dataArray: ByteArray?, isTrasformer: Boolean, isResidual: Boolean, isReset: Boolean
dataArray: ByteArray?, isTransformer: Boolean, isResidual: Boolean, isReset: Boolean
): Boolean {
return updatePointCloudDataByPb(
dataArray, isTrasformer, isResidual, isReset, mMapView.getMapController()
dataArray, isTransformer, isResidual, isReset, mMapView.getMapController()
)
}

View File

@@ -1,199 +0,0 @@
package com.mogo.map;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.utils.ObjectUtils;
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData;
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
import java.util.ArrayList;
import java.util.HashMap;
import mogo.telematics.pad.MessagePad;
import mogo.yycp.api.proto.SocketDownData;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 代理自研AMap
*/
public class AMapWrapper implements IMogoMap {
private static final String TAG = "AMapWrapper";
private final IMogoMapUIController mMapUIController;
private MapAutoViewHelper mAMap;
private final MapAutoView mMapView;
private IMogoUiSettings mUiSettings;
public AMapWrapper(MapAutoViewHelper map, MapAutoView mapView, IMogoMapUIController controller) {
CallerLogger.INSTANCE.i(TAG, "autoop--AMapWrapper: init" + this);
this.mAMap = map;
this.mMapView = mapView;
mMapUIController = controller;
}
@Override
public IMogoUiSettings getUiSettings() {
if (!checkAMap()) {
return null;
}
if (mUiSettings == null) {
mUiSettings = new AMapUiSettingsWrapper(mAMap);
}
return mUiSettings;
}
@Override
public IMogoMapUIController getUiController() {
return mMapUIController;
}
@Override
public IMapPointOverlay addPoint(@NonNull com.mogo.map.overlay.point.Point.Options options) {
if (!checkAMap()) {
return null;
}
MarkerOptions markerOptions = ObjectUtils.fromMogo(options,mMapView);
if (markerOptions == null) {
CallerLogger.INSTANCE.e(TAG, "marker参数为空");
return null;
}
Marker delegate = mAMap.addMarker(markerOptions);
if (delegate == null) {
return null;
}
return new AMapPointWrapper(options.getId(), delegate,mMapView);
}
@Override
public IMapPolylineOverlay addLine(@NonNull com.mogo.map.overlay.line.Polyline.Options options) {
if (!checkAMap()) {
return null;
}
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options,mMapView);
if (polylineOptions == null) {
CallerLogger.INSTANCE.e(TAG, "polyline参数为空");
return null;
}
Polyline delegate = polylineOptions.getLineWidth() > 0 ? mAMap.drawThickLine(polylineOptions) : mAMap.drawLine(polylineOptions);
if (delegate == null) {
return null;
}
return new com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper(options.getId(), delegate,mMapView);
}
BatchMarkerOptions batchMarkerOptions = new BatchMarkerOptions();
@SuppressLint("NewApi")
@Override
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
if (!checkAMap()) {
return;
}
if(optionsArrayList == null || optionsArrayList.size() == 0){
return;
}
ArrayList<MarkerSimpleData> markerOptionsArrayList = new ArrayList<>();
optionsArrayList.forEach((s, trackedObject) -> {
MarkerSimpleData markerOptions = ObjectUtils.fromTrafficData(trackedObject);
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions);
}
});
if(markerOptionsArrayList.size() == 0){
return;
}
long time = markerOptionsArrayList.get(0).getTime();
batchMarkerOptions.setList(markerOptionsArrayList);
batchMarkerOptions.setDelayStrategy(false);
batchMarkerOptions.setRuleAngle(8.0f);
batchMarkerOptions.setControlIcon(1);
batchMarkerOptions.setSatelliteTime(time);
batchMarkerOptions.setDeleteRule(0);
if(mMapView.getMarkerController() != null){
mMapView.getMarkerController().updateBatchMarkerPositon(batchMarkerOptions);
}
}
BatchMarkerOptions aiBatchMarkerOptions = new BatchMarkerOptions();
@SuppressLint("NewApi")
@Override
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
if (!checkAMap()) {
return;
}
if(optionsArrayList == null || optionsArrayList.size() == 0){
return;
}
ArrayList<MarkerSimpleData> markerOptionsArrayList = new ArrayList<>();
optionsArrayList.forEach((s, trackedObject) -> {
MarkerSimpleData markerOptions = ObjectUtils.fromAiData(trackedObject);
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions);
}
});
if(markerOptionsArrayList.size() == 0){
return;
}
long time = markerOptionsArrayList.get(0).getTime();
// 最后一个参数,是否管理锚点的删除
aiBatchMarkerOptions.setList(markerOptionsArrayList);
aiBatchMarkerOptions.setDelayStrategy(false);
aiBatchMarkerOptions.setRuleAngle(8.0f);
aiBatchMarkerOptions.setControlIcon(1);
aiBatchMarkerOptions.setSatelliteTime(time);
aiBatchMarkerOptions.setDeleteRule(0);
if(mMapView.getMarkerController() != null) {
mMapView.getMarkerController().updateBatchMarkerPositon(aiBatchMarkerOptions);
}
}
@Override
public String addPreVehicleModel(int type, int modelRes) {
try {
if(mMapView.getMarkerController() != null){
return mMapView.getMarkerController().addPreVehicleModel(type, modelRes);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void removeMarker(String uuidString) {
try {
if(mMapView.getMarkerController() != null){
mMapView.getMarkerController().removeMarker(uuidString);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean checkAMap() {
mAMap = mMapView.getMapAutoViewHelper();
if (mAMap == null) {
CallerLogger.INSTANCE.e(TAG, "自研map实例为空请检查");
return false;
}
return true;
}
}

View File

@@ -0,0 +1,178 @@
package com.mogo.map
import android.annotation.SuppressLint
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
import com.mogo.map.overlay.line.Polyline
import com.mogo.map.overlay.point.Point
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay
import com.mogo.map.overlay.proxy.point.IMapPointOverlay
import com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper
import com.mogo.map.uicontroller.IMogoMapUIController
import com.mogo.map.utils.ObjectUtils
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData
import com.zhidaoauto.map.sdk.open.view.MapAutoView
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper
import mogo.telematics.pad.MessagePad.TrackedObject
import mogo.yycp.api.proto.SocketDownData
import java.util.function.BiConsumer
/**
* 代理自研AMap
*/
class AMapWrapper(map: MapAutoViewHelper?, mapView: MapAutoView, controller: IMogoMapUIController) :
IMogoMap {
companion object {
private const val TAG = "AMapWrapper"
}
override val uiController: IMogoMapUIController
private var mAMap: MapAutoViewHelper?
private val mMapView: MapAutoView
private var mUiSettings: IMogoUiSettings? = null
override val uiSettings: IMogoUiSettings?
get() {
if (!checkAMap()) {
return null
}
if (mUiSettings == null) {
mUiSettings = AMapUiSettingsWrapper(mAMap)
}
return mUiSettings
}
override fun addPoint(options: Point.Options): IMapPointOverlay? {
if (!checkAMap()) {
return null
}
val markerOptions = ObjectUtils.fromMogo(options, mMapView)
if (markerOptions == null) {
e(TAG, "marker参数为空")
return null
}
val delegate = mAMap!!.addMarker(markerOptions) ?: return null
return AMapPointWrapper(options.id, delegate, mMapView)
}
override fun addLine(options: Polyline.Options): IMapPolylineOverlay? {
if (!checkAMap()) {
return null
}
val polylineOptions = ObjectUtils.fromMogo(options, mMapView)
if (polylineOptions == null) {
e(TAG, "polyline参数为空")
return null
}
val delegate =
(if (polylineOptions.lineWidth > 0) mAMap!!.drawThickLine(polylineOptions) else mAMap!!.drawLine(
polylineOptions
))
?: return null
return AMapPolylineWrapper(options.id, delegate, mMapView)
}
var batchMarkerOptions = BatchMarkerOptions()
@SuppressLint("NewApi")
override fun updateBatchMarkerPosition(optionsArrayList: HashMap<String, TrackedObject>?) {
if (!checkAMap()) {
return
}
if (optionsArrayList == null || optionsArrayList.size == 0) {
return
}
val markerOptionsArrayList = ArrayList<MarkerSimpleData>()
optionsArrayList.forEach(BiConsumer { s: String?, trackedObject: TrackedObject? ->
val markerOptions = ObjectUtils.fromTrafficData(trackedObject)
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions)
}
})
if (markerOptionsArrayList.size == 0) {
return
}
val time = markerOptionsArrayList[0].time
batchMarkerOptions.list = markerOptionsArrayList
batchMarkerOptions.delayStrategy = false
batchMarkerOptions.ruleAngle = 8.0f
batchMarkerOptions.controlIcon = 1
batchMarkerOptions.satelliteTime = time
batchMarkerOptions.deleteRule = 0
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.updateBatchMarkerPositon(batchMarkerOptions)
}
}
var aiBatchMarkerOptions = BatchMarkerOptions()
init {
i(TAG, "autoop--AMapWrapper: init$this")
mAMap = map
mMapView = mapView
uiController = controller
}
@SuppressLint("NewApi")
override fun updateBatchAiMarkerPosition(optionsArrayList: HashMap<String, SocketDownData.CloudRoadDataProto>?) {
if (!checkAMap()) {
return
}
if (optionsArrayList == null || optionsArrayList.size == 0) {
return
}
val markerOptionsArrayList = ArrayList<MarkerSimpleData>()
optionsArrayList.forEach(BiConsumer { s: String?, trackedObject: SocketDownData.CloudRoadDataProto? ->
val markerOptions = ObjectUtils.fromAiData(trackedObject)
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions)
}
})
if (markerOptionsArrayList.size == 0) {
return
}
val time = markerOptionsArrayList[0].time
// 最后一个参数,是否管理锚点的删除
aiBatchMarkerOptions.list = markerOptionsArrayList
aiBatchMarkerOptions.delayStrategy = false
aiBatchMarkerOptions.ruleAngle = 8.0f
aiBatchMarkerOptions.controlIcon = 1
aiBatchMarkerOptions.satelliteTime = time
aiBatchMarkerOptions.deleteRule = 0
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.updateBatchMarkerPositon(aiBatchMarkerOptions)
}
}
override fun addPreVehicleModel(type: Int, modelRes: Int): String? {
try {
if (mMapView.getMarkerController() != null) {
return mMapView.getMarkerController()!!.addPreVehicleModel(type, modelRes)
}
} catch (e: Exception) {
e.printStackTrace()
}
return null
}
override fun removeMarker(uuidString: String?) {
try {
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.removeMarker(uuidString!!)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun checkAMap(): Boolean {
mAMap = mMapView.getMapAutoViewHelper()
if (mAMap == null) {
e(TAG, "自研map实例为空请检查")
return false
}
return true
}
}

View File

@@ -16,7 +16,7 @@ import com.zhidaoauto.map.sdk.open.data.CityInfo
import com.zhidaoauto.map.sdk.open.data.MapDataApi
/**
* 地图数据工具
* 地图数据工具,涉及到数据调用可能会有耗时建议IO操作
*/
object MapDataWrapper : IMogoData {
@@ -68,6 +68,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
override fun getCenterLineRangeInfo(
lon: Double,
lat: Double,
@@ -94,6 +95,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
override fun getLimitSpeed(lon: Double, lat: Double, angle: Float, call: ((Int) -> Unit)) {
MapDataApi.getLimitSpeed(lon, lat, angle, object : IResult<RoadInfo> {
override fun result(code: Int, result: RoadInfo?) {
@@ -109,6 +111,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
override fun getRoadAngle(lon: Double, lat: Double, angle: Float, call: ((Double) -> Unit)) {
MapDataApi.getRoadRectInfo(lon, lat, angle, object : IResult<RoadRectInfos> {
override fun result(code: Int, result: RoadRectInfos?) {
@@ -120,6 +123,7 @@ object MapDataWrapper : IMogoData {
/**
* 获取道路宽度
*/
@Synchronized
override fun getRoadWidth(
lon: Double,
lat: Double,
@@ -137,6 +141,7 @@ object MapDataWrapper : IMogoData {
*
* @return
*/
@Synchronized
override fun getAngle(
startLon: Double,
startLat: Double,
@@ -153,6 +158,7 @@ object MapDataWrapper : IMogoData {
* @param lat 纬度
* @return 瓦片id
*/
@Synchronized
override fun getTileId(lon: Double, lat: Double): Long {
return MapAutoApi.getTileID(lon, lat, 13) // 13为默认获取瓦片层级级别
}
@@ -160,6 +166,7 @@ object MapDataWrapper : IMogoData {
/**
* 通过cityCode获取HDMap对应缓存城市
*/
@Synchronized
override fun cacheHDDataByCity(
progress: (cityId: Int, progress: Double) -> Unit,
result: (cityId: Int, state: Int) -> Unit
@@ -183,6 +190,7 @@ object MapDataWrapper : IMogoData {
/**
* 通过经纬度信息获取HDMap对应缓存城市
*/
@Synchronized
override fun cacheHDDataByCityByLonLat(
location: MogoLocation,
progress: (cityId: Int, progress: Double) -> Unit,
@@ -206,6 +214,7 @@ object MapDataWrapper : IMogoData {
/**
* 当前城市离线数据是否已缓存
*/
@Synchronized
override fun isCityDataCached(cache: ((Boolean) -> Unit)) {
val cityCode = gdLocationClient.lastCityCode
i(M_MAP + TAG, "gdCityCode is:$cityCode")
@@ -228,6 +237,7 @@ object MapDataWrapper : IMogoData {
}
}
@Synchronized
override fun cancelDownloadCacheData() {
MapDataApi.cancelCacheHDData()
}

View File

@@ -1,120 +0,0 @@
package com.mogo.map;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
import com.zhidaoauto.map.sdk.open.view.MapStyleParams;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 地图实例
*/
public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
private static final String TAG = "MogoMapView";
public MogoMapView(Context context) {
super(context);
}
public MogoMapView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MogoMapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private MapAutoView mapAutoView;
@Override
protected void addMapView(Context context, AttributeSet attrs) {
if (mapAutoView == null) {
if (getStyleParams() == null) {
mapAutoView = new MapAutoView(context, attrs);
} else {
mapAutoView = new MapAutoView(context, getStyleParams());
}
}
if (mMapView == null) {
mMapView = new AMapViewWrapper(mapAutoView);
final View mapView = mMapView.getMapView();
if (mapView != null) {
addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
} else {
CallerLogger.e(TAG, "create MapView instance failed.");
}
}
}
/**
* 子类实现
* 代码StyleParams和XML初始化设置同时仅支持一种
*
* @return MapStyleParams
*/
protected MapStyleParams getStyleParams() {
return null;
}
protected IMogoMapUIController getUIController(){
return mMapView.getMap().getUiController();
}
@Override
protected String getInstanceTag() {
return MogoMap.DEFAULT;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
CallerLogger.d(TAG, "onCreate");
}
@Override
public void onResume() {
super.onResume();
CallerLogger.d(TAG, "onResume");
}
@Override
public void onPause() {
super.onPause();
CallerLogger.d(TAG, "onPause");
}
@Override
public void onDestroy() {
super.onDestroy();
CallerLogger.d(TAG, "onDestroy");
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
@Override
public void onLowMemory() {
super.onLowMemory();
}
public void setExtraGPSData(MogoLocation gnssInfo) {
getMap().getUiController().setExtraGPSData(gnssInfo);
}
}

View File

@@ -0,0 +1,103 @@
package com.mogo.map
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.ViewGroup
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.zhidaoauto.map.sdk.open.view.MapAutoView
import com.zhidaoauto.map.sdk.open.view.MapStyleParams
/**
* @author congtaowang
* @since 2019-12-18
*
*
* 地图实例
*/
open class MogoMapView : MogoBaseMapView, ILifeCycle {
constructor(context: Context?) : super(context) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr) {
}
private var mapAutoView: MapAutoView? = null
override fun addMapView(context: Context, attrs: AttributeSet) {
if (mapAutoView == null) {
mapAutoView = if (styleParams == null) {
MapAutoView(context, attrs)
} else {
MapAutoView(context, styleParams!!)
}
}
if (mMapView == null) {
mMapView = AMapViewWrapper(mapAutoView!!)
val mapView = mMapView.mapView
if (mapView != null) {
addView(
mapView, LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
} else {
e(TAG, "create MapView instance failed.")
}
}
}
/**
* 子类实现
* 代码StyleParams和XML初始化设置同时仅支持一种
*
* @return MapStyleParams
*/
protected val styleParams: MapStyleParams?
protected get() = null
override fun getInstanceTag(): String {
return MogoMap.DEFAULT
}
override fun onCreate(bundle: Bundle) {
super.onCreate(bundle)
d(TAG, "onCreate")
}
override fun onResume() {
super.onResume()
d(TAG, "onResume")
}
override fun onPause() {
super.onPause()
d(TAG, "onPause")
}
override fun onDestroy() {
super.onDestroy()
d(TAG, "onDestroy")
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
}
override fun onLowMemory() {
super.onLowMemory()
}
fun setExtraGPSData(gnssInfo: MogoLocation) {
map?.uiController?.setExtraGPSData(gnssInfo)
}
companion object {
private const val TAG = "MogoMapView"
}
}

View File

@@ -64,15 +64,11 @@ class GDLocationClient private constructor() : AMapLocationListener,
} catch (e: Exception) {
e.printStackTrace()
}
if (mLocationClient != null) {
mLocationClient.startLocation()
}
mLocationClient.startLocation()
}
override fun stop() {
if (mLocationClient != null) {
mLocationClient.stopLocation()
}
mLocationClient.stopLocation()
}
override fun onLocationChanged(aMapLocation: AMapLocation) {
@@ -170,7 +166,7 @@ class GDLocationClient private constructor() : AMapLocationListener,
}
companion object {
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
GDLocationClient()
}
}

View File

@@ -15,8 +15,6 @@ import java.util.List;
*/
public class MogoMapUtils {
private static final String TAG = "MogoMapUtils";
public static LatLngBounds getLatLngBounds(MogoLatLng carPosition, List< MogoLatLng > lonLats, boolean lockCarPosition ) throws Exception {
if ( lonLats == null || lonLats.isEmpty() ) {
@@ -42,14 +40,14 @@ public class MogoMapUtils {
return null;
}
double south = 0.0;
double west = 0.0;
double south;
double west;
double east = 0.0;
double north = 0.0;
double east;
double north;
double dLat = 0.0;
double dLon = 0.0;
double dLat;
double dLon;
if ( latLngBounds.getNortheast() == null ) {
dLat = Math.abs( carPosition.lat - latLngBounds.getSouthwest().getLatitude() );