This commit is contained in:
wangcongtao
2020-04-30 16:06:47 +08:00
parent 19fd34e7bc
commit 44db32023d
2 changed files with 68 additions and 32 deletions

View File

@@ -76,7 +76,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
private boolean mIsMarkerClicked = false;
private RefreshModel mRefreshModel;
private MogoLatLng mCarLatLng;
private int mCarSmoothDuration = 15;
// 平滑移动事件间隔(单位:秒)
private static final int SMOOTH_DURATION = 15;
private MapMarkerManager() {
}
@@ -490,17 +491,20 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
try {
// 在ACC on 之后第一次获取到了在线车辆数据选中最近的一个Marker
if (mIsAISearchOnlineData) {
if (mNearlyMarker != null) {
Logger.d(TAG, "语音搜索触发,默认选中最近的在线车辆:" + mNearlyMarker);
// 移动地图到指定位置
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(ServiceConst.TYPE, true, false);
MarkerServiceHandler.getMapUIController().moveToCenter(mNearlyMarker.getPosition());
onMarkerClicked(mNearlyMarker);
MogoMarkersHandler.getInstance().onMarkerClicked(mNearlyMarker);
mIsAISearchOnlineData = false;
}
if ( !mIsAISearchOnlineData ) {
return;
}
if ( mNearlyMarker == null ) {
return;
}
Logger.d(TAG, "语音搜索触发,默认选中最近的在线车辆:" + mNearlyMarker);
// 移动地图到指定位置
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(ServiceConst.TYPE, true, false);
MarkerServiceHandler.getMapUIController().moveToCenter(mNearlyMarker.getPosition());
onMarkerClicked(mNearlyMarker);
MogoMarkersHandler.getInstance().onMarkerClicked(mNearlyMarker);
mIsAISearchOnlineData = false;
} catch (Exception e) {
e.printStackTrace();
}
@@ -701,12 +705,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
// List<MarkerOnlineCar> onlineCarList = mLastDataResult.getOnlineCar();
List<MarkerExploreWay> exploreWayList = mLastDataResult.getExploreWay();
List<MarkerNoveltyInfo> noveltyInfoList = mLastDataResult.getNoveltyInfo();
// dispatchDataToBis(ServiceConst.CARD_TYPE_USER_DATA, onlineCarList == null ?
// new ArrayList<>() : onlineCarList);
dispatchDataToBis(ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList == null ?
new ArrayList<>() : exploreWayList);
dispatchDataToBis(ServiceConst.CARD_TYPE_NOVELTY, noveltyInfoList == null ?
new ArrayList<>() : noveltyInfoList);
// dispatchDataToBis(ServiceConst.CARD_TYPE_USER_DATA, onlineCarList == null ?new ArrayList<>() : onlineCarList);
dispatchDataToBis(ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList == null ? new ArrayList<>() : exploreWayList);
dispatchDataToBis(ServiceConst.CARD_TYPE_NOVELTY, noveltyInfoList == null ? new ArrayList<>() : noveltyInfoList);
}
/**
@@ -829,14 +830,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mCarLatLng = latlng;
getOnlineCarList();
UiThreadHandler.removeCallbacks(runnable);
UiThreadHandler.postDelayed(runnable, mCarSmoothDuration * 1000);
UiThreadHandler.postDelayed( runnable, SMOOTH_DURATION * 1000 );
}
private Runnable runnable = new Runnable() {
@Override
public void run() {
getOnlineCarList();
UiThreadHandler.postDelayed(this, mCarSmoothDuration * 1000);
UiThreadHandler.postDelayed( this, SMOOTH_DURATION * 1000 );
}
};
@@ -863,7 +864,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
if (MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() ){
return;
}
drawOnlineCarMarkers(onlineCarList, ServiceConst.MAX_AMOUNT_SINGLE_CARD);
runOnTargetThread( () -> {
drawOnlineCarMarkers( onlineCarList, ServiceConst.MAX_AMOUNT_SINGLE_CARD );
} );
}
@Override
@@ -899,28 +902,53 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
// 平滑移动
private void startSmooth(IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
MarkerLocation markerLocation) {
List<MarkerCarPois> poisList = markerOnlineCar.getPois();
if (poisList != null && poisList.size() > 0) {
// Logger.d(TAG, "坐标------"+markerLocation.getLon()+", "+markerLocation.getLat());
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
filterErrorPoint( poiList );
if ( poiList == null || poiList.size() < 2 ) {
return;
}
List<MogoLatLng> points = new ArrayList<>();
for (int j = 0; j < poisList.size(); j++) {
MarkerCarPois pois = poisList.get(j);
if (pois != null && pois.getCoordinates() != null && pois.getCoordinates().size() >= 2) {
// Logger.d(TAG, "坐标点:" + pois.getCoordinates().toString());
double lat = Double.valueOf(pois.getCoordinates().get(1) + "");
double lng = Double.valueOf(pois.getCoordinates().get(0) + "");
for ( int j = 0; j < poiList.size(); j++ ) {
MarkerCarPois poi = poiList.get( j );
if ( poi == null || poi.getCoordinates() == null && poi.getCoordinates().size() != 2 ) {
continue;
}
try {
double lat = Double.valueOf( poi.getCoordinates().get( 1 ) + "" );
double lng = Double.valueOf( poi.getCoordinates().get( 0 ) + "" );
points.add(new MogoLatLng(lat, lng));
} catch ( Exception e ) {
}
}
if (points.size() >= 1){
points.add(new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()));
iMogoMarker.startSmooth(points, mCarSmoothDuration);
iMogoMarker.startSmooth( points, SMOOTH_DURATION );
}
}
}
/**
* 有可能出现终点到起点跳跃的情况,需要用"500M"约束起点和终点
* @param poiList
*/
private void filterErrorPoint(List< MarkerCarPois > poiList){
if ( poiList == null || poiList.size() < 2 ) {
return;
}
MarkerCarPois start = poiList.get( 0 );
MarkerCarPois end = poiList.get( poiList.size() - 1 );
try {
double lat1 = Double.valueOf( start.getCoordinates().get( 1 ) + "" );
double lng1 = Double.valueOf( start.getCoordinates().get( 0 ) + "" );
double lat2 = Double.valueOf( end.getCoordinates().get( 1 ) + "" );
double lng2 = Double.valueOf( end.getCoordinates().get( 0 ) + "" );
if ( Utils.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) {
poiList.remove( poiList.size() - 1 );
}
} catch ( Exception e ) {
}
}
private boolean ignoreDrawRequest() {
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() || MarkerServiceHandler.getMogoStatusManager().isADASShow();