2.2.0 绘制重点marker 调整
This commit is contained in:
@@ -25,20 +25,17 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MogoRouteOverlayManager implements IMogoCarLocationChangedListener2, IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener {
|
||||
public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener {
|
||||
private static volatile MogoRouteOverlayManager sInstance;
|
||||
private Context mContext;
|
||||
private String TAG = "MogoRouteOverlayManager";
|
||||
private String TAG2 = "MogoRouteOverlayManager routes";
|
||||
private int STATUS_AUTOPILOT = 0;//0 非自动驾驶 ; 1 自动驾驶
|
||||
private MogoRouteOverlayManager(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
@@ -54,34 +51,6 @@ public class MogoRouteOverlayManager implements IMogoCarLocationChangedListener2
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
// updateLocation(latLng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
//坐标转换
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
RouteOverlayDrawer.getInstance(mContext).drawRouteOverlay(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(ArrayList<ADASTrajectoryInfo> trajectoryInfos) {
|
||||
if (trajectoryInfos == null || trajectoryInfos.size() == 0) {
|
||||
@@ -111,9 +80,7 @@ public class MogoRouteOverlayManager implements IMogoCarLocationChangedListener2
|
||||
for (AutopilotRouteInfo.RouteModels routeModel : routeList.getModels()) {
|
||||
latLngList.add(new MogoLatLng(routeModel.getLat(), routeModel.getLon()));
|
||||
}
|
||||
Log.e(TAG, "routeResult:" + latLngList.size());
|
||||
|
||||
RouteOverlayDrawer.getInstance(mContext).putRouteList(latLngList);
|
||||
Log.d(TAG2, "routeResult:" + latLngList.size());
|
||||
int listSize = latLngList.size();
|
||||
RouteOverlayDrawer.getInstance(mContext).addEndingMarker(latLngList.get(listSize - 1).lat,latLngList.get(listSize - 1).lon);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.module.service.routeoverlay;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
@@ -69,71 +70,21 @@ public class RouteOverlayDrawer {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private List<MogoLatLng> mRouteList;
|
||||
|
||||
public void drawRouteOverlay(MogoLocation location){
|
||||
if (mRouteList == null ){
|
||||
clearMogoRouteOverlay();
|
||||
return;
|
||||
}
|
||||
if (mRouteList.size() >0){
|
||||
//adas回调导航路径 绘制引导线
|
||||
draw(location,mRouteList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制最优路线
|
||||
*
|
||||
* @param routelist 要绘制的经纬度度集合
|
||||
*/
|
||||
public IMogoPolyline draw(MogoLocation carLocal, List<MogoLatLng> routelist) {
|
||||
clearMogoRouteOverlay();
|
||||
if (routelist != null) {
|
||||
if (carLocal == null){
|
||||
for (MogoLatLng polyline : routelist) {
|
||||
// Log.e("IMogoPolyline",polyline.getLat()+":"+polyline.lon);
|
||||
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中的点是否在当前车辆行驶方向前面如果不在则抛弃
|
||||
mPolylinePointList.add(polyline);
|
||||
}
|
||||
}else {
|
||||
// 将当前车辆位置放进去
|
||||
// mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
|
||||
for (MogoLatLng polyline : routelist) {
|
||||
// Log.e("IMogoPolyline",polyline.getLat()+":"+polyline.lon);
|
||||
if (LocationUtils.isPointOnCarFront(carLocal, polyline)) {
|
||||
}
|
||||
mPolylinePointList.add(polyline);
|
||||
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中的点是否在当前车辆行驶方向前面如果不在则抛弃
|
||||
// Log.e("lianglihui",polyline.getLat()+":"+polyline.getLon());
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤后台推送的推荐路线集合
|
||||
|
||||
mPolylineOptions.setGps(true);
|
||||
mPolylineColors.addAll(ColorUtils.getGradientAlpha("#002965ED", "#FF2965ED", "#002965ED", mPolylinePointList.size()));
|
||||
// 替换路径集合
|
||||
mPolylineOptions.points(mPolylinePointList);
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(14).useGradient(true).colorValues(mPolylineColors);
|
||||
// 绘制线
|
||||
mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions);
|
||||
}
|
||||
return mMoGoPolyline;
|
||||
}
|
||||
|
||||
public void addEndingMarker(double lat,double lon){
|
||||
if (markderOptions == null){
|
||||
markderOptions = new MogoMarkerOptions().
|
||||
set3DMode(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode())
|
||||
.matchOnRoadSide(true)
|
||||
.gps(true)
|
||||
.icon(endingBitmap)
|
||||
.owner(markerType)
|
||||
.zIndex(20001);
|
||||
.anchor(0.5f, 0.5f)
|
||||
.zIndex(30001);
|
||||
// .object(markerShowEntity)
|
||||
}
|
||||
markderOptions.latitude(lat).longitude(lon);
|
||||
Log.d("lianglihui","addEndingMarker-"+lat+":"+lon);
|
||||
endMarker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerType, markderOptions);
|
||||
}
|
||||
|
||||
@@ -152,9 +103,6 @@ public class RouteOverlayDrawer {
|
||||
}
|
||||
}
|
||||
|
||||
public void putRouteList(List<MogoLatLng> routeList) {
|
||||
this.mRouteList = routeList;
|
||||
}
|
||||
|
||||
public void drawTrajectoryList(List<MogoLatLng> routeList) {
|
||||
// clearMogoRouteOverlay();
|
||||
@@ -163,9 +111,8 @@ public class RouteOverlayDrawer {
|
||||
for (MogoLatLng latLng : routeList) {
|
||||
mPolylinePointList.add(latLng);
|
||||
}
|
||||
if (mPolylineColors.isEmpty()){
|
||||
mPolylineColors.addAll(ColorUtils.getGradientAlpha("#002965ED", "#FF2965ED", "#2AAFFD", mPolylinePointList.size()));
|
||||
}
|
||||
mPolylineColors.clear();
|
||||
mPolylineColors.addAll(ColorUtils.getGradientAlpha("#002965ED", "#FF2965ED", "#2AAFFD", mPolylinePointList.size()));
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(12).useGradient(true).colorValues(mPolylineColors);
|
||||
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()){
|
||||
|
||||
Reference in New Issue
Block a user