Complete small map draw line and remove line
This commit is contained in:
1
.idea/runConfigurations.xml
generated
1
.idea/runConfigurations.xml
generated
@@ -3,6 +3,7 @@
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
|
||||
@@ -36,7 +36,7 @@ ext {
|
||||
// 地图
|
||||
amapnavi3dmap : "com.amap.api:navi-3dmap:7.2.0_3dmap7.2.0",
|
||||
amapsearch : "com.amap.api:search:7.1.0",
|
||||
amaplocation : "com.amap.api:location:5.2.0",
|
||||
amaplocation : "com.amap.api:location:5.3.1",
|
||||
// json 转换
|
||||
gson : "com.google.code.gson:gson:2.8.4",
|
||||
// 内存泄漏检测
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.commons;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -11,8 +12,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.android.internal.policy.MyPhoneLayoutInflater;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.mogo.commons.analytics.AnalyticsUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.device.Devices;
|
||||
@@ -61,16 +61,16 @@ public abstract class AbsMogoApplication extends Application {
|
||||
return sApp;
|
||||
}
|
||||
|
||||
public static AMapNaviView aMapNaviView;
|
||||
public static TextureMapView aMapNaviView;
|
||||
|
||||
public static AMapNaviView getMapNaviView() {
|
||||
public static TextureMapView getMapNaviView() {
|
||||
return aMapNaviView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
aMapNaviView = new AMapNaviView(this);
|
||||
aMapNaviView = new TextureMapView(this);
|
||||
aMapNaviView.onCreate(null);
|
||||
// 在设置皮肤布局填充器之前进行克隆一个出来
|
||||
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));
|
||||
|
||||
@@ -180,6 +180,7 @@ public class V2XMessageEntity<T> implements Serializable {
|
||||
V2XTypeEnum.ALERT_RECOMMEND_PARKING,
|
||||
V2XTypeEnum.ALERT_PUSH_VR_SHOW,
|
||||
V2XTypeEnum.ALERT_OBU_EVENT,
|
||||
V2XTypeEnum.ALERT_THE_FRONT_WEAKNESS,
|
||||
})
|
||||
@Target({
|
||||
ElementType.PARAMETER,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.mogo.module.small.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -13,37 +14,59 @@ 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.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
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.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.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.module.small.map.animation.DirectionRotateAnimation;
|
||||
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
|
||||
import com.mogo.module.small.map.view.ISmallMapDirectionView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
*
|
||||
* @author donghongyu
|
||||
* @date 12/14/20 4:40 PM
|
||||
*/
|
||||
public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLocationChangedListener2 {
|
||||
public class SmallMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMogoCarLocationChangedListener2, ISmallMapDirectionView {
|
||||
|
||||
/**
|
||||
* 小地图名称
|
||||
*/
|
||||
public static final String MODULE_NAME = "SmallMap";
|
||||
|
||||
private RoundLayout rlSmallMapBorder;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private AMapNavi mAMapNavi;
|
||||
private int zoomLevel = 15;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private int lastAngle = 0;
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private DirectionRotateAnimation mRotateAnimation;
|
||||
|
||||
public SmallMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
@@ -63,6 +86,8 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
mRotateAnimation = new DirectionRotateAnimation(context, null);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
mAMapNaviView = AbsMogoApplication.getMapNaviView();
|
||||
@@ -100,10 +125,7 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
// 车头朝上
|
||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
// 设置电子眼所在路线的可见性
|
||||
mAMapNaviView.setRouteOverlayVisible(false);
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 关闭地图文字标注
|
||||
mAMap.showMapText(false);
|
||||
@@ -112,9 +134,26 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
mAMapNavi = AMapNavi.getInstance(getContext());
|
||||
//使用外部GPS数据
|
||||
mAMapNavi.setIsUseExtraGPSData(true);
|
||||
|
||||
// MyLocationStyle myLocationStyle;
|
||||
// myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
|
||||
// myLocationStyle.interval(1000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
|
||||
// myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE);//连续定位、蓝点不会移动到地图中心点,地图依照设备方向旋转,并且蓝点会跟随设备移动。
|
||||
// myLocationStyle.myLocationIcon(BitmapDescriptorFactory
|
||||
// .fromResource(R.drawable.module_small_map_view_my_location_logo));
|
||||
// mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
|
||||
// mAMap.getUiSettings().setMyLocationButtonEnabled(false);//设置默认定位按钮是否显示,非必需设置。
|
||||
// mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
|
||||
// mAMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
|
||||
|
||||
// 设置 锚点 图标
|
||||
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)));
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
@@ -130,8 +169,7 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap.moveCamera(cameraUpdate);
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
}).start();
|
||||
|
||||
// 设置地图的样式
|
||||
@@ -141,70 +179,6 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
// 导航地图
|
||||
AMapNaviViewOptions options = mAMapNaviView.getViewOptions();
|
||||
//设置导航界面UI是否显示。
|
||||
if (options != null) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode(false);
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar(true);
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow(false);
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
|
||||
R.drawable.module_small_map_view_my_location_logo));
|
||||
// 设置罗盘位图对象
|
||||
options.setFourCornersBitmap(BitmapFactory.decodeResource(getContext().getResources(),
|
||||
R.drawable.icon_module_small_map_four_corners));
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled(false);
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled(false);
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled(false);
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow(false);
|
||||
// 设置屏幕是否常亮,默认开启
|
||||
options.setScreenAlwaysBright(false);
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled(false);
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled(false);
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled(false);
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine(false);
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled(-1);
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible(false);
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute(false);
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow(false);
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow(false);
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow(false);
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom(false);
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview(false);
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible(false);
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray(false);
|
||||
options.setZoom(((int) 10));
|
||||
//options.setPointToCenter(0.7D, 0.5D);
|
||||
// 2D模式
|
||||
options.setTilt(0);
|
||||
// 黑夜模式
|
||||
options.setNaviNight(true);
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -216,8 +190,30 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
|
||||
if (mAMapNavi != null) {
|
||||
mAMapNavi.setExtraGPSData(2, latLng);
|
||||
LatLng currentLatLng = new LatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
|
||||
if (mCarMarker != null) {
|
||||
//mAMap.moveCamera(CameraUpdateFactory.changeBearing(latLng.getBearing()));
|
||||
|
||||
// changeAngle((int) latLng.getBearing());
|
||||
// mStartMarker.setRotateAngle(360 - latLng.getBearing());
|
||||
// mEndMarker.setRotateAngle(360 - latLng.getBearing());
|
||||
|
||||
mCarMarker.setRotateAngle(360 - latLng.getBearing());
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
mCoordinatesLatLngCurrent.clear();
|
||||
for (LatLng lng : mCoordinatesLatLng) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
|
||||
mCoordinatesLatLngCurrent.add(mogoLatLng);
|
||||
}
|
||||
drawablePolyline(mCoordinatesLatLngCurrent);
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,4 +221,84 @@ public class SmallMapDirectionView extends RelativeLayout implements IMogoCarLoc
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged latLng:" + latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
clearPolyline();
|
||||
mCoordinatesLatLng.clear();
|
||||
|
||||
for (MogoLatLng coordinate : coordinates) {
|
||||
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.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
|
||||
//存放所有点的经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
|
||||
//把所有点都include进去(LatLng类型)
|
||||
boundsBuilder.include(mCoordinatesLatLng.get(i));
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.animateCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 65, 65, 65, 65));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(
|
||||
new PolylineOptions()
|
||||
.addAll(mCoordinatesLatLng)
|
||||
.color(Color.argb(255, 31, 127, 255))
|
||||
.width(5));
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCoordinatesLatLng.get(0), zoomLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角度
|
||||
*
|
||||
* @param angle 角度 0 - 359 度旋转,相对于自身中心位置
|
||||
*/
|
||||
public void changeAngle(int angle) {
|
||||
// int tempAngle = 360 - angle;
|
||||
// if (tempAngle > 180) {
|
||||
// tempAngle = -(360 - tempAngle);
|
||||
// }
|
||||
|
||||
mRotateAnimation.setFromDegrees(lastAngle);
|
||||
mRotateAnimation.setToDegrees(angle);
|
||||
|
||||
//设置线性插值,可以解决旋转一圈后卡顿问题
|
||||
mRotateAnimation.setInterpolator(new LinearInterpolator());
|
||||
//设置旋转一圈时间
|
||||
mRotateAnimation.setDuration(300);
|
||||
//控件动画结束时是否保持动画最后的状态
|
||||
mRotateAnimation.setFillAfter(true);
|
||||
startAnimation(mRotateAnimation);
|
||||
// 刷新最后一次角度
|
||||
lastAngle = angle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
@@ -18,6 +21,7 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
*/
|
||||
public class SmallMapFragment extends Fragment {
|
||||
protected View mRootView;
|
||||
protected SmallMapDirectionView mSmallMapDirectionView;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -30,6 +34,7 @@ public class SmallMapFragment extends Fragment {
|
||||
if (mRootView == null) {
|
||||
mRootView = AbsMogoApplication.getLayoutInflaterNoSkin()
|
||||
.inflate(R.layout.module_small_map_fragment, container, false);
|
||||
mSmallMapDirectionView = mRootView.findViewById(R.id.smallMapDirectionView);
|
||||
} else {
|
||||
ViewGroup viewGroup = (ViewGroup) mRootView.getParent();
|
||||
if (viewGroup != null) {
|
||||
@@ -38,4 +43,17 @@ public class SmallMapFragment extends Fragment {
|
||||
}
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
if (mSmallMapDirectionView != null) {
|
||||
mSmallMapDirectionView.drawablePolyline(coordinates);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearPolyline() {
|
||||
if (mSmallMapDirectionView != null) {
|
||||
mSmallMapDirectionView.clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,19 +82,18 @@ public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChang
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeAngle(double angle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
|
||||
if (mSmallMapFragment != null) {
|
||||
mSmallMapFragment.drawablePolyline(coordinates);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
|
||||
if (mSmallMapFragment != null) {
|
||||
mSmallMapFragment.clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.module.small.map.view;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
public interface ISmallMapDirectionView {
|
||||
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
void drawablePolyline(List<MogoLatLng> coordinates);
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 604 B |
Binary file not shown.
|
After Width: | Height: | Size: 601 B |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -5,6 +5,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mogo.module.small.map.SmallMapDirectionView
|
||||
android:id="@+id/smallMapDirectionView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
android:id="@+id/aMapNaviView"
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width" />-->
|
||||
<!--<com.amap.api.maps.TextureMapView
|
||||
android:id="@+id/aMapNaviView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />-->
|
||||
</com.mogo.module.common.view.RoundLayout>
|
||||
|
||||
</merge>
|
||||
@@ -35,6 +35,7 @@ import com.mogo.service.module.IMogoSearchManager;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.share.IMogoTanluProvider;
|
||||
import com.mogo.service.share.IMogoTrafficUploadProvider;
|
||||
import com.mogo.service.smp.IMogoSmallMapProvider;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.strategy.IMogoOnlineCarListPanelProvider;
|
||||
import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
@@ -98,6 +99,7 @@ public class V2XServiceManager {
|
||||
private static V2XStatusManager mV2XStatusManager;
|
||||
private static V2XSocketManager mV2XSocketManager;
|
||||
private static V2XCalculateServer mV2XCalculateServer;
|
||||
private static IMogoSmallMapProvider mSmallMapProvider;
|
||||
|
||||
|
||||
// 下面的是重构后的代码,建议
|
||||
@@ -139,6 +141,8 @@ public class V2XServiceManager {
|
||||
mIMogoTanluProvider = mMogoServiceApis.getTanluApi();
|
||||
mIMogoTrafficUploadProvider = mMogoServiceApis.getTrafficUploadApi();
|
||||
mMogoOnlineCarListPanelProvider = mMogoServiceApis.getOnlineCarPanelApi();
|
||||
mSmallMapProvider = mMogoServiceApis.getSmallMapProviderApi();
|
||||
|
||||
//事件面板
|
||||
mIEventPanelProvider = mMogoServiceApis.getEventPanelManager();
|
||||
|
||||
@@ -190,6 +194,10 @@ public class V2XServiceManager {
|
||||
return mMapService;
|
||||
}
|
||||
|
||||
public static IMogoSmallMapProvider getMogoSmallMapProvider() {
|
||||
return mSmallMapProvider;
|
||||
}
|
||||
|
||||
public static IMogoOverlayManager getMogoOverlayManager() {
|
||||
return mMogoOverlayManager;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@ import android.content.Intent;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
@@ -167,6 +165,11 @@ public class TestPanelBroadcastReceiver extends BroadcastReceiver {
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
V2XServiceManager.getMoGoStatusManager().setSeekHelping(MODULE_NAME, true);
|
||||
} else if (sceneType == 20) {// 小地图绘制线
|
||||
List<MogoLatLng> coordinates = TestOnLineCarUtils.getTestCoordinates();
|
||||
V2XServiceManager.getMogoSmallMapProvider().drawablePolyline(coordinates);
|
||||
} else if (sceneType == 21) {// 小地图清除绘制线
|
||||
V2XServiceManager.getMogoSmallMapProvider().clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.v2x.utils;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
@@ -7,7 +8,6 @@ import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
@@ -465,6 +465,7 @@ public class TestOnLineCarUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自车求助测试数据
|
||||
*/
|
||||
@@ -486,4 +487,30 @@ public class TestOnLineCarUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回绘制线路测试数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<MogoLatLng> getTestCoordinates() {
|
||||
try {
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.test_coordinates2);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
return GsonUtil.arrayFromJson(baos.toString(), MogoLatLng.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
[
|
||||
{
|
||||
"lon": 116.417695,
|
||||
"lat": 39.976655
|
||||
},
|
||||
{
|
||||
"lon": 116.41763,
|
||||
"lat": 39.978033
|
||||
},
|
||||
{
|
||||
"lon": 116.417593,
|
||||
"lat": 39.978772
|
||||
},
|
||||
{
|
||||
"lon": 116.417464,
|
||||
"lat": 39.981346
|
||||
},
|
||||
{
|
||||
"lon": 116.41741,
|
||||
"lat": 39.982965
|
||||
},
|
||||
{
|
||||
"lon": 116.417132,
|
||||
"lat": 39.987076
|
||||
},
|
||||
{
|
||||
"lon": 116.417217,
|
||||
"lat": 39.988621
|
||||
},
|
||||
{
|
||||
"lon": 116.417217,
|
||||
"lat": 39.990791
|
||||
},
|
||||
{
|
||||
"lon": 116.417325,
|
||||
"lat": 39.997432
|
||||
},
|
||||
{
|
||||
"lon": 116.417475,
|
||||
"lat": 39.998583
|
||||
},
|
||||
{
|
||||
"lon": 116.417818,
|
||||
"lat": 40.001377
|
||||
},
|
||||
{
|
||||
"lon": 116.417668,
|
||||
"lat": 40.002939
|
||||
},
|
||||
{
|
||||
"lon": 116.417475,
|
||||
"lat": 40.003777
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,54 @@
|
||||
[
|
||||
{
|
||||
"lon": 116.417475,
|
||||
"lat": 40.003777
|
||||
},
|
||||
{
|
||||
"lon": 116.417668,
|
||||
"lat": 40.002939
|
||||
},
|
||||
{
|
||||
"lon": 116.417818,
|
||||
"lat": 40.001377
|
||||
},
|
||||
{
|
||||
"lon": 116.417475,
|
||||
"lat": 39.998583
|
||||
},
|
||||
{
|
||||
"lon": 116.417325,
|
||||
"lat": 39.997432
|
||||
},
|
||||
{
|
||||
"lon": 116.417217,
|
||||
"lat": 39.990791
|
||||
},
|
||||
{
|
||||
"lon": 116.417217,
|
||||
"lat": 39.988621
|
||||
},
|
||||
{
|
||||
"lon": 116.417132,
|
||||
"lat": 39.987076
|
||||
},
|
||||
{
|
||||
"lon": 116.41741,
|
||||
"lat": 39.982965
|
||||
},
|
||||
{
|
||||
"lon": 116.417464,
|
||||
"lat": 39.981346
|
||||
},
|
||||
{
|
||||
"lon": 116.417593,
|
||||
"lat": 39.978772
|
||||
},
|
||||
{
|
||||
"lon": 116.41763,
|
||||
"lat": 39.978033
|
||||
},
|
||||
{
|
||||
"lon": 116.417695,
|
||||
"lat": 39.976655
|
||||
}
|
||||
]
|
||||
@@ -17,7 +17,7 @@ public interface IMogoSmallMapProvider extends IProvider {
|
||||
/**
|
||||
* 初始化网约车容器
|
||||
*
|
||||
* @param activity
|
||||
* @param activity activity
|
||||
* @param containerId 容器ID
|
||||
*/
|
||||
void init(FragmentActivity activity, @IdRes int containerId);
|
||||
@@ -32,13 +32,6 @@ public interface IMogoSmallMapProvider extends IProvider {
|
||||
*/
|
||||
void hidePanel();
|
||||
|
||||
/**
|
||||
* 修改轮盘角度
|
||||
*
|
||||
* @param angle 角度值 0-359
|
||||
*/
|
||||
void changeAngle(double angle);
|
||||
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user