From d9938b75ade453c9731b33b60eebaedee136c137 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 22 Jul 2022 16:35:00 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=E6=81=A2=E5=A4=8D=E5=B0=8F=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/hmi/ui/MoGoHmiFragment.kt | 14 +- .../core/function/main/MainActivity.java | 6 +- .../core/function/smp/AMapCustomView.java | 3 +- .../function/smp/OverviewMapFragment.java | 199 ++++++++++ .../function/smp/SmallMapDirectionView.java | 356 ++++++++++++++++++ .../core/function/smp/SmallMapFragment.java | 68 ++-- .../layout/module_overview_map_fragment.xml | 14 + .../res/layout/module_overview_map_view.xml | 46 +++ .../res/layout/module_small_map_fragment.xml | 8 +- .../main/res/layout/module_small_map_view.xml | 50 ++- .../data/constants/MoGoFragmentPaths.java | 5 + .../api/hmi/warning/IMoGoWaringProvider.kt | 3 + 12 files changed, 691 insertions(+), 81 deletions(-) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapDirectionView.java create mode 100644 core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml create mode 100644 core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index d2f79b5837..ae5d7e70cf 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -1169,25 +1169,25 @@ import java.util.* } override fun showSmallFragment() { - // 加载 小地图 图层 - val fragmentSmpMap = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP) + // 加载全览模式图层 + val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) .navigation() as BaseFragment activity?.supportFragmentManager?.beginTransaction() ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply { - if (!fragmentSmpMap.isAdded) { - add(R.id.module_main_id_smp_fragment, fragmentSmpMap, fragmentSmpMap.tagName) + if (!fragmentOverview.isAdded) { + add(R.id.module_main_id_smp_fragment, fragmentOverview, fragmentOverview.tagName) } else { - show(fragmentSmpMap) + show(fragmentOverview) }.commitAllowingStateLoss() } } override fun hideSmallFragment() { - val fragmentSmpMap = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP) + val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) .navigation() as BaseFragment activity?.supportFragmentManager?.beginTransaction() ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out) - ?.hide(fragmentSmpMap) + ?.hide(fragmentOverview) ?.commitAllowingStateLoss() } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java index 3fd95f611e..5fabab1775 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainActivity.java @@ -302,9 +302,9 @@ public class MainActivity extends MvpActivity implement // 加载 HMI 图层 BaseFragment fragmentHdMap = (BaseFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_HMI).navigation(); addFragment(fragmentHdMap, fragmentHdMap.getTagName(), R.id.module_main_id_waring_fragment); -// // 加载 小地图 图层 -// BaseFragment fragmentSmpMap = (BaseFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP).navigation(); -// addFragment(fragmentSmpMap, fragmentSmpMap.getTagName(), R.id.module_main_id_smp_fragment); + // 加载 小地图 图层 + BaseFragment fragmentSmpMap = (BaseFragment) ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP).navigation(); + addFragment(fragmentSmpMap, fragmentSmpMap.getTagName(), R.id.module_main_id_smp_fragment); } /** diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java index 7002f15e25..64deec1378 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java @@ -133,7 +133,7 @@ public class AMapCustomView private void initView(Context context) { mContext = context; - View smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); + View smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this); mAMapNaviView = smpView.findViewById(R.id.aMapNaviView); overLayerView = findViewById(R.id.overLayer); mAMapNavi = AMapNavi.getInstance(context); @@ -194,6 +194,7 @@ public class AMapCustomView // options.setAutoDrawRoute(false); //不显示导航界面 options.setLayoutVisible(false); + options.setTilt(60); //黑夜模式 options.setNaviNight(true); //导航全程光柱 diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java new file mode 100644 index 0000000000..561d788f1d --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java @@ -0,0 +1,199 @@ +package com.mogo.eagle.core.function.smp; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.commons.mvp.BaseFragment; +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; +import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; +import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; +import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider; +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; +import com.mogo.eagle.core.function.map.R; +import com.mogo.eagle.core.function.overview.InfStructureManager; +import com.mogo.eagle.core.function.overview.Infrastructure; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; + +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; +import system_master.SystemStatusInfo; + +/** + * @author donghongyu + * @date 2021/5/19 10:50 上午 + * 全览模式Fragment + */ +@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) +public class OverviewMapFragment extends BaseFragment + implements IMogoSmallMapProvider, IMoGoAutopilotPlanningListener, + IMoGoAutopilotStatusListener { + private final String TAG = "SmallMapFragment"; + protected AMapCustomView mAMapCustomView; + + @Override + public void onAttach(Context context) { + super.onAttach(context); + } + + @Override + protected int getLayoutId() { + return R.layout.module_overview_map_fragment; + } + + @Override + public String getTagName() { + return TAG; + } + + @Override + protected void initViews() { + + } + + @Override + protected void initViews(Bundle savedInstanceState) { + super.initViews(savedInstanceState); + mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView); + mAMapCustomView.onCreateView(savedInstanceState); + CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); + } + + @Override + public void showPanel() { + if (mAMapCustomView != null) { + mAMapCustomView.setVisibility(View.VISIBLE); + } + } + + @Override + public void hidePanel() { + if (mAMapCustomView != null) { + mAMapCustomView.setVisibility(View.GONE); + } + } + + @Override + public void drawablePolyline(List coordinates) { + if (mAMapCustomView != null) { + mAMapCustomView.convert(coordinates); + UiThreadHandler.post(() -> mAMapCustomView.drawablePolyline()); + } + } + + @Override + public void clearPolyline() { + if (mAMapCustomView != null) { + UiThreadHandler.post(() -> mAMapCustomView.clearPolyline()); + } + } + + @Override + public void onResume() { + super.onResume(); + if (mAMapCustomView != null) { + mAMapCustomView.onResume(); + } + Map> map = InfStructureManager.INSTANCE.getPathData(); + if (!map.isEmpty()) { + mAMapCustomView.drawInfMarkers(map); + } + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); +// queryInfStructure(); + } + +// private void queryInfStructure() { +// mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class); +// mViewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> { +// mAMapCustomView.updateInfStructures(map); +// }); +// // 本地数据库查询 +// mViewModel.fetchInfStructures(); +// } + + @Override + public void onPause() { + super.onPause(); + if (mAMapCustomView != null) { + mAMapCustomView.onPause(); + } + + } + + @Override + public void onDestroy() { + super.onDestroy(); + if (mAMapCustomView != null) { + mAMapCustomView.onDestroy(); + } + CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); + } + + @Override + public void onAutopilotTrajectory(List trajectoryInfos) { + + } + + @Override + public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { + if (autoPilotStatusInfo.getPilotmode() != 1) { + clearPolyline(); + } + } + + @Override + public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) { + + } + + @Override + public void onAutopilotSNRequest() { + + } + + @Override + public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo) { + + } + + @Override + public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) { + } + + @Override + public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) { + if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) { + return; + } + List latLngList = new ArrayList<>(); + for (MessagePad.Location routeModel : globalPathResp.getWayPointsList()) { + latLngList.add(new MogoLatLng(routeModel.getLatitude(), routeModel.getLongitude())); + } + if (latLngList.size() > 0) { + drawablePolyline(latLngList); + } else { + clearPolyline(); + } + } + + @Override + public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { + + } +} diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapDirectionView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapDirectionView.java new file mode 100644 index 0000000000..00270c4f24 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapDirectionView.java @@ -0,0 +1,356 @@ +package com.mogo.eagle.core.function.smp; + +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP; + +import android.content.Context; +import android.graphics.Color; +import android.location.Location; +import android.os.Bundle; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.RelativeLayout; + +import androidx.annotation.Nullable; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.CameraUpdate; +import com.amap.api.maps.CameraUpdateFactory; +import com.amap.api.maps.CoordinateConverter; +import com.amap.api.maps.TextureMapView; +import com.amap.api.maps.UiSettings; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.CameraPosition; +import com.amap.api.maps.model.CustomMapStyleOptions; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.MarkerOptions; +import com.amap.api.maps.model.Polyline; +import com.amap.api.maps.model.PolylineOptions; +import com.mogo.cloud.commons.utils.CoordinateUtils; +import com.mogo.eagle.core.data.map.MogoLatLng; +import com.mogo.eagle.core.data.map.MogoLocation; +import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener; +import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager; +import com.mogo.eagle.core.function.map.R; +import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView; +import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.widget.RoundLayout; +import com.mogo.module.common.utils.DrivingDirectionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 小地图的方向View + * + * @author donghongyu + * @date 12/14/20 4:40 PM + */ +public class SmallMapDirectionView + extends RelativeLayout + implements IMoGoMapLocationListener, ISmallMapDirectionView { + + //小地图名称 + public static final String TAG = "SmallMapDirectionView"; + + private RoundLayout rlSmallMapBorder; + private TextureMapView mAMapNaviView; + private AMap mAMap; + private Marker mCarMarker; + private Marker mStartMarker; + private Marker mEndMarker; + + private int zoomLevel = 15; + private final List mCoordinatesLatLng = new ArrayList<>(); + private final List mCoordinatesLatLngCurrent = new ArrayList<>(); + private Polyline mPolyline; + private CameraUpdate mCameraUpdate; + private Context mContext; + + public SmallMapDirectionView(Context context) { + this(context, null); + } + + public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + try { + initView(context); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void initView(Context context) { + mContext = context; + View smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); + + mAMapNaviView = smpView.findViewById(R.id.aMapNaviView); +// rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder); +// rlSmallMapBorder.addView(mAMapNaviView); + + initAMapView(); + + // 注册定位监听 + CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + // 注册定位监听 + CallerMapLocationListenerManager.INSTANCE.removeListener(TAG); + } + + private void initAMapView() { + mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel); + mAMap = mAMapNaviView.getMap(); + // 关闭地图文字标注 + mAMap.showMapText(false); + // 设置导航地图模式,aMap是地图控制器对象。 + mAMap.setMapType(AMap.MAP_TYPE_NIGHT); + // 关闭显示实时路况图层,aMap是地图控制器对象。 + mAMap.setTrafficEnabled(false); + // 设置 锚点 图标 + mCarMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo)) + .anchor(0.5f, 0.5f)); + mStartMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))); + mEndMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))); + // 加载自定义样式 + CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions() + .setEnable(true) + .setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "small_map_style.data")) + .setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "small_map_style_extra.data")); + // 设置自定义样式 + mAMap.setCustomMapStyle(customMapStyleOptions); + //设置希望展示的地图缩放级别 + mAMap.moveCamera(mCameraUpdate); + // 设置地图的样式 + UiSettings uiSettings = mAMap.getUiSettings(); + uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮 + uiSettings.setAllGesturesEnabled(false);// 所有手势 + uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮 + uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + mAMap.setOnMapLoadedListener(() -> { + CallerLogger.INSTANCE.d(M_MAP + TAG, "smp---onMapLoaded"); + // 加载自定义样式 + CustomMapStyleOptions customMapStyleOptions1 = new CustomMapStyleOptions() + .setEnable(true) + .setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "small_map_style.data")) + .setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "small_map_style_extra.data")); + // 设置自定义样式 + mAMap.setCustomMapStyle(customMapStyleOptions1); + mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2); + }); + } + + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return true; + } + + + @Override + public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) { + if (location == null) { + return; + } + if (mCarMarker == null){ + mCarMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo)) + .anchor(0.5f, 0.5f)); + } + if(mCarMarker == null){ + return; + } + LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); + //更新车辆位置 + mCarMarker.setPosition(currentLatLng); + + CameraPosition cameraPosition; + if (mCoordinatesLatLng.size() > 1) { +// mCoordinatesLatLngCurrent.clear(); +// for (LatLng lng : mCoordinatesLatLng) { +// MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude); +// mCoordinatesLatLngCurrent.add(mogoLatLng); +// } +// removeLoction(latLng); + + // 结束位置 + LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1); + // 与结束位置进行 GeoHash 0-12 +// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7); +// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7); + + float calculateDistance = CoordinateUtils.calculateLineDistance( + endLatLng.latitude, endLatLng.longitude, + currentLatLng.latitude, currentLatLng.longitude + ); + + CallerLogger.INSTANCE.d(M_MAP + TAG, "calculateDistance=" + calculateDistance); + if (calculateDistance <= 5) { + clearPolyline(); + mCoordinatesLatLng.clear(); + } + cameraPosition = new CameraPosition.Builder().target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build(); + } else { + //设置希望展示的地图缩放级别 + cameraPosition = new CameraPosition.Builder().target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build(); +// mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel)); + } + mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + } + + private void removeLocation(Location latLng) { + for (LatLng l : mCoordinatesLatLng) { + if (!isPointOnCarFront(latLng, l)) { + mCoordinatesLatLng.remove(l); + } + } + } + + public static boolean isPointOnCarFront(Location carLocal, LatLng pointLocal) { + double carLon = carLocal.getLongitude(); + double carLat = carLocal.getLatitude(); + double poiLon = pointLocal.longitude; + double poiLat = pointLocal.latitude; + float carAngle = carLocal.getBearing(); + + // 计算车辆与点之间的夹角 + int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi( + carLon, carLat, poiLon, poiLat, (int) carAngle); + + return diffAngle <= 90; + } + + + @Override + public void drawablePolyline() { + clearPolyline(); +// mCoordinatesLatLng.clear(); +// List latLngs = CoordinateConverterFrom84ForList(mContext,coordinates); +// mCoordinatesLatLng.addAll(latLngs); +// for (LatLng coordinate : mCoordinatesLatLng) { +// mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon())); +// } + if (mAMap != null) { + if (mCoordinatesLatLng.size() > 2) { + // 设置开始结束Marker位置 + mStartMarker.setPosition(mCoordinatesLatLng.get(0)); + mEndMarker.setPosition(mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1)); + mStartMarker.setToTop(); + mStartMarker.setVisible(true); + mEndMarker.setVisible(true); + mEndMarker.setToTop(); + + + //存放所有点的经纬度 + LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); + + for (int i = 0; i < mCoordinatesLatLng.size(); i++) { + //把所有点都include进去(LatLng类型) + boundsBuilder.include(mCoordinatesLatLng.get(i)); + } + //第二个参数为四周留空宽度 + mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 30)); + // 绘制线 + mPolyline = mAMap.addPolyline( + new PolylineOptions() + .addAll(mCoordinatesLatLng) + .color(Color.argb(255, 31, 127, 255)) + .width(12)); + + } +// else { +// //设置希望展示的地图缩放级别 +// mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel)); +// } + } + } + + + public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) { + CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext); + mCoordinateConverter.from(CoordinateConverter.CoordType.GPS); + mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon)); + return mCoordinateConverter.convert(); + } + + public List CoordinateConverterFrom84ForList(Context mContext, List mogoLatLngList) { + List list = new ArrayList<>(); + for (MogoLatLng m : mogoLatLngList) { + LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m); + list.add(mogoLatLng); + } + return list; + } + + @Override + public void clearPolyline() { +// mCoordinatesLatLng.clear(); + if (mPolyline != null) { + mPolyline.remove(); + } + if (mStartMarker != null) { + mStartMarker.setVisible(false); + } + if (mEndMarker != null) { + mEndMarker.setVisible(false); + } + } + + public void resetPolyLine() { + mCoordinatesLatLng.clear(); + if (mPolyline != null) { + mPolyline.remove(); + } + if (mStartMarker != null) { + mStartMarker.setVisible(false); + } + if (mEndMarker != null) { + mEndMarker.setVisible(false); + } + } + + public void onCreateView(Bundle savedInstanceState) { + if (mAMapNaviView != null) { + mAMapNaviView.onCreate(savedInstanceState); + } + } + + public void onResume() { + if (mAMapNaviView != null) { + mAMapNaviView.onResume(); + } + } + + public void onPause() { + if (mAMapNaviView != null) { + mAMapNaviView.onPause(); + } + } + + public void onDestroy() { + if (mAMapNaviView != null) { + mAMapNaviView.onDestroy(); + } + } + + public void convert(List coordinates) { + mCoordinatesLatLng.clear(); + List latLngs = CoordinateConverterFrom84ForList(mContext, coordinates); + mCoordinatesLatLng.addAll(latLngs); + } + +} diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java index 40725b3f56..17227329ec 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/SmallMapFragment.java @@ -17,15 +17,12 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.function.map.R; -import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.function.overview.Infrastructure; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; -import java.util.Map; import mogo.telematics.pad.MessagePad; import mogo_msg.MogoReportMsg; @@ -40,7 +37,7 @@ public class SmallMapFragment extends BaseFragment implements IMogoSmallMapProvider, IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener { private final String TAG = "SmallMapFragment"; - protected AMapCustomView mAMapCustomView; + protected SmallMapDirectionView mSmallMapDirectionView; @Override public void onAttach(Context context) { @@ -65,72 +62,63 @@ public class SmallMapFragment extends BaseFragment @Override protected void initViews(Bundle savedInstanceState) { super.initViews(savedInstanceState); - mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView); - mAMapCustomView.onCreateView(savedInstanceState); + mSmallMapDirectionView = mRootView.findViewById(R.id.smallMapDirectionView); + mSmallMapDirectionView.onCreateView(savedInstanceState); CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); } @Override public void showPanel() { - if (mAMapCustomView != null) { - mAMapCustomView.setVisibility(View.VISIBLE); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.setVisibility(View.VISIBLE); } } @Override public void hidePanel() { - if (mAMapCustomView != null) { - mAMapCustomView.setVisibility(View.GONE); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.setVisibility(View.GONE); } } @Override public void drawablePolyline(List coordinates) { - if (mAMapCustomView != null) { - mAMapCustomView.convert(coordinates); - UiThreadHandler.post(() -> mAMapCustomView.drawablePolyline()); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.convert(coordinates); + UiThreadHandler.post(new Runnable() { + @Override + public void run() { + mSmallMapDirectionView.drawablePolyline(); + } + }); } } @Override public void clearPolyline() { - if (mAMapCustomView != null) { - UiThreadHandler.post(() -> mAMapCustomView.clearPolyline()); + if (mSmallMapDirectionView != null) { + UiThreadHandler.post(new Runnable() { + @Override + public void run() { + mSmallMapDirectionView.clearPolyline(); + } + }); } } @Override public void onResume() { super.onResume(); - if (mAMapCustomView != null) { - mAMapCustomView.onResume(); - } - Map> map = InfStructureManager.INSTANCE.getPathData(); - if (!map.isEmpty()) { - mAMapCustomView.drawInfMarkers(map); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.onResume(); } } - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); -// queryInfStructure(); - } - -// private void queryInfStructure() { -// mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class); -// mViewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> { -// mAMapCustomView.updateInfStructures(map); -// }); -// // 本地数据库查询 -// mViewModel.fetchInfStructures(); -// } - @Override public void onPause() { super.onPause(); - if (mAMapCustomView != null) { - mAMapCustomView.onPause(); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.onPause(); } } @@ -138,8 +126,8 @@ public class SmallMapFragment extends BaseFragment @Override public void onDestroy() { super.onDestroy(); - if (mAMapCustomView != null) { - mAMapCustomView.onDestroy(); + if (mSmallMapDirectionView != null) { + mSmallMapDirectionView.onDestroy(); } CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml new file mode 100644 index 0000000000..8ed1c15374 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml new file mode 100644 index 0000000000..a8a1ede8d9 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_view.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_fragment.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_fragment.xml index 8ed1c15374..47b8763b7d 100644 --- a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_fragment.xml +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_fragment.xml @@ -4,10 +4,12 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_view.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_view.xml index a8a1ede8d9..0fa8d310d8 100644 --- a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_view.xml +++ b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_small_map_view.xml @@ -2,45 +2,41 @@ + android:layout_width="@dimen/module_small_map_view_border_width" + android:layout_height="@dimen/module_small_map_view_border_width" + android:layout_centerInParent="true" + android:background="@drawable/module_small_map_view_border" /> - + android:layout_width="@dimen/module_small_map_view_width" + android:layout_height="@dimen/module_small_map_view_width" + android:layout_centerInParent="true" + app:roundLayoutRadius="360dp"> - + + + + + - - + + - + android:visibility="gone" + android:src="@drawable/module_small_map_view_border_north" /> \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MoGoFragmentPaths.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MoGoFragmentPaths.java index f1c0a0a4c8..7ab277351d 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MoGoFragmentPaths.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MoGoFragmentPaths.java @@ -29,4 +29,9 @@ public class MoGoFragmentPaths { @Deprecated public static final String PATH_FRAGMENT_SMP = "/smp_ui/"; + /** + * 全览模式地图 Fragment + */ + @Keep + public static final String PATH_FRAGMENT_OVERVIEW = "/overview_ui/"; } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt index 81cc59c55e..c766cc953d 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt @@ -186,6 +186,9 @@ interface IMoGoWaringProvider : IMoGoHmiViewProxy { fun hideToolsView() + /** + * 加载全览模式图层 + */ fun showSmallFragment() fun hideSmallFragment()