修复了bug

【在线车辆】每次启动,在线车辆卡片都会选择一辆车显示,但是这辆车根本不在周边,ACCON后应当默认不显示某一车辆的在线车辆卡片,或者选取最近车辆的在线车辆卡片也行
http://jira.zhidaohulian.com/browse/UI-372?jql=project%20%3D%20UI%20AND%20assignee%20in%20(donghongyu)%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC
This commit is contained in:
董宏宇
2020-02-21 22:21:34 +08:00
parent 50d4463ac6
commit 6bc17d181b
2 changed files with 19 additions and 8 deletions

View File

@@ -56,7 +56,7 @@ public class MarkerServiceHandler {
mMarkerManager = mMapService.getMarkerManager(context);
mNavi = mMapService.getNavi(context);
mMapUIController = mMapService.getMapUIController();
mLocationClient = mMapService.getLocationClient(context);
mLocationClient = mMapService.getSingletonLocationClient(context);
mMapMarkerManager = MapMarkerManager.getInstance(context);
mMapMarkerManager.init(context);

View File

@@ -15,6 +15,7 @@ import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -387,7 +388,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
noveltyInfoList = markerCardResult.getNoveltyInfo();
}
if (onlineCarList != null) {
double nearlyDistance = Double.MAX_VALUE;
double nearlyDistance = Float.MAX_VALUE;
for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
@@ -401,16 +402,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
// 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
try {
double calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
new MogoLatLng(
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLatitude(),
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLongitude()
)
// 当前车辆的位置
MogoLocation currentLocation = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
// 计算车辆距离指定气泡的距离
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
// Logger.d("点之间距离",
// "当前车辆经纬度:" +
// "\n\tlatitude=" + currentLocation.getLatitude() +
// "\n\tlongitude=" + currentLocation.getLongitude() +
// "\n气泡经纬度" + markerLocation +
// "\n相距" + calculateDistance + "米");
// 进行比较,保留最近的一个数据
if (calculateDistance < nearlyDistance) {
nearlyDistance = calculateDistance;
nearlyMogoMarker = iMogoMarker;
}
@@ -418,6 +428,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
e.printStackTrace();
}
}
Logger.d("点之间距离", "距离当前车辆位置最近的距离为:" + nearlyDistance);
fillNumberTrackEventBody(array, 3, onlineCarList.size());
}