diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index f14d67a9ef..ed15b120db 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -92,11 +92,16 @@ public class AMapNaviViewWrapper implements IMogoMapView, .build(); private CarCursorOption mCarCursorOption = DEFAULT_OPTION; + private BnHooker bnHooker; + + private Location mLastDriveLocationShadow = null; + private Marker mMyLocationMarker; + public AMapNaviViewWrapper( AMapNaviView mapView ) { this.mMapView = mapView; this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView.getContext(), this ); try { - new BnHooker( mMapView.getMap(), mapView.getContext() ); + bnHooker = new BnHooker( mMapView.getMap() ); } catch ( Exception e ) { e.printStackTrace(); } @@ -276,8 +281,17 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onTouch( MotionEvent motionEvent ) { MogoMapListenerHandler.getInstance().onTouch( motionEvent ); + if ( motionEvent.getAction() == MotionEvent.ACTION_DOWN ) { changeMyLocationType2UnFollow(); } + if ( motionEvent.getAction() != MotionEvent.ACTION_UP ) { + try { + bnHooker.clearAllMessages(); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } /** * POI 点击 @@ -579,9 +593,6 @@ public class AMapNaviViewWrapper implements IMogoMapView, return; } MyLocationStyle style = getMyLocationStyle(); - if ( style == null ) { - style = new MyLocationStyle(); - } switch ( mCurrentUIMode ) { case NorthUP_2D: style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER ); @@ -592,6 +603,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, break; } mMapView.getMap().setMyLocationStyle( style ); + Logger.d( TAG, "设置" ); } private void changeMyLocationType2Follow() { @@ -650,8 +662,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); } Logger.d( TAG, "解锁锁车" ); - mockTouchEvent(); mIsCarLocked = false; + mockTouchEvent(); } /** @@ -674,7 +686,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, Logger.d( TAG, Log.getStackTraceString( new Throwable() ) ); } Logger.d( TAG, "Zoom锁定锁车比例尺 %s", var1 ); - mMapView.setLockZoom( var1 ); +// mMapView.setLockZoom( var1 ); } } @@ -883,9 +895,35 @@ public class AMapNaviViewWrapper implements IMogoMapView, @Override public void onMyLocationChange( Location location ) { + if ( ( int ) location.getSpeed() > 0 ) { + mLastDriveLocationShadow = location; + } else { + if ( ( int ) location.getBearing() == 0 + && mCurrentUIMode == EnumMapUI.NorthUP_2D + && mLastDriveLocationShadow != null ) { + if ( mMyLocationMarker == null ) { + initMyLocationMarker(); + } + if ( mMyLocationMarker != null ) { + mMyLocationMarker.setRotateAngle( 360 - mLastDriveLocationShadow.getBearing() ); + } + } + } NaviClient.getInstance( getContext() ).syncCarLocation( location ); } + private void initMyLocationMarker() { + List< Marker > markers = mMapView.getMap().getMapScreenMarkers(); + if ( markers != null ) { + for ( Marker marker : markers ) { + if ( marker != null && marker.getObject() == null ) { + this.mMyLocationMarker = marker; + break; + } + } + } + } + @Override public EnumMapUI getCurrentUiMode() { return mCurrentUIMode; diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java index 1eaa3557a3..a3135b59d6 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewHandler.java @@ -20,7 +20,7 @@ class AMapViewHandler { public static void createMapView( Context context ) { if ( DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE ) { - sMapView = new AMapViewWrapper( new MapView( context ) ); + sMapView = new AMapNaviViewWrapper( new AMapNaviView( context ) ); } else { sMapView = new AMapNaviViewWrapper( new AMapNaviView( context ) ); } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java index 8ef68ba368..abf153270b 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -94,7 +94,7 @@ public class AMapViewWrapper implements IMogoMapView, this.mMapView = mapView; this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView.getContext(), this ); try { - new BnHooker( mMapView.getMap(), mapView.getContext() ); + new BnHooker( mMapView.getMap() ); } catch ( Exception e ) { e.printStackTrace(); } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/hook/BnHooker.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/hook/BnHooker.java index 0840157652..82e014560a 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/hook/BnHooker.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/hook/BnHooker.java @@ -1,18 +1,16 @@ package com.mogo.map.impl.amap.hook; -import android.content.Context; - import com.amap.api.maps.AMap; import com.autonavi.amap.mapcore.interfaces.IAMap; +import com.autonavi.base.ae.gmap.GLMapEngine; import com.autonavi.base.amap.api.mapcore.IAMapDelegate; import com.autonavi.base.amap.mapcore.interfaces.IAMapListener; -import com.mogo.map.impl.amap.navi.NaviClient; -import com.mogo.utils.logger.Logger; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.util.List; /** * @author congtaowang @@ -23,13 +21,12 @@ import java.lang.reflect.Proxy; public class BnHooker implements InvocationHandler { private static final String TAG = "BnHooker"; - private final Context mContext; private Object host; + private Method getGLMapEngineMethod; + private GLMapEngine glMapEngineObject; - public BnHooker( AMap map, Context context ) throws Exception { - - mContext = context; + public BnHooker( AMap map ) throws Exception { if ( map == null ) { return; @@ -48,6 +45,28 @@ public class BnHooker implements InvocationHandler { this ); field.set( map, object ); + + } + + public void clearAllMessages() throws Exception { + if ( glMapEngineObject == null ) { + if ( getGLMapEngineMethod == null ) { + getGLMapEngineMethod = host.getClass().getDeclaredMethod( "getGLMapEngine" ); + getGLMapEngineMethod.setAccessible( true ); + } + glMapEngineObject = ( GLMapEngine ) getGLMapEngineMethod.invoke( host ); + } + if ( glMapEngineObject != null ) { + clearMessageList( "mStateMessageList", glMapEngineObject ); + clearMessageList( "mAnimateStateMessageList", glMapEngineObject ); + } + } + + private void clearMessageList( String filedName, Object obj ) throws Exception { + Field stateMessageListField = obj.getClass().getDeclaredField( filedName ); + stateMessageListField.setAccessible( true ); + List valList = ( List ) stateMessageListField.get( obj ); + valList.clear(); } @Override