完成最优路线的颜色梯度计算

增加逻辑,3D模式下关闭道路事件连线的绘制
This commit is contained in:
董宏宇
2021-04-16 17:53:54 +08:00
parent af05b71bdd
commit a2ef2bbd44
4 changed files with 69 additions and 44 deletions

View File

@@ -35,7 +35,9 @@ public class MoGoV2XPolylineManager implements IMoGoV2XPolylineManager {
}
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null
&& !V2XServiceManager.getMoGoStatusManager().isVrMode()
) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();

View File

@@ -6,6 +6,7 @@ import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.ColorUtils;
import java.util.ArrayList;
import java.util.List;
@@ -22,16 +23,15 @@ public class V2XOptimalRouteOverlay {
private MogoPolylineOptions mPolylineOptions;
// 线路径集合
private List<MogoLatLng> mPolylinePointList;
// 渐变色
private List<Integer> mPolylineColors;
public V2XOptimalRouteOverlay() {
mPolylineOptions = new MogoPolylineOptions();
// 渐变色
List<Integer> colors = new ArrayList<>();
colors.add(0xFFF95959);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(25).useGradient(true).colorValues(colors);
// 绘制路径集合
mPolylinePointList = new ArrayList<>();
// 引导线颜色
mPolylineColors = new ArrayList<>();
}
/**
@@ -43,8 +43,10 @@ public class V2XOptimalRouteOverlay {
if (mMoGoPolyline != null) {
mMoGoPolyline.remove();
mPolylinePointList.clear();
mPolylineColors.clear();
}
if (polylinePoint != null) {
// 将当前车辆位置放进去
mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
// 过滤后台推送的推荐路线集合
@@ -54,8 +56,13 @@ public class V2XOptimalRouteOverlay {
mPolylinePointList.add(polyline);
}
}
mPolylineColors.addAll(ColorUtils.gradientAlpha("#002965ED", "#FF2965ED", mPolylinePointList.size()/2));
// 替换路径集合
mPolylineOptions.points(mPolylinePointList);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(25).useGradient(true).colorValues(mPolylineColors);
// 绘制线
mMoGoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(mPolylineOptions);
}