@@ -68,27 +68,27 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
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 )
. carCursorRes ( R . drawable . map_api_ic_current_location2 )
. naviCursorRes ( R . drawable . ic_amap_navi_cursor )
. build ( ) ;
private CarCursorOption mCarCursorOption = DEFAULT_OPTION ;
public AMapViewWrapper ( MapAutoView mMapView ) {
public AMapViewWrapper ( MapAutoView mMapView ) {
startTime = System . currentTimeMillis ( ) ;
Logger . i ( TAG , " autoop--AMapViewWrapper: init " ) ;
Logger . i ( TAG , " autoop--AMapViewWrapper: init " ) ;
this . mMapView = mMapView ;
initListeners ( ) ;
this . mIMap = new AMapWrapper ( this . mMapView . getMapAutoViewHelper ( ) , this . mMapView , this ) ;
this . mIMap = new AMapWrapper ( this . mMapView . getMapAutoViewHelper ( ) , this . mMapView , this ) ;
}
private void initMapView ( ) {
if ( mMapView = = null ) {
if ( mMapView = = null ) {
return ;
}
MapAutoViewHelper options = mMapView . getMapAutoViewHelper ( ) ;
if ( options ! = null ) {
if ( options ! = null ) {
// 设置是否开启自动黑夜模式切换, 默认为false, 不自动切换
options. setAutoSwitchStyle( false ) ;
// options. setAutoSwitchStyle(false) ;
// 设置6秒后是否自动锁车
// options.setAutoLockCar( false );
// 设置路线上的摄像头气泡是否显示
@@ -96,11 +96,11 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options . setMyLocationStyle ( options . getMyLocationStyle ( ) . myLocationIcon ( DEFAULT_OPTION . getCarCursorRes ( ) ) ) ;
options . setMyLocationStyle ( options . getMyLocationStyle ( ) . myLocationIcon ( DEFAULT_OPTION . getCarCursorRes ( ) ) ) ;
// 设置指南针图标否在导航界面显示, 默认显示。true, 显示; false, 隐藏。
options. hiddenDirection( ) ;
// options. hiddenDirection() ;
// 黑夜模式
options. setMapStyle( MapAutoApi. MAP_STYLE_NIGHT) ;
// options. setMapStyle( MapAutoApi. MAP_STYLE_NIGHT) ;
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
// options.setTrafficBarEnabled( false );
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
@@ -137,29 +137,29 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
// options.setNaviArrowVisible( false );
// 通过路线是否自动置灰,仅支持驾车导航
// options.setAfterRouteAutoGray( true );
options. setZoom( ( ( int ) mDefaultZoomLevel) ) ;
// options. setZoom(((int) mDefaultZoomLevel)) ;
// options.setPointToCenter( 0.5D, 0.5D );
// 2D模式
options. setMapViewPerspective( MapAutoApi. MAP_PERSPECTIVE_2D) ;
// options. setMapViewPerspective( MapAutoApi. MAP_PERSPECTIVE_2D) ;
// mMapView.setViewOptions( options );
}
// mMapView.setRouteOverlayVisible( false );
// mMapView.setCarOverlayVisible( false );
setUIMode( EnumMapUI. CarUp_2D) ;
// setUIMode( EnumMapUI. CarUp_2D) ;
}
private void initListeners ( ) {
mMapView . setOnMarkClickListener ( this ) ;
mMapView . setOnMarkClickListener ( this ) ;
mMarkerClickHandler = new AMapMarkerClickHandler ( ) ;
mMapView . setOnMapLoadedListener ( this ) ;
mMapView . setOnMapTouchListener ( this ) ;
mMapView . setOnMapClickListener ( this ) ;
mMapView . getLocationClient ( ) . registerListener ( this ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_ZOOM ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_ROTATE ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_3D ) ;
mMapView . setMOnCameraChangeListener ( this ) ;
mMapView . setOnMapLoadedListener ( this ) ;
mMapView . setOnMapTouchListener ( this ) ;
mMapView . setOnMapClickListener ( this ) ;
mMapView . getLocationClient ( ) . registerListener ( this ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_ZOOM ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_ROTATE ) ;
mMapView . registerListener ( this , MapAutoApi . LISTENER_TYPE_3D ) ;
mMapView . setMOnCameraChangeListener ( this ) ;
// mMapView.setOnPolylineClickListener( this );
// mMapView.setAMapNaviViewListener( this );
@@ -190,10 +190,10 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public void onCreate ( Bundle bundle ) {
if ( mMapView ! = null ) {
mMapView . onCreate ( bundle ) ;
Logger . d ( TAG , " map onCreate " ) ;
public void onCreate ( Bundle bundle ) {
if ( mMapView ! = null ) {
mMapView . onCreate ( bundle ) ;
Logger . d ( TAG , " map onCreate " ) ;
initMapView ( ) ;
// initMyLocation();
@@ -202,33 +202,33 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
@Override
public void onResume ( ) {
if ( mMapView ! = null ) {
if ( mMapView ! = null ) {
mMapView . onResume ( ) ;
Logger . d ( TAG , " map onResume " ) ;
Logger . d ( TAG , " map onResume " ) ;
}
}
@Override
public void onPause ( ) {
if ( mMapView ! = null ) {
if ( mMapView ! = null ) {
mMapView . onPause ( ) ;
Logger . d ( TAG , " map onPause " ) ;
Logger . d ( TAG , " map onPause " ) ;
}
}
@Override
public void onDestroy ( ) {
if ( mMapView ! = null ) {
if ( mMapView ! = null ) {
mMapView . onDestroy ( ) ;
Logger . d ( TAG , " map onDestroy " ) ;
Logger . d ( TAG , " map onDestroy " ) ;
}
}
@Override
public void onSaveInstanceState ( Bundle outState ) {
if ( mMapView ! = null ) {
mMapView . onSaveInstanceState ( outState ) ;
Logger . d ( TAG , " map onSaveInstanceState " ) ;
public void onSaveInstanceState ( Bundle outState ) {
if ( mMapView ! = null ) {
mMapView . onSaveInstanceState ( outState ) ;
Logger . d ( TAG , " map onSaveInstanceState " ) ;
}
}
@@ -238,205 +238,207 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public void setTrafficEnabled ( boolean visible ) {
if ( checkAMapView ( ) ) {
public void setTrafficEnabled ( boolean visible ) {
if ( checkAMapView ( ) ) {
// mMapView.getMapAutoViewHelper().setTraffic(visible);
}
}
@Override
public MapControlResult changeZoom ( boolean zoom ) {
if ( checkAMapView ( ) ) {
mDefaultZoomLevel = ( getMap ( ) . getZoomLevel ( ) + 0 . 5f ) ;
public MapControlResult changeZoom ( boolean zoom ) {
if ( checkAMapView ( ) ) {
mDefaultZoomLevel = ( getMap ( ) . getZoomLevel ( ) + 0 . 5f ) ;
if ( zoom ) {
if ( mDefaultZoomLevel > = 20f ) {
if ( zoom ) {
if ( mDefaultZoomLevel > = 20f ) {
return MapControlResult . TARGET ;
}
} else {
if ( mDefaultZoomLevel < = 7f ) {
if ( mDefaultZoomLevel < = 7f ) {
return MapControlResult . TARGET ;
}
}
if ( zoom ) {
if ( zoom ) {
mDefaultZoomLevel + = 1f ;
if ( mDefaultZoomLevel > 19f ) {
if ( mDefaultZoomLevel > 19f ) {
mDefaultZoomLevel = 19f ;
}
} else {
mDefaultZoomLevel - = 1f ;
if ( mDefaultZoomLevel < 8f ) {
if ( mDefaultZoomLevel < 8f ) {
mDefaultZoomLevel = 8f ;
}
}
changeZoom ( mDefaultZoomLevel ) ;
changeZoom ( mDefaultZoomLevel ) ;
}
return MapControlResult . SUCCESS ;
}
@Override
public MapControlResult changeZoom ( float zoom ) {
Logger . d ( TAG , " changeZoom %s " , zoom ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
public MapControlResult changeZoom ( float zoom ) {
Logger . d ( TAG , " changeZoom %s " , zoom ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
}
getMap ( ) . changeZoom ( zoom ) ;
getMap ( ) . changeZoom ( zoom ) ;
return MapControlResult . SUCCESS ;
}
@Override
public void changeMapMode ( EnumMapUI ui ) {
if ( ui = = null ) {
public void changeMapMode ( EnumMapUI ui ) {
if ( ui = = null ) {
return ;
}
if ( checkAMapView ( ) ) {
switch ( ui ) {
case CarUp_2D :
case CarUp_3D :
case NorthUP_2D :
//setUIMode( ui, options ) ;
return ;
case Type_Light :
mMapView . getMapAutoViewHelper ( ) . setAutoSwitchStyle ( false ) ;
mMapView . getMapAutoViewHelper ( ) . setMapStyle ( MapAutoApi . MAP_STYLE_DAY ) ;
break ;
case Type_Night :
mMapView. getMapAutoViewHelper( ) . setAutoSwitchStyle ( false ) ;
mMapView . getMapAutoViewHelper ( ) . setMapStyle ( MapAutoApi . MAP_STYLE_NIGHT ) ;
break ;
case Type_AUTO_LIGHT_Night :
mMapView. getMapAutoViewHelper( ) . setAutoSwitchStyle ( true ) ;
break ;
}
if ( checkAMapView ( ) ) {
// switch (ui) {
// case CarUp_2D:
// case CarUp_3D:
// case NorthUP_2D:
// break ;
// case Type_VR:
// mMapView.getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_VR);
// //setUIMode( ui, options ) ;
// return ;
// case Type_Light:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView. getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_DAY) ;
// break ;
// case Type_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(false);
// mMapView. getMapAutoViewHelper().setMapStyle(MapAutoApi.MAP_STYLE_NIGHT) ;
// break;
// case Type_AUTO_LIGHT_Night:
// mMapView.getMapAutoViewHelper().setAutoSwitchStyle(true);
// break;
}
}
@Override
public void moveToCenter ( MogoLatLng latLng ) {
public void moveToCenter ( MogoLatLng latLng ) {
}
private void setUIMode ( EnumMapUI ui ) {
private void setUIMode ( EnumMapUI ui ) {
this . mCurrentUIMode = ui ;
if ( mMapView . getMapAutoViewHelper ( ) ! = null ) {
switch ( ui ) {
if ( mMapView . getMapAutoViewHelper ( ) ! = null ) {
switch ( ui ) {
case CarUp_2D :
mMapView . getMapAutoViewHelper ( ) . setMapViewPerspective ( MapAutoApi . MAP_PERSPECTIVE_2D ) ;
mMapView . getMapAutoViewHelper ( ) . setMapViewPerspective ( MapAutoApi . MAP_PERSPECTIVE_2D ) ;
break ;
case CarUp_3D :
mMapView . getMapAutoViewHelper ( ) . setMapViewPerspective ( MapAutoApi . MAP_PERSPECTIVE_3D ) ;
mMapView . getMapAutoViewHelper ( ) . setMapViewPerspective ( MapAutoApi . MAP_PERSPECTIVE_3D ) ;
break ;
case NorthUP_2D :
mMapView . getMapAutoViewHelper ( ) . setRotateGesturesEnabled ( false ) ;
mMapView . getMapAutoViewHelper ( ) . setRotateGesturesEnabled ( false ) ;
break ;
}
}
}
private boolean checkAMapView ( ) {
if ( mMapView = = null | | mMapView . getMapAutoViewHelper ( ) = = null ) {
Logger . e ( TAG , " 自研mapView实例为空, 请检查 " ) ;
if ( mMapView = = null | | mMapView . getMapAutoViewHelper ( ) = = null ) {
Logger . e ( TAG , " 自研mapView实例为空, 请检查 " ) ;
return false ;
}
return true ;
}
@Override
public void moveToCenter ( MogoLatLng latLng , boolean animate ) {
Logger . d ( TAG , " move to center %s " , latLng ) ;
if ( latLng = = null | | latLng . lat = = 0 . 0d | | latLng . lng = = 0 . 0d ) {
Logger . e ( TAG , " latlng = null or is illegal " ) ;
public void moveToCenter ( MogoLatLng latLng , boolean animate ) {
Logger . d ( TAG , " move to center %s " , latLng ) ;
if ( latLng = = null | | latLng . lat = = 0 . 0d | | latLng . lng = = 0 . 0d ) {
Logger . e ( TAG , " latlng = null or is illegal " ) ;
return ;
}
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
}
loseLockMode ( ) ;
mMapView . getMapAutoViewHelper ( ) . animateCamera ( new LonLatPoint ( latLng . lon , latLng . lat ) ) ;
mMapView . getMapAutoViewHelper ( ) . animateCamera ( new LonLatPoint ( latLng . lon , latLng . lat ) ) ;
}
@Override
public void showMyLocation ( boolean visible ) {
Logger . d ( TAG , " showMyLocation1 %s " , visible ) ;
if ( visible & & NaviClient . getInstance ( getContext ( ) ) . isNaviing ( ) ) {
public void showMyLocation ( boolean visible ) {
Logger . d ( TAG , " showMyLocation1 %s " , visible ) ;
if ( visible & & NaviClient . getInstance ( getContext ( ) ) . isNaviing ( ) ) {
return ;
}
// if (DebugConfig.isDebug()) {
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
// }
if ( checkAMapView ( ) ) {
if ( checkAMapView ( ) ) {
MyLocationStyle style = mMapView . getMapAutoViewHelper ( ) . getMyLocationStyle ( ) ;
if ( visible ) {
if ( visible ) {
// 强制刷新一遍车标
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
}
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
}
}
@Override
public void showMyLocation ( View view ) {
Logger . d ( TAG , " showMyLocation %s " , " view " ) ;
if ( NaviClient . getInstance ( getContext ( ) ) . isNaviing ( ) ) {
public void showMyLocation ( View view ) {
Logger . d ( TAG , " showMyLocation %s " , " view " ) ;
if ( NaviClient . getInstance ( getContext ( ) ) . isNaviing ( ) ) {
return ;
}
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
}
if ( checkAMapView ( ) ) {
if ( checkAMapView ( ) ) {
MyLocationStyle style = mMapView . getMapAutoViewHelper ( ) . getMyLocationStyle ( ) ;
style . myLocationIcon ( BitmapDescriptorFactory . INSTANCE . convertViewToBitmap ( view ) ) ;
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
}
}
public void initMyLocation ( ) {
if ( checkAMapView ( ) ) {
mMapView . getMapAutoViewHelper ( ) . setMyLocationEnabled ( true ) ;
if ( checkAMapView ( ) ) {
mMapView . getMapAutoViewHelper ( ) . setMyLocationEnabled ( true ) ;
MyLocationStyle style = mMapView . getMapAutoViewHelper ( ) . getMyLocationStyle ( ) ;
style . setLocationType ( MyLocationStyle . LOCATION_TYPE_FOLLOW_NO_CENTER ) ;
style . interval ( 1000 ) ;
style . setLocationType ( MyLocationStyle . LOCATION_TYPE_FOLLOW_NO_CENTER ) ;
style . interval ( 1000 ) ;
// style.anchor( 0.5F, 0.5F );
// style.strokeColor( Color.TRANSPARENT );
// style.strokeWidth( 0 );
// style.radiusFillColor( Color.TRANSPARENT );
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
}
}
@Override
public void recoverLockMode ( ) {
if ( checkAMapView ( ) ) {
if ( checkAMapView ( ) ) {
// if ( DebugConfig.isDebug() ) {
// Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
// }
Logger . d ( TAG , " 锁车 " ) ;
Logger . d ( TAG , " 锁车 " ) ;
// mMapView.getMapAutoViewHelper().setZoom(mLockZoom);
mMapView . getMapAutoViewHelper ( ) . setLockMode ( true ) ;
mMapView . getMapAutoViewHelper ( ) . setLockMode ( true ) ;
mIsCarLocked = true ;
}
}
@Override
public void loseLockMode ( ) {
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
}
Logger . d ( TAG , " 解锁锁车 " ) ;
mMapView . getMapAutoViewHelper ( ) . setLockMode ( false ) ;
Logger . d ( TAG , " 解锁锁车 " ) ;
mMapView . getMapAutoViewHelper ( ) . setLockMode ( false ) ;
mIsCarLocked = false ;
}
@Override
public void setLockZoom ( int var1 ) {
public void setLockZoom ( int var1 ) {
mLockZoom = var1 ;
}
@Override
public void displayOverview ( Rect bounds ) {
public void displayOverview ( Rect bounds ) {
}
@@ -453,15 +455,15 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
@Override
public MogoLatLng getCameraNorthEastPosition ( ) {
return ObjectUtils . fromAMap ( MapTools . INSTANCE . getVisibleRegion ( ) . getRightTopPoint ( ) ) ;
return ObjectUtils . fromAMap ( MapTools . INSTANCE . getVisibleRegion ( ) . getRightTopPoint ( ) ) ;
}
@Override
public MogoLatLng getCameraSouthWestPosition ( ) {
try {
return ObjectUtils . fromAMap ( MapTools . INSTANCE . getVisibleRegion ( ) . getLeftBottomPoint ( ) ) ;
} catch ( Exception e ) {
return ObjectUtils . fromAMap ( MapTools . INSTANCE . getVisibleRegion ( ) . getLeftBottomPoint ( ) ) ;
} catch ( Exception e ) {
}
return null ;
@@ -470,30 +472,30 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
@Override
public MogoLatLng getWindowCenterLocation ( ) {
try {
return ObjectUtils . fromAMap ( mMapView . getMapAutoViewHelper ( ) . getCenter ( ) ) ;
} catch ( Exception e ) {
return ObjectUtils . fromAMap ( mMapView . getMapAutoViewHelper ( ) . getCenter ( ) ) ;
} catch ( Exception e ) {
}
return null ;
}
@Override
public void setPointToCenter ( double mapCenterX , double mapCenterY ) {
if ( checkAMapView ( ) ) {
public void setPointToCenter ( double mapCenterX , double mapCenterY ) {
if ( checkAMapView ( ) ) {
// if (DebugConfig.isDebug()) {
// Logger.d(TAG, Log.getStackTraceString(new Throwable()));
// }
Logger . d ( TAG , " setPointToCenter(%s, %s) " , mapCenterX , mapCenterY ) ;
mMapView . getMapAutoViewHelper ( ) . setPointToCenter ( ( float ) mapCenterX , ( float ) mapCenterY ) ;
Logger . d ( TAG , " setPointToCenter(%s, %s) " , mapCenterX , mapCenterY ) ;
mMapView . getMapAutoViewHelper ( ) . setPointToCenter ( ( float ) mapCenterX , ( float ) mapCenterY ) ;
}
}
@Override
public Point getLocationPointInScreen ( MogoLatLng latLng ) {
if ( checkAMapView ( ) ) {
public Point getLocationPointInScreen ( MogoLatLng latLng ) {
if ( checkAMapView ( ) ) {
try {
return MapTools . INSTANCE . toScreenLocation ( ObjectUtils . fromMogo ( latLng ) ) ;
} catch ( Exception e ) {
return MapTools . INSTANCE . toScreenLocation ( ObjectUtils . fromMogo ( latLng ) ) ;
} catch ( Exception e ) {
return null ;
}
}
@@ -501,12 +503,12 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public MogoLatLng getLocationMogoLatLngInScreen ( Point point ) {
if ( checkAMapView ( ) ) {
public MogoLatLng getLocationMogoLatLngInScreen ( Point point ) {
if ( checkAMapView ( ) ) {
try {
return ObjectUtils . fromAMap (
MapTools . INSTANCE . fromScreenLocation ( point ) ) ;
} catch ( Exception e ) {
MapTools . INSTANCE . fromScreenLocation ( point ) ) ;
} catch ( Exception e ) {
return null ;
}
}
@@ -514,9 +516,9 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public void startJumpAnimation ( IMogoMarker marker , float high , Interpolator interpolator ,
long duration ) {
if ( marker = = null | | high < = 0 . 0f | | interpolator = = null | | duration < 0 ) {
public void startJumpAnimation ( IMogoMarker marker , float high , Interpolator interpolator ,
long duration ) {
if ( marker = = null | | high < = 0 . 0f | | interpolator = = null | | duration < 0 ) {
return ;
}
try {
@@ -534,55 +536,55 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
// ( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
// ( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
// }
} catch ( Exception e ) {
Logger . e ( TAG , e , " error. " ) ;
} catch ( Exception e ) {
Logger . e ( TAG , e , " error. " ) ;
}
}
@Override
public void setRenderFps ( int fps ) {
if ( checkAMapView ( ) ) {
if ( mMapView . getMapAutoViewHelper ( ) ! = null ) {
mMapView . getMapAutoViewHelper ( ) . setRenderFps ( fps ) ;
Logger . d ( TAG , " 设置刷新帧率 fps = %s " , fps ) ;
public void setRenderFps ( int fps ) {
if ( checkAMapView ( ) ) {
if ( mMapView . getMapAutoViewHelper ( ) ! = null ) {
mMapView . getMapAutoViewHelper ( ) . setRenderFps ( fps ) ;
Logger . d ( TAG , " 设置刷新帧率 fps = %s " , fps ) ;
}
}
}
@Override
public void showBounds ( String tag , MogoLatLng carPosition , List < MogoLatLng > lonLats , Rect bound , boolean lockCarPosition ) {
if ( ! checkAMapView ( ) ) {
public void showBounds ( String tag , MogoLatLng carPosition , List < MogoLatLng > lonLats , Rect bound , boolean lockCarPosition ) {
if ( ! checkAMapView ( ) ) {
return ;
}
Logger . i ( TAG , " showBounds:%s -%s-%s- %b " , tag , carPosition . toString ( ) , bound . toShortString ( ) , lockCarPosition ) ;
Logger . i ( TAG , " showBounds:%s -%s-%s- %b " , tag , carPosition . toString ( ) , bound . toShortString ( ) , lockCarPosition ) ;
try {
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
if ( DebugConfig . isDebug ( ) ) {
Logger . d ( TAG , Log . getStackTraceString ( new Throwable ( ) ) ) ;
}
LatLngBounds latLngBounds = MogoMapUtils . getLatLngBounds ( carPosition , lonLats , lockCarPosition ) ;
if ( ! lockCarPosition ) {
LatLngBounds latLngBounds = MogoMapUtils . getLatLngBounds ( carPosition , lonLats , lockCarPosition ) ;
if ( ! lockCarPosition ) {
loseLockMode ( ) ;
}
mMapView . getMapAutoViewHelper ( ) . setCenter ( ObjectUtils . fromMogo ( carPosition ) ) ;
mMapView . getMapAutoViewHelper ( ) . moveCamera ( CameraUpdateFactory . INSTANCE . newLatLngBounds ( latLngBounds , bound . left , bound . right , bound . top , bound . bottom ) ) ;
} catch ( Exception e ) {
Logger . e ( TAG , e , " %s error. " , tag ) ;
mMapView . getMapAutoViewHelper ( ) . setCenter ( ObjectUtils . fromMogo ( carPosition ) ) ;
mMapView . getMapAutoViewHelper ( ) . moveCamera ( CameraUpdateFactory . INSTANCE . newLatLngBounds ( latLngBounds , bound . left , bound . right , bound . top , bound . bottom ) ) ;
} catch ( Exception e ) {
Logger . e ( TAG , e , " %s error. " , tag ) ;
}
}
@Override
public void forceRender ( ) {
if ( checkAMapView ( ) ) {
if ( checkAMapView ( ) ) {
mMapView . getMapAutoViewHelper ( ) . runOnDrawFrame ( ) ;
}
}
@Override
public float calculateLineDistance ( MogoLatLng p1 , MogoLatLng p2 ) throws Exception {
if ( p1 = = null | | p2 = = null ) {
throw new Exception ( " 计算距离的点不能为 null " ) ;
public float calculateLineDistance ( MogoLatLng p1 , MogoLatLng p2 ) throws Exception {
if ( p1 = = null | | p2 = = null ) {
throw new Exception ( " 计算距离的点不能为 null " ) ;
}
return MogoMapUtils . calculateLineDistance ( ObjectUtils . fromMogo ( p1 ) , ObjectUtils . fromMogo ( p2 ) ) ;
return MogoMapUtils . calculateLineDistance ( ObjectUtils . fromMogo ( p1 ) , ObjectUtils . fromMogo ( p2 ) ) ;
}
@@ -592,7 +594,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public void changeMyLocation ( Location location ) {
public void changeMyLocation ( Location location ) {
}
@Override
@@ -601,125 +603,125 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
}
@Override
public void setCarCursorOption ( CarCursorOption option ) {
if ( mCarCursorOption ! = null & & mCarCursorOption ! = DEFAULT_OPTION ) {
public void setCarCursorOption ( CarCursorOption option ) {
if ( mCarCursorOption ! = null & & mCarCursorOption ! = DEFAULT_OPTION ) {
mCarCursorOption . destroy ( ) ;
}
if ( option ! = null ) {
if ( option ! = null ) {
try {
mCarCursorOption = option . clone ( ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
mCarCursorOption = DEFAULT_OPTION ;
}
} else {
mCarCursorOption = DEFAULT_OPTION ;
}
if ( ! checkAMapView ( ) ) {
if ( ! checkAMapView ( ) ) {
return ;
}
if ( mMapView . getMapAutoViewHelper ( ) = = null ) {
if ( mMapView . getMapAutoViewHelper ( ) = = null ) {
return ;
}
MyLocationStyle style = mMapView . getMapAutoViewHelper ( ) . getMyLocationStyle ( ) ;
if ( mCarCursorOption . getCarCursorBmp ( ) ! = null & & ! mCarCursorOption . getCarCursorBmp ( ) . isRecycled ( ) ) {
style . myLocationIcon ( mCarCursorOption . getCarCursorBmp ( ) ) ;
if ( mCarCursorOption . getCarCursorBmp ( ) ! = null & & ! mCarCursorOption . getCarCursorBmp ( ) . isRecycled ( ) ) {
style . myLocationIcon ( mCarCursorOption . getCarCursorBmp ( ) ) ;
} else {
if ( mCarCursorOption . getCarCursorRes ( ) ! = 0 ) {
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
if ( mCarCursorOption . getCarCursorRes ( ) ! = 0 ) {
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
} else {
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
style . myLocationIcon ( mCarCursorOption . getCarCursorRes ( ) ) ;
}
}
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
mMapView . getMapAutoViewHelper ( ) . setMyLocationStyle ( style ) ;
}
@Override
public MapCameraPosition getMapCameraPosition ( ) {
if ( checkAMapView ( ) ) {
if ( checkAMapView ( ) ) {
CameraPosition cameraPosition = mMapView . getMapAutoViewHelper ( ) . getCameraPosition ( ) ;
return ObjectUtils . fromAMap ( cameraPosition ) ;
return ObjectUtils . fromAMap ( cameraPosition ) ;
}
return null ;
}
@Override
public void changeBearing ( float bearing ) {
if ( checkAMapView ( ) ) {
mMapView . getMapAutoViewHelper ( ) . setMapViewRotation ( bearing ) ;
public void changeBearing ( float bearing ) {
if ( checkAMapView ( ) ) {
mMapView . getMapAutoViewHelper ( ) . setMapViewRotation ( bearing ) ;
}
}
@Override
public void onLocationChanged ( @NotNull com . zhidaoauto . map . sdk . open . location . MogoLocation location ) {
Location sysLocation = new Location ( location . getProvider ( ) ) ;
sysLocation . setAltitude ( location . getAltitude ( ) ) ;
sysLocation . setLatitude ( location . getLat ( ) ) ;
sysLocation . setLongitude ( location . getLon ( ) ) ;
sysLocation . setSpeed ( location . getSpeed ( ) ) ;
NaviClient . getInstance ( getContext ( ) ) . syncCarLocation ( sysLocation ) ;
public void onLocationChanged ( @NotNull com . zhidaoauto . map . sdk . open . location . MogoLocation location ) {
Location sysLocation = new Location ( location . getProvider ( ) ) ;
sysLocation . setAltitude ( location . getAltitude ( ) ) ;
sysLocation . setLatitude ( location . getLat ( ) ) ;
sysLocation . setLongitude ( location . getLon ( ) ) ;
sysLocation . setSpeed ( location . getSpeed ( ) ) ;
NaviClient . getInstance ( getContext ( ) ) . syncCarLocation ( sysLocation ) ;
}
@Override
public void onMapClick ( @Nullable LonLatPoint lonLatPoint ) {
if ( InterceptorHandler . getInstance ( ) . ignoreMapClicked ( getContext ( ) ) ) {
public void onMapClick ( @Nullable LonLatPoint lonLatPoint ) {
if ( InterceptorHandler . getInstance ( ) . ignoreMapClicked ( getContext ( ) ) ) {
return ;
}
MogoMapListenerHandler . getInstance ( ) . onMapClick ( ObjectUtils . fromAMap ( lonLatPoint ) ) ;
MogoMapListenerHandler . getInstance ( ) . onMapClick ( ObjectUtils . fromAMap ( lonLatPoint ) ) ;
}
@Override
public void onMapLoaded ( ) {
Logger . i ( TAG , " autoop--onMapLoaded: " ) ;
Logger . i ( TAG , " autoop--onMapLoaded: " ) ;
MogoMapListenerHandler . getInstance ( ) . onMapLoaded ( ) ;
CameraPosition cameraPosition = mMapView . getMapAutoViewHelper ( ) . getCameraPosition ( ) ;
if ( cameraPosition ! = null ) {
Trace . beginSection ( " timer.onCameraChangeFinish " ) ;
MogoMapListenerHandler . getInstance ( ) . onMapChanged ( ObjectUtils . fromAMap ( cameraPosition . getTarget ( ) ) ,
if ( cameraPosition ! = null ) {
Trace . beginSection ( " timer.onCameraChangeFinish " ) ;
MogoMapListenerHandler . getInstance ( ) . onMapChanged ( ObjectUtils . fromAMap ( cameraPosition . getTarget ( ) ) ,
cameraPosition . getZoom ( ) ,
cameraPosition . getTilt ( ) ,
cameraPosition . getBearing ( ) ) ;
cameraPosition . getBearing ( ) ) ;
Trace . endSection ( ) ;
}
}
@Override
public boolean onTouch ( @Nullable MotionEvent motionEvent ) {
MogoMapListenerHandler . getInstance ( ) . onTouch ( motionEvent ) ;
public boolean onTouch ( @Nullable MotionEvent motionEvent ) {
MogoMapListenerHandler . getInstance ( ) . onTouch ( motionEvent ) ;
return false ;
}
@Override
public void onMarkClick ( @NotNull Marker markerInfo ) {
mMarkerClickHandler . handleMarkerClicked ( markerInfo ) ;
public void onMarkClick ( @NotNull Marker markerInfo ) {
mMarkerClickHandler . handleMarkerClicked ( markerInfo ) ;
}
@Override
public void onRoadLoaded ( @Nullable String s ) {
public void onRoadLoaded ( @Nullable String s ) {
}
@Override
public void onMapStatusChanged ( int type , int value ) {
Logger . i ( TAG , " mapop--onMapStatusChanged-: " + type + " , " + value ) ;
public void onMapStatusChanged ( int type , int value ) {
Logger . i ( TAG , " mapop--onMapStatusChanged-: " + type + " , " + value ) ;
}
@Override
public void onCameraChange ( int type , int value ) {
Logger . i ( TAG , " mapop--onCameraChange-: " + type + " , " + value ) ;
public void onCameraChange ( int type , int value ) {
Logger . i ( TAG , " mapop--onCameraChange-: " + type + " , " + value ) ;
}
@Override
public void onCameraChangeFinish ( @Nullable CameraPosition cameraPosition ) {
Logger . i ( TAG , " mapop--onCameraChangeFinish-: " + cameraPosition + " cost: " + ( System . currentTimeMillis ( ) - startTime ) ) ;
if ( cameraPosition ! = null ) {
Trace . beginSection ( " timer.onCameraChangeFinish " ) ;
MogoMapListenerHandler . getInstance ( ) . onMapChanged ( ObjectUtils . fromAMap ( cameraPosition . getTarget ( ) ) ,
public void onCameraChangeFinish ( @Nullable CameraPosition cameraPosition ) {
Logger . i ( TAG , " mapop--onCameraChangeFinish-: " + cameraPosition + " cost: " + ( System . currentTimeMillis ( ) - startTime ) ) ;
if ( cameraPosition ! = null ) {
Trace . beginSection ( " timer.onCameraChangeFinish " ) ;
MogoMapListenerHandler . getInstance ( ) . onMapChanged ( ObjectUtils . fromAMap ( cameraPosition . getTarget ( ) ) ,
cameraPosition . getZoom ( ) ,
cameraPosition . getTilt ( ) ,
cameraPosition . getBearing ( ) ) ;
cameraPosition . getBearing ( ) ) ;
Trace . endSection ( ) ;
}
}