[290 bus/taxi司机屏] 解决小地图轨迹线绘制闪烁问题

This commit is contained in:
wangmingjun
2022-08-02 11:24:07 +08:00
parent 209423dbcd
commit c7bbdd2285
5 changed files with 26 additions and 18 deletions

View File

@@ -1,7 +1,6 @@
package com.mogo.och.bus.passenger.ui;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@@ -71,6 +70,8 @@ public class BusPassengerMapDirectionView
private List<Marker> mLineMarkers = new ArrayList<>();
private IBusPassengerMapViewCallback mIBusPassengerMapViewCallback;
private BitmapDescriptor mArrivedRes;
private BitmapDescriptor mUnArrivedRes;
public BusPassengerMapDirectionView(Context context) {
this(context, null);
@@ -133,6 +134,9 @@ public class BusPassengerMapDirectionView
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_end_point)));
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived);
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive);
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
.setEnable(true)
@@ -182,12 +186,12 @@ public class BusPassengerMapDirectionView
if (location == null) {
return;
}
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude() + ":" + location.getLongitude());
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude() + ":" + location.getLongitude());
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
//更新车辆位置
if (mCarMarker != null) {
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing());
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
@@ -228,8 +232,8 @@ public class BusPassengerMapDirectionView
//设置线段纹理
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.addAll(mCoordinatesLatLng);
polylineOptions.useGradient(true);
polylineOptions.width(10); //线段宽度
polylineOptions.width(14); //线段宽度
polylineOptions.setUseTexture(true);
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
polylineOptions.setCustomTextureList(textureList);
polylineOptions.setCustomTextureIndex(texIndexList);
@@ -251,9 +255,9 @@ public class BusPassengerMapDirectionView
texIndexList.clear();
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
if (i <= mHaveArrivedIndex){
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived));
textureList.add(mArrivedRes);
}else {
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive));
textureList.add(mUnArrivedRes);
}
texIndexList.add(i);
}

View File

@@ -4,8 +4,8 @@
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="#F2F7FF"
android:startColor="#E6ECF9"
android:endColor="#F2F6FF"
android:startColor="#E1E7F5"
android:type="linear" />
</shape>
</item>

View File

@@ -52,7 +52,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_28"
android:layout_marginTop="@dimen/dp_40"
android:elevation="@dimen/dp_10"
android:text="@string/bus_p_cur_station_title"
android:textColor="@color/bus_p_panel_cur_txt_color"
@@ -65,7 +65,7 @@
android:id="@+id/bus_p_cur_station_name"
android:layout_width="@dimen/bus_p_curent_station_txt_width"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_12"
android:elevation="@dimen/dp_10"
android:ellipsize="end"
android:maxLines="1"

View File

@@ -7,7 +7,7 @@
<com.mogo.och.common.module.wigets.OCHBorderShadowLayout
android:id="@+id/edge_view"
android:layout_width="716px"
android:layout_width="720px"
android:layout_height="match_parent"
app:shadowColor="@color/bus_p_route_view_left_edge_shadow"
app:xOffset="0px"

View File

@@ -66,6 +66,9 @@ public class TaxiPassengerMapDirectionView
List<BitmapDescriptor> textureList = new ArrayList<>();
List<Integer> texIndexList = new ArrayList<>();
private BitmapDescriptor mArrivedRes;
private BitmapDescriptor mUnArrivedRes;
private ITaxiPassengerMapViewCallback mITaxiPassengerMapViewCallback;
public TaxiPassengerMapDirectionView(Context context) {
@@ -129,6 +132,9 @@ public class TaxiPassengerMapDirectionView
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_view_dir_end)));
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived);
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive);
// 加载自定义样式
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
.setEnable(true)
@@ -189,7 +195,7 @@ public class TaxiPassengerMapDirectionView
boundsBuilder.include(endLatLng);
//第二个参数为四周留空宽度
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100,100,100,100));
CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
} else {
//设置希望展示的地图缩放级别
@@ -240,9 +246,7 @@ public class TaxiPassengerMapDirectionView
//设置线段纹理
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.addAll(mCoordinatesLatLng);
//polylineOptions.colorValues(colorList); // 1FC3FF -> 57ABFF
//加上这个属性,表示使用渐变线
//polylineOptions.useGradient(true);
polylineOptions.setUseTexture(true);
polylineOptions.width(15);
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
polylineOptions.setCustomTextureList(textureList);
@@ -264,9 +268,9 @@ public class TaxiPassengerMapDirectionView
texIndexList.clear();
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
if (i <= mHaveArrivedIndex){
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_arrived));
textureList.add(mArrivedRes);
}else {
textureList.add(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive));
textureList.add(mUnArrivedRes);
}
texIndexList.add(i);
}