fix#更换道路事件3D资源
This commit is contained in:
@@ -9,7 +9,10 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarker3DResAdapter;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.common.drawer.marker.OnlineCarMarkerView;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
@@ -41,9 +44,9 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
public static MarkerDrawer getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MarkerDrawer.class ) {
|
||||
if ( sInstance == null ) {
|
||||
if (sInstance == null) {
|
||||
synchronized (MarkerDrawer.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MarkerDrawer();
|
||||
}
|
||||
}
|
||||
@@ -60,46 +63,61 @@ class MarkerDrawer {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl( markerShowEntity, false, zIndex, 0, listener );
|
||||
public IMogoMarker drawMapMarkerImpl(MarkerShowEntity markerShowEntity, int zIndex, IMogoMarkerClickListener listener) {
|
||||
return drawMapMarkerImpl(markerShowEntity, false, zIndex, 0, listener);
|
||||
}
|
||||
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, IMogoMarkerClickListener listener ) {
|
||||
return drawMapMarkerImpl( markerShowEntity, matchRoadSide, zIndex, 0, listener );
|
||||
public IMogoMarker drawMapMarkerImpl(MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, IMogoMarkerClickListener listener) {
|
||||
return drawMapMarkerImpl(markerShowEntity, matchRoadSide, zIndex, 0, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* add marker, {@link OnlineCarDrawer 如果是需要在3D模式下显示,则需要设置 {@link MogoMarkerOptions icon3DRes 资源id}}
|
||||
*
|
||||
* @param markerShowEntity marker展示数据结构体
|
||||
* @param matchRoadSide 设置是否道路吸附,暂时没用到这个字段
|
||||
* @param zIndex zOrder
|
||||
* @param icon3DRes 3D Res资源
|
||||
* @param listener marker回调
|
||||
* @param matchRoadSide 设置是否道路吸附,暂时没用到这个字段
|
||||
* @param zIndex zOrder
|
||||
* @param icon3DRes 3D Res资源
|
||||
* @param listener marker回调
|
||||
* @return {@link IMogoMarker}
|
||||
*/
|
||||
public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) {
|
||||
if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) {
|
||||
public IMogoMarker drawMapMarkerImpl(MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener) {
|
||||
if (markerShowEntity == null || markerShowEntity.getMarkerLocation() == null) {
|
||||
return null;
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).set3DMode(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()).matchOnRoadSide( matchRoadSide ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options );
|
||||
if ( markerView instanceof OnlineCarMarkerView ) {
|
||||
try {
|
||||
options.icon( markerView.getBitmap( ( ( MarkerOnlineCar ) markerShowEntity.getBindObj() ).getCarInfo().getVehicleType() ) );
|
||||
} catch ( Exception e ) {
|
||||
options.icon( markerView.getBitmap( 0 ) );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes(icon3DRes).set3DMode(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()).matchOnRoadSide(matchRoadSide).owner(markerShowEntity.getMarkerType()).zIndex(zIndex).object(markerShowEntity).latitude(markerShowEntity.getMarkerLocation().getLat()).longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
if (bindObj instanceof MarkerExploreWay && ((MarkerExploreWay) bindObj).getPoiType() != null) {
|
||||
String poiType = ((MarkerExploreWay) bindObj).getPoiType();
|
||||
options.icon3DRes(MapMarker3DResAdapter.getMarker3DRes(poiType));
|
||||
}
|
||||
options.anchor( 0.5f, 0.5f );
|
||||
|
||||
}
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView(AbsMogoApplication.getApp(), markerShowEntity, options);
|
||||
if (markerView instanceof OnlineCarMarkerView) {
|
||||
try {
|
||||
options.icon(markerView.getBitmap(((MarkerOnlineCar) markerShowEntity.getBindObj()).getCarInfo().getVehicleType()));
|
||||
} catch (Exception e) {
|
||||
options.icon(markerView.getBitmap(0));
|
||||
}
|
||||
options.anchor(0.5f, 0.5f);
|
||||
} else {
|
||||
options.icon( markerView.getView() );
|
||||
options.icon(markerView.getView());
|
||||
}
|
||||
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).addMarker( markerShowEntity.getMarkerType(), options );
|
||||
if ( marker != null ) {
|
||||
marker.setOwner( markerShowEntity.getMarkerType() );
|
||||
markerView.setMarker( marker );
|
||||
marker.setOnMarkerClickListener( listener );
|
||||
markerShowEntity.setMarker( marker );
|
||||
if (options.getIcon3DRes() != 0) {
|
||||
options.icon(new EmptyMarkerView(AbsMogoApplication.getApp()));
|
||||
options.icon(markerView.getBitmap(0));
|
||||
}
|
||||
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
if (marker != null) {
|
||||
marker.setOwner(markerShowEntity.getMarkerType());
|
||||
markerView.setMarker(marker);
|
||||
marker.setOnMarkerClickListener(listener);
|
||||
markerShowEntity.setMarker(marker);
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
@@ -111,42 +129,42 @@ class MarkerDrawer {
|
||||
* @param newList
|
||||
* @return
|
||||
*/
|
||||
public Map< String, IMogoMarker > purgeMarkerData( List newList, String markerType ) {
|
||||
public Map<String, IMogoMarker> purgeMarkerData(List newList, String markerType) {
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
Map< String, IMogoMarker > existMap = new HashMap<>();
|
||||
List< IMogoMarker > allCarsList = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).getMarkers( markerType );
|
||||
if ( allCarsList == null || allCarsList.isEmpty() ) {
|
||||
Map<String, IMogoMarker> existMap = new HashMap<>();
|
||||
List<IMogoMarker> allCarsList = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(AbsMogoApplication.getApp()).getMarkers(markerType);
|
||||
if (allCarsList == null || allCarsList.isEmpty()) {
|
||||
return existMap;
|
||||
}
|
||||
if ( newList == null || newList.isEmpty() ) {
|
||||
if (newList == null || newList.isEmpty()) {
|
||||
return existMap;
|
||||
}
|
||||
|
||||
Map< String, IMogoMarker > allMap = new HashMap<>();
|
||||
for ( IMogoMarker marker : allCarsList ) {
|
||||
String sn = getPrimaryKeyFromMarker( marker );
|
||||
allMap.put( sn, marker );
|
||||
Map<String, IMogoMarker> allMap = new HashMap<>();
|
||||
for (IMogoMarker marker : allCarsList) {
|
||||
String sn = getPrimaryKeyFromMarker(marker);
|
||||
allMap.put(sn, marker);
|
||||
}
|
||||
for ( Object entity : newList ) {
|
||||
String sn = getPrimaryKeyFromEntity( entity );
|
||||
if ( allMap.containsKey( sn ) ) {
|
||||
if ( !isNewVehicleType( entity, allMap.get( sn ) ) ) {
|
||||
existMap.put( sn, allMap.get( sn ) );
|
||||
for (Object entity : newList) {
|
||||
String sn = getPrimaryKeyFromEntity(entity);
|
||||
if (allMap.containsKey(sn)) {
|
||||
if (!isNewVehicleType(entity, allMap.get(sn))) {
|
||||
existMap.put(sn, allMap.get(sn));
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( String sn : allMap.keySet() ) {
|
||||
if ( !existMap.containsKey( sn ) ) {
|
||||
IMogoMarker dirtyMarker = allMap.get( sn );
|
||||
allCarsList.remove( dirtyMarker );
|
||||
if ( dirtyMarker != null ) {
|
||||
for (String sn : allMap.keySet()) {
|
||||
if (!existMap.containsKey(sn)) {
|
||||
IMogoMarker dirtyMarker = allMap.get(sn);
|
||||
allCarsList.remove(dirtyMarker);
|
||||
if (dirtyMarker != null) {
|
||||
dirtyMarker.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
allMap.clear();
|
||||
Logger.i( "timer", "purge data cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
Logger.i("timer", "purge data cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return existMap;
|
||||
}
|
||||
|
||||
@@ -156,74 +174,74 @@ class MarkerDrawer {
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public int getAppropriateSize( int maxAmount, List list ) {
|
||||
if ( list == null ) {
|
||||
public int getAppropriateSize(int maxAmount, List list) {
|
||||
if (list == null) {
|
||||
return 0;
|
||||
}
|
||||
return Math.min( maxAmount, list.size() );
|
||||
return Math.min(maxAmount, list.size());
|
||||
}
|
||||
|
||||
|
||||
private boolean isNewVehicleType( Object object, IMogoMarker marker ) {
|
||||
if ( object instanceof MarkerOnlineCar
|
||||
private boolean isNewVehicleType(Object object, IMogoMarker marker) {
|
||||
if (object instanceof MarkerOnlineCar
|
||||
&& marker != null
|
||||
&& marker.getObject() instanceof MarkerShowEntity
|
||||
&& ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() instanceof MarkerOnlineCar ) {
|
||||
&& ((MarkerShowEntity) marker.getObject()).getBindObj() instanceof MarkerOnlineCar) {
|
||||
try {
|
||||
return ( ( MarkerOnlineCar ) object ).getCarInfo().getVehicleType()
|
||||
!= ( ( MarkerOnlineCar ) ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() ).getCarInfo().getVehicleType();
|
||||
} catch ( Exception e ) {
|
||||
return ((MarkerOnlineCar) object).getCarInfo().getVehicleType()
|
||||
!= ((MarkerOnlineCar) ((MarkerShowEntity) marker.getObject()).getBindObj()).getCarInfo().getVehicleType();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getPrimaryKeyFromEntity( Object entity ) {
|
||||
if ( entity instanceof MarkerExploreWay ) {
|
||||
String id = ( ( MarkerExploreWay ) entity ).getInfoId();
|
||||
if ( !TextUtils.isEmpty( id ) ) {
|
||||
public String getPrimaryKeyFromEntity(Object entity) {
|
||||
if (entity instanceof MarkerExploreWay) {
|
||||
String id = ((MarkerExploreWay) entity).getInfoId();
|
||||
if (!TextUtils.isEmpty(id)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
return getCarSnFromEntity( entity );
|
||||
return getCarSnFromEntity(entity);
|
||||
}
|
||||
|
||||
private String getPrimaryKeyFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
private String getPrimaryKeyFromMarker(IMogoMarker marker) {
|
||||
if (marker == null || marker.getObject() == null || marker.isDestroyed()) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
if (!(marker.getObject() instanceof MarkerShowEntity)) {
|
||||
return null;
|
||||
}
|
||||
return getPrimaryKeyFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() );
|
||||
return getPrimaryKeyFromEntity(((MarkerShowEntity) marker.getObject()).getBindObj());
|
||||
}
|
||||
|
||||
private String getCarSnFromEntity( Object entity ) {
|
||||
private String getCarSnFromEntity(Object entity) {
|
||||
try {
|
||||
if ( entity instanceof MarkerOnlineCar ) {
|
||||
return ( ( MarkerOnlineCar ) entity ).getUserInfo().getSn();
|
||||
} else if ( entity instanceof MarkerShareMusic ) {
|
||||
return ( ( MarkerShareMusic ) entity ).getUserInfo().getSn();
|
||||
} else if ( entity instanceof MarkerNoveltyInfo ) {
|
||||
return ( ( MarkerNoveltyInfo ) entity ).getSn();
|
||||
} else if ( entity instanceof MarkerExploreWay ) {
|
||||
return ( ( MarkerExploreWay ) entity ).getUserInfo().getSn();
|
||||
if (entity instanceof MarkerOnlineCar) {
|
||||
return ((MarkerOnlineCar) entity).getUserInfo().getSn();
|
||||
} else if (entity instanceof MarkerShareMusic) {
|
||||
return ((MarkerShareMusic) entity).getUserInfo().getSn();
|
||||
} else if (entity instanceof MarkerNoveltyInfo) {
|
||||
return ((MarkerNoveltyInfo) entity).getSn();
|
||||
} else if (entity instanceof MarkerExploreWay) {
|
||||
return ((MarkerExploreWay) entity).getUserInfo().getSn();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getCarSnFromMarker( IMogoMarker marker ) {
|
||||
if ( marker == null || marker.getObject() == null || marker.isDestroyed() ) {
|
||||
public String getCarSnFromMarker(IMogoMarker marker) {
|
||||
if (marker == null || marker.getObject() == null || marker.isDestroyed()) {
|
||||
return null;
|
||||
}
|
||||
if ( !( marker.getObject() instanceof MarkerShowEntity ) ) {
|
||||
if (!(marker.getObject() instanceof MarkerShowEntity)) {
|
||||
return null;
|
||||
}
|
||||
return getCarSnFromEntity( ( ( MarkerShowEntity ) marker.getObject() ).getBindObj() );
|
||||
return getCarSnFromEntity(((MarkerShowEntity) marker.getObject()).getBindObj());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,9 +251,9 @@ class MarkerDrawer {
|
||||
* @param point2 点二坐标
|
||||
* @return 两坐标的距离 单位:米(M)
|
||||
*/
|
||||
public static float calculateLineDistance( MogoLatLng point1, MogoLatLng point2 ) {
|
||||
if ( point1 != null && point2 != null ) {
|
||||
return calculateLineDistance( point1.lon, point1.lat, point2.lon, point2.lat );
|
||||
public static float calculateLineDistance(MogoLatLng point1, MogoLatLng point2) {
|
||||
if (point1 != null && point2 != null) {
|
||||
return calculateLineDistance(point1.lon, point1.lat, point2.lon, point2.lat);
|
||||
} else {
|
||||
return 0.0F;
|
||||
}
|
||||
@@ -248,7 +266,7 @@ class MarkerDrawer {
|
||||
* @param lat2
|
||||
* @return 两坐标的距离 单位:米(M)
|
||||
*/
|
||||
public static float calculateLineDistance( double lon1, double lat1, double lon2, double lat2 ) {
|
||||
return CoordinateUtils.calculateLineDistance( lon1, lat1, lon2, lat2 );
|
||||
public static float calculateLineDistance(double lon1, double lat1, double lon2, double lat2) {
|
||||
return CoordinateUtils.calculateLineDistance(lon1, lat1, lon2, lat2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ class RoadConditionDrawer {
|
||||
try {
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, true, MarkerDrawer.MARKER_Z_INDEX_HIGH, listener );
|
||||
mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
|
||||
mogoMarker.showInfoWindow();
|
||||
// mogoMarker.setInfoWindowAdapter( new RoadConditionInfoWindow3DAdapter( markerShowEntity, AbsMogoApplication.getApp(), mogoMarker.getMogoMarkerOptions() ) );
|
||||
// mogoMarker.showInfoWindow();
|
||||
} else {
|
||||
if ( DebugConfig.isRoadEventAnimated() ) {
|
||||
post2AddAndStartAnimation( markerShowEntity, i * 100L, listener );
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mogo.module.common.drawer.marker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_ACCIDENT;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_BLOCK_UP;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_FOG;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_ICE;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_LIVING;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_PONDING;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.FOURS_ROAD_WORK;
|
||||
import static com.mogo.module.common.entity.MarkerPoiTypeEnum.TRAFFIC_CHECK;
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/4/28 18:04
|
||||
* describe:地图Marker的3d资源适配器
|
||||
*/
|
||||
public class MapMarker3DResAdapter {
|
||||
|
||||
public static int getMarker3DRes(String poiType) {
|
||||
int res = 0;
|
||||
switch (poiType) {
|
||||
case FOURS_BLOCK_UP:
|
||||
res = R.raw.v2x_yongdu;
|
||||
break;
|
||||
case FOURS_ACCIDENT:
|
||||
res = R.raw.v2x_shigu;
|
||||
break;
|
||||
case FOURS_LIVING:
|
||||
res = R.raw.v2x_shishilukuang;
|
||||
break;
|
||||
case FOURS_FOG:
|
||||
res = R.raw.v2x_nongwu;
|
||||
break;
|
||||
case TRAFFIC_CHECK:
|
||||
res = R.raw.v2x_jiaotongjiancha;
|
||||
break;
|
||||
case FOURS_ROAD_WORK:
|
||||
res = R.raw.v2x_daolushigong;
|
||||
break;
|
||||
case FOURS_ICE:
|
||||
res = R.raw.v2x_daolujiebing;
|
||||
break;
|
||||
case FOURS_PONDING:
|
||||
res = R.raw.v2x_daolujishui;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user