导航功能
This commit is contained in:
@@ -46,16 +46,16 @@ import com.mogo.utils.logger.Logger;
|
||||
* 代理高德导航地图
|
||||
*/
|
||||
public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
IMogoMapUIController,
|
||||
AMap.OnMarkerClickListener,
|
||||
AMap.OnMapLoadedListener,
|
||||
AMap.OnMapTouchListener,
|
||||
AMap.OnPOIClickListener,
|
||||
AMap.OnMapClickListener,
|
||||
AMap.OnPolylineClickListener,
|
||||
AMapNaviViewListener,
|
||||
AMapMessageListener,
|
||||
AMap.OnCameraChangeListener {
|
||||
IMogoMapUIController,
|
||||
AMap.OnMarkerClickListener,
|
||||
AMap.OnMapLoadedListener,
|
||||
AMap.OnMapTouchListener,
|
||||
AMap.OnPOIClickListener,
|
||||
AMap.OnMapClickListener,
|
||||
AMap.OnPolylineClickListener,
|
||||
AMapNaviViewListener,
|
||||
AMapMessageListener,
|
||||
AMap.OnCameraChangeListener {
|
||||
|
||||
private static final String TAG = "AMapNaviViewWrapper";
|
||||
|
||||
@@ -64,101 +64,95 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
|
||||
public AMapNaviViewWrapper( AMapNaviView mapView ) {
|
||||
public AMapNaviViewWrapper(AMapNaviView mapView) {
|
||||
this.mMapView = mapView;
|
||||
this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView, this );
|
||||
initMapView();
|
||||
initListeners();
|
||||
this.mIMap = new AMapWrapper(mMapView.getMap(), mMapView, this);
|
||||
}
|
||||
|
||||
private void initMapView() {
|
||||
if ( mMapView != null ) {
|
||||
if (mMapView != null) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options != null ) {
|
||||
if (options != null) {
|
||||
// 设置是否开启自动黑夜模式切换,默认为false,不自动切换
|
||||
options.setAutoNaviViewNightMode( false );
|
||||
options.setAutoNaviViewNightMode(false);
|
||||
// 设置6秒后是否自动锁车
|
||||
options.setAutoLockCar( false );
|
||||
options.setAutoLockCar(false);
|
||||
// 设置路线上的摄像头气泡是否显示
|
||||
options.setCameraBubbleShow( true );
|
||||
options.setCameraBubbleShow(true);
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||
// 设置自车的图片对象
|
||||
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_amap_navi_cursor ) );
|
||||
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
|
||||
R.drawable.ic_amap_navi_cursor));
|
||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||
options.setCompassEnabled( false );
|
||||
options.setCompassEnabled(false);
|
||||
// 黑夜模式
|
||||
options.setNaviNight( true );
|
||||
options.setNaviNight(true);
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficBarEnabled( false );
|
||||
options.setTrafficBarEnabled(false);
|
||||
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficLayerEnabled( false );
|
||||
options.setTrafficLayerEnabled(false);
|
||||
// 设置导航界面是否显示路线全览按钮。
|
||||
options.setRouteListButtonShow( false );
|
||||
options.setRouteListButtonShow(false);
|
||||
// 设置导航状态下屏幕是否一直开启。
|
||||
options.setScreenAlwaysBright( true );
|
||||
options.setScreenAlwaysBright(true);
|
||||
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
|
||||
options.setTrafficInfoUpdateEnabled( true );
|
||||
options.setTrafficInfoUpdateEnabled(true);
|
||||
// 设置摄像头播报是否打开(只适用于驾车导航)。
|
||||
options.setCameraInfoUpdateEnabled( true );
|
||||
options.setCameraInfoUpdateEnabled(true);
|
||||
// 设置菜单按钮是否在导航界面显示。
|
||||
options.setSettingMenuEnabled( false );
|
||||
options.setSettingMenuEnabled(false);
|
||||
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
|
||||
options.setTrafficLine( true );
|
||||
options.setTrafficLine(true);
|
||||
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
|
||||
options.setLeaderLineEnabled( -1 );
|
||||
options.setLeaderLineEnabled(-1);
|
||||
// 设置导航界面UI是否显示。
|
||||
options.setLayoutVisible( false );
|
||||
options.setLayoutVisible(false);
|
||||
// 设置是否自动画路
|
||||
options.setAutoDrawRoute( false );
|
||||
options.setAutoDrawRoute(false);
|
||||
// 设置是否显示路口放大图(实景图)
|
||||
options.setRealCrossDisplayShow( false );
|
||||
options.setRealCrossDisplayShow(false);
|
||||
// 设置是否显示路口放大图(路口模型图)
|
||||
options.setModeCrossDisplayShow( false );
|
||||
options.setModeCrossDisplayShow(false);
|
||||
// 设置是否显示道路信息view
|
||||
options.setLaneInfoShow( false );
|
||||
options.setLaneInfoShow(false);
|
||||
// 设置是否自动改变缩放等级
|
||||
options.setAutoChangeZoom( true );
|
||||
options.setAutoChangeZoom(true);
|
||||
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setAutoDisplayOverview( false );
|
||||
options.setAutoDisplayOverview(false);
|
||||
// 设置路线转向箭头隐藏和显示
|
||||
options.setNaviArrowVisible( false );
|
||||
options.setNaviArrowVisible(false);
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray( true );
|
||||
options.setZoom( 16 );
|
||||
options.setPointToCenter( 0.5D, 0.5D );
|
||||
options.setAfterRouteAutoGray(true);
|
||||
options.setZoom(16);
|
||||
options.setPointToCenter(0.5D, 0.5D);
|
||||
// 2D模式
|
||||
options.setTilt( 0 );
|
||||
mMapView.setViewOptions( options );
|
||||
|
||||
options.setTilt(0);
|
||||
mMapView.setViewOptions(options);
|
||||
}
|
||||
mMapView.setRouteOverlayVisible( false );
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
mMapView.setRouteOverlayVisible(false);
|
||||
mMapView.setCarOverlayVisible(false);
|
||||
mMapView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
mMapView.setOnMarkerClickListener( this );
|
||||
mMapView.setOnMarkerClickListener(this);
|
||||
mMarkerClickHandler = new AMapMarkerClickHandler();
|
||||
mMapView.setOnMapLoadedListener( this );
|
||||
mMapView.setOnMapTouchListener( this );
|
||||
mMapView.setOnPolylineClickListener( this );
|
||||
mMapView.setAMapNaviViewListener( this );
|
||||
mMapView.setOnCameraChangeListener( this );
|
||||
mMapView.setOnMapLoadedListener(this);
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnPolylineClickListener(this);
|
||||
mMapView.setAMapNaviViewListener(this);
|
||||
mMapView.setOnCameraChangeListener(this);
|
||||
|
||||
final AMap aMap = mMapView.getMap();
|
||||
if ( aMap != null ) {
|
||||
aMap.setOnPOIClickListener( this );
|
||||
aMap.setOnMapClickListener( this );
|
||||
aMap.setOnCameraChangeListener( this );
|
||||
if (aMap != null) {
|
||||
aMap.setOnPOIClickListener(this);
|
||||
aMap.setOnMapClickListener(this);
|
||||
aMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||
|
||||
|
||||
|
||||
|
||||
AMapMessageManager.getInstance().registerAMapMessageListener(this);
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
@@ -176,61 +170,59 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( Bundle bundle ) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onCreate( bundle );
|
||||
public void onCreate(Bundle bundle) {
|
||||
if (mMapView != null) {
|
||||
mMapView.onCreate(bundle);
|
||||
Logger.d(TAG, "map onCreate");
|
||||
initMapView();
|
||||
initListeners();
|
||||
initMyLocation();
|
||||
}
|
||||
Logger.d( TAG, "map onCreate" );
|
||||
}
|
||||
|
||||
@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 );
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
if (mMapView != null) {
|
||||
mMapView.onSaveInstanceState(outState);
|
||||
Logger.d(TAG, "map onSaveInstanceState");
|
||||
}
|
||||
Logger.d( TAG, "map onSaveInstanceState" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
Logger.d( TAG, "map onLowMemory" );
|
||||
Logger.d(TAG, "map onLowMemory");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地图marker点击
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onMarkerClick( Marker marker ) {
|
||||
return mMarkerClickHandler.handleMarkerClicked( marker );
|
||||
public boolean onMarkerClick(Marker marker) {
|
||||
return mMarkerClickHandler.handleMarkerClicked(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,38 +235,34 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
|
||||
/**
|
||||
* 地图点击回调
|
||||
*
|
||||
* @param motionEvent
|
||||
*/
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
MogoMapListenerHandler.getInstance().onTouch( motionEvent );
|
||||
public void onTouch(MotionEvent motionEvent) {
|
||||
MogoMapListenerHandler.getInstance().onTouch(motionEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* POI 点击
|
||||
*
|
||||
* @param poi
|
||||
*/
|
||||
@Override
|
||||
public void onPOIClick( Poi poi ) {
|
||||
if ( InterceptorHandler.getInstance().ignorePoiClicked( getContext() ) ) {
|
||||
public void onPOIClick(Poi poi) {
|
||||
if (InterceptorHandler.getInstance().ignorePoiClicked(getContext())) {
|
||||
return;
|
||||
}
|
||||
MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) );
|
||||
MogoMapListenerHandler.getInstance().onPOIClick(ObjectUtils.fromAMap(poi));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( LatLng latLng ) {
|
||||
if ( InterceptorHandler.getInstance().ignoreMapClicked( getContext() ) ) {
|
||||
public void onMapClick(LatLng latLng) {
|
||||
if (InterceptorHandler.getInstance().ignoreMapClicked(getContext())) {
|
||||
return;
|
||||
}
|
||||
MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( latLng ) );
|
||||
MogoMapListenerHandler.getInstance().onMapClick(ObjectUtils.fromAMap(latLng));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPolylineClick( Polyline polyline ) {
|
||||
NaviClient.getInstance( getContext() ).handleClickedPolyline( polyline );
|
||||
public void onPolylineClick(Polyline polyline) {
|
||||
NaviClient.getInstance(getContext()).handleClickedPolyline(polyline);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,8 +284,8 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
* @param mode 0:车头朝上状态;1:正北朝上模式
|
||||
*/
|
||||
@Override
|
||||
public void onNaviMapMode( int mode ) {
|
||||
Logger.i( TAG, "mode=" + mode );
|
||||
public void onNaviMapMode(int mode) {
|
||||
Logger.i(TAG, "mode=" + mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,8 +304,8 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean isLock ) {
|
||||
MogoMapListenerHandler.getInstance().onLockMap( isLock );
|
||||
public void onLockMap(boolean isLock) {
|
||||
MogoMapListenerHandler.getInstance().onLockMap(isLock);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,128 +314,135 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapTypeChanged( int type ) {
|
||||
if ( type == 4 ) {
|
||||
MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_Light );
|
||||
} else if ( type == 3 ) {
|
||||
MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_Night );
|
||||
public void onMapTypeChanged(int type) {
|
||||
if (type == 4) {
|
||||
MogoMapListenerHandler.getInstance().onMapModeChanged(EnumMapUI.Type_Light);
|
||||
} else if (type == 3) {
|
||||
MogoMapListenerHandler.getInstance().onMapModeChanged(EnumMapUI.Type_Night);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviViewShowMode( int i ) {
|
||||
public void onNaviViewShowMode(int i) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTrafficEnabled( boolean visible ) {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.setTrafficLine( visible );
|
||||
public void setTrafficEnabled(boolean visible) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.setTrafficLine(visible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeZoom( boolean zoom ) {
|
||||
if ( checkAMapView() ) {
|
||||
if ( zoom ) {
|
||||
public void changeZoom(boolean zoom) {
|
||||
if (checkAMapView()) {
|
||||
if (zoom) {
|
||||
mMapView.zoomIn();
|
||||
} else {
|
||||
mMapView.zoomOut();
|
||||
}
|
||||
Logger.i( TAG, "mapview zoom = " + mMapView.getMap().getCameraPosition().zoom );
|
||||
Logger.i( TAG, "scalePerPixel = " + getMap().getScalePerPixel() );
|
||||
Logger.i(TAG, "mapview zoom = " + mMapView.getMap().getCameraPosition().zoom);
|
||||
Logger.i(TAG, "scalePerPixel = " + getMap().getScalePerPixel());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeZoom( float zoom ) {
|
||||
getMap().changeZoom( zoom );
|
||||
public void changeZoom(float zoom) {
|
||||
getMap().changeZoom(zoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMapMode( EnumMapUI ui ) {
|
||||
if ( ui == null ) {
|
||||
public void changeMapMode(EnumMapUI ui) {
|
||||
if (ui == null) {
|
||||
return;
|
||||
}
|
||||
if ( checkAMapView() ) {
|
||||
if (checkAMapView()) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
if ( options == null ) {
|
||||
if (options == null) {
|
||||
options = new AMapNaviViewOptions();
|
||||
}
|
||||
switch ( ui ) {
|
||||
switch (ui) {
|
||||
case CarUp_2D:
|
||||
options.setTilt( 0 );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
options.setTilt(0);
|
||||
mMapView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
break;
|
||||
case CarUp_3D:
|
||||
options.setTilt( 60 );
|
||||
mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE );
|
||||
options.setTilt(60);
|
||||
mMapView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
break;
|
||||
case NorthUP_2D:
|
||||
options.setTilt( 0 );
|
||||
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
||||
options.setTilt(0);
|
||||
mMapView.setNaviMode(AMapNaviView.NORTH_UP_MODE);
|
||||
break;
|
||||
case Type_Light:
|
||||
options.setNaviNight( false );
|
||||
options.setNaviNight(false);
|
||||
break;
|
||||
case Type_Night:
|
||||
options.setNaviNight( true );
|
||||
options.setNaviNight(true);
|
||||
break;
|
||||
case Type_AUTO_LIGHT_Night:
|
||||
options.setNaviNight( false );
|
||||
options.setAutoNaviViewNightMode( true );
|
||||
options.setNaviNight(false);
|
||||
options.setAutoNaviViewNightMode(true);
|
||||
break;
|
||||
}
|
||||
mMapView.setViewOptions( options );
|
||||
mMapView.setViewOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAMapView() {
|
||||
if ( mMapView == null ) {
|
||||
Logger.e( TAG, "高德mapView实例为空,请检查" );
|
||||
if (mMapView == null) {
|
||||
Logger.e(TAG, "高德mapView实例为空,请检查");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCenter( MogoLatLng 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) {
|
||||
if (latLng == null || latLng.lat == 0.0d || latLng.lng == 0.0d) {
|
||||
Logger.e(TAG, "latlng = null or is illegal");
|
||||
return;
|
||||
}
|
||||
mMapView.getMap().moveCamera( CameraUpdateFactory.newLatLng( new LatLng( latLng.lat, latLng.lng ) ) );
|
||||
mMapView.getMap()
|
||||
.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(latLng.lat, latLng.lng)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMyLocation( boolean visible ) {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMap().setMyLocationEnabled( true );
|
||||
public void showMyLocation(boolean visible) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMap().setMyLocationEnabled(visible);
|
||||
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
||||
style.myLocationType( MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER );
|
||||
style.interval(1000);
|
||||
style.showMyLocation( visible );
|
||||
style.strokeColor( Color.TRANSPARENT );
|
||||
style.strokeWidth( 0 );
|
||||
style.showMyLocation(visible);
|
||||
style.radiusFillColor( Color.TRANSPARENT );
|
||||
style.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.map_api_ic_current_location ) );
|
||||
mMapView.getMap().setMyLocationStyle( style );
|
||||
mMapView.getMap().setMyLocationStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
public void initMyLocation() {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMap().setMyLocationEnabled(true);
|
||||
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
||||
style.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
style.interval(1000);
|
||||
style.strokeColor(Color.TRANSPARENT);
|
||||
style.strokeWidth(0);
|
||||
style.myLocationIcon(
|
||||
BitmapDescriptorFactory.fromResource(R.drawable.map_api_ic_current_location));
|
||||
mMapView.getMap().setMyLocationStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if ( checkAMapView() ) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.recoverLockMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayOverview() {
|
||||
if ( checkAMapView() ) {
|
||||
if ( NaviClient.getInstance( getContext() ).isNaviing() ) {
|
||||
if (checkAMapView()) {
|
||||
if (NaviClient.getInstance(getContext()).isNaviing()) {
|
||||
mMapView.displayOverview();
|
||||
}
|
||||
}
|
||||
@@ -465,41 +460,44 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onNaviStarted() {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.setCarOverlayVisible( true );
|
||||
if (checkAMapView()) {
|
||||
mMapView.setCarOverlayVisible(true);
|
||||
//showMyLocation( false );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviStopped() {
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
showMyLocation( true );
|
||||
if (checkAMapView()) {
|
||||
mMapView.setCarOverlayVisible(false);
|
||||
showMyLocation(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdat( NaviInfo naviInfo ) {
|
||||
public void onNaviInfoUpdat(NaviInfo naviInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange( CameraPosition cameraPosition ) {
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish( CameraPosition cameraPosition ) {
|
||||
if ( cameraPosition != null ) {
|
||||
MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.target ), cameraPosition.zoom, cameraPosition.tilt, cameraPosition.bearing );
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
if (cameraPosition != null) {
|
||||
MogoMapListenerHandler.getInstance()
|
||||
.onMapChanged(ObjectUtils.fromAMap(cameraPosition.target), cameraPosition.zoom,
|
||||
cameraPosition.tilt, cameraPosition.bearing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast );
|
||||
} catch ( Exception e ) {
|
||||
return ObjectUtils.fromAMap(
|
||||
mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -508,8 +506,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest );
|
||||
} catch ( Exception e ) {
|
||||
return ObjectUtils.fromAMap(
|
||||
mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
@@ -518,28 +517,30 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public MogoLatLng getWindowCenterLocation() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap( mMapView.getMap().getCameraPosition().target );
|
||||
} catch ( Exception e ) {
|
||||
return ObjectUtils.fromAMap(mMapView.getMap().getCameraPosition().target);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter( double mapCenterX, double mapCenterY ) {
|
||||
if ( checkAMapView() ) {
|
||||
public void setPointToCenter(double mapCenterX, double mapCenterY) {
|
||||
if (checkAMapView()) {
|
||||
AMapNaviViewOptions options = mMapView.getViewOptions();
|
||||
options.setPointToCenter( mapCenterX, mapCenterY );
|
||||
mMapView.setViewOptions( options );
|
||||
options.setPointToCenter(mapCenterX, mapCenterY);
|
||||
mMapView.setViewOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getLocationPointInScreen( MogoLatLng latLng ) {
|
||||
if ( checkAMapView() ) {
|
||||
public Point getLocationPointInScreen(MogoLatLng latLng) {
|
||||
if (checkAMapView()) {
|
||||
try {
|
||||
return mMapView.getMap().getProjection().toScreenLocation( ObjectUtils.fromMogo2( latLng ) );
|
||||
} catch ( Exception e ) {
|
||||
return mMapView.getMap()
|
||||
.getProjection()
|
||||
.toScreenLocation(ObjectUtils.fromMogo2(latLng));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -548,10 +549,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||||
if ( checkAMapView() ) {
|
||||
if (checkAMapView()) {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(mMapView.getMap().getProjection().fromScreenLocation( point ));
|
||||
} catch ( Exception e ) {
|
||||
return ObjectUtils.fromAMap(
|
||||
mMapView.getMap().getProjection().fromScreenLocation(point));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -559,27 +561,28 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
@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 {
|
||||
final LatLng latLng = ObjectUtils.fromMogo2( marker.getPosition() );
|
||||
Point point = mMapView.getMap().getProjection().toScreenLocation( latLng );
|
||||
point.y -= WindowUtils.dip2px( getContext(), high );
|
||||
LatLng target = mMapView.getMap().getProjection().fromScreenLocation( point );
|
||||
final LatLng latLng = ObjectUtils.fromMogo2(marker.getPosition());
|
||||
Point point = mMapView.getMap().getProjection().toScreenLocation(latLng);
|
||||
point.y -= WindowUtils.dip2px(getContext(), high);
|
||||
LatLng target = mMapView.getMap().getProjection().fromScreenLocation(point);
|
||||
//使用TranslateAnimation,填写一个需要移动的目标点
|
||||
Animation animation = new TranslateAnimation( target );
|
||||
animation.setInterpolator( interpolator );
|
||||
Animation animation = new TranslateAnimation(target);
|
||||
animation.setInterpolator(interpolator);
|
||||
//整个移动所需要的时间
|
||||
animation.setDuration( duration );
|
||||
animation.setDuration(duration);
|
||||
//设置动画
|
||||
if ( marker instanceof AMapMarkerWrapper ) {
|
||||
( ( AMapMarkerWrapper ) marker ).getMarker().setAnimation( animation );
|
||||
( ( AMapMarkerWrapper ) marker ).getMarker().startAnimation();
|
||||
if (marker instanceof AMapMarkerWrapper) {
|
||||
((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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
}
|
||||
MogoNaviListenerHandler.getInstance().onStartNavi();
|
||||
AMapMessageManager.getInstance().postNaviStarted();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user