终点marker 调整终点marker的添加和清除逻辑
This commit is contained in:
@@ -279,7 +279,7 @@ public class SmallMapDirectionView
|
||||
boundsBuilder.include(mCoordinatesLatLng.get(i));
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.animateCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 65, 65, 65, 65));
|
||||
mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 30));
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(
|
||||
new PolylineOptions()
|
||||
|
||||
@@ -83,6 +83,57 @@ public class ColorUtils {
|
||||
return gradientColorArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对传入颜色生成梯度透明的颜色集合
|
||||
*
|
||||
* @param startColor 开始颜色
|
||||
* @param startColor 结束颜色
|
||||
* @param step 步长
|
||||
* @return 生成的梯度颜色集合
|
||||
*/
|
||||
public static List<Integer> gradientAlpha_(String startColor, String centerColor, String endColor, int step) {
|
||||
|
||||
// 生成渐变色
|
||||
List<Integer> gradientColorArr = new ArrayList<>();
|
||||
// 将HEX转为RGB
|
||||
int[] sColor = hexToArgb(startColor);
|
||||
int[] cColor = hexToArgb(centerColor);
|
||||
int[] eColor = hexToArgb(endColor);
|
||||
if (step >= 3) {
|
||||
int colorStep = (int) Math.floor(step/2);
|
||||
// 计算每一步的差值
|
||||
int aStep = (cColor[0] - sColor[0]) / colorStep;
|
||||
int rStep = (cColor[1] - sColor[1]) / colorStep;
|
||||
int gStep = (cColor[2] - sColor[2]) / colorStep;
|
||||
int bStep = (cColor[3] - sColor[3]) / colorStep;
|
||||
|
||||
|
||||
for (int i = 0; i < colorStep; i++) {
|
||||
gradientColorArr.add(
|
||||
Color.argb(aStep * i + sColor[0],
|
||||
rStep * i + sColor[1],
|
||||
gStep * i + sColor[2],
|
||||
bStep * i + sColor[3]));
|
||||
}
|
||||
int aStep_ = (eColor[0] - cColor[0]) / colorStep;
|
||||
int rStep_ = (eColor[1] - cColor[1]) / colorStep;
|
||||
int gStep_ = (eColor[2] - cColor[2]) / colorStep;
|
||||
int bStep_ = (eColor[3] - cColor[3]) / colorStep;
|
||||
|
||||
for (int i = 0; i < colorStep; i++) {
|
||||
gradientColorArr.add(
|
||||
Color.argb(aStep_ * i + cColor[0],
|
||||
rStep_ * i + cColor[1],
|
||||
gStep_ * i + cColor[2],
|
||||
bStep_ * i + cColor[3]));
|
||||
}
|
||||
|
||||
} else {
|
||||
gradientColorArr.add(Color.argb(cColor[0], cColor[1], cColor[2], cColor[3]));
|
||||
}
|
||||
return gradientColorArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一组渐变色数组
|
||||
*
|
||||
|
||||
@@ -21,12 +21,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MogoRouteOverlayManager implements 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 MogoLatLng mEnding;
|
||||
private MogoRouteOverlayManager(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
@@ -77,15 +78,19 @@ public class MogoRouteOverlayManager implements IMoGoAutopilotPlanningListener,
|
||||
latLngList.add(new MogoLatLng(routeModel.getLat(), routeModel.getLon()));
|
||||
}
|
||||
int listSize = latLngList.size();
|
||||
RouteOverlayDrawer.getInstance(mContext).addEndingMarker(latLngList.get(listSize - 1).lat,latLngList.get(listSize - 1).lon);
|
||||
mEnding = latLngList.get(listSize-1);
|
||||
// RouteOverlayDrawer.getInstance(mContext).addEndingMarker(latLngList.get(listSize - 1).lat,latLngList.get(listSize - 1).lon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
this.STATUS_AUTOPILOT = autoPilotStatusInfo.getControl_pilotmode();
|
||||
if (STATUS_AUTOPILOT != 1) {
|
||||
RouteOverlayDrawer.getInstance(mContext).clearMogoRouteOverlay();
|
||||
Log.d("lianglihui","onAutopilotStatusResponse:"+STATUS_AUTOPILOT);
|
||||
if (STATUS_AUTOPILOT == 1 && mEnding != null){
|
||||
RouteOverlayDrawer.getInstance(mContext).addEndingMarker(mEnding.lat,mEnding.lon);
|
||||
}else {
|
||||
RouteOverlayDrawer.getInstance(mContext).clearEndingMarker();
|
||||
RouteOverlayDrawer.getInstance(mContext).clearMogoRouteOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public class RouteOverlayDrawer {
|
||||
|
||||
|
||||
public void addEndingMarker(double lat,double lon){
|
||||
if (endMarker != null){
|
||||
return;
|
||||
}
|
||||
if (markderOptions == null){
|
||||
markderOptions = new MogoMarkerOptions()
|
||||
.matchOnRoadSide(true)
|
||||
@@ -101,6 +104,8 @@ public class RouteOverlayDrawer {
|
||||
}
|
||||
|
||||
public void clearEndingMarker(){
|
||||
Log.d("lianglihui","clearEndingMarker");
|
||||
endMarker = null;
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).removeMarkers(markerType);
|
||||
}
|
||||
|
||||
@@ -113,7 +118,7 @@ public class RouteOverlayDrawer {
|
||||
mPolylinePointList.add(latLng);
|
||||
}
|
||||
mPolylineColors.clear();
|
||||
mPolylineColors.addAll(ColorUtils.getGradientAlpha("#002965ED", "#FF2965ED", "#2AAFFD", mPolylinePointList.size()));
|
||||
mPolylineColors.addAll(ColorUtils.gradientAlpha_("#002965ED", "#FF2965ED", "#2AAFFD", mPolylinePointList.size()));
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(12).useGradient(true).colorValues(mPolylineColors);
|
||||
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()){
|
||||
|
||||
Reference in New Issue
Block a user