代码优化
This commit is contained in:
@@ -93,7 +93,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
|
||||
@Override
|
||||
public IMogoMapView getMapView( Context context ) {
|
||||
NavAutoApi.INSTANCE.init( context, MapParams.Companion.init()
|
||||
.setDebugMode( false )
|
||||
.setDebugMode( true )
|
||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||
.setZoom( 20 )
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.map.impl.custom.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
@@ -23,7 +22,6 @@ import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerScaleAnimation;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerTranslateAnimation;
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools;
|
||||
|
||||
@@ -542,4 +540,15 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerResName() {
|
||||
if ( mMarker != null ) {
|
||||
try {
|
||||
return mMarker.getMarkeOptions().getMarkerIconName();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,95 +53,100 @@ import java.util.List;
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
public static MarkerOptions fromMogo(MogoMarkerOptions opt) {
|
||||
public static MarkerOptions fromMogo( MogoMarkerOptions opt ) {
|
||||
|
||||
if (opt == null) {
|
||||
if ( opt == null ) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<BitmapDescriptor> descriptors = new ArrayList<>();
|
||||
final ArrayList<Bitmap> icons = opt.getIcons();
|
||||
if (icons != null && !icons.isEmpty()) {
|
||||
for (Bitmap icon : icons) {
|
||||
if (icon == null || icon.isRecycled()) {
|
||||
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
|
||||
final ArrayList< Bitmap > icons = opt.getIcons();
|
||||
if ( icons != null && !icons.isEmpty() ) {
|
||||
for ( Bitmap icon : icons ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
descriptors.add(new BitmapDescriptor(icon));
|
||||
descriptors.add( new BitmapDescriptor( icon ) );
|
||||
}
|
||||
}
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(new LonLatPoint(opt.getLongitude(), opt.getLatitude()))
|
||||
.anchor(opt.getU(), opt.getV())
|
||||
.position( new LonLatPoint( opt.getLongitude(), opt.getLatitude() ) )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
.icons( descriptors )
|
||||
.period( opt.getPeriod() )
|
||||
.controlAngle( opt.isControlAngle() )
|
||||
.rotateAngle(opt.getRotate())
|
||||
.setFlat(opt.isFlat())
|
||||
.visible(opt.isVisible())
|
||||
.infoWindowEnable(opt.isInifoWindowEnable())
|
||||
.alpha(opt.getAlpha())
|
||||
.setGps(opt.isGps())
|
||||
.rotateAngle( opt.getRotate() )
|
||||
.setFlat( opt.isFlat() )
|
||||
.visible( opt.isVisible() )
|
||||
.infoWindowEnable( opt.isInifoWindowEnable() )
|
||||
.alpha( opt.getAlpha() )
|
||||
.setGps( opt.isGps() )
|
||||
// .draggable( opt.isDraggable() )
|
||||
.setInfoWindowOffset(opt.getOffsetX(), opt.getOffsetY())
|
||||
.zIndex(opt.getzIndex());
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt);
|
||||
if (descriptor != null) {
|
||||
markerOptions.markerIcon(descriptor);
|
||||
}
|
||||
if (opt.getIcon3DRes() != 0) {
|
||||
markerOptions.marker3DIcon(opt.getIcon3DRes());
|
||||
try {
|
||||
Color.parseColor(opt.getAnchorColor());
|
||||
markerOptions.anchorColor( opt.getAnchorColor() );
|
||||
} catch ( Exception e ) {
|
||||
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
|
||||
.zIndex( opt.getzIndex() );
|
||||
if ( !TextUtils.isEmpty( opt.getResName() )) {
|
||||
markerOptions.setMarkerIconName( opt.getResName() );
|
||||
markerOptions.vrEnable( opt.is3DMode() );
|
||||
} else {
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||
if ( descriptor != null ) {
|
||||
markerOptions.markerIcon( descriptor );
|
||||
}
|
||||
if ( opt.getIcon3DRes() != 0 ) {
|
||||
markerOptions.marker3DIcon( opt.getIcon3DRes() );
|
||||
try {
|
||||
Color.parseColor( opt.getAnchorColor() );
|
||||
markerOptions.anchorColor( opt.getAnchorColor() );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getTitle())) {
|
||||
markerOptions.title(opt.getTitle());
|
||||
if ( !TextUtils.isEmpty( opt.getTitle() ) ) {
|
||||
markerOptions.title( opt.getTitle() );
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getSnippet())) {
|
||||
markerOptions.snippet(opt.getSnippet());
|
||||
if ( !TextUtils.isEmpty( opt.getSnippet() ) ) {
|
||||
markerOptions.snippet( opt.getSnippet() );
|
||||
}
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) {
|
||||
if (options == null) {
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo( MogoMarkerOptions options ) {
|
||||
if ( options == null ) {
|
||||
return null;
|
||||
}
|
||||
Bitmap icon = options.getIcon();
|
||||
if (icon != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
|
||||
if ( icon != null ) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap( icon );
|
||||
}
|
||||
View view = options.getIconView();
|
||||
if (view != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromView(view);
|
||||
if ( view != null ) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromView( view );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static MogoLocation fromLocation(com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation) {
|
||||
if (aLocation == null) {
|
||||
public static MogoLocation fromLocation( com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation ) {
|
||||
if ( aLocation == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoLocation location = new MogoLocation();
|
||||
// location.setLocType( aLocation.getLocationType() );
|
||||
location.setSpeed(aLocation.getSpeed());
|
||||
location.setLatitude(aLocation.getLat());
|
||||
location.setLongitude(aLocation.getLon());
|
||||
location.setAltitude(aLocation.getAltitude());
|
||||
location.setSpeed( aLocation.getSpeed() );
|
||||
location.setLatitude( aLocation.getLat() );
|
||||
location.setLongitude( aLocation.getLon() );
|
||||
location.setAltitude( aLocation.getAltitude() );
|
||||
// location.setTime( aLocation.getTime() );
|
||||
location.setBearing(aLocation.getHeading());
|
||||
location.setBearing( aLocation.getHeading() );
|
||||
// location.setAccuracy( aLocation.getAccuracy() );
|
||||
location.setCityCode(aLocation.getCityCode());
|
||||
location.setCityName(aLocation.getCity());
|
||||
location.setProvider(aLocation.getProvider());
|
||||
location.setAddress(aLocation.getAddress());
|
||||
location.setDistrict(aLocation.getDistrict());
|
||||
location.setProvince(aLocation.getProvince());
|
||||
location.setAdCode(aLocation.getAdCode());
|
||||
location.setCityCode( aLocation.getCityCode() );
|
||||
location.setCityName( aLocation.getCity() );
|
||||
location.setProvider( aLocation.getProvider() );
|
||||
location.setAddress( aLocation.getAddress() );
|
||||
location.setDistrict( aLocation.getDistrict() );
|
||||
location.setProvince( aLocation.getProvince() );
|
||||
location.setAdCode( aLocation.getAdCode() );
|
||||
// location.setLocationDetail( aLocation.getLocationDetail() );
|
||||
// location.setPoiName( aLocation.getPoiName() );
|
||||
// location.setAoiName( aLocation.getAoiName() );
|
||||
@@ -156,11 +161,11 @@ public class ObjectUtils {
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LonLatPoint fromMogo(MogoLatLng latLng) {
|
||||
if (latLng == null) {
|
||||
public static LonLatPoint fromMogo( MogoLatLng latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new LonLatPoint(latLng.lon, latLng.lat);
|
||||
return new LonLatPoint( latLng.lon, latLng.lat );
|
||||
}
|
||||
|
||||
// public static NaviLatLng fromMogoAsNavi( MogoLatLng latLng ) {
|
||||
@@ -177,11 +182,11 @@ public class ObjectUtils {
|
||||
// return new LatLng( latLng.lat, latLng.lng );
|
||||
// }
|
||||
|
||||
public static MogoLatLng fromAMap(LonLatPoint point) {
|
||||
if (point == null) {
|
||||
public static MogoLatLng fromAMap( LonLatPoint point ) {
|
||||
if ( point == null ) {
|
||||
return null;
|
||||
}
|
||||
return new MogoLatLng(point.getLatitude(), point.getLongitude());
|
||||
return new MogoLatLng( point.getLatitude(), point.getLongitude() );
|
||||
}
|
||||
|
||||
// public static MogoLatLng CameraPositionfromAMap( LatLng point ) {
|
||||
@@ -191,19 +196,19 @@ public class ObjectUtils {
|
||||
// return new MogoLatLng( point.latitude, point.longitude );
|
||||
// }
|
||||
|
||||
public static GeocodeQuery fromMogo(MogoGeocodeQuery query) {
|
||||
if (query == null) {
|
||||
public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
}
|
||||
GeocodeQuery q = new GeocodeQuery(query.getLocationName(), query.getCity());
|
||||
GeocodeQuery q = new GeocodeQuery( query.getLocationName(), query.getCity() );
|
||||
return q;
|
||||
}
|
||||
|
||||
public static RegeocodeQuery fromMogo(MogoRegeocodeQuery query) {
|
||||
if (query == null) {
|
||||
public static RegeocodeQuery fromMogo( MogoRegeocodeQuery query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
}
|
||||
RegeocodeQuery q = new RegeocodeQuery(fromMogo(query.getPoint()), 1000);
|
||||
RegeocodeQuery q = new RegeocodeQuery( fromMogo( query.getPoint() ), 1000 );
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -245,39 +250,39 @@ public class ObjectUtils {
|
||||
// return mogoCrossroad;
|
||||
// }
|
||||
|
||||
public static MogoGeocodeAddress fromAMap(GeocodeAddress address) {
|
||||
if (address == null) {
|
||||
public static MogoGeocodeAddress fromAMap( GeocodeAddress address ) {
|
||||
if ( address == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoGeocodeAddress mogoGeocodeAddress = new MogoGeocodeAddress();
|
||||
mogoGeocodeAddress.setAdcode(address.getAdcode());
|
||||
mogoGeocodeAddress.setBuilding(address.getBuilding());
|
||||
mogoGeocodeAddress.setCity(address.getCity());
|
||||
mogoGeocodeAddress.setDistrict(address.getDistrict());
|
||||
mogoGeocodeAddress.setFormatAddress(address.getFormatAddress());
|
||||
mogoGeocodeAddress.setLatlng(fromAMap(address.getLonlat()));
|
||||
mogoGeocodeAddress.setLevel(address.getLevel());
|
||||
mogoGeocodeAddress.setNeighborhood(address.getNeighborhood());
|
||||
mogoGeocodeAddress.setProvince(address.getProvince());
|
||||
mogoGeocodeAddress.setTownship(address.getTownship());
|
||||
mogoGeocodeAddress.setAdcode( address.getAdcode() );
|
||||
mogoGeocodeAddress.setBuilding( address.getBuilding() );
|
||||
mogoGeocodeAddress.setCity( address.getCity() );
|
||||
mogoGeocodeAddress.setDistrict( address.getDistrict() );
|
||||
mogoGeocodeAddress.setFormatAddress( address.getFormatAddress() );
|
||||
mogoGeocodeAddress.setLatlng( fromAMap( address.getLonlat() ) );
|
||||
mogoGeocodeAddress.setLevel( address.getLevel() );
|
||||
mogoGeocodeAddress.setNeighborhood( address.getNeighborhood() );
|
||||
mogoGeocodeAddress.setProvince( address.getProvince() );
|
||||
mogoGeocodeAddress.setTownship( address.getTownship() );
|
||||
return mogoGeocodeAddress;
|
||||
}
|
||||
|
||||
public static MogoGeocodeResult fromAMap(GeocodeResult result) {
|
||||
if (result == null || result.getGeocodeAddressList() == null) {
|
||||
public static MogoGeocodeResult fromAMap( GeocodeResult result ) {
|
||||
if ( result == null || result.getGeocodeAddressList() == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoGeocodeResult mogoGeocodeResult = new MogoGeocodeResult();
|
||||
final List<MogoGeocodeAddress> addresses = new ArrayList<>();
|
||||
List<GeocodeAddress> list = result.getGeocodeAddressList();
|
||||
for (GeocodeAddress geocodeAddress : list) {
|
||||
final MogoGeocodeAddress mogoGeocodeAddress = fromAMap(geocodeAddress);
|
||||
if (mogoGeocodeAddress != null) {
|
||||
addresses.add(mogoGeocodeAddress);
|
||||
final List< MogoGeocodeAddress > addresses = new ArrayList<>();
|
||||
List< GeocodeAddress > list = result.getGeocodeAddressList();
|
||||
for ( GeocodeAddress geocodeAddress : list ) {
|
||||
final MogoGeocodeAddress mogoGeocodeAddress = fromAMap( geocodeAddress );
|
||||
if ( mogoGeocodeAddress != null ) {
|
||||
addresses.add( mogoGeocodeAddress );
|
||||
}
|
||||
}
|
||||
|
||||
mogoGeocodeResult.setAddresses(addresses);
|
||||
mogoGeocodeResult.setAddresses( addresses );
|
||||
return mogoGeocodeResult;
|
||||
}
|
||||
|
||||
@@ -353,23 +358,23 @@ public class ObjectUtils {
|
||||
// return mogoSubPoiItem;
|
||||
// }
|
||||
|
||||
public static MogoPoiItem fromAMap(PoiItem poiItem) {
|
||||
if (poiItem == null) {
|
||||
public static MogoPoiItem fromAMap( PoiItem poiItem ) {
|
||||
if ( poiItem == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoPoiItem mogoPoiItem = new MogoPoiItem();
|
||||
mogoPoiItem.setAdCode(poiItem.getAdCode());
|
||||
mogoPoiItem.setAdName(poiItem.getAdName());
|
||||
mogoPoiItem.setBusinessArea(poiItem.getBusinessArea());
|
||||
mogoPoiItem.setCityCode(poiItem.getCityCode());
|
||||
mogoPoiItem.setCityName(poiItem.getCityName());
|
||||
mogoPoiItem.setDirection(poiItem.getDirection());
|
||||
mogoPoiItem.setDistance(poiItem.getDistance());
|
||||
mogoPoiItem.setEmail(poiItem.getEmail());
|
||||
mogoPoiItem.setEnter(fromAMap(poiItem.getEnter()));
|
||||
mogoPoiItem.setExit(fromAMap(poiItem.getExit()));
|
||||
mogoPoiItem.setAdCode( poiItem.getAdCode() );
|
||||
mogoPoiItem.setAdName( poiItem.getAdName() );
|
||||
mogoPoiItem.setBusinessArea( poiItem.getBusinessArea() );
|
||||
mogoPoiItem.setCityCode( poiItem.getCityCode() );
|
||||
mogoPoiItem.setCityName( poiItem.getCityName() );
|
||||
mogoPoiItem.setDirection( poiItem.getDirection() );
|
||||
mogoPoiItem.setDistance( poiItem.getDistance() );
|
||||
mogoPoiItem.setEmail( poiItem.getEmail() );
|
||||
mogoPoiItem.setEnter( fromAMap( poiItem.getEnter() ) );
|
||||
mogoPoiItem.setExit( fromAMap( poiItem.getExit() ) );
|
||||
// mogoPoiItem.setIndoorData( fromAMap( poiItem.getIndoorData() ) );
|
||||
mogoPoiItem.setParkingType(poiItem.getParkingType());
|
||||
mogoPoiItem.setParkingType( poiItem.getParkingType() );
|
||||
// mogoPoiItem.setIndoorMap( poiItem.isIndoorMap() );
|
||||
// if ( poiItem.getPhotos() != null ) {
|
||||
// List< MogoPhoto > mogoPhotos = new ArrayList<>();
|
||||
@@ -382,13 +387,13 @@ public class ObjectUtils {
|
||||
// mogoPoiItem.setPhotos( mogoPhotos );
|
||||
// }
|
||||
// mogoPoiItem.setPoiExtension( fromAMap( poiItem.getPoiExtension() ) );
|
||||
mogoPoiItem.setPoiId(poiItem.getPoiId());
|
||||
mogoPoiItem.setPoint(fromAMap(poiItem.getLonLatPoint()));
|
||||
mogoPoiItem.setPostcode(poiItem.getPostcode());
|
||||
mogoPoiItem.setProvinceCode(poiItem.getProvinceCode());
|
||||
mogoPoiItem.setProvinceName(poiItem.getProvinceName());
|
||||
mogoPoiItem.setShopID(poiItem.getShopID());
|
||||
mogoPoiItem.setSnippet(poiItem.getSnippet());
|
||||
mogoPoiItem.setPoiId( poiItem.getPoiId() );
|
||||
mogoPoiItem.setPoint( fromAMap( poiItem.getLonLatPoint() ) );
|
||||
mogoPoiItem.setPostcode( poiItem.getPostcode() );
|
||||
mogoPoiItem.setProvinceCode( poiItem.getProvinceCode() );
|
||||
mogoPoiItem.setProvinceName( poiItem.getProvinceName() );
|
||||
mogoPoiItem.setShopID( poiItem.getShopID() );
|
||||
mogoPoiItem.setSnippet( poiItem.getSnippet() );
|
||||
// if ( poiItem.getSubPois() != null ) {
|
||||
// List< MogoSubPoiItem > mogoSubPoiItems = new ArrayList<>();
|
||||
// for ( SubPoiItem subPois : poiItem.getSubPois() ) {
|
||||
@@ -399,20 +404,20 @@ public class ObjectUtils {
|
||||
// }
|
||||
// mogoPoiItem.setSubPois( mogoSubPoiItems );
|
||||
// }
|
||||
mogoPoiItem.setTel(poiItem.getTel());
|
||||
mogoPoiItem.setTypeCode(poiItem.getTypeCode());
|
||||
mogoPoiItem.setTitle(poiItem.getTitle());
|
||||
mogoPoiItem.setTypeDes(poiItem.getTypeDes());
|
||||
mogoPoiItem.setWebsite(poiItem.getWebsite());
|
||||
mogoPoiItem.setTel( poiItem.getTel() );
|
||||
mogoPoiItem.setTypeCode( poiItem.getTypeCode() );
|
||||
mogoPoiItem.setTitle( poiItem.getTitle() );
|
||||
mogoPoiItem.setTypeDes( poiItem.getTypeDes() );
|
||||
mogoPoiItem.setWebsite( poiItem.getWebsite() );
|
||||
return mogoPoiItem;
|
||||
}
|
||||
|
||||
public static MogoRegeocodeAddress fromAMap(RegeocodeAddress regeocodeAddress) {
|
||||
if (regeocodeAddress == null) {
|
||||
public static MogoRegeocodeAddress fromAMap( RegeocodeAddress regeocodeAddress ) {
|
||||
if ( regeocodeAddress == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoRegeocodeAddress mogoRegeocodeAddress = new MogoRegeocodeAddress();
|
||||
mogoRegeocodeAddress.setAdCode(regeocodeAddress.getAdCode());
|
||||
mogoRegeocodeAddress.setAdCode( regeocodeAddress.getAdCode() );
|
||||
// if ( regeocodeAddress.getAois() != null ) {
|
||||
// List< MogoAoiItem > items = new ArrayList<>();
|
||||
// for ( AoiItem aois : regeocodeAddress.getAois() ) {
|
||||
@@ -424,7 +429,7 @@ public class ObjectUtils {
|
||||
// mogoRegeocodeAddress.setAois( items );
|
||||
// }
|
||||
|
||||
mogoRegeocodeAddress.setBuilding(regeocodeAddress.getBuilding());
|
||||
mogoRegeocodeAddress.setBuilding( regeocodeAddress.getBuilding() );
|
||||
// if ( regeocodeAddress.getBusinessAreas() != null ) {
|
||||
// List< MogoBusinessArea > mogoBusinessAreas = new ArrayList<>();
|
||||
// for ( BusinessArea businessArea : regeocodeAddress.getBusinessAreas() ) {
|
||||
@@ -436,9 +441,9 @@ public class ObjectUtils {
|
||||
// mogoRegeocodeAddress.setBusinessAreas( mogoBusinessAreas );
|
||||
// }
|
||||
|
||||
mogoRegeocodeAddress.setCity(regeocodeAddress.getCity());
|
||||
mogoRegeocodeAddress.setCityCode(regeocodeAddress.getCityCode());
|
||||
mogoRegeocodeAddress.setCountry(regeocodeAddress.getCountry());
|
||||
mogoRegeocodeAddress.setCity( regeocodeAddress.getCity() );
|
||||
mogoRegeocodeAddress.setCityCode( regeocodeAddress.getCityCode() );
|
||||
mogoRegeocodeAddress.setCountry( regeocodeAddress.getCountry() );
|
||||
// if ( regeocodeAddress.getCrossroads() != null ) {
|
||||
// List< MogoCrossroad > mogoCrossroads = new ArrayList<>();
|
||||
// for ( Crossroad crossroad : regeocodeAddress.getCrossroads() ) {
|
||||
@@ -450,19 +455,19 @@ public class ObjectUtils {
|
||||
// }
|
||||
// mogoRegeocodeAddress.setCrossroads( mogoCrossroads );
|
||||
// }
|
||||
mogoRegeocodeAddress.setDistrict(regeocodeAddress.getDistrict());
|
||||
mogoRegeocodeAddress.setFormatAddress(regeocodeAddress.getFormatAddress());
|
||||
mogoRegeocodeAddress.setNeighborhood(regeocodeAddress.getNeighborhood());
|
||||
if (regeocodeAddress.getPoiList() != null) {
|
||||
List<MogoPoiItem> mogoPoiItems = new ArrayList<>();
|
||||
List<PoiItem> list = regeocodeAddress.getPoiList();
|
||||
for (PoiItem pois : list) {
|
||||
MogoPoiItem mogoPoiItem = fromAMap(pois);
|
||||
mogoPoiItems.add(mogoPoiItem);
|
||||
mogoRegeocodeAddress.setDistrict( regeocodeAddress.getDistrict() );
|
||||
mogoRegeocodeAddress.setFormatAddress( regeocodeAddress.getFormatAddress() );
|
||||
mogoRegeocodeAddress.setNeighborhood( regeocodeAddress.getNeighborhood() );
|
||||
if ( regeocodeAddress.getPoiList() != null ) {
|
||||
List< MogoPoiItem > mogoPoiItems = new ArrayList<>();
|
||||
List< PoiItem > list = regeocodeAddress.getPoiList();
|
||||
for ( PoiItem pois : list ) {
|
||||
MogoPoiItem mogoPoiItem = fromAMap( pois );
|
||||
mogoPoiItems.add( mogoPoiItem );
|
||||
}
|
||||
mogoRegeocodeAddress.setPois(mogoPoiItems);
|
||||
mogoRegeocodeAddress.setPois( mogoPoiItems );
|
||||
}
|
||||
mogoRegeocodeAddress.setProvince(regeocodeAddress.getProvince());
|
||||
mogoRegeocodeAddress.setProvince( regeocodeAddress.getProvince() );
|
||||
// if ( regeocodeAddress.getRoads() != null ) {
|
||||
// List< MogoRegeocodeRoad > mogoRegeocodeRoads = new ArrayList<>();
|
||||
// for ( RegeocodeRoad road : regeocodeAddress.getRoads() ) {
|
||||
@@ -474,43 +479,43 @@ public class ObjectUtils {
|
||||
// mogoRegeocodeAddress.setRoads( mogoRegeocodeRoads );
|
||||
// }
|
||||
// mogoRegeocodeAddress.setStreetNumber( fromAMap( regeocodeAddress.getStreetNumber() ) );
|
||||
mogoRegeocodeAddress.setTowncode(regeocodeAddress.getTowncode());
|
||||
mogoRegeocodeAddress.setTownship(regeocodeAddress.getTownship());
|
||||
mogoRegeocodeAddress.setTowncode( regeocodeAddress.getTowncode() );
|
||||
mogoRegeocodeAddress.setTownship( regeocodeAddress.getTownship() );
|
||||
return mogoRegeocodeAddress;
|
||||
}
|
||||
|
||||
public static MogoRegeocodeResult fromAMap(RegeocodeResult regeocodeResult) {
|
||||
if (regeocodeResult == null) {
|
||||
public static MogoRegeocodeResult fromAMap( RegeocodeResult regeocodeResult ) {
|
||||
if ( regeocodeResult == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoRegeocodeResult mogoRegeocodeResult = new MogoRegeocodeResult();
|
||||
mogoRegeocodeResult.setRegeocodeAddress(fromAMap(regeocodeResult.getRegeocodeAddress()));
|
||||
mogoRegeocodeResult.setRegeocodeAddress( fromAMap( regeocodeResult.getRegeocodeAddress() ) );
|
||||
return mogoRegeocodeResult;
|
||||
}
|
||||
|
||||
public static InputtipsQuery fromMogo(MogoInputtipsQuery query) {
|
||||
if (query == null) {
|
||||
public static InputtipsQuery fromMogo( MogoInputtipsQuery query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
}
|
||||
InputtipsQuery inputtipsQuery = new InputtipsQuery(query.getKeyword(), query.getCity());
|
||||
inputtipsQuery.setCityLimit(query.isCityLimit());
|
||||
inputtipsQuery.setLocation(fromMogo(query.getLocation()));
|
||||
inputtipsQuery.setType(query.getType());
|
||||
InputtipsQuery inputtipsQuery = new InputtipsQuery( query.getKeyword(), query.getCity() );
|
||||
inputtipsQuery.setCityLimit( query.isCityLimit() );
|
||||
inputtipsQuery.setLocation( fromMogo( query.getLocation() ) );
|
||||
inputtipsQuery.setType( query.getType() );
|
||||
return inputtipsQuery;
|
||||
}
|
||||
|
||||
public static MogoTip fromAMap(Tip tip) {
|
||||
if (tip == null) {
|
||||
public static MogoTip fromAMap( Tip tip ) {
|
||||
if ( tip == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoTip mogoTip = new MogoTip();
|
||||
mogoTip.setAdCode(tip.getAdcode());
|
||||
mogoTip.setAddress(tip.getAddress());
|
||||
mogoTip.setDistrict(tip.getDistrict());
|
||||
mogoTip.setName(tip.getName());
|
||||
mogoTip.setPoiID(tip.getPoiID());
|
||||
mogoTip.setPoint(fromAMap(tip.getLatPoint()));
|
||||
mogoTip.setTypeCode(tip.getTypeCode());
|
||||
mogoTip.setAdCode( tip.getAdcode() );
|
||||
mogoTip.setAddress( tip.getAddress() );
|
||||
mogoTip.setDistrict( tip.getDistrict() );
|
||||
mogoTip.setName( tip.getName() );
|
||||
mogoTip.setPoiID( tip.getPoiID() );
|
||||
mogoTip.setPoint( fromAMap( tip.getLatPoint() ) );
|
||||
mogoTip.setTypeCode( tip.getTypeCode() );
|
||||
return mogoTip;
|
||||
}
|
||||
|
||||
@@ -525,100 +530,100 @@ public class ObjectUtils {
|
||||
// return mogoPoi;
|
||||
// }
|
||||
|
||||
public static MogoPoiSearchQuery fromAMap(Query query) {
|
||||
if (query == null) {
|
||||
public static MogoPoiSearchQuery fromAMap( Query query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery(query.getKeyword(), query.getCategory(), query.getCity());
|
||||
MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery( query.getKeyword(), query.getCategory(), query.getCity() );
|
||||
// mogoPoiSearchQuery.setBuilding( query.getBuilding() );
|
||||
mogoPoiSearchQuery.setCityLimit(query.getCityLimit());
|
||||
mogoPoiSearchQuery.setDistanceSort(query.getDistanceSort());
|
||||
mogoPoiSearchQuery.setLocation(fromAMap(query.getLocation()));
|
||||
mogoPoiSearchQuery.setPageNum(query.getPageNum());
|
||||
mogoPoiSearchQuery.setPageSize(query.getPageSize());
|
||||
mogoPoiSearchQuery.setCityLimit( query.getCityLimit() );
|
||||
mogoPoiSearchQuery.setDistanceSort( query.getDistanceSort() );
|
||||
mogoPoiSearchQuery.setLocation( fromAMap( query.getLocation() ) );
|
||||
mogoPoiSearchQuery.setPageNum( query.getPageNum() );
|
||||
mogoPoiSearchQuery.setPageSize( query.getPageSize() );
|
||||
return mogoPoiSearchQuery;
|
||||
}
|
||||
|
||||
public static Query fromMogo(MogoPoiSearchQuery query) {
|
||||
if (query == null || query.getQuery() == null) {
|
||||
public static Query fromMogo( MogoPoiSearchQuery query ) {
|
||||
if ( query == null || query.getQuery() == null ) {
|
||||
return null;
|
||||
}
|
||||
Query psq = new Query(query.getQuery(), "", "");
|
||||
String category = getCategory(query.getQuery());
|
||||
if (!category.equals(""))
|
||||
psq = new Query("", "", getCategory(query.getQuery()));
|
||||
Query psq = new Query( query.getQuery(), "", "" );
|
||||
String category = getCategory( query.getQuery() );
|
||||
if ( !category.equals( "" ) )
|
||||
psq = new Query( "", "", getCategory( query.getQuery() ) );
|
||||
// psq.setBuilding( query.getBuilding() );
|
||||
psq.setCityLimit(query.isCityLimit());
|
||||
psq.setDistanceSort(query.isDistanceSort());
|
||||
psq.setLocation(fromMogo(query.getLocation()));
|
||||
psq.setPageNum(query.getPageNum());
|
||||
psq.setPageSize(query.getPageSize());
|
||||
psq.setCityLimit( query.isCityLimit() );
|
||||
psq.setDistanceSort( query.isDistanceSort() );
|
||||
psq.setLocation( fromMogo( query.getLocation() ) );
|
||||
psq.setPageNum( query.getPageNum() );
|
||||
psq.setPageSize( query.getPageSize() );
|
||||
return psq;
|
||||
}
|
||||
|
||||
public static MogoSearchBound fromAMap(SearchBound bound) {
|
||||
if (bound == null) {
|
||||
public static MogoSearchBound fromAMap( SearchBound bound ) {
|
||||
if ( bound == null ) {
|
||||
return null;
|
||||
}
|
||||
if (bound.getShape() == SearchBound.BOUND_SHAPE) {
|
||||
return new MogoSearchBound(fromAMap(bound.getCenter()), bound.getRange(), bound.isDistanceSort());
|
||||
} else if (bound.getShape() == SearchBound.POLYGON_SHAPE) {
|
||||
return new MogoSearchBound(fromAMap(bound.getPolyGonList()));
|
||||
} else if (bound.getShape() == SearchBound.RECTANGLE_SHAPE) {
|
||||
return new MogoSearchBound(fromAMap(bound.getLowerLeft()), fromAMap(bound.getUpperRight()));
|
||||
if ( bound.getShape() == SearchBound.BOUND_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
|
||||
} else if ( bound.getShape() == SearchBound.POLYGON_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getPolyGonList() ) );
|
||||
} else if ( bound.getShape() == SearchBound.RECTANGLE_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getLowerLeft() ), fromAMap( bound.getUpperRight() ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<MogoLatLng> fromAMap(List<LonLatPoint> latLngs) {
|
||||
if (latLngs == null) {
|
||||
public static List< MogoLatLng > fromAMap( List< LonLatPoint > latLngs ) {
|
||||
if ( latLngs == null ) {
|
||||
return null;
|
||||
}
|
||||
List<MogoLatLng> result = new ArrayList<>(latLngs.size());
|
||||
for (LonLatPoint latLng : latLngs) {
|
||||
result.add(fromAMap(latLng));
|
||||
List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
|
||||
for ( LonLatPoint latLng : latLngs ) {
|
||||
result.add( fromAMap( latLng ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<LonLatPoint> fromMogo(List<MogoLatLng> latLngs) {
|
||||
if (latLngs == null) {
|
||||
public static List< LonLatPoint > fromMogo( List< MogoLatLng > latLngs ) {
|
||||
if ( latLngs == null ) {
|
||||
return null;
|
||||
}
|
||||
List<LonLatPoint> result = new ArrayList<>(latLngs.size());
|
||||
for (MogoLatLng latLng : latLngs) {
|
||||
result.add(fromMogo(latLng));
|
||||
List< LonLatPoint > result = new ArrayList<>( latLngs.size() );
|
||||
for ( MogoLatLng latLng : latLngs ) {
|
||||
result.add( fromMogo( latLng ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static SearchBound fromMogo(MogoSearchBound bound) {
|
||||
if (bound == null) {
|
||||
public static SearchBound fromMogo( MogoSearchBound bound ) {
|
||||
if ( bound == null ) {
|
||||
return null;
|
||||
}
|
||||
if (bound.getShape() == MogoSearchBound.SHAPE_BOUND) {
|
||||
return new SearchBound(fromMogo(bound.getCenterPoint()), bound.getRadiusInMeters(), bound.isDistanceSort());
|
||||
} else if (bound.getShape() == MogoSearchBound.SHAPE_POLYGON) {
|
||||
return new SearchBound(fromMogo(bound.getPolyGonList()));
|
||||
} else if (bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE) {
|
||||
return new SearchBound(fromMogo(bound.getLowerLeft()), fromMogo(bound.getUpperRight()));
|
||||
if ( bound.getShape() == MogoSearchBound.SHAPE_BOUND ) {
|
||||
return new SearchBound( fromMogo( bound.getCenterPoint() ), bound.getRadiusInMeters(), bound.isDistanceSort() );
|
||||
} else if ( bound.getShape() == MogoSearchBound.SHAPE_POLYGON ) {
|
||||
return new SearchBound( fromMogo( bound.getPolyGonList() ) );
|
||||
} else if ( bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE ) {
|
||||
return new SearchBound( fromMogo( bound.getLowerLeft() ), fromMogo( bound.getUpperRight() ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MogoPoiResult fromAMap(PoiSearchResult result) {
|
||||
if (result == null) {
|
||||
public static MogoPoiResult fromAMap( PoiSearchResult result ) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoPoiResult mogoPoiResult = new MogoPoiResult();
|
||||
if (result.getItems() != null) {
|
||||
final List<PoiSearchItem> poiItems = result.getItems();
|
||||
final ArrayList<MogoPoiItem> mogoPoiItems = new ArrayList<>(poiItems.size());
|
||||
for (PoiSearchItem poiItem : poiItems) {
|
||||
mogoPoiItems.add(fromAMap(poiItem.getPoi()));
|
||||
if ( result.getItems() != null ) {
|
||||
final List< PoiSearchItem > poiItems = result.getItems();
|
||||
final ArrayList< MogoPoiItem > mogoPoiItems = new ArrayList<>( poiItems.size() );
|
||||
for ( PoiSearchItem poiItem : poiItems ) {
|
||||
mogoPoiItems.add( fromAMap( poiItem.getPoi() ) );
|
||||
}
|
||||
mogoPoiResult.setPois(mogoPoiItems);
|
||||
mogoPoiResult.setPois( mogoPoiItems );
|
||||
}
|
||||
return mogoPoiResult;
|
||||
}
|
||||
@@ -697,27 +702,27 @@ public class ObjectUtils {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public static PolylineOptions fromMogo(MogoPolylineOptions options) {
|
||||
if (options == null) {
|
||||
public static PolylineOptions fromMogo( MogoPolylineOptions options ) {
|
||||
if ( options == null ) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions target = new PolylineOptions();
|
||||
if (options.getPoints() != null) {
|
||||
List<LonLatPoint> points = new ArrayList<>();
|
||||
for (MogoLatLng point : options.getPoints()) {
|
||||
points.add(fromMogo(point));
|
||||
if ( options.getPoints() != null ) {
|
||||
List< LonLatPoint > points = new ArrayList<>();
|
||||
for ( MogoLatLng point : options.getPoints() ) {
|
||||
points.add( fromMogo( point ) );
|
||||
}
|
||||
target.lonLatPoints(points);
|
||||
target.lonLatPoints( points );
|
||||
}
|
||||
target.setLineWidth(options.getWidth());
|
||||
target.setColor(options.getColor());
|
||||
target.setLineWidth( options.getWidth() );
|
||||
target.setColor( options.getColor() );
|
||||
// target.zIndex( options.getWidth() );
|
||||
// target.visible( options.isVisible() );
|
||||
//// target.geodesic( options.isGeodesic() );
|
||||
// target.setDottedLine( options.isDottedLine() );
|
||||
target.useGradient(options.isGradient());
|
||||
if (options.getColorValues() != null) {
|
||||
target.colorValues(options.getColorValues());
|
||||
target.useGradient( options.isGradient() );
|
||||
if ( options.getColorValues() != null ) {
|
||||
target.colorValues( options.getColorValues() );
|
||||
}
|
||||
// target.transparency( options.getTransparency() );
|
||||
// target.aboveMaskLayer( options.isAboveMaskLayer() );
|
||||
@@ -734,24 +739,24 @@ public class ObjectUtils {
|
||||
// return new MogoLatLng( latLng.latitude, latLng.longitude );
|
||||
// }
|
||||
|
||||
public static MapCameraPosition fromAMap(CameraPosition position) {
|
||||
if (position == null) {
|
||||
public static MapCameraPosition fromAMap( CameraPosition position ) {
|
||||
if ( position == null ) {
|
||||
return null;
|
||||
}
|
||||
return new MapCameraPosition(fromAMap(position.getTarget()), position.getBearing(), position.getTilt(), position.getZoom());
|
||||
return new MapCameraPosition( fromAMap( position.getTarget() ), position.getBearing(), position.getTilt(), position.getZoom() );
|
||||
}
|
||||
|
||||
private static String getCategory(String key) {
|
||||
private static String getCategory( String key ) {
|
||||
String category = "";
|
||||
if (key.equals("加油站")) {
|
||||
if ( key.equals( "加油站" ) ) {
|
||||
category = "6";
|
||||
} else if (key.equals("停车场")) {
|
||||
} else if ( key.equals( "停车场" ) ) {
|
||||
category = "12";
|
||||
} else if (key.equals("餐馆")) {
|
||||
} else if ( key.equals( "餐馆" ) ) {
|
||||
category = "22";
|
||||
} else if (key.equals("洗车")) {
|
||||
} else if ( key.equals( "洗车" ) ) {
|
||||
category = "8";
|
||||
} else if (key.equals("厕所")) {
|
||||
} else if ( key.equals( "厕所" ) ) {
|
||||
|
||||
}
|
||||
return category;
|
||||
|
||||
@@ -364,11 +364,20 @@ public interface IMogoMarker {
|
||||
|
||||
}
|
||||
|
||||
default void setInfoWindowOffset(int offsetX, int offsetY){
|
||||
default void setInfoWindowOffset( int offsetX, int offsetY ) {
|
||||
|
||||
}
|
||||
|
||||
default void addDynamicAnchorPosition(MogoLatLng latLng, long duration){
|
||||
default void addDynamicAnchorPosition( MogoLatLng latLng, long duration ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 marker 内部使用资源内容 md5
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getMarkerResName() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,20 @@ public class MogoMarkerOptions extends Observable {
|
||||
|
||||
private boolean mIsControlAngle = false;
|
||||
|
||||
/**
|
||||
* 资源名称,便于缓存重复使用,和mIcon3DRes、mIconView、icon等冲突,需要县设置
|
||||
*/
|
||||
private String mResName;
|
||||
|
||||
public MogoMarkerOptions resName( String resName ) {
|
||||
this.mResName = resName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getResName() {
|
||||
return mResName;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions controlAngle( boolean controlAngle ) {
|
||||
this.mIsControlAngle = controlAngle;
|
||||
return this;
|
||||
|
||||
@@ -69,12 +69,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
*/
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
clearOldMarker();
|
||||
return;
|
||||
@@ -99,7 +95,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult, machineVision, curSpeed );
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,36 +130,49 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param recognizedListResult
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult,
|
||||
boolean machineVision,
|
||||
double curSpeed ) {
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String resIdVal = null;
|
||||
int resId = getVrModelResId();
|
||||
resIdVal = resId + "";
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.set3DMode( true )
|
||||
.controlAngle( true )
|
||||
.icon3DRes( getVrModel() )
|
||||
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
|
||||
.icon3DRes( resId )
|
||||
.rotate( ( float ) recognizedListResult.heading )
|
||||
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
cacheMarkerIconResMd5Val( resIdVal, marker );
|
||||
return marker;
|
||||
}
|
||||
|
||||
private int getVrModel() {
|
||||
/**
|
||||
* 获取 vr 模型资源 id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getVrModelResId() {
|
||||
return R.raw.cargrey;
|
||||
}
|
||||
|
||||
/**
|
||||
* vr 模式切换
|
||||
*/
|
||||
public void notifyVrModeChanged() {
|
||||
clearOldMarker();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除旧的 marker 数据
|
||||
*/
|
||||
private void clearOldMarker() {
|
||||
if ( mAdasRecognizedMarkersCaches != null ) {
|
||||
mAdasRecognizedMarkersCaches.clear();
|
||||
|
||||
@@ -5,20 +5,18 @@ import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.CoordinatesTransformer;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.constants.CarModelType;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.constants.SafeType;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
@@ -30,19 +28,15 @@ public
|
||||
*/
|
||||
class BaseDrawer {
|
||||
|
||||
public static final int POS_LON = 1;
|
||||
public static final int POS_LAT = 0;
|
||||
|
||||
public static final double BOUND_DISTANCE_DANGEROUS = 0.5;
|
||||
public static final double BOUND_SPEED_DANGEROUS = 1.5;
|
||||
|
||||
public static final double BOUND_DISTANCE_WARM = 1;
|
||||
public static final double BOUND_SPEED_WARM = 1.1;
|
||||
|
||||
// 移除过期的 marker
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
|
||||
|
||||
/**
|
||||
* 地图内部资源md5缓存,便于资源复用
|
||||
*/
|
||||
protected static final Map< String, String > mMarkerCachesResMd5Values = new HashMap<>();
|
||||
|
||||
public BaseDrawer() {
|
||||
if ( mWorkThreadHandler == null ) {
|
||||
initWorkThreadHandler();
|
||||
@@ -93,66 +87,11 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全类型
|
||||
* 判断是否是车辆
|
||||
*
|
||||
* @param distance
|
||||
* @param speed
|
||||
* @param curSpeed
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
protected SafeType getSafeType( double distance, double speed, double curSpeed ) {
|
||||
if ( distance < BOUND_DISTANCE_DANGEROUS ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
|
||||
return SafeType.SpeedDangerous;
|
||||
}
|
||||
if ( distance < BOUND_DISTANCE_WARM ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
|
||||
return SafeType.DistanceWarm;
|
||||
}
|
||||
return SafeType.Normal;
|
||||
}
|
||||
|
||||
|
||||
protected SafeType getSafeType( double distanceX, double distanceY, double speed, double curSpeed ) {
|
||||
if ( distanceX < BOUND_DISTANCE_DANGEROUS || distanceY < BOUND_DISTANCE_DANGEROUS ) {
|
||||
return SafeType.DistanceDangerous;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
|
||||
return SafeType.SpeedDangerous;
|
||||
}
|
||||
if ( distanceX < BOUND_DISTANCE_WARM || distanceY < BOUND_DISTANCE_WARM ) {
|
||||
return SafeType.DistanceWarm;
|
||||
}
|
||||
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
|
||||
return SafeType.SpeedWarm;
|
||||
}
|
||||
return SafeType.Normal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车模
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected CarModelType getCarModelType() {
|
||||
// 根据车道、行驶方向等计算出选用哪个车模图片
|
||||
return CarModelType.Other;
|
||||
}
|
||||
|
||||
private CoordinatesTransformer mTransformer;
|
||||
|
||||
protected double[] transformGcj02ToFitMap( double lat, double lon ) {
|
||||
if ( mTransformer == null ) {
|
||||
mTransformer = MogoApisHandler.getInstance().getApis().getMapServiceApi().getCoordinatesTransformer();
|
||||
}
|
||||
return mTransformer.transform( lat, lon );
|
||||
}
|
||||
|
||||
protected boolean isCarType( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
@@ -166,6 +105,14 @@ class BaseDrawer {
|
||||
|
||||
private TextView mSpeedView = null;
|
||||
|
||||
/**
|
||||
* 展示车辆速度
|
||||
*
|
||||
* @param context
|
||||
* @param mogoMarker
|
||||
* @param speed
|
||||
* @param isVrMode
|
||||
*/
|
||||
protected void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
return;
|
||||
@@ -213,4 +160,21 @@ class BaseDrawer {
|
||||
}
|
||||
dirtyMarkers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存绘制 marker 的 id 和 marker 资源缓存的 md5 的关系
|
||||
*
|
||||
* @param id
|
||||
* @param marker
|
||||
*/
|
||||
protected static void cacheMarkerIconResMd5Val( String id, IMogoMarker marker ) {
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
String md5 = marker.getMarkerResName();
|
||||
if ( TextUtils.isEmpty( md5 ) || TextUtils.isEmpty( id ) ) {
|
||||
return;
|
||||
}
|
||||
mMarkerCachesResMd5Values.put( id, md5 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -135,8 +134,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
*
|
||||
* @param data 自车周边数据
|
||||
*/
|
||||
public void renderSnapshotData( MogoSnapshotSetData data,
|
||||
boolean machineVision ) {
|
||||
public void renderSnapshotData( MogoSnapshotSetData data ) {
|
||||
|
||||
if ( clear( data ) ) {
|
||||
return;
|
||||
@@ -164,11 +162,11 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
continue;
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
|
||||
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData, machineVision, data.curSpeed );
|
||||
|
||||
marker = drawSnapshotDataMarker( cloudRoadData );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
@@ -176,22 +174,18 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
bindClickListener( marker );
|
||||
}
|
||||
}
|
||||
Log.i( "mock-snapshot-timer2", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
|
||||
start = System.currentTimeMillis();
|
||||
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
|
||||
if ( mChangeCarModeStatus ) {
|
||||
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
|
||||
mChangeCarModeStatus = false;
|
||||
if ( mIsVrMode ) {
|
||||
Logger.d( TAG, "3D模型-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
marker.use3DResource( getVrModel( cloudRoadData ) );
|
||||
marker.use3DResource( getVrModelResId( cloudRoadData ) );
|
||||
} else {
|
||||
Logger.d( TAG, "2D贴图-%s", uniqueKey );
|
||||
marker.getMogoMarkerOptions().set3DMode( false );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) );
|
||||
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,14 +211,12 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
interval2 -= 25;
|
||||
marker.startSmoothInMs( points, interval2 );
|
||||
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
|
||||
}
|
||||
} else {
|
||||
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
}
|
||||
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
|
||||
Log.i( "mock-snapshot-timer3", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
|
||||
mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
@@ -279,16 +271,13 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
* 绘制 marker
|
||||
*
|
||||
* @param data
|
||||
* @param machineVision
|
||||
* @param curSpeed
|
||||
* @return
|
||||
*/
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data, boolean machineVision, double curSpeed ) {
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) {
|
||||
if ( data == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
@@ -296,17 +285,23 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
.object( data )
|
||||
.controlAngle( true )
|
||||
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
|
||||
String resIdVal = null;
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
options.set3DMode( true );
|
||||
options.anchorColor( "#00FF00" );
|
||||
Logger.d( TAG, "3D模型 - %s", data.getUniqueKey() );
|
||||
options.icon3DRes( getVrModel( data ) );
|
||||
int resId = getVrModelResId( data );
|
||||
resIdVal = resId + "";
|
||||
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
|
||||
options.icon3DRes( resId );
|
||||
} else {
|
||||
options.set3DMode( false );
|
||||
Logger.d( TAG, "2D贴图 - %s", data.getUniqueKey() );
|
||||
options.icon( inflateView( data, machineVision, curSpeed ) );
|
||||
View view = inflateView( data );
|
||||
options.icon( view );
|
||||
resIdVal = view.getId() + "";
|
||||
}
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
cacheMarkerIconResMd5Val( resIdVal, marker );
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +310,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private int getVrModel( CloudRoadData data ) {
|
||||
private int getVrModelResId( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
return R.raw.cargrey;
|
||||
@@ -327,20 +322,18 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
}
|
||||
}
|
||||
|
||||
private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) {
|
||||
/**
|
||||
* 生成 2d marker 资源
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private View inflateView( CloudRoadData data ) {
|
||||
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
|
||||
// SafeType safeType = getSafeType( data.getDistance(), data.getSpeed(), curSpeed );
|
||||
// TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
|
||||
// // 机器视觉展示速度,用户视觉展示安全类型
|
||||
// tv.setText( machineVision ? String.valueOf( data.getSpeed() ) : safeType.getMsg() );
|
||||
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
|
||||
// iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
|
||||
// machineVision ? VisionMode.Machine : VisionMode.User,
|
||||
// AdasRecognizedType.valueFrom( data.getType() ),
|
||||
// getCarModelType(),
|
||||
// safeType
|
||||
// ) );
|
||||
iv.setImageResource( get2DModel( data ) );
|
||||
int viewIdLike = get2DModel( data );
|
||||
iv.setImageResource( viewIdLike );
|
||||
rootView.setId( viewIdLike );
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@@ -353,9 +346,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
|
||||
private int get2DModel( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
// return R.drawable.icon_map_marker_car_type_taxi;
|
||||
case CloudRoadData.FROM_ROAD_UNIT:
|
||||
// return R.drawable.icon_map_marker_car_type_bus;
|
||||
case CloudRoadData.FROM_MY_LOCATION:
|
||||
default:
|
||||
return R.drawable.icon_map_marker_car_gray;
|
||||
|
||||
1
modules/mogo-module-service/src/main/assets/adas.txt
Normal file
1
modules/mogo-module-service/src/main/assets/adas.txt
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -29,9 +29,11 @@ import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
@@ -551,11 +553,12 @@ public class MockIntentHandler implements IntentHandler {
|
||||
break;
|
||||
case 46:
|
||||
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ), false );
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
|
||||
break;
|
||||
case 47:
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -609,6 +612,17 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
br2 = null;
|
||||
}
|
||||
} else if ( msg.what == 3 ) {
|
||||
try {
|
||||
handleMockAdasIntent();
|
||||
} catch ( Exception e ) {
|
||||
try {
|
||||
br3.close();
|
||||
} catch ( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
br3 = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -624,7 +638,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
throw new Exception( "end of file." );
|
||||
}
|
||||
JSONObject jo = new JSONObject( line );
|
||||
final long start = System.currentTimeMillis();
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
|
||||
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
|
||||
return true;
|
||||
}
|
||||
@@ -655,10 +671,39 @@ public class MockIntentHandler implements IntentHandler {
|
||||
data.setAllList( allList );
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
|
||||
Log.i("mock-snapshot-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
|
||||
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
private BufferedReader br3;
|
||||
|
||||
private boolean handleMockAdasIntent() throws Exception {
|
||||
if ( br3 == null ) {
|
||||
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas.txt" ) ) );
|
||||
}
|
||||
String line = br3.readLine();
|
||||
if ( line == null ) {
|
||||
throw new Exception( "end of file 3." );
|
||||
}
|
||||
List< ADASRecognizedResult > allList = new ArrayList<>();
|
||||
if ( ++count % 300 != 0 ) {
|
||||
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
|
||||
if ( adasRecognizedResult == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
|
||||
adasRecognizedResult.lon = coor[0];
|
||||
adasRecognizedResult.lat = coor[1];
|
||||
allList.add( adasRecognizedResult );
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
|
||||
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
});
|
||||
}
|
||||
// 每隔一秒下发的数据
|
||||
// 下发的数据
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
@@ -143,17 +143,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
}
|
||||
});
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
|
||||
double speed = 0.0;
|
||||
if (MogoServices.getInstance().getLastCarLocation() != null) {
|
||||
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
|
||||
// 绘制近景识别到的车辆
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,6 +248,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据点击 marker 更新用户信息面板内容
|
||||
* @param marker
|
||||
*/
|
||||
private void updateCarUserInfoWindow(IMogoMarker marker) {
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
try {
|
||||
@@ -299,6 +299,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特殊车辆类型
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
private int getCarVehicleType(IMogoMarker marker) {
|
||||
try {
|
||||
return ((MarkerOnlineCar)
|
||||
@@ -475,6 +480,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步绘制大而全的数据 marker
|
||||
* @param response
|
||||
*/
|
||||
public void onSyncMarkerResponse(MarkerResponse response) {
|
||||
if (ignoreDrawRequest()) {
|
||||
return;
|
||||
@@ -484,10 +493,19 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前地图中心点坐标
|
||||
* @param lon
|
||||
* @param lat
|
||||
*/
|
||||
public void syncLocation(double lon, double lat) {
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度请求数据
|
||||
* @param latlng
|
||||
*/
|
||||
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
@@ -516,6 +534,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 移除绘制
|
||||
*/
|
||||
public void stopAutoRefresh() {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
}
|
||||
@@ -622,11 +643,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
return ignoreDrawRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除在线车辆 marker
|
||||
*/
|
||||
private void removeCarMarkers() {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_USER_DATA);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以下条件,不绘制 marker
|
||||
* @return
|
||||
*/
|
||||
private boolean ignoreDrawRequest() {
|
||||
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()
|
||||
|| MarkerServiceHandler.getMogoStatusManager().isV2XShow()
|
||||
@@ -668,14 +695,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
switch (mapUI) {
|
||||
case Type_Light:
|
||||
case Type_Night:
|
||||
// if ( !AppUtils.isAppForeground( mContext ) ) {
|
||||
// return;
|
||||
// }
|
||||
redrawMarkerByStyleChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重绘内容
|
||||
*/
|
||||
public void redrawMarkerByStyleChanged() {
|
||||
if (mLastDataResult != null) {
|
||||
runOnTargetThread(() -> {
|
||||
@@ -686,6 +713,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭当前点击过的 marker
|
||||
*/
|
||||
public void onCloseCurrentSelectedMarker() {
|
||||
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
|
||||
closeMarker(mLastCheckMarker);
|
||||
|
||||
Reference in New Issue
Block a user