[1.5.0] 1、解决bus乘客屏小地图闪烁 2、舍弃取两站间轨迹报错情况

This commit is contained in:
wangmingjun
2022-09-09 15:15:50 +08:00
parent 2e2c7612d7
commit 9f2d5d8fbf
2 changed files with 13 additions and 10 deletions

View File

@@ -432,7 +432,9 @@ public class BusPassengerModel {
//要前往的站在轨迹中对应的点
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndex(mRoutePoints
,stationNext.getGcjLon(),stationNext.getGcjLat());
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面直接舍弃这个轨迹不显示
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex));
}
}
}else { //只有两个站点的时候整个路线就是两个站点之间的轨迹
mTwoStationsRouts.clear();

View File

@@ -57,8 +57,8 @@ public class BusPassengerMapDirectionView
private int mCurrentIndex = -1;
private int zoomLevel = 13;
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
private List<LatLng> mLinePointsLatLng = new ArrayList<>();
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //站点坐标数据
private List<LatLng> mLinePointsLatLng = new ArrayList<>(); //轨迹坐标数据
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private Context mContext;
@@ -197,7 +197,7 @@ public class BusPassengerMapDirectionView
mCarMarker.setToTop();
}
if (mLinePointsLatLng.size() > 1){
if (mLinePointsLatLng.size() > 0){
//圈定地图显示范围
//存放经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
@@ -208,12 +208,13 @@ public class BusPassengerMapDirectionView
//第二个参数为四周留空宽度
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
}else {
//设置希望展示的地图缩放级别
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
// else {
// //设置希望展示的地图缩放级别
// CameraPosition cameraPosition = new CameraPosition.Builder()
// .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
// mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// }
}
@@ -368,7 +369,7 @@ public class BusPassengerMapDirectionView
mLinePointsLatLng.clear();
mLinePointsLatLng.addAll(routeLineLatLngs);
if (mCoordinatesLatLng.size() > 0 && mCurrentIndex != currentIndex) {
if (mLinePointsLatLng.size() > 0 && mCurrentIndex != currentIndex) {
if (mAMap != null && mLineMarkers.size() > 0) {
mCurrentIndex = currentIndex;
for (int i = 0; i < mLineMarkers.size(); i++) {