开始绘制对象来车的场景
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
package com.mogo.module.v2x.scenario.scene.pushVR;
|
||||
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerExploreWayItem;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.V2XPoiTypeEnum;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XMarkerClickListener;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,42 +21,52 @@ import java.util.List;
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
|
||||
private final String TAG = "V2XPushVREventMarker";
|
||||
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XPushMessageEntity entity) {
|
||||
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "drawPOI 绘制VR Marker");
|
||||
|
||||
try {
|
||||
// 清除道路事件
|
||||
V2XServiceManager
|
||||
.getMoGoV2XMarkerManager().clearALLPOI();
|
||||
|
||||
// 位置信息
|
||||
MarkerLocation markerLocation = new MarkerLocation();
|
||||
markerLocation.setLon(entity.getLon());
|
||||
markerLocation.setLat(entity.getLat());
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 进行数据转换,用于Marker展示
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
MarkerExploreWay markerNoveltyInfo = new MarkerExploreWay();
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0xFFFA8C34);
|
||||
colors.add(0xFFBD6D36);
|
||||
colors.add(0xFFFA8C34);
|
||||
|
||||
List<MarkerExploreWayItem> items = new ArrayList<>();
|
||||
MarkerExploreWayItem exploreWayItem = new MarkerExploreWayItem();
|
||||
exploreWayItem.setThumbnail(entity.getMsgImgUrl());
|
||||
items.add(exploreWayItem);
|
||||
markerNoveltyInfo.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
|
||||
markerNoveltyInfo.setItems(items);
|
||||
markerNoveltyInfo.setUploadType("1");
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(10).useGradient(true).colorValues(colors);
|
||||
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerNoveltyInfo);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
for (double[] doubles : entity.getPolyline()) {
|
||||
options.add(doubles[0],doubles[1]);
|
||||
}
|
||||
// 当前车辆位置
|
||||
// MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
|
||||
// if (carLocation != null) {
|
||||
// options.add(carLocation);
|
||||
// } else {
|
||||
// options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
// }
|
||||
// // 目标车辆位置
|
||||
// options.add(entity.getLon(), entity.getLat());
|
||||
|
||||
|
||||
// 绘制线的对象
|
||||
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
|
||||
V2XServiceManager
|
||||
.getMoGoV2XMarkerManager()
|
||||
.drawableAlarmPOI(V2XServiceManager.getContext(),
|
||||
v2XRoadEventEntity,
|
||||
V2XMarkerClickListener.getInstance());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -69,10 +78,18 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
|
||||
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
|
||||
MarkerUtils.resetMapZoom(16);
|
||||
// 移除线
|
||||
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
|
||||
clearLine();
|
||||
// 移除事件POI
|
||||
V2XServiceManager.getMoGoV2XMarkerManager().clearAlarmPOI();
|
||||
// 绘制上次的数据
|
||||
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user