This commit is contained in:
wangcongtao
2020-04-13 11:18:35 +08:00
parent 45e480cefa
commit 798df646bf
7 changed files with 221 additions and 38 deletions

View File

@@ -14,7 +14,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Interpolator;
import com.alibaba.idst.nls.internal.utils.L;
import com.amap.api.maps.AMap;
import com.amap.api.maps.AMapUtils;
import com.amap.api.maps.CameraUpdateFactory;
@@ -47,6 +46,7 @@ import com.mogo.map.impl.amap.utils.MogoMapUtils;
import com.mogo.map.impl.amap.utils.ObjectUtils;
import com.mogo.map.listener.MogoMapListenerHandler;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.uicontroller.CarCursorOption;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapControlResult;
@@ -87,6 +87,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
private boolean mIsCarLocked = false;
private float mDefaultZoomLevel = 16.0f;
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
.carCursorRes( R.drawable.map_api_ic_current_location2 )
.naviCursorRes( R.drawable.ic_amap_navi_cursor )
.build();
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
public AMapNaviViewWrapper( AMapNaviView mapView ) {
this.mMapView = mapView;
@@ -113,8 +118,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(),
R.drawable.ic_amap_navi_cursor ) );
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), DEFAULT_OPTION.getNaviCursorRes() ) );
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏。
options.setCompassEnabled( false );
// 黑夜模式
@@ -463,10 +467,10 @@ public class AMapNaviViewWrapper implements IMogoMapView,
break;
case NorthUP_2D:
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
break;
break;
}
Logger.d(TAG,"mCurrentUIMode--->"+mCurrentUIMode.name());
Logger.d( TAG, "mCurrentUIMode--->" + mCurrentUIMode.name() );
if ( options == null ) {
return;
}
@@ -517,7 +521,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
style.showMyLocation( visible );
if ( visible ) {
// 强制刷新一遍车标
style.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.map_api_ic_current_location2 ) );
style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) );
}
mMapView.getMap().setMyLocationStyle( style );
}
@@ -840,4 +844,37 @@ public class AMapNaviViewWrapper implements IMogoMapView,
public synchronized boolean isCarLocked() {
return mIsCarLocked;
}
@Override
public void setCarCursorOption( CarCursorOption option ) {
if ( mCarCursorOption != null ) {
mCarCursorOption.destroy();
}
try {
mCarCursorOption = option.clone();
} catch ( CloneNotSupportedException e ) {
mCarCursorOption = DEFAULT_OPTION;
}
if ( !checkAMapView() ) {
return;
}
AMapNaviViewOptions options = mMapView.getViewOptions();
if ( options != null && mCarCursorOption.getNaviCursorRes() != 0 ) {
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), mCarCursorOption.getNaviCursorRes() ) );
mMapView.setViewOptions( options );
}
if ( mMapView.getMap() == null ) {
return;
}
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) {
style.myLocationIcon( BitmapDescriptorFactory.fromBitmap( mCarCursorOption.getCarCursorBmp() ) );
} else {
if ( mCarCursorOption.getCarCursorRes() != 0 ) {
style.myLocationIcon( BitmapDescriptorFactory.fromResource( mCarCursorOption.getCarCursorRes() ) );
}
}
mMapView.getMap().setMyLocationStyle( style );
}
}

View File

@@ -9,6 +9,7 @@ import android.view.animation.Interpolator;
import com.mogo.map.MogoLatLng;
import com.mogo.map.MogoMap;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.uicontroller.CarCursorOption;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapControlResult;
@@ -252,4 +253,11 @@ public class AMapUIController implements IMogoMapUIController {
}
return false;
}
@Override
public void setCarCursorOption( CarCursorOption option ) {
if ( mClient != null ) {
mClient.setCarCursorOption( option );
}
}
}