+ * 描述 + */ +public class AMapBaseMapView extends MogoBaseMapView { + + public AMapBaseMapView( Context context ) { + super( context ); + } + + public AMapBaseMapView( Context context, @Nullable AttributeSet attrs ) { + super( context, attrs ); + } + + public AMapBaseMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) { + super( context, attrs, defStyleAttr ); + } + + @Override + protected IMogoMapView createMapView( Context context ) { + return new AMapNaviViewWrapper( new AMapNaviView( context ) ); + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapMarkerClickHandler.java similarity index 95% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapMarkerClickHandler.java index bb15e1b351..1592ad0503 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapMarkerClickHandler.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap; +package com.mogo.map.impl.amap; import com.amap.api.maps.model.Marker; import com.mogo.map.marker.IMogoMarker; 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 new file mode 100644 index 0000000000..34268ce112 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -0,0 +1,303 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; +import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.Poi; +import com.amap.api.maps.model.Polyline; +import com.amap.api.navi.AMapNaviListener; +import com.amap.api.navi.AMapNaviView; +import com.amap.api.navi.AMapNaviViewListener; +import com.amap.api.navi.AMapNaviViewOptions; +import com.mogo.map.IMogoMap; +import com.mogo.map.IMogoMapView; +import com.mogo.map.impl.amap.navi.NaviClient; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.listener.MogoMapListenerHandler; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 代理高德导航地图 + */ +public class AMapNaviViewWrapper implements IMogoMapView, + AMap.OnMarkerClickListener, + AMap.OnMapLoadedListener, + AMap.OnMapTouchListener, + AMap.OnPOIClickListener, + AMap.OnMapClickListener, + AMap.OnPolylineClickListener, + AMapNaviViewListener { + + private static final String TAG = "AMapNaviViewWrapper"; + + private final AMapNaviView mMapView; + private IMogoMap mIMap; + + private AMapMarkerClickHandler mMarkerClickHandler; + + public AMapNaviViewWrapper( AMapNaviView mapView ) { + this.mMapView = mapView; + this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView ); + initMapView(); + initListeners(); + } + + private void initMapView() { + if ( mMapView != null ) { + AMapNaviViewOptions options = mMapView.getViewOptions(); + if ( options != null ) { + // 设置是否开启自动黑夜模式切换,默认为false,不自动切换 + options.setAutoNaviViewNightMode( false ); + // 设置6秒后是否自动锁车 + options.setAutoLockCar( true ); + // 设置路线上的摄像头气泡是否显示 + options.setCameraBubbleShow( true ); + // 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。 + // options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() ); + // 设置自车的图片对象 + options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_search_poi_location ) ); + // 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。 + options.setCompassEnabled( false ); + //设置路况光柱条是否显示(只适用于驾车导航,需要联网)。 + options.setTrafficBarEnabled( false ); + // 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。 + options.setTrafficLayerEnabled( false ); + // 设置导航界面是否显示路线全览按钮。 + options.setRouteListButtonShow( false ); + // 设置起点位图,须在画路前设置 +// options.setStartPointBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_current_location_cursor ) ); + // 设置终点位图,须在画路前设置 +// options.setEndPointBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_search_choice_point ) ); + // 设置导航状态下屏幕是否一直开启。 + options.setScreenAlwaysBright( true ); + // 设置交通播报是否打开(只适用于驾车导航,需要联网)。 + options.setTrafficInfoUpdateEnabled( true ); + // 设置摄像头播报是否打开(只适用于驾车导航)。 + options.setCameraInfoUpdateEnabled( true ); + // 设置菜单按钮是否在导航界面显示。 + options.setSettingMenuEnabled( false ); + // 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。 + options.setTrafficLine( true ); + // 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。 + options.setLeaderLineEnabled( -1 ); + // 设置导航界面UI是否显示。 + options.setLayoutVisible( false ); + // 设置是否自动画路 + options.setAutoDrawRoute( false ); + // 设置是否显示路口放大图(实景图) + options.setRealCrossDisplayShow( false ); + // 设置是否显示路口放大图(路口模型图) + options.setModeCrossDisplayShow( false ); + // 设置是否显示道路信息view + options.setLaneInfoShow( false ); + // 设置是否自动改变缩放等级 + options.setAutoChangeZoom( false ); + // 设置是否自动全览模式,即在算路成功后自动进入全览模式 + options.setAutoDisplayOverview( false ); + // 设置路线转向箭头隐藏和显示 + options.setNaviArrowVisible( false ); + // 通过路线是否自动置灰,仅支持驾车导航 + options.setAfterRouteAutoGray( true ); + options.setPointToCenter( 0.5D, 0.5D ); + // 2D模式 + options.setTilt( 0 ); + mMapView.setViewOptions( options ); + } + mMapView.setRouteOverlayVisible( false ); + mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE ); + } + } + + private void initListeners() { + mMapView.setOnMarkerClickListener( this ); + mMarkerClickHandler = new AMapMarkerClickHandler(); + mMapView.setOnMapLoadedListener( this ); + mMapView.setOnMapTouchListener( this ); + mMapView.setOnPolylineClickListener( this ); + mMapView.setAMapNaviViewListener( this ); + if ( mMapView.getMap() != null ) { + mMapView.getMap().setOnPOIClickListener( this ); + mMapView.getMap().setOnMapClickListener( this ); + } + } + + private Context getContext() { + return mMapView.getContext(); + } + + @Override + public View getMapView() { + return mMapView; + } + + @Override + public IMogoMap getMap() { + return mIMap; + } + + @Override + public void onCreate( Bundle bundle ) { + if ( mMapView != null ) { + mMapView.onCreate( bundle ); + } + } + + @Override + public void onResume() { + if ( mMapView != null ) { + mMapView.onResume(); + } + } + + @Override + public void onPause() { + if ( mMapView != null ) { + mMapView.onPause(); + } + } + + @Override + public void onDestroy() { + if ( mMapView != null ) { + mMapView.onDestroy(); + } + } + + @Override + public void onSaveInstanceState( Bundle outState ) { + if ( mMapView != null ) { + mMapView.onSaveInstanceState( outState ); + } + } + + @Override + public void onLowMemory() { + } + + + /** + * 地图marker点击 + * + * @param marker + * @return + */ + @Override + public boolean onMarkerClick( Marker marker ) { + return mMarkerClickHandler.handleMarkerClicked( marker ); + } + + /** + * 地图加载完毕 + */ + @Override + public void onMapLoaded() { + MogoMapListenerHandler.getInstance().onMapLoaded(); + } + + /** + * 地图点击回调 + * + * @param motionEvent + */ + @Override + public void onTouch( MotionEvent motionEvent ) { + MogoMapListenerHandler.getInstance().onTouch( motionEvent ); + } + + /** + * POI 点击 + * + * @param poi + */ + @Override + public void onPOIClick( Poi poi ) { + if ( InterceptorHandler.getInstance().ignorePoiClickedWhenNaviing( getContext() ) ) { + return; + } + MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) ); + } + + @Override + public void onMapClick( LatLng latLng ) { + if ( InterceptorHandler.getInstance().ignoreMapClickedWhenNaviing( getContext() ) ) { + return; + } + MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromAMap( latLng ) ); + } + + @Override + public void onPolylineClick( Polyline polyline ) { + NaviClient.getInstance( getContext() ).handleClickedPolyline( polyline ); + } + + @Override + public void onNaviSetting() { + + } + + @Override + public void onNaviCancel() { + + } + + @Override + public boolean onNaviBackClick() { + return true; + } + + @Override + public void onNaviMapMode( int i ) { + + } + + @Override + public void onNaviTurnClick() { + + } + + @Override + public void onNextRoadClick() { + + } + + @Override + public void onScanViewButtonClick() { + + } + + @Override + public void onLockMap( boolean isLock ) { + MogoMapListenerHandler.getInstance().onLockMap( isLock ); + } + + @Override + public void onNaviViewLoaded() { + + } + + @Override + public void onMapTypeChanged( int type ) { + if ( type == AMap.MAP_TYPE_NAVI ) { + MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_Navi ); + } else if ( type == AMap.MAP_TYPE_NORMAL ) { + MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_Light ); + } else if ( type == AMap.MAP_TYPE_NIGHT ) { + MogoMapListenerHandler.getInstance().onMapModeChanged( EnumMapUI.Type_Light ); + } + } + + @Override + public void onNaviViewShowMode( int i ) { + + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapUiSettingsWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapUiSettingsWrapper.java similarity index 95% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapUiSettingsWrapper.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapUiSettingsWrapper.java index 877e4c582a..fa904a0afa 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapUiSettingsWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapUiSettingsWrapper.java @@ -1,7 +1,7 @@ -package com.mogo.map.amap; +package com.mogo.map.impl.amap; import com.amap.api.maps.UiSettings; -import com.mogo.map.IUiSettings; +import com.mogo.map.IMogoUiSettings; import java.lang.reflect.Method; @@ -11,7 +11,7 @@ import java.lang.reflect.Method; *
* 代理高德地图UiSettings */ -public class AMapUiSettingsWrapper implements IUiSettings { +public class AMapUiSettingsWrapper implements IMogoUiSettings { private UiSettings mUiSettings; diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java new file mode 100644 index 0000000000..7d929ffa8d --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapWrapper.java @@ -0,0 +1,313 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.CameraUpdateFactory; +import com.amap.api.maps.model.BitmapDescriptorFactory; +import com.amap.api.maps.model.LatLng; +import com.amap.api.maps.model.Marker; +import com.amap.api.maps.model.MarkerOptions; +import com.amap.api.maps.model.MyLocationStyle; +import com.amap.api.navi.AMapNaviView; +import com.amap.api.navi.AMapNaviViewOptions; +import com.mogo.map.IMogoMap; +import com.mogo.map.IMogoUiSettings; +import com.mogo.map.impl.amap.location.ALocationClient; +import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter; +import com.mogo.map.impl.amap.marker.AMapMarkerWrapper; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.location.MogoLocation; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.marker.MogoMarkersHandler; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 代理高德AMap + */ +public class AMapWrapper implements IMogoMap, IMogoMapUIController { + + private static final String TAG = "AMapWrapper"; + + private static AMap sAMap; + private AMap mAMap; + private AMapNaviView mMapView; + private IMogoUiSettings mUiSettings; + + public AMapWrapper( AMap map, AMapNaviView mapView ) { + this.mAMap = map; + sAMap = map; + this.mMapView = mapView; + // 设置实现自定义 info window + mAMap.setInfoWindowAdapter( new AMapInfoWindowAdapter() ); + } + + public static AMap getAMap() { + return sAMap; + } + + @Override + public IMogoUiSettings getUiSettings() { + if ( !checkAMap() ) { + return null; + } + if ( mUiSettings == null ) { + mUiSettings = new AMapUiSettingsWrapper( mAMap.getUiSettings() ); + } + return mUiSettings; + } + + @Override + public IMogoMapUIController getUIController() { + return this; + } + + @Override + public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) { + if ( !checkAMap() ) { + return null; + } + MarkerOptions markerOptions = ObjectUtils.fromMogo( options ); + if ( markerOptions == null ) { + Logger.e( TAG, "marker参数为空" ); + return null; + } + final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ) ); + MogoMarkersHandler.getInstance().add( tag, mogoMarker ); + return mogoMarker; + } + + @Override + public ArrayList< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) { + if ( !checkAMap() ) { + return null; + } + + if ( options == null || options.isEmpty() ) { + return null; + } + + // 地图导航时,忽略参数 + if ( InterceptorHandler.getInstance().ignoreAddMarkersMoveToCenterParameters( getContext() ) ) { + moveToCenter = false; + } + + ArrayList< Marker > markers = null; + ArrayList< MarkerOptions > markerOptions = new ArrayList<>(); + ArrayList< IMogoMarker > mogoMarkers = new ArrayList<>(); + + for ( MogoMarkerOptions option : options ) { + if ( option == null ) { + continue; + } + MarkerOptions mo = ObjectUtils.fromMogo( option ); + if ( mo == null ) { + continue; + } + markerOptions.add( mo ); + } + if ( markerOptions.isEmpty() ) { + return null; + } + markers = mAMap.addMarkers( markerOptions, moveToCenter ); + if ( markers == null || markers.isEmpty() ) { + return null; + } + for ( Marker marker : markers ) { + if ( marker == null ) { + continue; + } + mogoMarkers.add( new AMapMarkerWrapper( marker ) ); + } + MogoMarkersHandler.getInstance().add( tag, mogoMarkers ); + return mogoMarkers; + } + + @Override + public void clear() { + if ( checkAMap() ) { + mAMap.clear(); + } + } + + @Override + public void clear( boolean isKeepMyLocationOverlay ) { + if ( checkAMap() ) { + mAMap.clear( isKeepMyLocationOverlay ); + } + } + + @Override + public void setPointToCenter( int x, int y ) { + if ( checkAMap() ) { + mAMap.setPointToCenter( x, y ); + } + } + + @Override + public void setTouchPoiEnable( boolean touchPoiEnable ) { + if ( checkAMap() ) { + mAMap.setTouchPoiEnable( touchPoiEnable ); + } + } + + @Override + public void setTrafficEnable( boolean enable ) { + if ( checkAMap() ) { + mAMap.setTrafficEnabled( enable ); + } + } + + @Override + public void showBuildings( boolean enabled ) { + if ( checkAMap() ) { + mAMap.showBuildings( enabled ); + } + } + + @Override + public void showIndoorMap( boolean enable ) { + if ( checkAMap() ) { + mAMap.showIndoorMap( enable ); + } + } + + @Override + public void showMapText( boolean enable ) { + if ( checkAMap() ) { + mAMap.showMapText( enable ); + } + } + + @Override + public void stopAnimation() { + if ( checkAMap() ) { + mAMap.stopAnimation(); + } + } + + @Override + public void setTrafficEnabled( boolean visible ) { + if ( checkAMap() ) { + mAMap.setTrafficEnabled( visible ); + } + } + + @Override + public void changeZoom( boolean zoom ) { + if ( checkAMapView() ) { + if ( zoom ) { + mMapView.zoomIn(); + } else { + mMapView.zoomOut(); + } + } + } + + @Override + public void changeMapMode( EnumMapUI ui ) { + if ( ui == null ) { + return; + } + if ( checkAMapView() ) { + AMapNaviViewOptions options = mMapView.getViewOptions(); + if ( options == null ) { + options = new AMapNaviViewOptions(); + } + switch ( ui ) { + case CarUp_2D: + options.setTilt( 0 ); + mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE ); + break; + case CarUp_3D: + options.setTilt( 60 ); + mMapView.setNaviMode( AMapNaviView.CAR_UP_MODE ); + break; + case NorthUP_2D: + options.setTilt( 0 ); + mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE ); + break; + case Type_Light: + if ( checkAMap() ) { + mAMap.setMapType( AMap.MAP_TYPE_NORMAL ); + } + return; + case Type_Night: + if ( checkAMap() ) { + mAMap.setMapType( AMap.MAP_TYPE_NIGHT ); + } + return; + case Type_Navi: + if ( checkAMap() ) { + mAMap.setMapType( AMap.MAP_TYPE_NAVI ); + } + return; + } + mMapView.setViewOptions( options ); + } + } + + private boolean checkAMap() { + if ( mAMap == null ) { + Logger.e( TAG, "高德map实例为空,请检查" ); + return false; + } + return true; + } + + private boolean checkAMapView() { + if ( mMapView == null ) { + Logger.e( TAG, "高德mapView实例为空,请检查" ); + return false; + } + return true; + } + + @Override + public void moveToCurrentLocation() { + MogoLocation location = ALocationClient.getInstance( getContext() ).getLastKnowLocation(); + if ( location != null ) { + mAMap.animateCamera( CameraUpdateFactory.newLatLng( new LatLng( location.getLatitude(), location.getLongitude() ) ) ); + } + } + + private Context getContext() { + if ( checkAMapView() ) { + return mMapView.getContext(); + } + return null; + } + + @Override + public void showMyLocation( boolean visible ) { + if ( checkAMapView() ) { + mAMap.setMyLocationEnabled( true ); + MyLocationStyle style = mAMap.getMyLocationStyle(); + style.showMyLocation( visible ); + style.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.ic_search_poi_location ) ); + mAMap.setMyLocationStyle( style ); + } + } + + @Override + public void recoverLockMode() { + if ( checkAMapView() ) { + mMapView.recoverLockMode(); + } + } + + @Override + public void displayOverview() { + if ( checkAMapView() ) { + mMapView.displayOverview(); + } + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java new file mode 100644 index 0000000000..819d5b5cf3 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/IInterceptor.java @@ -0,0 +1,37 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; + +/** + * @author congtaowang + * @since 2019-12-27 + *
+ * 操作拦截器 + */ +public interface IInterceptor { + + /** + * 是否忽略添加多个marker时聚拢参数 + *
+ * 导航时:不需要聚拢 + * + * @return true - 忽略 false - 不忽略 + */ + boolean ignoreAddMarkersMoveToCenterParameters( Context context ); + + /** + * 导航时,是否响应 poi 点击 + * + * @param context + * @return + */ + boolean ignorePoiClickedWhenNaviing( Context context ); + + /** + * 导航时,是否响应地图点击 + * + * @param context + * @return + */ + boolean ignoreMapClickedWhenNaviing( Context context ); +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java new file mode 100644 index 0000000000..d1b1e41519 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/InterceptorHandler.java @@ -0,0 +1,49 @@ +package com.mogo.map.impl.amap; + +import android.content.Context; + +import com.mogo.map.impl.amap.navi.NaviClient; + +/** + * @author congtaowang + * @since 2019-12-27 + *
+ * 操作拦截器 + */ +public class InterceptorHandler implements IInterceptor { + + private static volatile InterceptorHandler sInstance; + + private InterceptorHandler() { + } + + public static InterceptorHandler getInstance() { + if ( sInstance == null ) { + synchronized ( InterceptorHandler.class ) { + if ( sInstance == null ) { + sInstance = new InterceptorHandler(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public boolean ignoreAddMarkersMoveToCenterParameters( Context context ) { + return NaviClient.getInstance( context ).isNaviing(); + } + + @Override + public boolean ignorePoiClickedWhenNaviing( Context context ) { + return NaviClient.getInstance( context ).isNaviing(); + } + + @Override + public boolean ignoreMapClickedWhenNaviing( Context context ) { + return NaviClient.getInstance( context ).isNaviing(); + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/location/LocationClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java similarity index 75% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/location/LocationClient.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java index 550d43679f..7705e65744 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/location/LocationClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/location/ALocationClient.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.location; +package com.mogo.map.impl.amap.location; import android.content.Context; @@ -6,8 +6,8 @@ import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; -import com.mogo.map.amap.utils.ObjectUtils; -import com.mogo.map.location.ILocationListener; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.location.IMogoLocationListener; import com.mogo.map.location.IMogoLocationClient; import com.mogo.map.location.MogoLocation; import com.mogo.utils.logger.Logger; @@ -22,24 +22,25 @@ import java.util.Set; *
* 高德定位 */ -public class LocationClient implements IMogoLocationClient { +public class ALocationClient implements IMogoLocationClient { private static final String TAG = "LocationClient"; - private static volatile LocationClient sInstance; - private static Set< ILocationListener > sListeners = new HashSet<>( 10 ); + private static volatile ALocationClient sInstance; + private static Set< IMogoLocationListener > sListeners = new HashSet<>( 10 ); private static MogoLocation sLastLocation = new MogoLocation(); - private LocationClient( Context context ) { + private ALocationClient( Context context ) { mClient = new AMapLocationClient( context ); mClient.setLocationListener( new InternalLocationListener() ); + sLastLocation = ObjectUtils.fromAMap( mClient.getLastKnownLocation() ); } - public static LocationClient getInstance( Context context ) { + public static ALocationClient getInstance( Context context ) { if ( sInstance == null ) { - synchronized ( LocationClient.class ) { + synchronized ( ALocationClient.class ) { if ( sInstance == null ) { - sInstance = new LocationClient( context ); + sInstance = new ALocationClient( context ); } } } @@ -74,7 +75,7 @@ public class LocationClient implements IMogoLocationClient { } @Override - public void addLocationListener( ILocationListener listener ) { + public void addLocationListener( IMogoLocationListener listener ) { if ( listener != null ) { synchronized ( sListeners ) { sListeners.add( listener ); @@ -83,7 +84,7 @@ public class LocationClient implements IMogoLocationClient { } @Override - public void removeLocationListener( ILocationListener listener ) { + public void removeLocationListener( IMogoLocationListener listener ) { if ( listener != null ) { synchronized ( sListeners ) { sListeners.remove( listener ); @@ -107,7 +108,7 @@ public class LocationClient implements IMogoLocationClient { Logger.d( TAG, aMapLocation.toString() ); sLastLocation = ObjectUtils.fromAMap( aMapLocation ); synchronized ( sListeners ) { - Iterator< ILocationListener > listenerIterator = sListeners.iterator(); + Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator(); while ( listenerIterator.hasNext() ) { listenerIterator.next().onLocationChanged( sLastLocation.clone() ); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapInfoWindowAdapter.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapInfoWindowAdapter.java similarity index 95% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapInfoWindowAdapter.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapInfoWindowAdapter.java index 8b2c273aaa..fa7a13eae3 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapInfoWindowAdapter.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapInfoWindowAdapter.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.marker; +package com.mogo.map.impl.amap.marker; import android.view.View; diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java similarity index 94% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java index 2fa2bd5073..0b0e76ec14 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.marker; +package com.mogo.map.impl.amap.marker; import android.graphics.Bitmap; @@ -8,11 +8,11 @@ import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.marker.IMogoInfoWindowAdapter; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.IMogoMarkerClickListener; import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.map.amap.utils.ObjectUtils; import java.util.ArrayList; @@ -20,7 +20,7 @@ import java.util.ArrayList; * @author congtaowang * @since 2019-12-18 *
- * 代理高德marker + * 高德marker */ public class AMapMarkerWrapper implements IMogoMarker { @@ -31,11 +31,11 @@ public class AMapMarkerWrapper implements IMogoMarker { private boolean mIsDestroy = false; - public AMapMarkerWrapper( Marker mMarker ) { - this.mMarker = mMarker; - if ( mMarker != null ) { + public AMapMarkerWrapper( Marker marker ) { + this.mMarker = marker; + if ( marker != null ) { // 设置高德 marker 的object对象为 IMogoMarker 实例。!!!! - mMarker.setObject( this ); + marker.setObject( this ); } } @@ -203,7 +203,7 @@ public class AMapMarkerWrapper implements IMogoMarker { } @Override - public void setZIndex( float zIndex ) { + public void setZIndex( int zIndex ) { if ( mMarker != null ) { mMarker.setZIndex( zIndex ); } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/AMapNaviListenerAdapter.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/AMapNaviListenerAdapter.java new file mode 100644 index 0000000000..dfe0daa985 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/AMapNaviListenerAdapter.java @@ -0,0 +1,211 @@ +package com.mogo.map.impl.amap.navi; + +import com.amap.api.navi.AMapNaviListener; +import com.amap.api.navi.model.AMapCalcRouteResult; +import com.amap.api.navi.model.AMapLaneInfo; +import com.amap.api.navi.model.AMapModelCross; +import com.amap.api.navi.model.AMapNaviCameraInfo; +import com.amap.api.navi.model.AMapNaviCross; +import com.amap.api.navi.model.AMapNaviInfo; +import com.amap.api.navi.model.AMapNaviLocation; +import com.amap.api.navi.model.AMapNaviRouteNotifyData; +import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; +import com.amap.api.navi.model.AMapServiceAreaInfo; +import com.amap.api.navi.model.AimLessModeCongestionInfo; +import com.amap.api.navi.model.AimLessModeStat; +import com.amap.api.navi.model.NaviInfo; +import com.autonavi.tbt.TrafficFacilityInfo; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 高德导航事件:导航事件 + */ +public abstract class AMapNaviListenerAdapter implements AMapNaviListener { + + @Override + public void onInitNaviFailure() { + + } + + @Override + public void onInitNaviSuccess() { + + } + + @Override + public void onStartNavi( int i ) { + + } + + @Override + public void onTrafficStatusUpdate() { + + } + + @Override + public void onLocationChange( AMapNaviLocation aMapNaviLocation ) { + + } + + @Override + public void onGetNavigationText( int i, String s ) { + + } + + @Override + public void onGetNavigationText( String s ) { + + } + + @Override + public void onEndEmulatorNavi() { + + } + + @Override + public void onArriveDestination() { + + } + + @Override + public void onCalculateRouteFailure( int i ) { + + } + + @Override + public void onReCalculateRouteForYaw() { + + } + + @Override + public void onReCalculateRouteForTrafficJam() { + + } + + @Override + public void onArrivedWayPoint( int i ) { + + } + + @Override + public void onGpsOpenStatus( boolean b ) { + + } + + @Override + public void onNaviInfoUpdate( NaviInfo naviInfo ) { + + } + + @Override + public void onNaviInfoUpdated( AMapNaviInfo aMapNaviInfo ) { + + } + + @Override + public void updateCameraInfo( AMapNaviCameraInfo[] aMapNaviCameraInfos ) { + + } + + @Override + public void updateIntervalCameraInfo( AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i ) { + + } + + @Override + public void onServiceAreaUpdate( AMapServiceAreaInfo[] aMapServiceAreaInfos ) { + + } + + @Override + public void showCross( AMapNaviCross aMapNaviCross ) { + + } + + @Override + public void hideCross() { + + } + + @Override + public void showModeCross( AMapModelCross aMapModelCross ) { + + } + + @Override + public void hideModeCross() { + + } + + @Override + public void showLaneInfo( AMapLaneInfo[] aMapLaneInfos, byte[] bytes, byte[] bytes1 ) { + + } + + @Override + public void showLaneInfo( AMapLaneInfo aMapLaneInfo ) { + + } + + @Override + public void hideLaneInfo() { + + } + + @Override + public void onCalculateRouteSuccess( int[] ints ) { + + } + + @Override + public void notifyParallelRoad( int i ) { + + } + + @Override + public void OnUpdateTrafficFacility( AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos ) { + + } + + @Override + public void OnUpdateTrafficFacility( AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo ) { + + } + + @Override + public void OnUpdateTrafficFacility( TrafficFacilityInfo trafficFacilityInfo ) { + + } + + @Override + public void updateAimlessModeStatistics( AimLessModeStat aimLessModeStat ) { + + } + + @Override + public void updateAimlessModeCongestionInfo( AimLessModeCongestionInfo aimLessModeCongestionInfo ) { + + } + + @Override + public void onPlayRing( int i ) { + + } + + @Override + public void onCalculateRouteSuccess( AMapCalcRouteResult aMapCalcRouteResult ) { + + } + + @Override + public void onCalculateRouteFailure( AMapCalcRouteResult aMapCalcRouteResult ) { + + } + + @Override + public void onNaviRouteNotify( AMapNaviRouteNotifyData aMapNaviRouteNotifyData ) { + + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/CalculatePathItem.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/CalculatePathItem.java new file mode 100644 index 0000000000..a89996465e --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/CalculatePathItem.java @@ -0,0 +1,134 @@ +package com.mogo.map.impl.amap.navi; + +import android.content.Context; +import android.text.TextUtils; + +import com.amap.api.maps.AMap; +import com.amap.api.navi.model.AMapNaviPath; +import com.amap.api.navi.model.AMapNaviStep; +import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-04 + *
+ * 导航路径代理类 + */ +public class CalculatePathItem { + + private Context mContext; + private AMap mAMap; + private int mId; + private AMapNaviPath mPath; + + private RouteOverLayWrapper mOverLazWrapper; + + public int getId() { + return mId; + } + + public AMapNaviPath getPath() { + return mPath; + } + + public RouteOverLayWrapper getOverLazWrapper( boolean createIfNull ) { + if ( mOverLazWrapper == null && createIfNull ) { + mOverLazWrapper = new RouteOverLayWrapper( mContext, mAMap, mPath ); + } + return mOverLazWrapper; + } + + public CalculatePathItem( Context context, AMap amap, int id, AMapNaviPath path ) { + mContext = context; + mAMap = amap; + this.mId = id; + this.mPath = path; + } + + public String getStrategyName() { + return mPath.getLabels(); + } + + public String getTime() { + if ( mTimeBuilder == null ) { + final int time = mPath.getAllTime(); + mTimeBuilder = new StringBuilder(); + fillFormatTime( time, mTimeBuilder ); + } + return mTimeBuilder.toString(); + } + + private StringBuilder mTimeBuilder; + + private void fillFormatTime( int seconds, StringBuilder builder ) { +// int days = seconds / ( 24 * 60 * 60 ); +// if ( days > 0 ) { +// builder.append( days ).append( "天" ); +// } +// seconds -= days * 24 * 60 * 60; + int hours = seconds / ( 60 * 60 ); + if ( hours > 0 ) { + builder.append( hours ).append( "小时" ); + } + seconds -= hours * 60 * 60; + int min = seconds / 60; + builder.append( min > 1 ? min : 1 ).append( "分钟" ); + } + + private String mDistanceCacheStr = ""; + + public String getDistance() { + if ( TextUtils.isEmpty( mDistanceCacheStr ) ) { + int distance = mPath.getAllLength(); + if ( distance == -1 ) { + mDistanceCacheStr = "路程总程未获取"; + } + if ( distance >= 1000 ) { + mDistanceCacheStr = String.format( "%.1f公里", ( float ) distance / 1000 ); + } else { + mDistanceCacheStr = distance + "米"; + } + } + return mDistanceCacheStr; + } + + private StringBuilder mDescBuilder = null; + + public String getDesc() { + if ( mDescBuilder == null ) { + mDescBuilder = new StringBuilder(); + int lightsSize = getTrafficNumber(); + if ( lightsSize > 0 ) { + mDescBuilder.append( "红绿灯" ).append( lightsSize ).append( "个" ); + } + mDescBuilder.append( " " ); + mDescBuilder.append( "收费" ).append( mPath.getTollCost() ).append( "元" ); + } + + return mDescBuilder.toString(); + } + + public int getTrafficNumber() { + int trafficLightNumber = 0; + if ( mPath == null ) { + return trafficLightNumber; + } + List< AMapNaviStep > steps = mPath.getSteps(); + for ( AMapNaviStep step : steps ) { + trafficLightNumber += step.getTrafficLightNumber(); + } + return trafficLightNumber; + } + + public void release() { + mContext = null; + mAMap = null; + mPath = null; + if ( mOverLazWrapper != null ) { + mOverLazWrapper.destroy(); + } + mOverLazWrapper = null; + } +} \ No newline at end of file diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java new file mode 100644 index 0000000000..c1afede122 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviClient.java @@ -0,0 +1,160 @@ +package com.mogo.map.impl.amap.navi; + +import android.content.Context; + +import com.amap.api.maps.model.Polyline; +import com.amap.api.navi.AMapNavi; +import com.amap.api.navi.enums.NaviType; +import com.amap.api.navi.model.NaviLatLng; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoNaviConfig; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 高德导航 + */ +public class NaviClient implements IMogoNavi { + + private static final String TAG = "NaviClient"; + + private AMapNavi mAMapNavi; + private final NaviListenerAdapter mAMapNaviListener; + + /** + * 导航策略配置 + */ + private MogoNaviConfig mMogoNaviConfig = new MogoNaviConfig(); + + private static volatile NaviClient sInstance; + + private NaviClient( Context context ) { + mAMapNavi = AMapNavi.getInstance( context ); + mAMapNaviListener = new NaviListenerAdapter( context, mAMapNavi, this ); + mAMapNavi.addAMapNaviListener( mAMapNaviListener ); + } + + public static NaviClient getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( NaviClient.class ) { + if ( sInstance == null ) { + sInstance = new NaviClient( context ); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public void naviTo( MogoLatLng endPoint ) { + naviTo( endPoint, mMogoNaviConfig ); + } + + @Override + public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) { + naviTo( endPoint, null, config ); + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) { + naviTo( endPoint, wayPoints, mMogoNaviConfig ); + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) { + if ( !checkAMapNavi() ) { + return; + } + Logger.i( TAG, "开始规划路径" ); + mMogoNaviConfig = config; + if ( mMogoNaviConfig == null ) { + mMogoNaviConfig = new MogoNaviConfig(); + } + int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() ); + List< NaviLatLng > naviWayPoints = null; + if ( wayPoints != null && !wayPoints.isEmpty() ) { + naviWayPoints = new ArrayList<>( wayPoints.size() ); + for ( MogoLatLng wayPoint : wayPoints ) { + naviWayPoints.add( ObjectUtils.fromMogoAsNavi( wayPoint ) ); + } + } else { + naviWayPoints = new ArrayList<>(); + } + mAMapNavi.calculateDriveRoute( + new ArrayList( Arrays.asList( ObjectUtils.fromMogoAsNavi( endPoint ) ) ), + naviWayPoints, + strategy + ); + } + + @Override + public void reCalculateRoute( MogoNaviConfig config ) { + if ( !checkAMapNavi() ) { + return; + } + mMogoNaviConfig = config; + if ( mMogoNaviConfig == null ) { + mMogoNaviConfig = new MogoNaviConfig(); + } + int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() ); + mAMapNavi.reCalculateRoute( strategy ); + } + + @Override + public void stopNavi() { + if ( mAMapNaviListener != null ) { + mAMapNaviListener.stopNavi(); + } + } + + @Override + public void startNavi() { + if ( mAMapNaviListener.isStopped() ) { + return; + } + mAMapNavi.startNavi( isRealNavi() ? NaviType.GPS : NaviType.EMULATOR ); + } + + @Override + public boolean isNaviing() { + if ( mAMapNaviListener != null ) { + return mAMapNaviListener.isNaviing(); + } + return false; + } + + // -- end + + private boolean checkAMapNavi() { + if ( mAMapNavi == null ) { + Logger.e( TAG, "高德导航实例为空!!!" ); + return false; + } + return true; + } + + public boolean isRealNavi() { + if ( mMogoNaviConfig != null ) { + return mMogoNaviConfig.isRealNavi(); + } + return true; + } + + public void handleClickedPolyline( Polyline polyline ) { + if ( mAMapNaviListener != null ) { + mAMapNaviListener.handleClickedPolyline( polyline ); + } + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java new file mode 100644 index 0000000000..5a42d8dc32 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviListenerAdapter.java @@ -0,0 +1,142 @@ +package com.mogo.map.impl.amap.navi; + +import android.content.Context; + +import com.amap.api.maps.model.Polyline; +import com.amap.api.navi.AMapNavi; +import com.amap.api.navi.enums.NaviType; +import com.amap.api.navi.model.AMapCalcRouteResult; +import com.amap.api.navi.model.NaviInfo; +import com.mogo.map.impl.amap.AMapWrapper; +import com.mogo.map.impl.amap.utils.ObjectUtils; +import com.mogo.map.navi.MogoNaviListenerHandler; +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 高德导航回调 + */ +public class NaviListenerAdapter extends AMapNaviListenerAdapter { + + private static final String TAG = "NaviListenerAdapter"; + + private Context mContext; + private AMapNavi mAMapNavi; + private NaviClient mClient; + /** + * 导航状态:true - 导航 onStartNavi(int) 被调用, false - 到达目的地、手动挺固执 + */ + private boolean mIsNaviing = false; + + /** + * 导航是否被停止:true - 手动停止或到达目的地、false - 规划路径成功、开启导航 + */ + private boolean mIsStopped = true; + + /** + * 路线规划 + */ + private NaviOverlayHelper mNaviOverlayHelper; + + public NaviListenerAdapter( Context mContext, AMapNavi mAMapNavi, NaviClient client ) { + this.mContext = mContext; + this.mAMapNavi = mAMapNavi; + this.mClient = client; + mNaviOverlayHelper = new NaviOverlayHelper( mAMapNavi, AMapWrapper.getAMap(), mContext ); + } + + public void setNaviing( boolean mIsNaviing ) { + this.mIsNaviing = mIsNaviing; + } + + public boolean isNaviing() { + return mIsNaviing; + } + + public void setStopped( boolean isStopped ) { + this.mIsStopped = isStopped; + } + + public boolean isStopped() { + return mIsStopped; + } + + public Context getContext() { + return mContext; + } + + @Override + public void onInitNaviFailure() { + MogoNaviListenerHandler.getInstance().onInitNaviFailure(); + } + + @Override + public void onInitNaviSuccess() { + MogoNaviListenerHandler.getInstance().onInitNaviSuccess(); + } + + @Override + public void onStartNavi( int i ) { + setStopped( false ); + setNaviing( true ); + if ( mAMapNavi != null ) { + mAMapNavi.startSpeak(); + } + MogoNaviListenerHandler.getInstance().onStartNavi(); + } + + @Override + public void onEndEmulatorNavi() { + setNaviing( false ); + setStopped( true ); + MogoNaviListenerHandler.getInstance().onStopNavi(); + } + + @Override + public void onArriveDestination() { + setNaviing( false ); + setStopped( true ); + MogoNaviListenerHandler.getInstance().onStopNavi(); + } + + @Override + public void onNaviInfoUpdate( NaviInfo naviInfo ) { + MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( ObjectUtils.fromAMap( naviInfo ) ); + } + + @Override + public void onCalculateRouteFailure( AMapCalcRouteResult aMapCalcRouteResult ) { + if ( aMapCalcRouteResult != null ) { + Logger.i( TAG, PathPlanningErrorCodeConstants.getErrorMsg( aMapCalcRouteResult.getErrorCode() ) ); + } + } + + @Override + public void onCalculateRouteSuccess( AMapCalcRouteResult aMapCalcRouteResult ) { + super.onCalculateRouteSuccess( aMapCalcRouteResult ); + Logger.i( TAG, "导航规划成功" ); + setStopped( false ); + mNaviOverlayHelper.showCalculatedPaths(); + } + + public void stopNavi() { + setStopped( true ); + setNaviing( false ); + mAMapNavi.stopNavi(); + MogoNaviListenerHandler.getInstance().onStopNavi(); + mNaviOverlayHelper.clearCalculatedOverlay(); + } + + public void handleClickedPolyline( Polyline polyline ) { + if ( mNaviOverlayHelper != null ) { + mNaviOverlayHelper.handleClickedPolyline( polyline ); + if ( isNaviing() ) { + mAMapNavi.stopNavi(); + mAMapNavi.selectRouteId( mNaviOverlayHelper.getSelectedPathId() ); + mAMapNavi.startNavi( mClient.isRealNavi() ? NaviType.GPS : NaviType.EMULATOR ); + } + } + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java new file mode 100644 index 0000000000..c80928fc49 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/NaviOverlayHelper.java @@ -0,0 +1,223 @@ +package com.mogo.map.impl.amap.navi; + +import android.content.Context; +import android.graphics.Rect; +import android.text.TextUtils; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.CameraUpdateFactory; +import com.amap.api.maps.model.LatLngBounds; +import com.amap.api.maps.model.Polyline; +import com.amap.api.navi.AMapNavi; +import com.amap.api.navi.model.AMapNaviPath; +import com.mogo.map.impl.amap.R; +import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper; +import com.mogo.utils.WindowUtils; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author congtaowang + * @since 2019-12-27 + *
+ * 导航路径管理 + */ +public class NaviOverlayHelper { + + private static final String TAG = "NaviOverlayHelper"; + + /** + * 选中的路径透明度 + */ + public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED = 1f; + + /** + * 未选中的路径透明度 + */ + public static final float AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED = 0.3f; + + private AMapNavi mAMapNavi; + private AMap mAMap; + private Context mContext; + // 规划的路线显示边距 + private Rect mBoundRect = null; + + private List< CalculatePathItem > mCalculatePathItems; + + private int mSelectedPathId; + + public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) { + this.mAMapNavi = mAMapNavi; + this.mAMap = mAMap; + this.mContext = mContext; + calculateBoundArea(); + } + + /** + * 显示规划的路径 + */ + public void showCalculatedPaths() { + clearCalculatedOverlay(); + mCalculatePathItems = getSortedPaths(); + if ( mCalculatePathItems == null || mCalculatePathItems.isEmpty() ) { + return; + } + showPathsBound( mCalculatePathItems.get( 0 ).getPath().getBoundsForPath() ); + renderPathOverlay( mCalculatePathItems ); + } + + /** + * 按pathId升序排序 + * + * @return 排序好的路径规划列表 + */ + private List< CalculatePathItem > getSortedPaths() { + final Map< Integer, AMapNaviPath > pathMap = mAMapNavi.getNaviPaths(); + if ( pathMap == null || pathMap.isEmpty() ) { + return null; + } + TreeMap< Integer, AMapNaviPath > sortedMap = new TreeMap< Integer, AMapNaviPath >( new Comparator< Integer >() { + @Override + public int compare( Integer obj1, Integer obj2 ) { + if ( obj1 != null ) { + return obj1.compareTo( obj2 ); + } + if ( obj2 != null ) { + return obj2.compareTo( obj1 ); + } + return 0; + } + } ); + sortedMap.putAll( pathMap ); + + final List< CalculatePathItem > items = new ArrayList<>(); + for ( Map.Entry< Integer, AMapNaviPath > entry : sortedMap.entrySet() ) { + if ( entry == null || entry.getKey() == null || entry.getValue() == null ) { + continue; + } + items.add( new CalculatePathItem( mContext, mAMap, entry.getKey(), entry.getValue() ) ); + } + return items; + } + + private void calculateBoundArea() { + if ( mBoundRect == null ) { + mBoundRect = new Rect(); + final int padding = WindowUtils.dip2px( mContext, 80 ); + mBoundRect.left = padding; + mBoundRect.right = padding; + mBoundRect.top = padding; + mBoundRect.bottom = padding; + } + } + + /** + * 将规划好的路径显示在视野内 + * + * @param bounds + */ + private void showPathsBound( LatLngBounds bounds ) { + mAMap.animateCamera( CameraUpdateFactory.newLatLngBoundsRect( bounds, mBoundRect.left, mBoundRect.right, mBoundRect.top, mBoundRect.bottom ) ); + } + + public void renderPathOverlay( List< CalculatePathItem > paths ) { + if ( paths == null || paths.size() == 0 ) { + return; + } + for ( int i = 0; i < paths.size(); i++ ) { + final CalculatePathItem item = paths.get( i ); + if ( item == null || item.getPath() == null ) { + continue; + } + RouteOverLayWrapper wrapper = item.getOverLazWrapper( true ); + wrapper.setTrafficLightsVisible( false ); + // 默认选中第一个 + if ( i == 0 ) { + wrapper.setStartBitmap( R.drawable.ic_amap_navi_cursor ).setEndBitmap( R.drawable.ic_search_choice_point ); + mAMapNavi.selectRouteId( item.getId() ); + } + wrapper.addToMap(); + wrapper.setTransparency( i == 0 ? AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED : AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED ); + } + } + + public void clearCalculatedOverlay() { + if ( mCalculatePathItems != null && !mCalculatePathItems.isEmpty() ) { + for ( CalculatePathItem calculatePathItem : mCalculatePathItems ) { + if ( calculatePathItem == null ) { + continue; + } + RouteOverLayWrapper wrapper = calculatePathItem.getOverLazWrapper( false ); + if ( wrapper != null ) { + wrapper.destroy(); + } + } + mCalculatePathItems.clear(); + } + } + + /** + * 是否切换成功 + * + * @param polyline 选中的线 + * @return + */ + public boolean handleClickedPolyline( Polyline polyline ) { + if ( polyline == null ) { + return false; + } + Logger.i( TAG, "polyline id = " + polyline.getId() ); + CalculatePathItem calculatePathItem = isCalculatePolyline( polyline ); + if ( calculatePathItem == null ) { + return false; + } + mSelectedPathId = calculatePathItem.getId(); + if ( mCalculatePathItems != null ) { + for ( CalculatePathItem item : mCalculatePathItems ) { + final RouteOverLayWrapper wrapper = item.getOverLazWrapper( false ); + if ( wrapper == null ) { + continue; + } + wrapper.setTransparency( + item == calculatePathItem + ? AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED + : AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED + ); + } + } + return true; + } + + private CalculatePathItem isCalculatePolyline( Polyline polyline ) { + CalculatePathItem result = null; + if ( mCalculatePathItems == null || mCalculatePathItems.isEmpty() ) { + return result; + } + for ( CalculatePathItem calculatePathItem : mCalculatePathItems ) { + if ( calculatePathItem == null ) { + continue; + } + final RouteOverLayWrapper wrapper = calculatePathItem.getOverLazWrapper( false ); + if ( wrapper == null ) { + continue; + } + if ( wrapper.getTrafficColorfulPolyline() == null ) { + continue; + } + if ( TextUtils.equals( wrapper.getTrafficColorfulPolyline().getId(), polyline.getId() ) + || wrapper.getTrafficColorfulPolyline() == polyline ) { + result = calculatePathItem; + } + } + return result; + } + + public int getSelectedPathId() { + return mSelectedPathId; + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/PathPlanningErrorCodeConstants.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/PathPlanningErrorCodeConstants.java new file mode 100644 index 0000000000..7404d6049d --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/navi/PathPlanningErrorCodeConstants.java @@ -0,0 +1,92 @@ +package com.mogo.map.impl.amap.navi; + +import com.amap.api.navi.enums.PathPlanningErrCode; + +/** + * @author congtaowang + * @since 2019-10-18 + *
+ * 描述 + */ +public enum PathPlanningErrorCodeConstants { + + NONE( -1, "路线规划错误,请重试" ), + + ACCESS_TOO_FREQUENT( PathPlanningErrCode.ACCESS_TOO_FREQUENT, "访问过于频繁,请稍后再试" ), + + DISABLE_RESTRICT( PathPlanningErrCode.DISABLE_RESTRICT, "无法躲避限行区域,请重新规划" ), + + ERROR_BUF( PathPlanningErrCode.ERROR_BUF, "Buf数据格式错误" ), + + ERROR_CONNECTION( PathPlanningErrCode.ERROR_CONNECTION, "网络超时或网络失败。" ), + + ERROR_DISTANCE( PathPlanningErrCode.ERROR_DISTANCE, "起点/终点/途经点的距离太长(步行距离>100km,骑行距离>1200km)" ), + + ERROR_ENCODER( PathPlanningErrCode.ERROR_ENCODER, "算路服务端编码失败" ), + + ERROR_ENDPOINT( PathPlanningErrCode.ERROR_ENDPOINT, "终点错误" ), + + ERROR_NAVI_PARAMS( PathPlanningErrCode.ERROR_NAVI_PARAMS, "调用直接导航 没有算路 参数错误,缺失有效的导航路径,无法开始导航" ), + + ERROR_NOROADFORENDPOINT( PathPlanningErrCode.ERROR_NOROADFORENDPOINT, "终点没有找到道路" ), + + ERROR_NOROADFORSTARTPOINT( PathPlanningErrCode.ERROR_NOROADFORSTARTPOINT, "起点没有找到道路。" ), + + ERROR_NOROADFORWAYPOINT( PathPlanningErrCode.ERROR_NOROADFORWAYPOINT, "途径点没有找到道路" ), + + ERROR_PREVIEW( PathPlanningErrCode.ERROR_PREVIEW, "路径数据缺乏预览数据" ), + + ERROR_PROTOCOL( PathPlanningErrCode.ERROR_PROTOCOL, "请求协议非法。" ), + + ERROR_STARTPOINT( PathPlanningErrCode.ERROR_STARTPOINT, "起点错误" ), + + ERROR_WAYPOINT( PathPlanningErrCode.ERROR_WAYPOINT, "途经点错误" ), + + INSUFFICIENT_PRIVILEGES( PathPlanningErrCode.INSUFFICIENT_PRIVILEGES, "无权限访问此服务。" ), + + INVALID_PARAMS( PathPlanningErrCode.INVALID_PARAMS, "请求参数非法。" ), + + INVALID_USER_KEY( PathPlanningErrCode.INVALID_USER_KEY, "用户key非法或过期(请检查key是否正确)" ), + + INVALID_USER_SCODE( PathPlanningErrCode.INVALID_USER_SCODE, "MD5安全码未通过验证,需要开发者判定key绑定的SHA1,package是否与sdk包里的一致." ), + + OUT_OF_SERVICE( PathPlanningErrCode.OUT_OF_SERVICE, "使用路径规划服务接口时可能出现该问题,规划点(包括起点、终点、途经点)不在中国陆地范围内" ), + + OVER_DIRECTION_RANGE( PathPlanningErrCode.OVER_DIRECTION_RANGE, "使用路径规划服务接口时可能出现该问题,路线计算失败,通常是由于道路起点和终点距离过长导致" ), + + OVER_QUOTA( PathPlanningErrCode.OVER_QUOTA, "请求超出配额。" ), + + SERVICE_NOT_EXIST( PathPlanningErrCode.SERVICE_NOT_EXIST, "请求服务不存在。" ), + + SERVICE_RESPONSE_ERROR( PathPlanningErrCode.SERVICE_RESPONSE_ERROR, "请求服务响应错误。" ), + + UNKNOWN_ERROR( PathPlanningErrCode.UNKNOWN_ERROR, "未知错误(可能是由于连接的网络无法访问外网)" ), + + USERKEY_PLAT_NOMATCH( PathPlanningErrCode.USERKEY_PLAT_NOMATCH, "请求中使用的key与绑定平台不符,例如:开发者申请的是js api的key,却用来调web服务接口" ); + + private int code; + private String errorMsg; + + PathPlanningErrorCodeConstants( int code, String errorMsg ) { + this.code = code; + this.errorMsg = errorMsg; + } + + public int getCode() { + return code; + } + + public String getErrorMsg() { + return errorMsg; + } + + public static String getErrorMsg( int code ) { + for ( PathPlanningErrorCodeConstants value : PathPlanningErrorCodeConstants.values() ) { + if ( value.getCode() == code ) { + return value.getErrorMsg(); + } + } + return NONE.getErrorMsg(); + } + +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverLayWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverLayWrapper.java new file mode 100644 index 0000000000..b2ab754d91 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/overlay/RouteOverLayWrapper.java @@ -0,0 +1,188 @@ +package com.mogo.map.impl.amap.overlay; + +import android.content.Context; +import android.graphics.BitmapFactory; +import android.util.Log; + +import com.amap.api.maps.AMap; +import com.amap.api.maps.model.Polyline; +import com.amap.api.navi.model.AMapNaviLocation; +import com.amap.api.navi.model.AMapNaviPath; +import com.amap.api.navi.model.NaviInfo; +import com.amap.api.navi.view.RouteOverLay; +import com.mogo.map.impl.amap.utils.MapStyleUtils; + +import java.lang.ref.WeakReference; + +/** + * @author congtaowang + * @since 2019-10-04 + *
+ * 路径覆盖物 + */ +public class RouteOverLayWrapper { + + private static final String TAG = "RouteOverLayWrapper"; + + private final WeakReference< Context > mContextRef; + private final AMap mAMap; + private final AMapNaviPath mPath; + + private RouteOverLay mRouteOverLay; + private boolean mIsRemoved = true; + + private boolean mIsTrafficLightsVisible = true; + private int mStartBitmapResId = 0; + private int mEndBitmapResId = 0; + private int mZIndex = 0; + + public RouteOverLayWrapper( Context context, + AMap mAMap, + AMapNaviPath mPath ) { + this.mContextRef = new WeakReference<>( context ); + this.mAMap = mAMap; + this.mPath = mPath; + } + + public void addToMap() { + if ( mContextRef == null || mContextRef.get() == null ) { + return; + } + mRouteOverLay = new RouteOverLay( mAMap, mPath, mContextRef.get() ); + mRouteOverLay.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() ); + mRouteOverLay.setTrafficLine( true ); + mRouteOverLay.setRouteOverlayVisible( true ); + mRouteOverLay.setTrafficLightsVisible( true ); + mRouteOverLay.setArrowOnRoute( true ); + mRouteOverLay.setZindex( mZIndex ); + mRouteOverLay.setNaviArrowVisible( true ); + mRouteOverLay.setLightsVisible( true ); + mRouteOverLay.setTrafficLightsVisible( mIsTrafficLightsVisible ); + + if ( mStartBitmapResId != 0 ) { + try { + mRouteOverLay.setStartPointBitmap( BitmapFactory.decodeResource( mContextRef.get().getResources(), mStartBitmapResId ) ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } else { + mRouteOverLay.setStartPointBitmap( null ); + } + + if ( mEndBitmapResId != 0 ) { + try { + mRouteOverLay.setEndPointBitmap( BitmapFactory.decodeResource( mContextRef.get().getResources(), mEndBitmapResId ) ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } else { + mRouteOverLay.setEndPointBitmap( null ); + } + + mRouteOverLay.addToMap(); + mIsRemoved = false; + } + + public void remove() { + Log.d( TAG, "remove" ); + if ( mRouteOverLay != null ) { + try { + mRouteOverLay.removeFromMap(); + mIsRemoved = true; + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } + + /** + * 设置透明度 + * + * @param alpha + */ + public void setTransparency( float alpha ) { + if ( mRouteOverLay != null ) { + mRouteOverLay.setTransparency( alpha ); + } + } + + public RouteOverLayWrapper setTrafficLightsVisible( boolean visible ) { + mIsTrafficLightsVisible = visible; + return this; + } + + public RouteOverLayWrapper setStartBitmap( int startBitmapResId ) { + mStartBitmapResId = startBitmapResId; + return this; + } + + public RouteOverLayWrapper setEndBitmap( int endBitmapResId ) { + mEndBitmapResId = endBitmapResId; + return this; + } + + public RouteOverLayWrapper setZIndex( int zIndex ) { + mZIndex = zIndex; + return this; + } + + public int getZIndex() { + return mZIndex; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + mIsRemoved = true; + } + + public synchronized boolean isRemoved() { + return mIsRemoved; + } + + public void updatePolyline( AMapNaviLocation aMapNaviLocation ) { + Log.d( TAG, "updatePolyline" ); + if ( mIsRemoved ) { + return; + } + if ( mRouteOverLay != null ) { + mRouteOverLay.updatePolyline( aMapNaviLocation ); + } + } + + public void drawArrow( NaviInfo naviInfo ) { + Log.d( TAG, "drawArrow" ); + if ( mIsRemoved ) { + return; + } + if ( naviInfo == null ) { + return; + } + if ( mRouteOverLay != null ) { + try { + mRouteOverLay.drawArrow( mRouteOverLay.getArrowPoints( naviInfo.getCurStep() ) ); + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } + + public Polyline getTrafficColorfulPolyline() { + if ( mRouteOverLay != null ) { + return mRouteOverLay.mTrafficColorfulPolyline; + } + return null; + } + + public void destroy() { + Log.d( TAG, "destroy" ); + if ( mRouteOverLay != null ) { + try { + mRouteOverLay.destroy(); + mIsRemoved = true; + } catch ( Exception e ) { + e.printStackTrace(); + } + } + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/GeocodeSearchClient.java similarity index 93% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/GeocodeSearchClient.java index 0e1ee2fc30..4de829cd54 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/GeocodeSearchClient.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.search; +package com.mogo.map.impl.amap.search; import android.content.Context; @@ -8,8 +8,8 @@ import com.amap.api.services.geocoder.GeocodeResult; import com.amap.api.services.geocoder.GeocodeSearch; import com.amap.api.services.geocoder.RegeocodeAddress; import com.amap.api.services.geocoder.RegeocodeResult; -import com.mogo.map.amap.utils.ObjectUtils; import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.search.geo.IMogoGeoSearch; import com.mogo.map.search.geo.IMogoGeoSearchListener; import com.mogo.map.search.geo.MogoGeocodeAddress; @@ -88,14 +88,20 @@ public class GeocodeSearchClient implements IMogoGeoSearch, GeocodeSearch.OnGeoc @Override public void onRegeocodeSearched( RegeocodeResult regeocodeResult, int i ) { if ( mListener != null ) { - mListener.onRegeocodeSearched( ObjectUtils.fromAMap( regeocodeResult ), i ); + mListener.onRegeocodeSearched( ObjectUtils.fromAMap( regeocodeResult ) ); } } @Override public void onGeocodeSearched( GeocodeResult geocodeResult, int i ) { if ( mListener != null ) { - mListener.onGeocodeSearched( ObjectUtils.fromAMap( geocodeResult ), i ); + mListener.onGeocodeSearched( ObjectUtils.fromAMap( geocodeResult ) ); } } + + @Override + public void destroy() { + mClient = null; + mListener = null; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/InputtipsSearch.java similarity index 80% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/InputtipsSearch.java index 0803a24576..b96c2e2847 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/InputtipsSearch.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.search; +package com.mogo.map.impl.amap.search; import android.content.Context; @@ -6,12 +6,13 @@ import com.amap.api.services.core.AMapException; import com.amap.api.services.help.Inputtips; import com.amap.api.services.help.InputtipsQuery; import com.amap.api.services.help.Tip; -import com.mogo.map.amap.utils.ObjectUtils; import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.search.inputtips.IMogoInputtipsListener; import com.mogo.map.search.inputtips.IMogoInputtipsSearch; import com.mogo.map.search.inputtips.MogoTip; import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; +import com.mogo.utils.logger.Logger; import java.util.ArrayList; import java.util.List; @@ -24,6 +25,8 @@ import java.util.List; */ public class InputtipsSearch implements IMogoInputtipsSearch, Inputtips.InputtipsListener { + private static final String TAG = "InputtipsSearch"; + private Inputtips mClient; private InputtipsQuery mQuery; private IMogoInputtipsListener mListener; @@ -51,21 +54,14 @@ public class InputtipsSearch implements IMogoInputtipsSearch, Inputtips.Inputtip } } - @Override - public List< MogoTip > requestInputtips() throws MogoMapException { - try { - List< Tip > tips = mClient.requestInputtips(); - List< MogoTip > mogoTips = getResult( tips ); - return mogoTips; - } catch ( AMapException e ) { - throw new MogoMapException( e ); - } - } - @Override public void onGetInputtips( List< Tip > list, int i ) { - if ( mListener != null ) { - mListener.onGetInputtips( getResult( list ), i ); + if ( i == 1000 ) { + if ( mListener != null ) { + mListener.onGetInputtips( getResult( list ) ); + } + } else { + Logger.e( TAG, "errorcode = " + i ); } } @@ -81,4 +77,11 @@ public class InputtipsSearch implements IMogoInputtipsSearch, Inputtips.Inputtip } return mogoTips; } + + @Override + public void destroy() { + mClient = null; + mListener = null; + mQuery = null; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/PoiSearchClient.java similarity index 92% rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/PoiSearchClient.java index 8549611e57..ccefac7867 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/search/PoiSearchClient.java @@ -1,4 +1,4 @@ -package com.mogo.map.amap.search; +package com.mogo.map.impl.amap.search; import android.content.Context; @@ -6,8 +6,8 @@ import com.amap.api.services.core.AMapException; import com.amap.api.services.core.PoiItem; import com.amap.api.services.poisearch.PoiResult; import com.amap.api.services.poisearch.PoiSearch; -import com.mogo.map.amap.utils.ObjectUtils; import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.amap.utils.ObjectUtils; import com.mogo.map.search.geo.MogoPoiItem; import com.mogo.map.search.poisearch.IMogoPoiSearch; import com.mogo.map.search.poisearch.IMogoPoiSearchListener; @@ -96,7 +96,7 @@ public class PoiSearchClient implements IMogoPoiSearch, PoiSearch.OnPoiSearchLis public void setBound( MogoSearchBound bound ) { mBound = bound; if ( mClient != null ) { - mClient.setBound( ObjectUtils.fromMogo( bound ) ); + mClient.setBound( ObjectUtils.fromMogo( mBound ) ); } } @@ -119,4 +119,12 @@ public class PoiSearchClient implements IMogoPoiSearch, PoiSearch.OnPoiSearchLis mListener.onPoiItemSearched( ObjectUtils.fromAMap( poiItem ), errorCode ); } } + + @Override + public void destroy() { + mQuery = null; + mClient = null; + mListener = null; + mBound = null; + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java new file mode 100644 index 0000000000..4632e15bc0 --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java @@ -0,0 +1,93 @@ +package com.mogo.map.impl.amap.uicontroller; + +import com.mogo.map.MogoMap; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 描述 + */ +public class AMapUIController implements IMogoMapUIController { + + private static final String TAG = "AMapUIController"; + + private static volatile AMapUIController sInstance; + + private IMogoMapUIController mClient; + + private AMapUIController() { + try { + mClient = MogoMap.getInstance().getMogoMap().getUIController(); + } catch ( Exception e ) { + Logger.e( TAG, "获取UI控制实例失败", e ); + } + } + + public static AMapUIController getInstance() { + if ( sInstance == null ) { + synchronized ( AMapUIController.class ) { + if ( sInstance == null ) { + sInstance = new AMapUIController(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public void setTrafficEnabled( boolean visible ) { + if ( mClient != null ) { + mClient.setTrafficEnabled( visible ); + } + } + + @Override + public void changeZoom( boolean zoom ) { + if ( mClient != null ) { + mClient.changeZoom( zoom ); + } + } + + @Override + public void changeMapMode( EnumMapUI mode ) { + if ( mClient != null ) { + mClient.changeMapMode( mode ); + } + } + + @Override + public void moveToCurrentLocation() { + if ( mClient != null ) { + mClient.moveToCurrentLocation(); + } + } + + @Override + public void showMyLocation( boolean visible ) { + if ( mClient != null ) { + mClient.showMyLocation( visible ); + } + } + + @Override + public void recoverLockMode() { + if ( mClient != null ) { + mClient.recoverLockMode(); + } + } + + @Override + public void displayOverview() { + if ( mClient != null ) { + mClient.displayOverview(); + } + } +} diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/MapStyleUtils.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/MapStyleUtils.java new file mode 100644 index 0000000000..0ce253910b --- /dev/null +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/MapStyleUtils.java @@ -0,0 +1,67 @@ +package com.mogo.map.impl.amap.utils; + +import android.graphics.Bitmap; +import android.graphics.Color; + +import com.amap.api.navi.model.RouteOverlayOptions; + +/** + * @author congtaowang + * @since 2019-10-04 + *
+ * 描述
+ */
+public class MapStyleUtils {
+
+ enum ColorEnum {
+ route_overlay_line_normal( Color.parseColor( "#7AD9B4" ) ),
+ route_overlay_line_unknown( Color.parseColor( "#3CD26E" ) ),
+ route_overlay_line_slow( Color.parseColor( "#EFCC7A" ) ),
+ route_overlay_line_very_traffic( Color.parseColor( "#E16262" ) ),
+ route_overlay_line_traffic( Color.parseColor( "#E88181" ) ),
+ transparent( Color.parseColor( "#00000000" ) ),
+ light_gray( Color.parseColor( "#CDD8FF" ) );
+
+ private int color;
+
+ ColorEnum( int color ) {
+ this.color = color;
+ }
+
+ public int getColor() {
+ return color;
+ }
+ }
+
+ public static RouteOverlayOptions getRouteOverlayOptions() {
+ RouteOverlayOptions options = new RouteOverlayOptions();
+ // 设置导航线路的宽度
+ options.setLineWidth( 32 );
+ // 设置交通状况情况良好下的纹理位图
+ options.setSmoothTraffic( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
+ // 设置路线的图标
+ options.setNormalRoute( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
+ // 设置交通状况未知下的纹理位图
+ options.setUnknownTraffic( colorToBitmap( ColorEnum.route_overlay_line_unknown.getColor() ) );
+ // 设置交通状况迟缓下的纹理位图
+ options.setSlowTraffic( colorToBitmap( ColorEnum.route_overlay_line_slow.getColor() ) );
+ // 设置交通状况非常拥堵下的纹理位图
+ options.setVeryJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_very_traffic.getColor() ) );
+ // 设置交通状况拥堵下的纹理位图
+ options.setJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_traffic.getColor() ) );
+ // 设置浮于道路上的『小箭头』图标的纹理位图
+ options.setArrowOnTrafficRoute( colorToBitmap( ColorEnum.transparent.getColor() ) );
+ // 自定义走过路线纹理,默认走过路线置灰功能为关,需要在AMapNaviViewOptions.setAfterRouteAutoGray(boolean)打开,该方法才生效
+ options.setPassRoute( colorToBitmap( ColorEnum.light_gray.getColor() ) );
+ // 设置路线虚线纹理
+ options.setFairWayRes( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
+ return options;
+ }
+
+ public static Bitmap colorToBitmap( int color ) {
+ Bitmap.Config config = Bitmap.Config.ARGB_8888;
+ Bitmap bitmap = Bitmap.createBitmap( 1, 1, config );
+ bitmap.eraseColor( color );
+ return bitmap;
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java
similarity index 95%
rename from libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java
rename to libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java
index 7549118272..74bdf52b23 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/utils/ObjectUtils.java
@@ -1,4 +1,4 @@
-package com.mogo.map.amap.utils;
+package com.mogo.map.impl.amap.utils;
import android.graphics.Bitmap;
@@ -8,6 +8,8 @@ import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Poi;
+import com.amap.api.navi.model.NaviInfo;
+import com.amap.api.navi.model.NaviLatLng;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.geocoder.AoiItem;
@@ -33,6 +35,7 @@ import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.model.MogoPoi;
+import com.mogo.map.navi.MogoNaviInfo;
import com.mogo.map.search.geo.MogoAoiItem;
import com.mogo.map.search.geo.MogoBusinessArea;
import com.mogo.map.search.geo.MogoCrossroad;
@@ -47,10 +50,10 @@ import com.mogo.map.search.geo.MogoRegeocodeResult;
import com.mogo.map.search.geo.MogoRegeocodeRoad;
import com.mogo.map.search.geo.MogoStreetNumber;
import com.mogo.map.search.geo.MogoSubPoiItem;
-import com.mogo.map.search.inputtips.MogoTip;
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
-import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
+import com.mogo.map.search.inputtips.MogoTip;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import com.mogo.map.search.poisearch.MogoPoiResult;
import com.mogo.map.search.poisearch.MogoSearchBound;
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
@@ -143,6 +146,13 @@ public class ObjectUtils {
return new LatLonPoint( latLng.lat, latLng.lng );
}
+ public static NaviLatLng fromMogoAsNavi( MogoLatLng latLng ) {
+ if ( latLng == null ) {
+ return null;
+ }
+ return new NaviLatLng( latLng.lat, latLng.lng );
+ }
+
public static LatLng fromMogo2( MogoLatLng latLng ) {
if ( latLng == null ) {
return null;
@@ -237,7 +247,7 @@ public class ObjectUtils {
}
public static MogoGeocodeResult fromAMap( GeocodeResult result ) {
- if ( result == null || result.getGeocodeAddressList() != null ) {
+ if ( result == null || result.getGeocodeAddressList() == null ) {
return null;
}
MogoGeocodeResult mogoGeocodeResult = new MogoGeocodeResult();
@@ -589,6 +599,21 @@ public class ObjectUtils {
mogoPoiResult.setPois( mogoPoiItems );
}
return mogoPoiResult;
+ }
+ public static MogoNaviInfo fromAMap( NaviInfo naviInfo ) {
+ if ( naviInfo == null ) {
+ return null;
+ }
+ MogoNaviInfo mogoNaviInfo = new MogoNaviInfo();
+ mogoNaviInfo.setCurrentRoadName( naviInfo.getCurrentRoadName() );
+ mogoNaviInfo.setCurrentSpeed( naviInfo.getCurrentSpeed() );
+ mogoNaviInfo.setCurStepRetainDistance( naviInfo.getCurStepRetainDistance() );
+ mogoNaviInfo.setCurStepRetainTime( naviInfo.getCurStepRetainTime() );
+ mogoNaviInfo.setIconType( naviInfo.getIconType() );
+ mogoNaviInfo.setNextRoadName( naviInfo.getNextRoadName() );
+ mogoNaviInfo.setPathRetainDistance( naviInfo.getPathRetainDistance() );
+ mogoNaviInfo.setPathRetainTime( naviInfo.getPathRetainTime() );
+ return mogoNaviInfo;
}
}
diff --git a/libraries/map-amap/src/main/res/values/strings.xml b/libraries/map-amap/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..63a33e31ae
--- /dev/null
+++ b/libraries/map-amap/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ * 描述 + */ +public class BMap { + + public static void init( Context context ) { + SDKInitializer.initialize( context.getApplicationContext() ); + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapBaseMapView.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapBaseMapView.java new file mode 100644 index 0000000000..d612ac84aa --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapBaseMapView.java @@ -0,0 +1,44 @@ +package com.mogo.map.impl.baidu; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.annotation.Nullable; + +import com.baidu.mapapi.SDKInitializer; +import com.baidu.mapapi.map.MapView; +import com.mogo.map.IMogoMapView; +import com.mogo.map.MogoBaseMapView; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 描述 + */ +public class BMapBaseMapView extends MogoBaseMapView { + + public BMapBaseMapView( Context context ) { + super( context ); + init( context ); + } + + public BMapBaseMapView( Context context, @Nullable AttributeSet attrs ) { + super( context, attrs ); + init( context ); + } + + public BMapBaseMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) { + super( context, attrs, defStyleAttr ); + init( context ); + } + + private void init( Context context ) { + + } + + @Override + protected IMogoMapView createMapView( Context context ) { + return new BMapViewWrapper( new MapView( context ) ); + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapMarkerClickHandler.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapMarkerClickHandler.java new file mode 100644 index 0000000000..c9729530db --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapMarkerClickHandler.java @@ -0,0 +1,26 @@ +package com.mogo.map.impl.baidu; + +import com.baidu.mapapi.map.Marker; +import com.mogo.map.impl.baidu.marker.BMapMarkerMap; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; + +/** + * @author congtaowang + * @since 2019-12-24 + *
+ * marker 点击事件处理 + */ +public class BMapMarkerClickHandler { + + public boolean handleMarkerClicked( Marker marker ) { + IMogoMarker iMogoMarker = BMapMarkerMap.get( marker ); + if ( iMogoMarker != null ) { + IMogoMarkerClickListener listener = iMogoMarker.getOnMarkerClickListener(); + if ( listener != null ) { + return listener.onMarkerClicked( iMogoMarker ); + } + } + return false; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapUiSettingsWrapper.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapUiSettingsWrapper.java new file mode 100644 index 0000000000..05eaba5176 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapUiSettingsWrapper.java @@ -0,0 +1,91 @@ +package com.mogo.map.impl.baidu; + +import com.baidu.mapapi.map.UiSettings; +import com.mogo.map.IMogoUiSettings; + +import java.lang.reflect.Method; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 代理高德地图UiSettings + */ +public class BMapUiSettingsWrapper implements IMogoUiSettings { + + private UiSettings mUiSettings; + + public BMapUiSettingsWrapper( UiSettings mUiSettings ) { + this.mUiSettings = mUiSettings; + } + + @Override + public void setScaleControlsEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setScrollGesturesEnabled( enabled ); + } + } + + @Override + public void setZoomControlsEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setZoomGesturesEnabled( enabled ); + } + } + + @Override + public void setCompassEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setCompassEnabled( enabled ); + } + } + + @Override + public void setMyLocationButtonEnabled( boolean enabled ) { + } + + @Override + public void setScrollGesturesEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setScrollGesturesEnabled( enabled ); + } + } + + @Override + public void setZoomGesturesEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setZoomGesturesEnabled( enabled ); + } + } + + @Override + public void setTiltGesturesEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setOverlookingGesturesEnabled( enabled ); + } + } + + @Override + public void setRotateGesturesEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setRotateGesturesEnabled( enabled ); + } + } + + @Override + public void setAllGesturesEnabled( boolean enabled ) { + if ( mUiSettings != null ) { + mUiSettings.setAllGesturesEnabled( enabled ); + } + } + + @Override + public void setIndoorSwitchEnabled( boolean enabled ) { + // don't edit. + } + + @Override + public void setLogoEnable( boolean enabled ) { + // don't edit. + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapViewWrapper.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapViewWrapper.java new file mode 100644 index 0000000000..2b1d1d08bf --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapViewWrapper.java @@ -0,0 +1,144 @@ +package com.mogo.map.impl.baidu; + +import android.content.Context; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; + +import com.baidu.mapapi.map.BaiduMap; +import com.baidu.mapapi.map.MapPoi; +import com.baidu.mapapi.map.MapView; +import com.baidu.mapapi.map.Marker; +import com.baidu.mapapi.model.LatLng; +import com.baidu.navisdk.adapter.BaiduNaviManagerFactory; +import com.mogo.map.IMogoMap; +import com.mogo.map.IMogoMapView; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.listener.MogoMapListenerHandler; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 代理高德导航地图 + */ +public class BMapViewWrapper implements IMogoMapView, + BaiduMap.OnMarkerClickListener, + BaiduMap.OnMapLoadedCallback, + BaiduMap.OnMapTouchListener, + BaiduMap.OnMapClickListener { + + private final MapView mMapView; + private IMogoMap mIMap; + + private BMapMarkerClickHandler mMarkerClickHandler; + + private static final String TAG = "AMapNaviViewWrapper"; + + public BMapViewWrapper( MapView mapView ) { + this.mMapView = mapView; + mMarkerClickHandler = new BMapMarkerClickHandler(); + BaiduMap map = mMapView.getMap(); + if ( map != null ) { + map.setOnMarkerClickListener( this ); + map.setOnMapLoadedCallback( this ); + map.setOnMapClickListener( this ); + } + } + + private Context getContext() { + return mMapView.getContext(); + } + + @Override + public View getMapView() { + return mMapView; + } + + @Override + public IMogoMap getMap() { + if ( mMapView != null ) { + if ( mIMap == null ) { + mIMap = new BMapWrapper( mMapView.getMap() ); + } + } + return mIMap; + } + + @Override + public void onCreate( Bundle bundle ) { + if ( mMapView != null ) { + mMapView.onCreate( getContext(), bundle ); + } + if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) { + BaiduNaviManagerFactory.getRouteResultManager().onCreate( getContext() ); + } + } + + @Override + public void onResume() { + if ( mMapView != null ) { + mMapView.onResume(); + } + if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) { + BaiduNaviManagerFactory.getRouteResultManager().onResume(); + } + } + + @Override + public void onPause() { + if ( mMapView != null ) { + mMapView.onPause(); + } + if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) { + BaiduNaviManagerFactory.getRouteResultManager().onPause(); + } + } + + @Override + public void onDestroy() { + if ( mMapView != null ) { + mMapView.onDestroy(); + } + + if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) { + BaiduNaviManagerFactory.getRouteResultManager().onDestroy(); + } + } + + @Override + public void onSaveInstanceState( Bundle outState ) { + if ( mMapView != null ) { + mMapView.onSaveInstanceState( outState ); + } + } + + @Override + public void onLowMemory() { + } + + @Override + public boolean onMarkerClick( Marker marker ) { + return mMarkerClickHandler.handleMarkerClicked( marker ); + } + + @Override + public void onMapLoaded() { + MogoMapListenerHandler.getInstance().onMapLoaded(); + } + + @Override + public void onTouch( MotionEvent motionEvent ) { + MogoMapListenerHandler.getInstance().onTouch( motionEvent ); + } + + @Override + public void onMapClick( LatLng latLng ) { + MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromBMap( latLng ) ); + } + + @Override + public void onMapPoiClick( MapPoi mapPoi ) { + MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromBMap( mapPoi ) ); + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapWrapper.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapWrapper.java new file mode 100644 index 0000000000..78b81081fe --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/BMapWrapper.java @@ -0,0 +1,170 @@ +package com.mogo.map.impl.baidu; + +import com.baidu.mapapi.map.BaiduMap; +import com.baidu.mapapi.map.Marker; +import com.baidu.mapapi.map.MarkerOptions; +import com.baidu.mapapi.map.Overlay; +import com.baidu.mapapi.map.OverlayOptions; +import com.mogo.map.IMogoMap; +import com.mogo.map.IMogoUiSettings; +import com.mogo.map.impl.baidu.marker.BMapMarkerWrapper; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.marker.MogoMarkersHandler; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 代理高德AMap + */ +public class BMapWrapper implements IMogoMap { + + private static final String TAG = "BMapWrapper"; + + private BaiduMap mBMap; + private IMogoUiSettings mUiSettings; + + public BMapWrapper( BaiduMap map ) { + this.mBMap = map; + } + + @Override + public IMogoUiSettings getUiSettings() { + if ( mUiSettings == null ) { + mUiSettings = new BMapUiSettingsWrapper( mBMap.getUiSettings() ); + } + return null; + } + + @Override + public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) { + if ( !checkBMap() ) { + return null; + } + MarkerOptions markerOptions = ObjectUtils.fromMogo( options ); + if ( markerOptions == null ) { + Logger.e( TAG, "marker参数为空" ); + return null; + } + final IMogoMarker mogoMarker = new BMapMarkerWrapper( ( Marker ) mBMap.addOverlay( markerOptions ) ); + MogoMarkersHandler.getInstance().add( tag, mogoMarker ); + return mogoMarker; + } + + @Override + public ArrayList< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) { + if ( !checkBMap() ) { + return null; + } + + if ( options == null || options.isEmpty() ) { + return null; + } + + List< Overlay > markers = null; + ArrayList< OverlayOptions > markerOptions = new ArrayList<>(); + ArrayList< IMogoMarker > mogoMarkers = new ArrayList<>(); + + for ( MogoMarkerOptions option : options ) { + if ( option == null ) { + continue; + } + MarkerOptions mo = ObjectUtils.fromMogo( option ); + if ( mo == null ) { + continue; + } + markerOptions.add( mo ); + } + if ( markerOptions.isEmpty() ) { + return null; + } + markers = mBMap.addOverlays( markerOptions ); + if ( markers == null || markers.isEmpty() ) { + return null; + } + for ( Overlay marker : markers ) { + if ( marker instanceof Marker ) { + mogoMarkers.add( new BMapMarkerWrapper( ( ( Marker ) marker ) ) ); + } + } + MogoMarkersHandler.getInstance().add( tag, mogoMarkers ); + return mogoMarkers; + } + + @Override + public void clear() { + if ( checkBMap() ) { + mBMap.clear(); + } + } + + @Override + public void clear( boolean isKeepMyLocationOverlay ) { + if ( checkBMap() ) { + mBMap.clear(); + } + } + + @Override + public void setPointToCenter( int x, int y ) { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - setPointToCenter" ); + } + } + + @Override + public void setTouchPoiEnable( boolean touchPoiEnable ) { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - setTouchPoiEnable" ); + } + } + + @Override + public void setTrafficEnable( boolean enable ) { + if ( checkBMap() ) { + mBMap.setTrafficEnabled( enable ); + } + } + + @Override + public void showBuildings( boolean enabled ) { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - showBuildings" ); + } + } + + @Override + public void showIndoorMap( boolean enable ) { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - showIndoorMap" ); + } + } + + @Override + public void showMapText( boolean enable ) { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - showMapText" ); + } + } + + @Override + public void stopAnimation() { + if ( checkBMap() ) { + Logger.w( TAG, "百度地图未实现该方法 - stopAnimation" ); + } + } + + private boolean checkBMap() { + if ( mBMap == null ) { + Logger.e( TAG, "百度map实例为空,请检查" ); + return false; + } + return true; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/location/BLocationClient.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/location/BLocationClient.java new file mode 100644 index 0000000000..b8278c2c57 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/location/BLocationClient.java @@ -0,0 +1,118 @@ +package com.mogo.map.impl.baidu.location; + +import android.content.Context; + +import com.baidu.location.BDAbstractLocationListener; +import com.baidu.location.BDLocation; +import com.baidu.location.LocationClient; +import com.baidu.location.LocationClientOption; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.location.IMogoLocationClient; +import com.mogo.map.location.IMogoLocationListener; +import com.mogo.map.location.MogoLocation; +import com.mogo.utils.logger.Logger; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +/** + * @author congtaowang + * @since 2019-12-19 + *
+ * 百度定位 + */ +public class BLocationClient implements IMogoLocationClient { + + private static final String TAG = "LocationClient"; + + private static volatile BLocationClient sInstance; + private static Set< IMogoLocationListener > sListeners = new HashSet<>( 10 ); + private static MogoLocation sLastLocation = new MogoLocation(); + + private BLocationClient( Context context ) { + mClient = new LocationClient( context ); + mClient.registerLocationListener( new InternalLocationListener() ); + sLastLocation = ObjectUtils.fromBMap( mClient.getLastKnownLocation() ); + } + + public static BLocationClient getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( BLocationClient.class ) { + if ( sInstance == null ) { + sInstance = new BLocationClient( context ); + } + } + } + return sInstance; + } + + private LocationClient mClient; + + @Override + public void start() { + start( 2_000L ); + } + + @Override + public void start( long interval ) { + stop(); + LocationClientOption option = new LocationClientOption(); + option.setLocationMode( LocationClientOption.LocationMode.Hight_Accuracy ); + option.setIsNeedAddress( true ); + option.setScanSpan( ( ( int ) interval ) ); + if ( mClient != null ) { + mClient.setLocOption( option ); + } + mClient.start(); + } + + @Override + public void stop() { + if ( mClient != null ) { + mClient.stop(); + } + } + + @Override + public void addLocationListener( IMogoLocationListener listener ) { + if ( listener != null ) { + synchronized ( sListeners ) { + sListeners.add( listener ); + } + } + } + + @Override + public void removeLocationListener( IMogoLocationListener listener ) { + if ( listener != null ) { + synchronized ( sListeners ) { + sListeners.remove( listener ); + } + } + } + + @Override + public MogoLocation getLastKnowLocation() { + return sLastLocation; + } + + private static class InternalLocationListener extends BDAbstractLocationListener { + @Override + public void onReceiveLocation( BDLocation bdLocation ) { + if ( bdLocation == null || + bdLocation.getLatitude() == 0.0D || + bdLocation.getLongitude() == 0.0D ) { + return; + } + Logger.d( TAG, bdLocation.toString() ); + sLastLocation = ObjectUtils.fromBMap( bdLocation ); + synchronized ( sListeners ) { + Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator(); + while ( listenerIterator.hasNext() ) { + listenerIterator.next().onLocationChanged( sLastLocation.clone() ); + } + } + } + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerMap.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerMap.java new file mode 100644 index 0000000000..abef89e35a --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerMap.java @@ -0,0 +1,30 @@ +package com.mogo.map.impl.baidu.marker; + +import com.baidu.mapapi.map.Marker; +import com.mogo.map.marker.IMogoMarker; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 管理百度marker和mogoMarker的映射关系 + */ +public class BMapMarkerMap { + + private static Map< Marker, IMogoMarker > sMap = new HashMap<>(); + + public static void put( Marker marker, IMogoMarker mogoMarker ) { + sMap.put( marker, mogoMarker ); + } + + public static IMogoMarker get( Marker marker ) { + return sMap.get( marker ); + } + + public static IMogoMarker remove( Marker marker ) { + return sMap.remove( marker ); + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerWrapper.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerWrapper.java new file mode 100644 index 0000000000..17ddb3fe4b --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/marker/BMapMarkerWrapper.java @@ -0,0 +1,239 @@ +package com.mogo.map.impl.baidu.marker; + +import android.graphics.Bitmap; +import android.view.View; + +import com.baidu.mapapi.map.BitmapDescriptor; +import com.baidu.mapapi.map.BitmapDescriptorFactory; +import com.baidu.mapapi.map.InfoWindow; +import com.baidu.mapapi.map.Marker; +import com.baidu.mapapi.model.LatLng; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.marker.IMogoInfoWindowAdapter; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; +import com.mogo.map.marker.MogoMarkerOptions; + +import java.util.ArrayList; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 高德marker + */ +public class BMapMarkerWrapper implements IMogoMarker { + + private Marker mMarker; + private Object mObject; + private IMogoMarkerClickListener mMogoMarkerClickListener; + private IMogoInfoWindowAdapter mMogoInfoWindowAdapter; + + private boolean mIsDestroy = false; + + public BMapMarkerWrapper( Marker marker ) { + this.mMarker = marker; + if ( marker != null ) { + // 设置百度 marker 的object对象为 IMogoMarker 实例。!!!! + BMapMarkerMap.put( marker, this ); + } + } + + @Override + public void destroy() { + BMapMarkerMap.remove( mMarker ); + if ( mMarker != null ) { + mMarker.remove(); + mMarker = null; + } + mMogoInfoWindowAdapter = null; + mMogoMarkerClickListener = null; + mObject = null; + mIsDestroy = true; + } + + @Override + public void remove() { + destroy(); + } + + @Override + public void hideInfoWindow() { + if ( mMarker != null ) { + mMarker.hideInfoWindow(); + } + } + + @Override + public void setAlpha( float alpha ) { + if ( mMarker != null ) { + mMarker.setAlpha( alpha ); + } + } + + @Override + public void setAnchor( float anchorU, float anchorV ) { + if ( mMarker != null ) { + mMarker.setAnchor( anchorU, anchorV ); + } + } + + @Override + public void setDraggable( boolean paramBoolean ) { + if ( mMarker != null ) { + mMarker.setDraggable( paramBoolean ); + } + } + + @Override + public void setIcon( Bitmap icon ) { + if ( icon == null || icon.isRecycled() ) { + return; + } + if ( mMarker != null ) { + mMarker.setIcon( BitmapDescriptorFactory.fromBitmap( icon ) ); + } + } + + @Override + public void setIcons( ArrayList< Bitmap > icons ) { + if ( icons == null || icons.isEmpty() ) { + return; + } + ArrayList< BitmapDescriptor > descriptors = new ArrayList<>(); + for ( Bitmap icon : icons ) { + if ( icon == null || icon.isRecycled() ) { + continue; + } + descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) ); + } + if ( descriptors.isEmpty() ) { + return; + } + if ( mMarker != null ) { + mMarker.setIcons( descriptors ); + } + } + + @Override + public void setInfoWindowEnable( boolean enabled ) { + + } + + @Override + public void setMarkerOptions( MogoMarkerOptions opt ) { + } + + @Override + public void setObject( Object object ) { + mObject = object; + } + + @Override + public Object getObject() { + return mObject; + } + + @Override + public void setPeriod( int period ) { + if ( mMarker != null ) { + mMarker.setPeriod( period ); + } + } + + @Override + public void setPosition( double lat, double lng ) { + if ( mMarker != null ) { + mMarker.setPosition( new LatLng( lat, lng ) ); + } + } + + @Override + public MogoLatLng getPosition() { + if ( mMarker != null ) { + final LatLng latLng = mMarker.getPosition(); + return ObjectUtils.fromBMap( latLng ); + } + return null; + } + + @Override + public void setRotateAngle( float rotate ) { + if ( mMarker != null ) { + mMarker.setRotate( rotate ); + } + } + + @Override + public void setSnippet( String snippet ) { + + } + + @Override + public void setTitle( String title ) { + if ( mMarker != null ) { + mMarker.setTitle( title ); + } + } + + @Override + public void setToTop() { + if ( mMarker != null ) { + mMarker.setToTop(); + } + } + + @Override + public void setVisible( boolean visible ) { + if ( mMarker != null ) { + mMarker.setVisible( visible ); + } + } + + @Override + public void setZIndex( int zIndex ) { + if ( mMarker != null ) { + mMarker.setZIndex( zIndex ); + } + } + + @Override + public void showInfoWindow() { + if ( mMarker != null ) { + InfoWindow iw = mMarker.getInfoWindow(); + View infoWindowView = getInfoWindowAdapter().getInfoWindow( this ); + if ( iw == null ) { + iw = new InfoWindow( infoWindowView, mMarker.getPosition(), 0 ); + mMarker.showInfoWindow( iw ); + } else { + mMarker.updateInfoWindowView( infoWindowView ); + } + } + } + + @Override + public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) { + mMogoMarkerClickListener = listener; + } + + @Override + public IMogoMarkerClickListener getOnMarkerClickListener() { + return mMogoMarkerClickListener; + } + + @Override + public void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter ) { + mMogoInfoWindowAdapter = adapter; + } + + @Override + public IMogoInfoWindowAdapter getInfoWindowAdapter() { + return mMogoInfoWindowAdapter; + } + + @Override + public boolean isDestroyed() { + return mIsDestroy; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/BMapNaviListenerAdapter.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/BMapNaviListenerAdapter.java new file mode 100644 index 0000000000..6e0603f20b --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/BMapNaviListenerAdapter.java @@ -0,0 +1,302 @@ +package com.mogo.map.impl.baidu.navi; + +import android.graphics.Bitmap; +import android.view.View; + +import com.baidu.navisdk.adapter.IBNRouteGuideManager; +import com.baidu.navisdk.adapter.IBNaviListener; +import com.baidu.navisdk.adapter.IBNaviViewListener; +import com.baidu.navisdk.adapter.IBaiduNaviManager; +import com.baidu.navisdk.adapter.struct.BNHighwayInfo; +import com.baidu.navisdk.adapter.struct.BNRoadCondition; +import com.baidu.navisdk.adapter.struct.BNaviInfo; +import com.baidu.navisdk.adapter.struct.BNaviLocation; +import com.baidu.navisdk.ui.routeguide.model.RGLineItem; +import com.mogo.utils.logger.Logger; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 百度导航监听: 导航初始化,专业导航,导航事件,导航视图事件 + */ +public class BMapNaviListenerAdapter implements + IBaiduNaviManager.INaviInitListener, + IBNRouteGuideManager.OnNavigationListener, + IBNaviListener, + IBNaviViewListener { + + private static final String TAG = "BMapNaviListenerAdapter"; + + // 导航初始化 + + /** + * 授权校验结果 + * + * @param status 0 表示成功,其他表示失败 + * @param msg 具体授权校验失败信息 + */ + @Override + public void onAuthResult( int status, String msg ) { + if ( status != 0 ) { + Logger.i( TAG, "key校验失败:" + msg ); + } + } + + /** + * 百度导航初始化开始 + */ + @Override + public void initStart() { + Logger.i( TAG, "百度导航开始初始化" ); + } + + /** + * 百度导航初始化成功 + */ + @Override + public void initSuccess() { + Logger.i( TAG, "百度导航初始化成功" ); + } + + /** + * 百度导航初始化失败 + */ + @Override + public void initFailed( int errorCode ) { + Logger.i( TAG, "百度导航初始化失败:errorcode=" + errorCode ); + } + // 导航初始化 - end + + // 专业导航 + + @Override + public void onNaviGuideEnd() { + + } + + @Override + public void notifyOtherAction( int i, int i1, int i2, Object o ) { + + } + + // 专业导航 - end + + // 导航事件 + + /** + * 当前路名更新 + * + * @param name 当前道路名 + */ + @Override + public void onRoadNameUpdate( String name ) { + + } + + /** + * 距离目的地的剩余距离 + * + * @param remainDistance 剩余距离,单位米 + * @param remainTime 剩余时间,单位秒 + */ + @Override + public void onRemainInfoUpdate( int remainDistance, int remainTime ) { + + } + + /** + * 诱导信息 + * + * @param naviInfo 对应的诱导信息 + */ + @Override + public void onGuideInfoUpdate( BNaviInfo naviInfo ) { + + } + + /** + * 高速信息 + * + * @param action SHOW: 展示 HIDE: 消隐 UPDATE: 更新信息 + * @param info 对应的高速信息 + */ + @Override + public void onHighWayInfoUpdate( IBNaviListener.Action action, BNHighwayInfo info ) { + + } + + /** + * 快速路出口信息 + * + * @param action SHOW: 展示 HIDE: 消隐 UPDATE: 更新信息 + * @param name 快速路名称 + * @param dist 离快速路出口的距离 + * @param id 快速路ID + */ + @Override + public void onFastExitWayInfoUpdate( IBNaviListener.Action action, String name, int dist, String id ) { + + } + + /** + * 放大图回调接口 + * + * @param action 显示/刷新/隐藏动作 + * @param enlargeMap 放大图View + * @param remainDistance 剩余距离 + * @param progress 路口的进度 + * @param roadName 下一个路名 + * @param turnIcon 转向标 + */ + @Override + public void onEnlargeMapUpdate( IBNaviListener.Action action, View enlargeMap, String remainDistance, int progress, String roadName, Bitmap turnIcon ) { + + } + + /** + * 日夜模式改变 + * + * @param style DayNightMode.DAY: 白天 DayNightMode.NIGHT: 黑夜 + */ + @Override + public void onDayNightChanged( DayNightMode style ) { + + } + + /** + * 路况信息更新 + * + * @param v 车行驶的进度 单位为浮点类型,0-1为0%-100% + * @param items 路况信息 + */ + @Override + public void onRoadConditionInfoUpdate( double v, List< BNRoadCondition > items ) { + + } + + /** + * 主辅路、高架桥信息更新 + * + * @param type {@link com.baidu.navisdk.adapter.BNaviCommonParams.BNMainSideBridge} + */ + @Override + public void onMainSideBridgeUpdate( int type ) { + + } + + /** + * 车道线信息更新 + * + * @param action Action.SHOW:显示 Action.HIDE:消隐 + * @param laneItems 车道线数据 + */ + @Override + public void onLaneInfoUpdate( IBNaviListener.Action action, List< RGLineItem > laneItems ) { + + } + + + /** + * 速度信息 + * + * @param speed 车速 "--" 代表速度不可信,其他String返回值为数字 km/h + * @param isOverSpeed 是否超速 + */ + @Override + public void onSpeedUpdate( String speed, boolean isOverSpeed ) { + + } + + /** + * 到达目的地后回调函数 + */ + @Override + public void onArriveDestination() { + + } + + /** + * 驾车路径导航到达某个途经点的回调函数 + */ + @Override + public void onArrivedWayPoint( int index ) { + + } + + /** + * 位置变化 + * + * @param bNaviLocation + */ + @Override + public void onLocationChange( BNaviLocation bNaviLocation ) { + + } + + // 导航事件 — end + + // 导航视图事件 + + /** + * 诱导面板的点击事件 + */ + @Override + public void onMainInfoPanCLick() { + + } + + /** + * 界面左上角转向操作的点击回调 + */ + @Override + public void onNaviTurnClick() { + + } + + /** + * 全览按钮的点击回调 + */ + @Override + public void onFullViewButtonClick( boolean show ) { + + } + + /** + * 全览小窗口的点击 + */ + @Override + public void onFullViewWindowClick( boolean show ) { + + } + + /** + * 导航页面左下角退出按钮点击后的回调接口 + */ + @Override + public void onNaviBackClick() { + + } + + /** + * 底部中间部分点击事件 + */ + @Override + public void onBottomBarClick( IBNaviViewListener.Action action ) { + + } + + /** + * 界面右下角功能设置按钮的回调接口 + * + * @param isOpen 设置界面是否打开 + */ + @Override + public void onNaviSetting( boolean isOpen ) { + + } + + // 导航视图事件 - end +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviClient.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviClient.java new file mode 100644 index 0000000000..923cd5f30e --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviClient.java @@ -0,0 +1,210 @@ +package com.mogo.map.impl.baidu.navi; + +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; + +import com.baidu.navisdk.adapter.BNRoutePlanNode; +import com.baidu.navisdk.adapter.BaiduNaviManagerFactory; +import com.baidu.navisdk.adapter.IBNRoutePlanManager; +import com.mogo.map.MogoLatLng; +import com.mogo.map.impl.baidu.location.BLocationClient; +import com.mogo.map.location.MogoLocation; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoNaviConfig; +import com.mogo.utils.TipToast; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 高德导航 + */ +public class NaviClient implements IMogoNavi { + + private static final String TAG = "NaviClient"; + private final Context mContext; + + private NaviListenerAdapter mBMapNaviListener; + + /** + * 导航策略配置 + */ + private MogoNaviConfig mMogoNaviConfig = new MogoNaviConfig(); + + private static volatile NaviClient sInstance; + + private NaviClient( Context context ) { + mContext = context; + mBMapNaviListener = new NaviListenerAdapter(); + BaiduNaviManagerFactory.getBaiduNaviManager().init( context, "", "", mBMapNaviListener ); + } + + public static NaviClient getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( NaviClient.class ) { + if ( sInstance == null ) { + sInstance = new NaviClient( context ); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public void naviTo( MogoLatLng endPoint ) { + naviTo( endPoint, mMogoNaviConfig ); + } + + @Override + public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) { + naviTo( endPoint, null, config ); + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) { + naviTo( endPoint, wayPoints, mMogoNaviConfig ); + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) { + if ( !checkAMapNavi() ) { + return; + } + Logger.i( TAG, "开始规划路径" ); + mMogoNaviConfig = config; + if ( mMogoNaviConfig == null ) { + mMogoNaviConfig = new MogoNaviConfig(); + } + MogoLocation location = BLocationClient.getInstance( mContext ).getLastKnowLocation(); + if ( location == null ) { + location = new MogoLocation(); + } + List< BNRoutePlanNode > nodes = new ArrayList<>(); + BNRoutePlanNode sNode = getBNRoutePlanNode( location ); + if ( sNode == null ) { + TipToast.shortTip( "起点错误,请开启定位功能" ); + return; + } + nodes.add( sNode ); + if ( wayPoints != null && !wayPoints.isEmpty() ) { + for ( MogoLatLng wayPoint : wayPoints ) { + if ( wayPoint == null ) { + continue; + } + nodes.add( getBNRoutePlanNode( wayPoint ) ); + } + } + BNRoutePlanNode eNode = getBNRoutePlanNode( endPoint ); + if ( eNode == null ) { + if ( sNode == null ) { + TipToast.shortTip( "终点错误,请确认" ); + return; + } + } + nodes.add( eNode ); + Bundle extras = new Bundle(); + + int strategy = IBNRoutePlanManager.RoutePlanPreference.ROUTE_PLAN_PREFERENCE_DEFAULT; + + BaiduNaviManagerFactory.getRoutePlanManager().routeplanToNavi( nodes, strategy, extras, new Handler( Looper.getMainLooper() ) { + @Override + public void handleMessage( Message msg ) { + switch ( msg.what ) { + case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_START: + Logger.i( TAG, "算路开始" ); + break; + case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_SUCCESS: + Logger.i( TAG, "算路成功" ); + break; + case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_FAILED: + Logger.i( TAG, "算路失败" ); + break; + case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_TO_NAVI: + Logger.i( TAG, "算路成功准备进入导航" ); + BaiduNaviManagerFactory.getRouteResultManager().startNavi(); + break; + default: + // nothing + break; + } + } + } ); + } + + private BNRoutePlanNode getBNRoutePlanNode( MogoLatLng latLng ) { + if ( latLng == null ) { + return null; + } + return new BNRoutePlanNode.Builder() + .latitude( latLng.lat ) + .longitude( latLng.lng ) + .coordinateType( BNRoutePlanNode.CoordinateType.GCJ02 ) + .build(); + } + + private BNRoutePlanNode getBNRoutePlanNode( MogoLocation latLng ) { + if ( latLng == null ) { + return null; + } + return new BNRoutePlanNode.Builder() + .latitude( latLng.getLatitude() ) + .longitude( latLng.getLongitude() ) + .coordinateType( BNRoutePlanNode.CoordinateType.GCJ02 ) + .build(); + } + + @Override + public void reCalculateRoute( MogoNaviConfig config ) { + if ( !checkAMapNavi() ) { + return; + } + mMogoNaviConfig = config; + if ( mMogoNaviConfig == null ) { + mMogoNaviConfig = new MogoNaviConfig(); + } +// int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() ); +// mAMapNavi.reCalculateRoute( strategy ); + } + + @Override + public void stopNavi() { + BaiduNaviManagerFactory.getRouteGuideManager().forceQuitNaviWithoutDialog(); + } + + @Override + public boolean isNaviing() { + if ( mBMapNaviListener != null ) { + return mBMapNaviListener.isNaviing(); + } + return false; + } + + // -- end + + private boolean checkAMapNavi() { +// if ( mAMapNavi == null ) { +//// throw new MogoMapException( new NullPointerException( "高德导航实例为空!!!" ) ); +// Logger.e( TAG, "高德导航实例为空!!!" ); +// return false; +// } + return true; + } + + public boolean isRealNavi() { + if ( mMogoNaviConfig != null ) { + return mMogoNaviConfig.isRealNavi(); + } + return true; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviListenerAdapter.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviListenerAdapter.java new file mode 100644 index 0000000000..d9157a12f7 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/navi/NaviListenerAdapter.java @@ -0,0 +1,26 @@ +package com.mogo.map.impl.baidu.navi; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 百度导航 + */ +public class NaviListenerAdapter extends BMapNaviListenerAdapter { + + private boolean isNaviing = false; + + public void setNaviing( boolean naviing ) { + isNaviing = naviing; + } + + public boolean isNaviing() { + return isNaviing; + } + + @Override + public void onArriveDestination() { + isNaviing = true; + super.onArriveDestination(); + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/GeocodeSearchClient.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/GeocodeSearchClient.java new file mode 100644 index 0000000000..4682e6067d --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/GeocodeSearchClient.java @@ -0,0 +1,91 @@ +package com.mogo.map.impl.baidu.search; + +import android.content.Context; + +import com.baidu.mapapi.search.geocode.GeoCodeOption; +import com.baidu.mapapi.search.geocode.GeoCodeResult; +import com.baidu.mapapi.search.geocode.GeoCoder; +import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener; +import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption; +import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult; +import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.search.geo.IMogoGeoSearch; +import com.mogo.map.search.geo.IMogoGeoSearchListener; +import com.mogo.map.search.geo.MogoGeocodeAddress; +import com.mogo.map.search.geo.MogoRegeocodeAddress; +import com.mogo.map.search.geo.query.MogoGeocodeQuery; +import com.mogo.map.search.geo.query.MogoRegeocodeQuery; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-19 + *
+ * 百度地理编码/逆地理编码 + */ +public class GeocodeSearchClient implements IMogoGeoSearch, OnGetGeoCoderResultListener { + + private GeoCoder mClient; + private IMogoGeoSearchListener mListener; + + public GeocodeSearchClient( Context context ) { + mClient = GeoCoder.newInstance(); + mClient.setOnGetGeoCodeResultListener( this ); + } + + @Override + public void setGeoSearchListener( IMogoGeoSearchListener listener ) { + mListener = listener; + } + + @Override + public MogoRegeocodeAddress getFromLocation( MogoRegeocodeQuery query ) throws MogoMapException { + throw new MogoMapException( "百度地图不支持同步获取逆地理位置编码" ); + } + + @Override + public List< MogoGeocodeAddress > getFromLocationName( MogoGeocodeQuery query ) throws MogoMapException { + throw new MogoMapException( "百度地图不支持同步获取地理位置编码" ); + } + + @Override + public void getFromLocationAsyn( MogoRegeocodeQuery query ) { + if ( mClient != null ) { + mClient.reverseGeoCode( new ReverseGeoCodeOption() + .location( ObjectUtils.fromMogo2( query.getPoint() ) ) + .newVersion( 1 ) + .radius( query.getRadius() ) ); + } + } + + @Override + public void getFromLocationNameAsyn( MogoGeocodeQuery query ) { + if ( mClient != null ) { + mClient.geocode( new GeoCodeOption() + .city( query.getCity() ) + .address( query.getLocationName() ) ); + } + } + + @Override + public void onGetGeoCodeResult( GeoCodeResult geoCodeResult ) { + if ( mListener != null ) { + mListener.onGeocodeSearched( ObjectUtils.fromBMap( geoCodeResult ) ); + } + } + + @Override + public void onGetReverseGeoCodeResult( ReverseGeoCodeResult reverseGeoCodeResult ) { + if ( mListener != null ) { + mListener.onRegeocodeSearched( ObjectUtils.fromBMap( reverseGeoCodeResult ) ); + } + } + + @Override + public void destroy() { + mClient = null; + mListener = null; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/InputtipsSearch.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/InputtipsSearch.java new file mode 100644 index 0000000000..da18ad08f5 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/InputtipsSearch.java @@ -0,0 +1,90 @@ +package com.mogo.map.impl.baidu.search; + +import android.content.Context; + +import com.baidu.mapapi.search.core.SearchResult; +import com.baidu.mapapi.search.sug.OnGetSuggestionResultListener; +import com.baidu.mapapi.search.sug.SuggestionResult; +import com.baidu.mapapi.search.sug.SuggestionSearch; +import com.baidu.mapapi.search.sug.SuggestionSearchOption; +import com.mogo.map.impl.baidu.utils.ObjectUtils; +import com.mogo.map.search.inputtips.IMogoInputtipsListener; +import com.mogo.map.search.inputtips.IMogoInputtipsSearch; +import com.mogo.map.search.inputtips.MogoTip; +import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-20 + *
+ * 百度地图 inputtips 搜索实现 + */ +public class InputtipsSearch implements IMogoInputtipsSearch, OnGetSuggestionResultListener { + + private static final String TAG = "InputtipsSearch"; + + private SuggestionSearch mClient; + private SuggestionSearchOption mQuery; + private IMogoInputtipsListener mListener; + + public InputtipsSearch( Context context, MogoInputtipsQuery query ) { + mQuery = ObjectUtils.fromMogo( query ); + mClient = SuggestionSearch.newInstance(); + mClient.setOnGetSuggestionResultListener( this ); + } + + @Override + public void setQuery( MogoInputtipsQuery query ) { + this.mQuery = ObjectUtils.fromMogo( query ); + } + + @Override + public void setInputtipsListener( IMogoInputtipsListener listener ) { + this.mListener = listener; + } + + @Override + public void requestInputtipsAsyn() { + if ( mClient != null ) { + mClient.requestSuggestion( mQuery ); + } + } + + @Override + public void onGetSuggestionResult( SuggestionResult suggestionResult ) { + if ( suggestionResult.error == SearchResult.ERRORNO.NO_ERROR ) { + if ( mListener != null ) { + mListener.onGetInputtips( getResult( suggestionResult.getAllSuggestions() ) ); + } + } else { + Logger.e( TAG, "errorcode = " + suggestionResult.error ); + } + } + + private List< MogoTip > getResult( List< SuggestionResult.SuggestionInfo > suggestionInfos ) { + List< MogoTip > mogoTips = new ArrayList<>(); + if ( suggestionInfos != null ) { + for ( SuggestionResult.SuggestionInfo tip : suggestionInfos ) { + MogoTip mogoTip = ObjectUtils.fromBMap( tip ); + if ( mogoTip != null ) { + mogoTips.add( mogoTip ); + } + } + } + return mogoTips; + } + + @Override + public void destroy() { + if ( mClient != null ) { + mClient.destroy(); + } + mClient = null; + mListener = null; + mQuery = null; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/PoiSearchClient.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/PoiSearchClient.java new file mode 100644 index 0000000000..759dc52bca --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/search/PoiSearchClient.java @@ -0,0 +1,99 @@ +package com.mogo.map.impl.baidu.search; + +import android.content.Context; + +import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener; +import com.baidu.mapapi.search.poi.PoiDetailResult; +import com.baidu.mapapi.search.poi.PoiDetailSearchResult; +import com.baidu.mapapi.search.poi.PoiIndoorResult; +import com.baidu.mapapi.search.poi.PoiResult; +import com.baidu.mapapi.search.poi.PoiSearch; +import com.mogo.map.exception.MogoMapException; +import com.mogo.map.search.geo.MogoPoiItem; +import com.mogo.map.search.poisearch.IMogoPoiSearch; +import com.mogo.map.search.poisearch.IMogoPoiSearchListener; +import com.mogo.map.search.poisearch.MogoPoiResult; +import com.mogo.map.search.poisearch.MogoSearchBound; +import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; + +/** + * @author congtaowang + * @since 2019-12-24 + *
+ * 百度poi搜索 + *
+ */ +public class PoiSearchClient implements IMogoPoiSearch, OnGetPoiSearchResultListener { + + private static final String TAG = "PoiSearchClient"; + + private MogoPoiSearchQuery mQuery; + private PoiSearch mClient; + private IMogoPoiSearchListener mListener; + private MogoSearchBound mBound; + + public PoiSearchClient( Context context, MogoPoiSearchQuery query ) { + mQuery = query; + mClient = PoiSearch.newInstance(); + mClient.setOnGetPoiSearchResultListener( this ); + } + + @Override + public void setPoiSearchListener( IMogoPoiSearchListener listener ) { + mListener = listener; + } + + @Override + public void searchPOIAsyn() { + } + + @Override + public MogoPoiResult searchPOI() throws MogoMapException { + return null; + } + + @Override + public void setQuery( MogoPoiSearchQuery query ) { + } + + @Override + public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException { + return null; + } + + @Override + public void searchPOIIdAsyn( String poiId ) { + } + + @Override + public void setBound( MogoSearchBound bound ) { + } + + @Override + public void onGetPoiResult( PoiResult poiResult ) { + + } + + @Override + public void onGetPoiDetailResult( PoiDetailResult poiDetailResult ) { + + } + + @Override + public void onGetPoiDetailResult( PoiDetailSearchResult poiDetailSearchResult ) { + + } + + @Override + public void onGetPoiIndoorResult( PoiIndoorResult poiIndoorResult ) { + + } + + @Override + public void destroy() { + mQuery = null; + mClient = null; + mListener = null; + mBound = null; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/MapStyleUtils.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/MapStyleUtils.java new file mode 100644 index 0000000000..97d25339e3 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/MapStyleUtils.java @@ -0,0 +1,65 @@ +package com.mogo.map.impl.baidu.utils; + +import android.graphics.Bitmap; +import android.graphics.Color; + +/** + * @author congtaowang + * @since 2019-10-04 + *
+ * 描述 + */ +public class MapStyleUtils { + + enum ColorEnum { + route_overlay_line_normal( Color.parseColor( "#7AD9B4" ) ), + route_overlay_line_unknown( Color.parseColor( "#3CD26E" ) ), + route_overlay_line_slow( Color.parseColor( "#EFCC7A" ) ), + route_overlay_line_very_traffic( Color.parseColor( "#E16262" ) ), + route_overlay_line_traffic( Color.parseColor( "#E88181" ) ), + transparent( Color.parseColor( "#00000000" ) ), + light_gray( Color.parseColor( "#CDD8FF" ) ); + + private int color; + + ColorEnum( int color ) { + this.color = color; + } + + public int getColor() { + return color; + } + } + +// public static RouteOverlayOptions getRouteOverlayOptions() { +// RouteOverlayOptions options = new RouteOverlayOptions(); +// // 设置导航线路的宽度 +// options.setLineWidth( 16 ); +// // 设置交通状况情况良好下的纹理位图 +// options.setSmoothTraffic( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) ); +// // 设置路线的图标 +// options.setNormalRoute( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) ); +// // 设置交通状况未知下的纹理位图 +// options.setUnknownTraffic( colorToBitmap( ColorEnum.route_overlay_line_unknown.getColor() ) ); +// // 设置交通状况迟缓下的纹理位图 +// options.setSlowTraffic( colorToBitmap( ColorEnum.route_overlay_line_slow.getColor() ) ); +// // 设置交通状况非常拥堵下的纹理位图 +// options.setVeryJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_very_traffic.getColor() ) ); +// // 设置交通状况拥堵下的纹理位图 +// options.setJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_traffic.getColor() ) ); +// // 设置浮于道路上的『小箭头』图标的纹理位图 +// options.setArrowOnTrafficRoute( colorToBitmap( ColorEnum.transparent.getColor() ) ); +// // 自定义走过路线纹理,默认走过路线置灰功能为关,需要在AMapNaviViewOptions.setAfterRouteAutoGray(boolean)打开,该方法才生效 +// options.setPassRoute( colorToBitmap( ColorEnum.light_gray.getColor() ) ); +// // 设置路线虚线纹理 +// options.setFairWayRes( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) ); +// return options; +// } + + public static Bitmap colorToBitmap( int color ) { + Bitmap.Config config = Bitmap.Config.ARGB_8888; + Bitmap bitmap = Bitmap.createBitmap( 1, 1, config ); + bitmap.eraseColor( color ); + return bitmap; + } +} diff --git a/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/ObjectUtils.java b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/ObjectUtils.java new file mode 100644 index 0000000000..a0992f20b1 --- /dev/null +++ b/libraries/map-baidu/src/main/java/com/mogo/map/impl/baidu/utils/ObjectUtils.java @@ -0,0 +1,596 @@ +package com.mogo.map.impl.baidu.utils; + +import android.graphics.Bitmap; + +import com.baidu.location.BDLocation; +import com.baidu.location.Poi; +import com.baidu.mapapi.map.BitmapDescriptor; +import com.baidu.mapapi.map.BitmapDescriptorFactory; +import com.baidu.mapapi.map.MapPoi; +import com.baidu.mapapi.map.MarkerOptions; +import com.baidu.mapapi.model.LatLng; +import com.baidu.mapapi.search.geocode.GeoCodeResult; +import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult; +import com.baidu.mapapi.search.sug.SuggestionResult; +import com.baidu.mapapi.search.sug.SuggestionSearchOption; +import com.mogo.map.MogoLatLng; +import com.mogo.map.location.MogoLocation; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.model.MogoPoi; +import com.mogo.map.search.geo.MogoGeocodeAddress; +import com.mogo.map.search.geo.MogoGeocodeResult; +import com.mogo.map.search.geo.MogoRegeocodeAddress; +import com.mogo.map.search.geo.MogoRegeocodeResult; +import com.mogo.map.search.inputtips.MogoTip; +import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-18 + *
+ * 业务对象和实际对象转换
+ */
+public class ObjectUtils {
+
+ public static MarkerOptions fromMogo( MogoMarkerOptions opt ) {
+
+ 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() ) {
+ continue;
+ }
+ descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
+ }
+ }
+
+ return new MarkerOptions()
+ .position( new LatLng( opt.getLatitude(), opt.getLongitude() ) )
+ .title( opt.getTitle() )
+ .icon( BitmapDescriptorFactory.fromBitmap( opt.getIcon() ) )
+ .icons( descriptors )
+ .clickable( true )
+ .period( opt.getPeriod() )
+ .rotate( opt.getRotate() )
+ .flat( opt.isFlat() )
+ .visible( opt.isVisible() )
+ .alpha( opt.getAlpha() )
+ .anchor( opt.getU(), opt.getV() )
+ .draggable( opt.isDraggable() )
+ .zIndex( opt.getzIndex() );
+ }
+
+ //
+//
+ public static MogoLocation fromBMap( BDLocation bdLocation ) {
+ if ( bdLocation == null ) {
+ return null;
+ }
+ MogoLocation location = new MogoLocation();
+ location.setLocType( bdLocation.getLocType() );
+ location.setSpeed( bdLocation.getSpeed() );
+ location.setLatitude( bdLocation.getLatitude() );
+ location.setLongitude( bdLocation.getLongitude() );
+ location.setAltitude( bdLocation.getAltitude() );
+// location.setTime( bdLocation.getTime() );
+// location.setBearing( bdLocation.getBearing() );
+ location.setAccuracy( bdLocation.getGpsAccuracyStatus() );
+ location.setCityCode( bdLocation.getCityCode() );
+ location.setCityName( bdLocation.getCity() );
+// location.setProvider( bdLocation.getProvider() );
+ location.setAddress( bdLocation.getAddress().address );
+ location.setDistrict( bdLocation.getDistrict() );
+ location.setProvince( bdLocation.getProvince() );
+ location.setAdCode( bdLocation.getAdCode() );
+// location.setLocationDetail( bdLocation.getLocationDetail() );
+// location.setPoiName( bdLocation.getPoiName() );
+// location.setAoiName( bdLocation.getAoiName() );
+// location.setErrCode( bdLocation.getErrorCode() );
+// location.setErrInfo( bdLocation.getErrorInfo() );
+ location.setStreetNum( bdLocation.getStreetNumber() );
+ location.setDescription( bdLocation.getLocationDescribe() );
+ location.setBuildingId( bdLocation.getBuildingID() );
+ location.setFloor( bdLocation.getFloor() );
+ location.setGpsAccuracyStatus( bdLocation.getGpsAccuracyStatus() );
+ location.setSatellite( bdLocation.getSatelliteNumber() );
+ return location;
+ }
+
+ //
+// public static LatLonPoint fromMogo( MogoLatLng latLng ) {
+// if ( latLng == null ) {
+// return null;
+// }
+// return new LatLonPoint( latLng.lat, latLng.lng );
+// }
+//
+// public static NaviLatLng fromMogoAsNavi( MogoLatLng latLng ) {
+// if ( latLng == null ) {
+// return null;
+// }
+// return new NaviLatLng( latLng.lat, latLng.lng );
+// }
+//
+ public static LatLng fromMogo2( MogoLatLng latLng ) {
+ if ( latLng == null ) {
+ return null;
+ }
+ return new LatLng( latLng.lat, latLng.lng );
+ }
+
+ //
+// public static MogoLatLng fromBMap( LatLonPoint point ) {
+// if ( point == null ) {
+// return null;
+// }
+// return new MogoLatLng( point.getLatitude(), point.getLongitude() );
+// }
+//
+ public static MogoLatLng fromBMap( LatLng point ) {
+ if ( point == null ) {
+ return null;
+ }
+ return new MogoLatLng( point.latitude, point.longitude );
+ }
+
+ public static MogoPoi fromBMap( MapPoi poi ) {
+ if ( poi == null ) {
+ return null;
+ }
+ MogoPoi mogoPoi = new MogoPoi();
+ mogoPoi.setCoordinate( fromBMap( poi.getPosition() ) );
+ mogoPoi.setName( poi.getName() );
+ mogoPoi.setPoiId( poi.getUid() );
+ return mogoPoi;
+ }
+
+ //
+// public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
+// if ( query == null ) {
+// return null;
+// }
+// GeocodeQuery q = new GeocodeQuery( query.getLocationName(), query.getCity() );
+// return q;
+// }
+//
+// public static RegeocodeQuery fromMogo( MogoRegeocodeQuery query ) {
+// if ( query == null ) {
+// return null;
+// }
+// RegeocodeQuery q = new RegeocodeQuery( fromMogo( query.getPoint() ), query.getRadius(), query.getLatlngType() );
+// return q;
+// }
+//
+// public static MogoAoiItem fromBMap( AoiItem amapItem ) {
+// if ( amapItem == null ) {
+// return null;
+// }
+// MogoAoiItem mogoAoiItem = new MogoAoiItem();
+// mogoAoiItem.setAdCode( amapItem.getAdCode() );
+// mogoAoiItem.setAoiArea( amapItem.getAoiArea() );
+// mogoAoiItem.setAoiCenterPoint( fromBMap( amapItem.getAoiCenterPoint() ) );
+// mogoAoiItem.setAoiId( amapItem.getAoiId() );
+// mogoAoiItem.setAoiName( amapItem.getAoiName() );
+// return mogoAoiItem;
+// }
+//
+// public static MogoBusinessArea fromBMap( BusinessArea amapItem ) {
+// if ( amapItem == null ) {
+// return null;
+// }
+// MogoBusinessArea mogoBusinessArea = new MogoBusinessArea();
+// mogoBusinessArea.setCenterPoint( fromBMap( amapItem.getCenterPoint() ) );
+// mogoBusinessArea.setName( amapItem.getName() );
+// return mogoBusinessArea;
+// }
+//
+//
+// public static MogoCrossroad fromBMap( Crossroad amapItem ) {
+// if ( amapItem == null ) {
+// return null;
+// }
+// MogoCrossroad mogoCrossroad = new MogoCrossroad();
+// mogoCrossroad.setDirection( amapItem.getDirection() );
+// mogoCrossroad.setDistance( amapItem.getDistance() );
+// mogoCrossroad.setFirstRoadId( amapItem.getFirstRoadId() );
+// mogoCrossroad.setFirstRoadName( amapItem.getFirstRoadName() );
+// mogoCrossroad.setSecondRoadId( amapItem.getSecondRoadId() );
+// mogoCrossroad.setSecondRoadName( amapItem.getSecondRoadName() );
+// return mogoCrossroad;
+// }
+//
+// public static MogoGeocodeAddress fromBMap( 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( fromBMap( address.getLatLonPoint() ) );
+// mogoGeocodeAddress.setLevel( address.getLevel() );
+// mogoGeocodeAddress.setNeighborhood( address.getNeighborhood() );
+// mogoGeocodeAddress.setProvince( address.getProvince() );
+// mogoGeocodeAddress.setTownship( address.getTownship() );
+// return mogoGeocodeAddress;
+// }
+
+ //
+ public static MogoGeocodeResult fromBMap( GeoCodeResult result ) {
+ if ( result == null ) {
+ return null;
+ }
+ MogoGeocodeResult mogoGeocodeResult = new MogoGeocodeResult();
+ final List< MogoGeocodeAddress > addresses = new ArrayList<>();
+ MogoGeocodeAddress mogoGeocodeAddress = new MogoGeocodeAddress();
+ mogoGeocodeAddress.setLatlng( fromBMap( result.getLocation() ) );
+ mogoGeocodeResult.setAddresses( addresses );
+ return mogoGeocodeResult;
+ }
+
+ //
+// public static MogoIndoorData fromBMap( IndoorData data ) {
+// if ( data == null ) {
+// return null;
+// }
+// MogoIndoorData mogoIndoorData = new MogoIndoorData();
+// mogoIndoorData.setFloor( data.getFloor() );
+// mogoIndoorData.setFloorName( data.getFloorName() );
+// mogoIndoorData.setPoiId( data.getPoiId() );
+// return mogoIndoorData;
+// }
+//
+// public static MogoPhoto fromBMap( Photo photo ) {
+// if ( photo == null ) {
+// return null;
+// }
+// MogoPhoto mogoPhoto = new MogoPhoto();
+// mogoPhoto.setTitle( photo.getTitle() );
+// mogoPhoto.setUrl( photo.getUrl() );
+// return mogoPhoto;
+// }
+//
+// public static MogoPoiItemExtension fromBMap( PoiItemExtension poiItemExtension ) {
+// if ( poiItemExtension == null ) {
+// return null;
+// }
+// MogoPoiItemExtension mogoPoiItemExtension = new MogoPoiItemExtension();
+// mogoPoiItemExtension.setOpentime( poiItemExtension.getOpentime() );
+// mogoPoiItemExtension.setRating( poiItemExtension.getmRating() );
+// return mogoPoiItemExtension;
+// }
+//
+// public static MogoRegeocodeRoad fromBMap( RegeocodeRoad regeocodeRoad ) {
+// if ( regeocodeRoad == null ) {
+// return null;
+// }
+// MogoRegeocodeRoad mogoRegeocodeRoad = new MogoRegeocodeRoad();
+// mogoRegeocodeRoad.setDirection( regeocodeRoad.getDirection() );
+// mogoRegeocodeRoad.setDistance( regeocodeRoad.getDistance() );
+// mogoRegeocodeRoad.setId( regeocodeRoad.getId() );
+// mogoRegeocodeRoad.setName( regeocodeRoad.getName() );
+// mogoRegeocodeRoad.setPoint( fromBMap( regeocodeRoad.getLatLngPoint() ) );
+// return mogoRegeocodeRoad;
+// }
+//
+// public static MogoStreetNumber fromBMap( StreetNumber streetNumber ) {
+// if ( streetNumber == null ) {
+// return null;
+// }
+// MogoStreetNumber mogoStreetNumber = new MogoStreetNumber();
+// mogoStreetNumber.setDirection( streetNumber.getDirection() );
+// mogoStreetNumber.setDistance( streetNumber.getDistance() );
+// mogoStreetNumber.setLatLonPoint( fromBMap( streetNumber.getLatLonPoint() ) );
+// mogoStreetNumber.setNumber( streetNumber.getNumber() );
+// mogoStreetNumber.setStreet( streetNumber.getStreet() );
+// return mogoStreetNumber;
+// }
+//
+// public static MogoSubPoiItem fromBMap( SubPoiItem subPoiItem ) {
+// if ( subPoiItem == null ) {
+// return null;
+// }
+// MogoSubPoiItem mogoSubPoiItem = new MogoSubPoiItem();
+// mogoSubPoiItem.setDistance( subPoiItem.getDistance() );
+// mogoSubPoiItem.setPoiId( subPoiItem.getPoiId() );
+// mogoSubPoiItem.setPoint( fromBMap( subPoiItem.getLatLonPoint() ) );
+// mogoSubPoiItem.setSnippet( subPoiItem.getSnippet() );
+// mogoSubPoiItem.setSubName( mogoSubPoiItem.getSubName() );
+// mogoSubPoiItem.setSubTypeDes( mogoSubPoiItem.getSubTypeDes() );
+// mogoSubPoiItem.setTitle( mogoSubPoiItem.getTitle() );
+// return mogoSubPoiItem;
+// }
+//
+// public static MogoPoiItem fromBMap( 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( fromBMap( poiItem.getEnter() ) );
+// mogoPoiItem.setExit( fromBMap( poiItem.getExit() ) );
+// mogoPoiItem.setIndoorData( fromBMap( poiItem.getIndoorData() ) );
+// mogoPoiItem.setParkingType( poiItem.getParkingType() );
+// mogoPoiItem.setIndoorMap( poiItem.isIndoorMap() );
+// if ( poiItem.getPhotos() != null ) {
+// List< MogoPhoto > mogoPhotos = new ArrayList<>();
+// for ( Photo photo : poiItem.getPhotos() ) {
+// MogoPhoto mogoPhoto = fromBMap( photo );
+// if ( mogoPhoto != null ) {
+// mogoPhotos.add( mogoPhoto );
+// }
+// }
+// mogoPoiItem.setPhotos( mogoPhotos );
+// }
+// mogoPoiItem.setPoiExtension( fromBMap( poiItem.getPoiExtension() ) );
+// mogoPoiItem.setPoiId( poiItem.getPoiId() );
+// mogoPoiItem.setPoint( fromBMap( poiItem.getLatLonPoint() ) );
+// 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() ) {
+// MogoSubPoiItem mogoSubPoiItem = fromBMap( subPois );
+// if ( mogoPoiItem != null ) {
+// mogoSubPoiItems.add( mogoSubPoiItem );
+// }
+// }
+// mogoPoiItem.setSubPois( mogoSubPoiItems );
+// }
+// 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 fromBMap( ReverseGeoCodeResult regeocodeAddress ) {
+// if ( regeocodeAddress == null ) {
+// return null;
+// }
+// MogoRegeocodeAddress mogoRegeocodeAddress = new MogoRegeocodeAddress();
+// mogoRegeocodeAddress.setAdCode( regeocodeAddress.getAdcode() + "" );
+// if ( regeocodeAddress.getAois() != null ) {
+// List< MogoAoiItem > items = new ArrayList<>();
+// for ( AoiItem aois : regeocodeAddress.getAois() ) {
+// final MogoAoiItem mogoAoiItem = fromBMap( aois );
+// if ( mogoAoiItem != null ) {
+// items.add( mogoAoiItem );
+// }
+// }
+// mogoRegeocodeAddress.setAois( items );
+// }
+//
+// mogoRegeocodeAddress.setBuilding( regeocodeAddress.getB );
+// if ( regeocodeAddress.getBusinessAreas() != null ) {
+// List< MogoBusinessArea > mogoBusinessAreas = new ArrayList<>();
+// for ( BusinessArea businessArea : regeocodeAddress.getBusinessAreas() ) {
+// MogoBusinessArea mogoBusinessArea = fromBMap( businessArea );
+// if ( mogoBusinessArea != null ) {
+// mogoBusinessAreas.add( mogoBusinessArea );
+// }
+// }
+// mogoRegeocodeAddress.setBusinessAreas( mogoBusinessAreas );
+// }
+//
+// 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() ) {
+//
+// MogoCrossroad mogoCrossroad = fromBMap( crossroad );
+// if ( mogoCrossroad != null ) {
+// mogoCrossroads.add( mogoCrossroad );
+// }
+// }
+// mogoRegeocodeAddress.setCrossroads( mogoCrossroads );
+// }
+// mogoRegeocodeAddress.setDistrict( regeocodeAddress.getDistrict() );
+// mogoRegeocodeAddress.setFormatAddress( regeocodeAddress.getFormatAddress() );
+// mogoRegeocodeAddress.setNeighborhood( regeocodeAddress.getNeighborhood() );
+// if ( regeocodeAddress.getPois() != null ) {
+// List< MogoPoiItem > mogoPoiItems = new ArrayList<>();
+// for ( PoiItem pois : regeocodeAddress.getPois() ) {
+// MogoPoiItem mogoPoiItem = fromBMap( pois );
+// mogoPoiItems.add( mogoPoiItem );
+// }
+// mogoRegeocodeAddress.setPois( mogoPoiItems );
+// }
+// mogoRegeocodeAddress.setProvince( regeocodeAddress.getProvince() );
+// if ( regeocodeAddress.getRoads() != null ) {
+// List< MogoRegeocodeRoad > mogoRegeocodeRoads = new ArrayList<>();
+// for ( RegeocodeRoad road : regeocodeAddress.getRoads() ) {
+// MogoRegeocodeRoad mogoRegeocodeRoad = fromBMap( road );
+// if ( mogoRegeocodeRoad != null ) {
+// mogoRegeocodeRoads.add( mogoRegeocodeRoad );
+// }
+// }
+// mogoRegeocodeAddress.setRoads( mogoRegeocodeRoads );
+// }
+// mogoRegeocodeAddress.setStreetNumber( fromBMap( regeocodeAddress.getStreetNumber() ) );
+// mogoRegeocodeAddress.setTowncode( regeocodeAddress.getTowncode() );
+// mogoRegeocodeAddress.setTownship( regeocodeAddress.getTownship() );
+// return mogoRegeocodeAddress;
+// }
+
+ //
+ public static MogoRegeocodeResult fromBMap( ReverseGeoCodeResult regeocodeResult ) {
+ if ( regeocodeResult == null ) {
+ return null;
+ }
+ MogoRegeocodeResult mogoRegeocodeResult = new MogoRegeocodeResult();
+ mogoRegeocodeResult.setRegeocodeAddress( null );
+ return mogoRegeocodeResult;
+ }
+
+ //
+ public static SuggestionSearchOption fromMogo( MogoInputtipsQuery query ) {
+ if ( query == null ) {
+ return null;
+ }
+ SuggestionSearchOption searchOption = new SuggestionSearchOption();
+ searchOption.city( query.getCity() )
+ .keyword( query.getKeyword() )
+ .citylimit( query.isCityLimit() );
+ return searchOption;
+ }
+
+ public static MogoTip fromBMap( SuggestionResult.SuggestionInfo tip ) {
+ if ( tip == null ) {
+ return null;
+ }
+ MogoTip mogoTip = new MogoTip();
+ mogoTip.setAddress( tip.getAddress() );
+ mogoTip.setAdCode( "" );
+ mogoTip.setDistrict( tip.getDistrict() );
+ mogoTip.setName( tip.getKey() );
+ mogoTip.setPoiID( tip.getUid() );
+ mogoTip.setPoint( fromBMap( tip.getPt() ) );
+ mogoTip.setTypeCode( "" );
+ return mogoTip;
+ }
+//
+// public static MogoPoi fromBMap( Poi poi ) {
+// if ( poi == null ) {
+// return null;
+// }
+// MogoPoi mogoPoi = new MogoPoi();
+// mogoPoi.setCoordinate( fromBMap( poi.getCoordinate() ) );
+// mogoPoi.setName( poi.getName() );
+// mogoPoi.setPoiId( poi.getPoiId() );
+// return mogoPoi;
+// }
+//
+// public static MogoPoiSearchQuery fromBMap( PoiSearch.Query query ) {
+// if ( query == null ) {
+// return null;
+// }
+// MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery( query.getQueryString(), query.getCategory(), query.getCity() );
+// mogoPoiSearchQuery.setBuilding( query.getBuilding() );
+// mogoPoiSearchQuery.setCityLimit( query.getCityLimit() );
+// mogoPoiSearchQuery.setDistanceSort( query.isDistanceSort() );
+// mogoPoiSearchQuery.setLocation( fromBMap( query.getLocation() ) );
+// mogoPoiSearchQuery.setPageNum( query.getPageNum() );
+// mogoPoiSearchQuery.setPageSize( query.getPageSize() );
+// return mogoPoiSearchQuery;
+// }
+//
+// public static PoiSearch.Query fromMogo( MogoPoiSearchQuery query ) {
+// if ( query == null ) {
+// return null;
+// }
+// PoiSearch.Query psq = new PoiSearch.Query( query.getQuery(), query.getCategory(), query.getCity() );
+// 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() );
+// return psq;
+// }
+//
+// public static MogoSearchBound fromBMap( PoiSearch.SearchBound bound ) {
+// if ( bound == null ) {
+// return null;
+// }
+// if ( bound.getShape() == PoiSearch.SearchBound.BOUND_SHAPE ) {
+// return new MogoSearchBound( fromBMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
+// } else if ( bound.getShape() == PoiSearch.SearchBound.POLYGON_SHAPE ) {
+// return new MogoSearchBound( fromBMap( bound.getPolyGonList() ) );
+// } else if ( bound.getShape() == PoiSearch.SearchBound.RECTANGLE_SHAPE ) {
+// return new MogoSearchBound( fromBMap( bound.getLowerLeft() ), fromBMap( bound.getUpperRight() ) );
+// }
+// return null;
+// }
+//
+// public static List< MogoLatLng > fromBMap( List< LatLonPoint > latLngs ) {
+// if ( latLngs == null ) {
+// return null;
+// }
+// List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
+// for ( LatLonPoint latLng : latLngs ) {
+// result.add( fromBMap( latLng ) );
+// }
+// return result;
+// }
+//
+// public static List< LatLonPoint > fromMogo( List< MogoLatLng > latLngs ) {
+// if ( latLngs == null ) {
+// return null;
+// }
+// List< LatLonPoint > result = new ArrayList<>( latLngs.size() );
+// for ( MogoLatLng latLng : latLngs ) {
+// result.add( fromMogo( latLng ) );
+// }
+// return result;
+// }
+//
+//
+// public static PoiSearch.SearchBound fromMogo( MogoSearchBound bound ) {
+// if ( bound == null ) {
+// return null;
+// }
+// if ( bound.getShape() == MogoSearchBound.SHAPE_BOUND ) {
+// return new PoiSearch.SearchBound( fromMogo( bound.getCenterPoint() ), bound.getRadiusInMeters(), bound.isDistanceSort() );
+// } else if ( bound.getShape() == MogoSearchBound.SHAPE_POLYGON ) {
+// return new PoiSearch.SearchBound( fromMogo( bound.getPolyGonList() ) );
+// } else if ( bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE ) {
+// return new PoiSearch.SearchBound( fromMogo( bound.getLowerLeft() ), fromMogo( bound.getUpperRight() ) );
+// }
+// return null;
+// }
+//
+// public static MogoPoiResult fromBMap( PoiResult result ) {
+// if ( result == null ) {
+// return null;
+// }
+// MogoPoiResult mogoPoiResult = new MogoPoiResult();
+// if ( result.getPois() != null ) {
+// final List< PoiItem > poiItems = result.getPois();
+// final ArrayList< MogoPoiItem > mogoPoiItems = new ArrayList<>( poiItems.size() );
+// for ( PoiItem poiItem : poiItems ) {
+// mogoPoiItems.add( fromBMap( poiItem ) );
+// }
+// mogoPoiResult.setPois( mogoPoiItems );
+// }
+// return mogoPoiResult;
+// }
+//
+// public static MogoNaviInfo fromBMap( NaviInfo naviInfo ) {
+// if ( naviInfo == null ) {
+// return null;
+// }
+// MogoNaviInfo mogoNaviInfo = new MogoNaviInfo();
+// mogoNaviInfo.setCurrentRoadName( naviInfo.getCurrentRoadName() );
+// mogoNaviInfo.setCurrentSpeed( naviInfo.getCurrentSpeed() );
+// mogoNaviInfo.setCurStepRetainDistance( naviInfo.getCurStepRetainDistance() );
+// mogoNaviInfo.setCurStepRetainTime( naviInfo.getCurStepRetainTime() );
+// mogoNaviInfo.setIconType( naviInfo.getIconType() );
+// mogoNaviInfo.setNextRoadName( naviInfo.getNextRoadName() );
+// mogoNaviInfo.setPathRetainDistance( naviInfo.getPathRetainDistance() );
+// mogoNaviInfo.setPathRetainTime( naviInfo.getPathRetainTime() );
+// return mogoNaviInfo;
+// }
+}
diff --git a/libraries/map-baidu/src/main/res/values/strings.xml b/libraries/map-baidu/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..9641815763
--- /dev/null
+++ b/libraries/map-baidu/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ * 销毁 + */ +public interface IDestroyable { + + void destroy(); +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/ILifeCycle.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/ILifeCycle.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/ILifeCycle.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/ILifeCycle.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/IMogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java similarity index 92% rename from libraries/mogo-map/src/main/java/com/mogo/map/IMogoMap.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java index a345e67ce6..76e105dd11 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/IMogoMap.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java @@ -2,6 +2,7 @@ package com.mogo.map; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.uicontroller.IMogoMapUIController; import java.util.ArrayList; @@ -18,7 +19,14 @@ public interface IMogoMap { * * @return */ - IUiSettings getUiSettings(); + IMogoUiSettings getUiSettings(); + + /** + * 操作地图视图 + * + * @return + */ + IMogoMapUIController getUIController(); /** * 在地图上添一个图片标记(marker)对象。 diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/IMogoMapView.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapView.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/IMogoMapView.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMapView.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/IUiSettings.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoUiSettings.java similarity index 98% rename from libraries/mogo-map/src/main/java/com/mogo/map/IUiSettings.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoUiSettings.java index 85d1895297..a01de2d904 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/IUiSettings.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoUiSettings.java @@ -6,7 +6,7 @@ package com.mogo.map; *
* 图层控制 */ -public interface IUiSettings { +public interface IMogoUiSettings { /** * 设置比例尺功能是否可用。 diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/MogoBaseMapView.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoLatLng.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoLatLng.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/MogoLatLng.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/MogoLatLng.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/MogoMap.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/exception/MogoMapException.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/exception/MogoMapException.java similarity index 87% rename from libraries/mogo-map/src/main/java/com/mogo/map/exception/MogoMapException.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/exception/MogoMapException.java index 1c85abbecc..9fd2137025 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/exception/MogoMapException.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/exception/MogoMapException.java @@ -6,7 +6,7 @@ package com.mogo.map.exception; *
* 异常 */ -public class MogoMapException extends Exception { +public class MogoMapException extends RuntimeException { public MogoMapException() { } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/IMogoMapListener.java similarity index 52% rename from libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/listener/IMogoMapListener.java index ef1975e970..b66379e1a8 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/IMogoMapListener.java @@ -2,7 +2,10 @@ package com.mogo.map.listener; import android.view.MotionEvent; +import com.mogo.map.MogoLatLng; import com.mogo.map.model.MogoPoi; +import com.mogo.map.navi.IMogoNaviListener; +import com.mogo.map.uicontroller.EnumMapUI; /** * @author congtaowang @@ -30,4 +33,25 @@ public interface IMogoMapListener { * @param poi */ void onPOIClick( MogoPoi poi ); + + /** + * 地图点击 + * + * @param latLng + */ + void onMapClick( MogoLatLng latLng ); + + /** + * 地图锁定 + * + * @param isLock + */ + void onLockMap( boolean isLock ); + + /** + * 地图白天黑夜、导航视角切换 + * + * @param ui + */ + void onMapModeChanged( EnumMapUI ui ); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java similarity index 68% rename from libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java index 942ea96794..01de8f6d06 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java @@ -2,7 +2,10 @@ package com.mogo.map.listener; import android.view.MotionEvent; +import com.mogo.map.MogoLatLng; import com.mogo.map.model.MogoPoi; +import com.mogo.map.navi.MogoNaviInfo; +import com.mogo.map.uicontroller.EnumMapUI; /** * @author congtaowang @@ -73,4 +76,31 @@ public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListene } } } + + @Override + public void onMapClick( MogoLatLng latLng ) { + if ( mDelegateListener != null ) { + synchronized ( mDelegateListener ) { + mDelegateListener.onMapClick( latLng ); + } + } + } + + @Override + public void onLockMap( boolean isLock ) { + if ( mDelegateListener != null ) { + synchronized ( mDelegateListener ) { + mDelegateListener.onLockMap( isLock ); + } + } + } + + @Override + public void onMapModeChanged( EnumMapUI ui ) { + if ( mDelegateListener != null ) { + synchronized ( mDelegateListener ) { + mDelegateListener.onMapModeChanged( ui ); + } + } + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/IMogoLocationClient.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationClient.java similarity index 81% rename from libraries/mogo-map/src/main/java/com/mogo/map/location/IMogoLocationClient.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationClient.java index ea24dac392..ad81b5a9ab 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/location/IMogoLocationClient.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationClient.java @@ -30,14 +30,14 @@ public interface IMogoLocationClient { * * @param listener */ - void addLocationListener( ILocationListener listener ); + void addLocationListener( IMogoLocationListener listener ); /** * 注销定位回调 * * @param listener */ - void removeLocationListener( ILocationListener listener ); + void removeLocationListener( IMogoLocationListener listener ); MogoLocation getLastKnowLocation(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/ILocationListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationListener.java similarity index 85% rename from libraries/mogo-map/src/main/java/com/mogo/map/location/ILocationListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationListener.java index 7069166e20..adfa1bd924 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/location/ILocationListener.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/location/IMogoLocationListener.java @@ -6,7 +6,7 @@ package com.mogo.map.location; *
* 定位回调 */ -public interface ILocationListener { +public interface IMogoLocationListener { /** * 定位发生改变 diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/MogoLocation.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/location/MogoLocation.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/location/MogoLocation.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/location/MogoLocation.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoInfoWindowAdapter.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoInfoWindowAdapter.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoInfoWindowAdapter.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoInfoWindowAdapter.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java similarity index 98% rename from libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java index fd6c467c77..f0a5f57bab 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java @@ -140,7 +140,7 @@ public interface IMogoMarker { * * @param zIndex */ - void setZIndex( float zIndex ); + void setZIndex( int zIndex ); /** * 显示 Marker 覆盖物的信息窗口。 diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java new file mode 100644 index 0000000000..65fd3ac8dd --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java @@ -0,0 +1,43 @@ +package com.mogo.map.marker; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 地图 marker 管理 + */ +public interface IMogoMarkerManager { + + /** + * 添加marker + * + * @param tag 标识调用者 + * @param options + * @return + */ + IMogoMarker addMarker( String tag, MogoMarkerOptions options ); + + /** + * 添加多个marker + * + * @param tag 标识调用者 + * @param options + * @return + */ + List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ); + + /** + * 移除某一个类、某个模块的markers + * + * @param tag + */ + void removeMarkers( String tag ); + + /** + * 移除地图上所有markers + */ + void removeMarkers(); +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java similarity index 97% rename from libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java index 7b55d96847..30771de9bd 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkerOptions.java @@ -52,7 +52,7 @@ public class MogoMarkerOptions { private int offsetY = 0; // 设置Marker覆盖物 zIndex。 - private float zIndex = 0.0f; + private int zIndex = 0; public MogoMarkerOptions latitude( double latitude ) { this.latitude = latitude; @@ -139,7 +139,7 @@ public class MogoMarkerOptions { return this; } - public MogoMarkerOptions zIndex( float zIndex ) { + public MogoMarkerOptions zIndex( int zIndex ) { this.zIndex = zIndex; return this; } @@ -216,7 +216,7 @@ public class MogoMarkerOptions { return offsetY; } - public float getzIndex() { + public int getzIndex() { return zIndex; } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/marker/MogoMarkersHandler.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/model/MogoPoi.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/model/MogoPoi.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/model/MogoPoi.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/model/MogoPoi.java diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java new file mode 100644 index 0000000000..c57d8c72a9 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNavi.java @@ -0,0 +1,70 @@ +package com.mogo.map.navi; + +import com.mogo.map.MogoLatLng; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 导航操作 + */ +public interface IMogoNavi { + + /** + * 开启路径规划并导航 + * + * @param endPoint 目的地 + */ + void naviTo( MogoLatLng endPoint ); + + /** + * 开启路径规划并导航 + * + * @param endPoint 目的地 + * @param config 规划路线策略 + */ + void naviTo( MogoLatLng endPoint, MogoNaviConfig config ); + + /** + * 开启路径规划并导航 + * + * @param endPoint 导航目的地 + * @param wayPoints 途经点 + */ + void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ); + + /** + * 开启路径规划并导航 + * + * @param endPoint 导航目的地 + * @param wayPoints 途经点 + * @param config 规划路线策略 + */ + void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ); + + /** + * 重新算路 + * + * @param config 规划路线策略 + */ + void reCalculateRoute( MogoNaviConfig config ); + + /** + * 退出导航 + */ + void stopNavi(); + + /** + * 开始导航 + */ + void startNavi(); + + /** + * 是否正在导航 + * + * @return + */ + boolean isNaviing(); +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListener.java new file mode 100644 index 0000000000..6282dc2d62 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListener.java @@ -0,0 +1,37 @@ +package com.mogo.map.navi; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 导航监听 + */ +public interface IMogoNaviListener { + + /** + * 导航初始化失败 + */ + void onInitNaviFailure(); + + /** + * 导航初始化成功 + */ + void onInitNaviSuccess(); + + /** + * 导航引导信息 + * + * @param naviinfo + */ + void onNaviInfoUpdate( MogoNaviInfo naviinfo ); + + /** + * 导航开始回调 + */ + void onStartNavi(); + + /** + * 导航停止:包括到达目的地和主动停止导航 + */ + void onStopNavi(); +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListenerRegister.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListenerRegister.java new file mode 100644 index 0000000000..1bf51743d6 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/IMogoNaviListenerRegister.java @@ -0,0 +1,22 @@ +package com.mogo.map.navi; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * 地图操作回调 + */ +public interface IMogoNaviListenerRegister { + + /** + * 注册导航回调,各业务模块不用关注 + * + * @param listener 回调函数 + */ + void registerHostNaviListener( IMogoNaviListener listener ); + + /** + * 注销导航回调,各业务模块不用关注 + */ + void unregisterHostNaviListener(); +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviConfig.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviConfig.java new file mode 100644 index 0000000000..5e01890065 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviConfig.java @@ -0,0 +1,121 @@ +package com.mogo.map.navi; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 导航参数 + */ +public class MogoNaviConfig { + + /** + * 是否躲避拥堵 + */ + private boolean congestion = false; + + /** + * 不走高速 + */ + private boolean avoidSpeed = false; + + /** + * 避免收费 + */ + private boolean cost = false; + + /** + * 高速优先 + */ + private boolean highSpeed = false; + + /** + * 是否多路线算路 + */ + private boolean multipleRoute = true; + + /** + * 是否是正式的导航 + *
+ * false 为模拟导航 + */ + private boolean realNavi = true; + + /** + * 是否躲避拥堵 + */ + public MogoNaviConfig congestion( boolean congestion ) { + this.congestion = congestion; + return this; + } + + /** + * 不走高速 + */ + public MogoNaviConfig avoidSpeed( boolean avoidSpeed ) { + this.avoidSpeed = avoidSpeed; + this.highSpeed = false; + return this; + } + + /** + * 避免收费 + */ + public MogoNaviConfig cost( boolean cost ) { + this.cost = cost; + this.highSpeed = false; + return this; + } + + /** + * 高速优先 + */ + public MogoNaviConfig highSpeed( boolean highSpeed ) { + this.highSpeed = highSpeed; + this.avoidSpeed = false; + this.cost = false; + return this; + } + + /** + * 是否多路线算路 + */ + public MogoNaviConfig multipleRoute( boolean multipleRoute ) { + this.multipleRoute = multipleRoute; + return this; + } + + /** + * 导航模式 + * + * @param realNavi true - 正式导航, false - 模拟导航 + * @return + */ + public MogoNaviConfig realNavi( boolean realNavi ) { + this.realNavi = realNavi; + return this; + } + + public boolean isCongestion() { + return congestion; + } + + public boolean isAvoidSpeed() { + return avoidSpeed; + } + + public boolean isCost() { + return cost; + } + + public boolean isHighSpeed() { + return highSpeed; + } + + public boolean isMultipleRoute() { + return multipleRoute; + } + + public boolean isRealNavi() { + return realNavi; + } +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviInfo.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviInfo.java new file mode 100644 index 0000000000..2d578f4ec5 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviInfo.java @@ -0,0 +1,161 @@ +package com.mogo.map.navi; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 导航引导信息 + */ +public class MogoNaviInfo implements Parcelable { + + /** + * 当前路线名称 + */ + private String currentRoadName; + + /** + * 导航过程中当前的车速 + */ + private int currentSpeed; + + /** + * 当前路段剩余距离 + */ + private int curStepRetainDistance; + + /** + * 当前路段剩余时间 + */ + private int curStepRetainTime; + + /** + * 导航转向图标 + */ + private int iconType; + + /** + * 下条路名 + */ + private String nextRoadName; + + /** + * 剩余时间(秒) + */ + private int pathRetainTime; + + /** + * 剩余距离 + */ + private int pathRetainDistance; + + public String getCurrentRoadName() { + return currentRoadName; + } + + public void setCurrentRoadName( String currentRoadName ) { + this.currentRoadName = currentRoadName; + } + + public int getCurrentSpeed() { + return currentSpeed; + } + + public void setCurrentSpeed( int currentSpeed ) { + this.currentSpeed = currentSpeed; + } + + public int getCurStepRetainDistance() { + return curStepRetainDistance; + } + + public void setCurStepRetainDistance( int curStepRetainDistance ) { + this.curStepRetainDistance = curStepRetainDistance; + } + + public int getCurStepRetainTime() { + return curStepRetainTime; + } + + public void setCurStepRetainTime( int curStepRetainTime ) { + this.curStepRetainTime = curStepRetainTime; + } + + public int getIconType() { + return iconType; + } + + public void setIconType( int iconType ) { + this.iconType = iconType; + } + + public String getNextRoadName() { + return nextRoadName; + } + + public void setNextRoadName( String nextRoadName ) { + this.nextRoadName = nextRoadName; + } + + public int getPathRetainTime() { + return pathRetainTime; + } + + public void setPathRetainTime( int pathRetainTime ) { + this.pathRetainTime = pathRetainTime; + } + + public int getPathRetainDistance() { + return pathRetainDistance; + } + + public void setPathRetainDistance( int pathRetainDistance ) { + this.pathRetainDistance = pathRetainDistance; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel( Parcel dest, int flags ) { + dest.writeString( this.currentRoadName ); + dest.writeInt( this.currentSpeed ); + dest.writeInt( this.curStepRetainDistance ); + dest.writeInt( this.curStepRetainTime ); + dest.writeInt( this.iconType ); + dest.writeString( this.nextRoadName ); + dest.writeInt( this.pathRetainTime ); + dest.writeInt( this.pathRetainDistance ); + } + + public MogoNaviInfo() { + } + + protected MogoNaviInfo( Parcel in ) { + this.currentRoadName = in.readString(); + this.currentSpeed = in.readInt(); + this.curStepRetainDistance = in.readInt(); + this.curStepRetainTime = in.readInt(); + this.iconType = in.readInt(); + this.nextRoadName = in.readString(); + this.pathRetainTime = in.readInt(); + this.pathRetainDistance = in.readInt(); + } + + public static final Parcelable.Creator< MogoNaviInfo > CREATOR = new Parcelable.Creator< MogoNaviInfo >() { + @Override + public MogoNaviInfo createFromParcel( Parcel source ) { + return new MogoNaviInfo( source ); + } + + @Override + public MogoNaviInfo[] newArray( int size ) { + return new MogoNaviInfo[size]; + } + }; +} + diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviListenerHandler.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviListenerHandler.java new file mode 100644 index 0000000000..65d61abbf9 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/navi/MogoNaviListenerHandler.java @@ -0,0 +1,80 @@ +package com.mogo.map.navi; + +/** + * @author congtaowang + * @since 2019-12-24 + *
+ * 地图监听注册管理 + */ +public class MogoNaviListenerHandler implements IMogoNaviListener, IMogoNaviListenerRegister { + + private static volatile MogoNaviListenerHandler sInstance; + + private MogoNaviListenerHandler() { + } + + public static MogoNaviListenerHandler getInstance() { + if ( sInstance == null ) { + synchronized ( MogoNaviListenerHandler.class ) { + if ( sInstance == null ) { + sInstance = new MogoNaviListenerHandler(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + /** + * 上层模块代理对象 + */ + private IMogoNaviListener mDelegateListener = null; + + @Override + public void registerHostNaviListener( IMogoNaviListener listener ) { + mDelegateListener = listener; + } + + @Override + public void unregisterHostNaviListener() { + mDelegateListener = null; + } + + @Override + public synchronized void onInitNaviFailure() { + if ( mDelegateListener != null ) { + mDelegateListener.onInitNaviFailure(); + } + } + + @Override + public synchronized void onInitNaviSuccess() { + if ( mDelegateListener != null ) { + mDelegateListener.onInitNaviSuccess(); + } + } + + @Override + public synchronized void onNaviInfoUpdate( MogoNaviInfo naviinfo ) { + if ( mDelegateListener != null ) { + mDelegateListener.onNaviInfoUpdate( naviinfo ); + } + } + + @Override + public synchronized void onStartNavi() { + if ( mDelegateListener != null ) { + mDelegateListener.onStartNavi(); + } + } + + @Override + public synchronized void onStopNavi() { + if ( mDelegateListener != null ) { + mDelegateListener.onStopNavi(); + } + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java similarity index 90% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java index 94d7533dfb..1517e517f6 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java @@ -1,5 +1,6 @@ package com.mogo.map.search.geo; +import com.mogo.map.IDestroyable; import com.mogo.map.exception.MogoMapException; import com.mogo.map.search.geo.query.MogoGeocodeQuery; import com.mogo.map.search.geo.query.MogoRegeocodeQuery; @@ -12,7 +13,7 @@ import java.util.List; *
* 地理/逆地理位置搜索 */ -public interface IMogoGeoSearch { +public interface IMogoGeoSearch extends IDestroyable { /** * 添加异步编码回调 @@ -28,6 +29,7 @@ public interface IMogoGeoSearch { * @return * @throws MogoMapException */ + @Deprecated MogoRegeocodeAddress getFromLocation( MogoRegeocodeQuery query ) throws MogoMapException; /** @@ -37,6 +39,7 @@ public interface IMogoGeoSearch { * @return * @throws MogoMapException */ + @Deprecated List< MogoGeocodeAddress > getFromLocationName( MogoGeocodeQuery query ) throws MogoMapException; /** diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java similarity index 79% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java index a4145d5d90..29a0f6cb0a 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java @@ -12,15 +12,13 @@ public interface IMogoGeoSearchListener { * 逆地理编码(根据经纬度获取地理位置信息) * * @param regeocodeResult - * @param rCode */ - void onRegeocodeSearched( MogoRegeocodeResult regeocodeResult, int rCode ); + void onRegeocodeSearched( MogoRegeocodeResult regeocodeResult ); /** * 根据名称和城市获取地理位置信息 * * @param geocodeResult - * @param i */ - void onGeocodeSearched( MogoGeocodeResult geocodeResult, int i ); + void onGeocodeSearched( MogoGeocodeResult geocodeResult ); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPhoto.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPhoto.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPhoto.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPhoto.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java similarity index 93% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java index bb4e05a725..ea5bf42895 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java @@ -14,7 +14,7 @@ import com.mogo.map.MogoLatLng; public class MogoRegeocodeQuery implements Parcelable { private MogoLatLng point; - private float radius; + private int radius; private String latlngType; private String poiType; @@ -26,11 +26,11 @@ public class MogoRegeocodeQuery implements Parcelable { this.point = point; } - public float getRadius() { + public int getRadius() { return radius; } - public void setRadius( float radius ) { + public void setRadius( int radius ) { this.radius = radius; } @@ -69,7 +69,7 @@ public class MogoRegeocodeQuery implements Parcelable { protected MogoRegeocodeQuery( Parcel in ) { this.point = in.readParcelable( MogoLatLng.class.getClassLoader() ); - this.radius = in.readFloat(); + this.radius = in.readInt(); this.latlngType = in.readString(); this.poiType = in.readString(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java similarity index 74% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java index 5386d843a3..76dffd78bd 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java @@ -10,5 +10,5 @@ import java.util.List; */ public interface IMogoInputtipsListener { - void onGetInputtips( List< MogoTip > result, int code ); + void onGetInputtips( List< MogoTip > result ); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java similarity index 79% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java index 9bde874135..29ac55bd09 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java @@ -1,5 +1,6 @@ package com.mogo.map.search.inputtips; +import com.mogo.map.IDestroyable; import com.mogo.map.exception.MogoMapException; import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; @@ -11,14 +12,12 @@ import java.util.List; *
* 描述 */ -public interface IMogoInputtipsSearch { +public interface IMogoInputtipsSearch extends IDestroyable { void setQuery( MogoInputtipsQuery query ); void setInputtipsListener( IMogoInputtipsListener listener ); void requestInputtipsAsyn(); - - List< MogoTip > requestInputtips() throws MogoMapException; } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoTip.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/MogoTip.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoTip.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/MogoTip.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java similarity index 92% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java index 6f5e8ac2a8..e291931fb5 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java @@ -1,5 +1,6 @@ package com.mogo.map.search.poisearch; +import com.mogo.map.IDestroyable; import com.mogo.map.exception.MogoMapException; import com.mogo.map.search.geo.MogoPoiItem; import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; @@ -10,7 +11,7 @@ import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; *
* poi 搜索 */ -public interface IMogoPoiSearch { +public interface IMogoPoiSearch extends IDestroyable { void setPoiSearchListener( IMogoPoiSearchListener listener ); diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java similarity index 100% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java rename to libraries/mogo-map-api/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/EnumMapUI.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/EnumMapUI.java new file mode 100644 index 0000000000..923dbc64ad --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/EnumMapUI.java @@ -0,0 +1,56 @@ +package com.mogo.map.uicontroller; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 地图样式 + */ +public enum EnumMapUI { + + /** + * 正北朝上2D + */ + NorthUP_2D( 0, 1 ), + /** + * 车头朝上2D + */ + CarUp_2D( 1, 2 ), + + /** + * 3D,只能头朝上 + */ + CarUp_3D( 2, 0 ), + + /** + * 白天模式 + */ + Type_Light( 3, 4 ), + + /** + * 夜晚模式 + */ + Type_Night( 4, 3 ), + + /** + * 导航模式 + */ + Type_Navi( 5, 5 ); + + private int next; + private int code; + + EnumMapUI( int code, int next ) { + this.code = code; + this.next = next; + } + + public EnumMapUI next() { + for ( EnumMapUI value : EnumMapUI.values() ) { + if ( value.code == next ) { + return value; + } + } + return this; + } +} diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java new file mode 100644 index 0000000000..f9b5c35bd8 --- /dev/null +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -0,0 +1,53 @@ +package com.mogo.map.uicontroller; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 地图UI控制
+ */
+public interface IMogoMapUIController {
+
+ /**
+ * 实时路况
+ *
+ * @param visible
+ */
+ void setTrafficEnabled( boolean visible );
+
+ /**
+ * 地图缩放
+ *
+ * @param zoomIn true - 方法 false - 缩小
+ */
+ void changeZoom( boolean zoomIn );
+
+ /**
+ * 切换2D/3D模式
+ *
+ * @param mode true - 3D模式 false - 2D模式
+ */
+ void changeMapMode( EnumMapUI mode );
+
+ /**
+ * 将地图移动至当前位置
+ */
+ void moveToCurrentLocation();
+
+ /**
+ * 显示我的位置
+ *
+ * @param visible true - 显示 false - 不显示
+ */
+ void showMyLocation( boolean visible );
+
+ /**
+ * 解锁锁车
+ */
+ void recoverLockMode();
+
+ /**
+ * 预览全程
+ */
+ void displayOverview();
+}
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_current_location_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_current_location_bkg.png
new file mode 100755
index 0000000000..ae6a30532c
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_current_location_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_exit_navi_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_exit_navi_bkg.png
new file mode 100755
index 0000000000..3f2cde9f94
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_exit_navi_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_search_bar_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_search_bar_bkg.png
new file mode 100755
index 0000000000..ea21518567
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_app_main_search_bar_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_navi_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_navi_cursor.png
new file mode 100755
index 0000000000..1f731b0db3
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_amap_navi_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back.png
new file mode 100755
index 0000000000..4b51fc8060
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back_dark.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back_dark.png
new file mode 100755
index 0000000000..bad7f51e3d
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_back_dark.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location.png
new file mode 100755
index 0000000000..2d5ff8d4c9
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location_cursor.png
new file mode 100755
index 0000000000..3f08bc021f
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_current_location_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_delete.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_delete.png
new file mode 100755
index 0000000000..c9b34a4fe6
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_delete.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_main_setting.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_main_setting.png
new file mode 100755
index 0000000000..472d9b702e
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_main_setting.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_navi_info_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_navi_info_bkg.png
new file mode 100755
index 0000000000..d20b9596bc
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_navi_info_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search.png
new file mode 100755
index 0000000000..4d668580a3
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_choice_point.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_choice_point.png
new file mode 100755
index 0000000000..8ca4538285
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_choice_point.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_company.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_company.png
new file mode 100755
index 0000000000..9697f060f0
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_company.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_home.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_home.png
new file mode 100755
index 0000000000..3452e4e433
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_home.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_poi_location.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_poi_location.png
new file mode 100755
index 0000000000..25940d02c6
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_poi_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_unshadow.png b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_unshadow.png
new file mode 100755
index 0000000000..7e8bf2b9c5
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-hdpi/ic_search_unshadow.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_current_location_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_current_location_bkg.png
new file mode 100755
index 0000000000..6ae8cdd6df
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_current_location_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_exit_navi_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_exit_navi_bkg.png
new file mode 100755
index 0000000000..a26b1c41c3
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_exit_navi_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_search_bar_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_search_bar_bkg.png
new file mode 100755
index 0000000000..6cb2857bbe
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_app_main_search_bar_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_navi_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_navi_cursor.png
new file mode 100755
index 0000000000..d9056dc066
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_amap_navi_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back.png
new file mode 100755
index 0000000000..9d4ad53f3b
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back_dark.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back_dark.png
new file mode 100755
index 0000000000..5a6b9d916f
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_back_dark.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location.png
new file mode 100755
index 0000000000..1b08cc5f53
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location_cursor.png
new file mode 100755
index 0000000000..732e2f228b
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_current_location_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_delete.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_delete.png
new file mode 100755
index 0000000000..6cbe4afd03
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_delete.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_main_setting.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_main_setting.png
new file mode 100755
index 0000000000..4122417b9d
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_main_setting.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_navi_info_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_navi_info_bkg.png
new file mode 100755
index 0000000000..0f86d86a29
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_navi_info_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search.png
new file mode 100755
index 0000000000..a94be88d18
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_choice_point.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_choice_point.png
new file mode 100755
index 0000000000..13ea311e83
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_choice_point.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_company.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_company.png
new file mode 100755
index 0000000000..2c2e86d0a8
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_company.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_home.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_home.png
new file mode 100755
index 0000000000..0b18677f59
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_home.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_poi_location.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_poi_location.png
new file mode 100755
index 0000000000..4dd0495294
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_poi_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_unshadow.png b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_unshadow.png
new file mode 100755
index 0000000000..cd32e7f85f
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-mdpi/ic_search_unshadow.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_current_location_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_current_location_bkg.png
new file mode 100755
index 0000000000..d1f7d180b7
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_current_location_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_exit_navi_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_exit_navi_bkg.png
new file mode 100755
index 0000000000..41abd4899d
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_exit_navi_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_search_bar_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_search_bar_bkg.png
new file mode 100755
index 0000000000..631b8f799c
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_app_main_search_bar_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_navi_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_navi_cursor.png
new file mode 100755
index 0000000000..e14034ffe4
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_amap_navi_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back.png
new file mode 100755
index 0000000000..c77c7bc701
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back_dark.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back_dark.png
new file mode 100755
index 0000000000..f2e0599f2a
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_back_dark.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location.png
new file mode 100755
index 0000000000..cef9326010
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location_cursor.png
new file mode 100755
index 0000000000..cebdc6a37a
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_current_location_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_delete.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_delete.png
new file mode 100755
index 0000000000..3b6a6f6aff
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_delete.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_main_setting.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_main_setting.png
new file mode 100755
index 0000000000..37caaba37c
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_main_setting.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_navi_info_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_navi_info_bkg.png
new file mode 100755
index 0000000000..eec694492e
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_navi_info_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search.png
new file mode 100755
index 0000000000..38cd883c1d
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_choice_point.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_choice_point.png
new file mode 100755
index 0000000000..9f75ac8e88
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_choice_point.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_company.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_company.png
new file mode 100755
index 0000000000..c460e09b11
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_company.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_home.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_home.png
new file mode 100755
index 0000000000..cfc9516ad7
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_home.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_poi_location.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_poi_location.png
new file mode 100755
index 0000000000..484f80efd5
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_poi_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_unshadow.png b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_unshadow.png
new file mode 100755
index 0000000000..cc0965e58b
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xhdpi/ic_search_unshadow.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_current_location_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_current_location_bkg.png
new file mode 100755
index 0000000000..1bedf36034
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_current_location_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_exit_navi_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_exit_navi_bkg.png
new file mode 100755
index 0000000000..729d5bd115
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_exit_navi_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_search_bar_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_search_bar_bkg.png
new file mode 100755
index 0000000000..88c1aba933
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_app_main_search_bar_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_navi_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_navi_cursor.png
new file mode 100755
index 0000000000..29446b440e
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_amap_navi_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back.png
new file mode 100755
index 0000000000..8b71d64823
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back_dark.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back_dark.png
new file mode 100755
index 0000000000..d7fb53b07e
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_back_dark.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_current_location.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_current_location.png
new file mode 100755
index 0000000000..394816a629
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_current_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_delete.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_delete.png
new file mode 100755
index 0000000000..b2be7d69e8
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_delete.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_main_setting.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_main_setting.png
new file mode 100755
index 0000000000..c45cca1001
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_main_setting.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_mini_current_position_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_mini_current_position_cursor.png
new file mode 100755
index 0000000000..54d30f28d7
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_mini_current_position_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_navi_info_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_navi_info_bkg.png
new file mode 100755
index 0000000000..df753302d6
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_navi_info_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search.png
new file mode 100755
index 0000000000..d1e92f18ff
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_choice_point.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_choice_point.png
new file mode 100755
index 0000000000..f1fdb8f94d
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_choice_point.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_company.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_company.png
new file mode 100755
index 0000000000..79c58e30dc
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_company.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_home.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_home.png
new file mode 100755
index 0000000000..499db278e1
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_home.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_poi_location.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_poi_location.png
new file mode 100755
index 0000000000..3b9b833dc3
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_poi_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_unshadow.png b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_unshadow.png
new file mode 100755
index 0000000000..83321b0852
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxhdpi/ic_search_unshadow.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_current_location_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_current_location_bkg.png
new file mode 100755
index 0000000000..f497b06bfb
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_current_location_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_exit_navi_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_exit_navi_bkg.png
new file mode 100755
index 0000000000..9c793553d4
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_exit_navi_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_search_bar_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_search_bar_bkg.png
new file mode 100755
index 0000000000..ab8f0dd66a
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_app_main_search_bar_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_navi_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_navi_cursor.png
new file mode 100755
index 0000000000..fd5a4f97a8
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_amap_navi_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back.png
new file mode 100755
index 0000000000..355b270598
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back_dark.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back_dark.png
new file mode 100755
index 0000000000..26e63062ee
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_back_dark.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location.png
new file mode 100755
index 0000000000..b57ab6d37f
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location_cursor.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location_cursor.png
new file mode 100755
index 0000000000..52fbfe85e6
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_current_location_cursor.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_delete.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_delete.png
new file mode 100755
index 0000000000..b11c525539
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_delete.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_main_setting.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_main_setting.png
new file mode 100755
index 0000000000..24efb3c610
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_main_setting.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_navi_info_bkg.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_navi_info_bkg.png
new file mode 100755
index 0000000000..fa9d08d9eb
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_navi_info_bkg.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search.png
new file mode 100755
index 0000000000..1f3eb227da
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_choice_point.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_choice_point.png
new file mode 100755
index 0000000000..17c80dd1c7
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_choice_point.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_company.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_company.png
new file mode 100755
index 0000000000..f6185feccf
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_company.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_home.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_home.png
new file mode 100755
index 0000000000..1e3cfbec83
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_home.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_poi_location.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_poi_location.png
new file mode 100755
index 0000000000..dc98953d56
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_poi_location.png differ
diff --git a/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_unshadow.png b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_unshadow.png
new file mode 100755
index 0000000000..bb04d0dfbd
Binary files /dev/null and b/libraries/mogo-map-api/src/main/res/drawable-xxxhdpi/ic_search_unshadow.png differ
diff --git a/libraries/mogo-map-api/src/main/res/values/strings.xml b/libraries/mogo-map-api/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..95cfda1d0d
--- /dev/null
+++ b/libraries/mogo-map-api/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ * 描述 + */ +public class MogoInitor { + + public static void init( Context context ) { + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoInputtipsSearch.java similarity index 76% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java rename to libraries/mogo-map/src/main/java/com/mogo/map/MogoInputtipsSearch.java index e13e2d06d0..5c16622307 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoInputtipsSearch.java @@ -1,13 +1,12 @@ -package com.mogo.map.search.inputtips; +package com.mogo.map; import android.content.Context; -import com.mogo.map.amap.search.InputtipsSearch; -import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.amap.search.InputtipsSearch; +import com.mogo.map.search.inputtips.IMogoInputtipsListener; +import com.mogo.map.search.inputtips.IMogoInputtipsSearch; import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; -import java.util.List; - /** * @author congtaowang * @since 2019-12-20 @@ -44,10 +43,10 @@ public class MogoInputtipsSearch implements IMogoInputtipsSearch { } @Override - public List< MogoTip > requestInputtips() throws MogoMapException { + public void destroy() { if ( mDelegate != null ) { - return mDelegate.requestInputtips(); + mDelegate.destroy(); } - return null; + mDelegate = null; } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/MogoLocationClient.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java similarity index 77% rename from libraries/mogo-map/src/main/java/com/mogo/map/location/MogoLocationClient.java rename to libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java index 181444ada4..e1d7c6ebdc 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/location/MogoLocationClient.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoLocationClient.java @@ -1,8 +1,11 @@ -package com.mogo.map.location; +package com.mogo.map; import android.content.Context; -import com.mogo.map.amap.location.LocationClient; +import com.mogo.map.impl.amap.location.ALocationClient; +import com.mogo.map.location.IMogoLocationListener; +import com.mogo.map.location.IMogoLocationClient; +import com.mogo.map.location.MogoLocation; /** * @author congtaowang @@ -14,7 +17,7 @@ public class MogoLocationClient implements IMogoLocationClient { private static volatile MogoLocationClient sInstance; private MogoLocationClient( Context context ) { - mDelegate = LocationClient.getInstance( context ); + mDelegate = ALocationClient.getInstance( context ); } public static MogoLocationClient getInstance( Context context ) { @@ -52,14 +55,14 @@ public class MogoLocationClient implements IMogoLocationClient { } @Override - public void addLocationListener( ILocationListener listener ) { + public void addLocationListener( IMogoLocationListener listener ) { if ( mDelegate != null ) { mDelegate.addLocationListener( listener ); } } @Override - public void removeLocationListener( ILocationListener listener ) { + public void removeLocationListener( IMogoLocationListener listener ) { if ( mDelegate != null ) { mDelegate.removeLocationListener( listener ); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java new file mode 100644 index 0000000000..6e1ebfd46b --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -0,0 +1,86 @@ +package com.mogo.map; + +import com.mogo.map.impl.amap.uicontroller.AMapUIController; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.map.uicontroller.IMogoMapUIController; + +/** + * @author congtaowang + * @since 2019-12-26 + *
+ * 描述 + */ +public class MogoMapUIController implements IMogoMapUIController { + + private IMogoMapUIController mDelegate; + + private static volatile MogoMapUIController sInstance; + + private MogoMapUIController() { + mDelegate = AMapUIController.getInstance(); + } + + public static MogoMapUIController getInstance() { + if ( sInstance == null ) { + synchronized ( MogoMapUIController.class ) { + if ( sInstance == null ) { + sInstance = new MogoMapUIController(); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public void setTrafficEnabled( boolean visible ) { + if ( mDelegate != null ) { + mDelegate.setTrafficEnabled( visible ); + } + } + + @Override + public void changeZoom( boolean zoom ) { + if ( mDelegate != null ) { + mDelegate.changeZoom( zoom ); + } + } + + @Override + public void changeMapMode( EnumMapUI mode ) { + if ( mDelegate != null ) { + mDelegate.changeMapMode( mode ); + } + } + + @Override + public void moveToCurrentLocation() { + if ( mDelegate != null ) { + mDelegate.moveToCurrentLocation(); + } + } + + @Override + public void showMyLocation( boolean visible ) { + if ( mDelegate != null ) { + mDelegate.showMyLocation( visible ); + } + } + + @Override + public void recoverLockMode() { + if ( mDelegate != null ) { + mDelegate.recoverLockMode(); + } + } + + @Override + public void displayOverview() { + if ( mDelegate != null ) { + mDelegate.displayOverview(); + } + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java index 342d9d2a83..b82c0ff50a 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapView.java @@ -1,12 +1,13 @@ package com.mogo.map; import android.content.Context; +import android.os.Bundle; import android.util.AttributeSet; import androidx.annotation.Nullable; -import com.amap.api.navi.AMapNaviView; -import com.mogo.map.amap.AMapNaviViewWrapper; +import com.mogo.map.impl.amap.AMapBaseMapView; + /** * @author congtaowang @@ -14,7 +15,7 @@ import com.mogo.map.amap.AMapNaviViewWrapper; *
* 地图实例 */ -public class MogoMapView extends MogoBaseMapView { +public class MogoMapView extends AMapBaseMapView implements ILifeCycle { public MogoMapView( Context context ) { super( context ); @@ -29,7 +30,42 @@ public class MogoMapView extends MogoBaseMapView { } @Override - protected IMogoMapView createMapView( Context context ) { - return new AMapNaviViewWrapper( new AMapNaviView( context ) ); + public IMogoMap getMap() { + return super.getMap(); + } + + @Override + public void onCreate( Bundle bundle ) { + super.onCreate( bundle ); + } + + @Override + public void onResume() { + super.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + public void onSaveInstanceState( Bundle outState ) { + super.onSaveInstanceState( outState ); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + } + + @Override + public IMogoMapView getMapView() { + return super.getMapView(); } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java new file mode 100644 index 0000000000..4fb3250a6b --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java @@ -0,0 +1,75 @@ +package com.mogo.map; + +import android.content.Context; + +import com.mogo.map.impl.amap.InterceptorHandler; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerManager; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.marker.MogoMarkersHandler; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-20 + *
+ * marker 管理实现 + */ +public class MogoMarkerManager implements IMogoMarkerManager { + + private static volatile MogoMarkerManager sInstance; + private Context mApplicationContext; + + private MogoMarkerManager( Context context ) { + if ( context != null ) { + mApplicationContext = context.getApplicationContext(); + } + } + + public static MogoMarkerManager getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( MogoMarkerManager.class ) { + if ( sInstance == null ) { + sInstance = new MogoMarkerManager( context ); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) { + try { + return MogoMap.getInstance().getMogoMap().addMarker( tag, options ); + } catch ( Exception e ) { + return null; + } + } + + @Override + public List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) { + try { + return MogoMap.getInstance().getMogoMap().addMarkers( tag, options, moveToCenter ); + } catch ( Exception e ) { + return null; + } + } + + + @Override + public void removeMarkers( String tag ) { + MogoMarkersHandler.getInstance().remove( tag ); + } + + @Override + public void removeMarkers() { + MogoMarkersHandler.getInstance().removeAll(); + } + +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java new file mode 100644 index 0000000000..311e120f77 --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoNavi.java @@ -0,0 +1,98 @@ +package com.mogo.map; + +import android.content.Context; + +import com.mogo.map.impl.amap.navi.NaviClient; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoNaviConfig; + +import java.util.List; + +/** + * @author congtaowang + * @since 2019-12-25 + *
+ * 导航代理 + */ +public class MogoNavi implements IMogoNavi { + + private IMogoNavi mDelegate; + + private static volatile MogoNavi sInstance; + + private MogoNavi( Context context ) { + mDelegate = NaviClient.getInstance( context ); + } + + public static MogoNavi getInstance( Context context ) { + if ( sInstance == null ) { + synchronized ( MogoNavi.class ) { + if ( sInstance == null ) { + sInstance = new MogoNavi( context ); + } + } + } + return sInstance; + } + + public synchronized void release() { + sInstance = null; + } + + @Override + public void naviTo( MogoLatLng endPoint ) { + if ( mDelegate != null ) { + mDelegate.naviTo( endPoint ); + } + } + + @Override + public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) { + if ( mDelegate != null ) { + mDelegate.naviTo( endPoint, config ); + } + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) { + if ( mDelegate != null ) { + mDelegate.naviTo( endPoint, wayPoints ); + } + } + + @Override + public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) { + if ( mDelegate != null ) { + mDelegate.naviTo( endPoint, wayPoints, config ); + } + } + + @Override + public void reCalculateRoute( MogoNaviConfig config ) { + if ( mDelegate != null ) { + mDelegate.reCalculateRoute( config ); + } + } + + @Override + public void stopNavi() { + if ( mDelegate != null ) { + mDelegate.stopNavi(); + } + } + + @Override + public void startNavi() { + if ( mDelegate != null ) { + mDelegate.startNavi(); + } + } + + @Override + public boolean isNaviing() { + if ( mDelegate != null ) { + return mDelegate.isNaviing(); + } + return false; + } +} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoPoiSearch.java similarity index 79% rename from libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java rename to libraries/mogo-map/src/main/java/com/mogo/map/MogoPoiSearch.java index 564c775d5f..c40e73de9f 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoPoiSearch.java @@ -1,10 +1,14 @@ -package com.mogo.map.search.poisearch; +package com.mogo.map; import android.content.Context; -import com.mogo.map.amap.search.PoiSearchClient; import com.mogo.map.exception.MogoMapException; +import com.mogo.map.impl.amap.search.PoiSearchClient; import com.mogo.map.search.geo.MogoPoiItem; +import com.mogo.map.search.poisearch.IMogoPoiSearch; +import com.mogo.map.search.poisearch.IMogoPoiSearchListener; +import com.mogo.map.search.poisearch.MogoPoiResult; +import com.mogo.map.search.poisearch.MogoSearchBound; import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; /** @@ -71,4 +75,12 @@ public class MogoPoiSearch implements IMogoPoiSearch { mDelegate.setBound( bound ); } } + + @Override + public void destroy() { + if ( mDelegate != null ) { + mDelegate.destroy(); + } + mDelegate = null; + } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java deleted file mode 100644 index 8c6bb1bb3f..0000000000 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.mogo.map.amap; - -import android.os.Bundle; -import android.view.MotionEvent; -import android.view.View; - -import com.amap.api.maps.AMap; -import com.amap.api.maps.model.Marker; -import com.amap.api.maps.model.Poi; -import com.amap.api.navi.AMapNaviView; -import com.mogo.map.IMogoMap; -import com.mogo.map.IMogoMapView; -import com.mogo.map.amap.utils.ObjectUtils; -import com.mogo.map.listener.MogoMapListenerHandler; -import com.mogo.map.marker.IMogoMarker; -import com.mogo.map.marker.IMogoMarkerClickListener; - -/** - * @author congtaowang - * @since 2019-12-18 - *
- * 代理高德导航地图 - */ -public class AMapNaviViewWrapper implements IMogoMapView, - AMap.OnMarkerClickListener, - AMap.OnMapLoadedListener, - AMap.OnMapTouchListener, - AMap.OnPOIClickListener { - - private final AMapNaviView mMapView; - private IMogoMap mIMap; - - private AMapMarkerClickHandler mMarkerClickHandler; - - public AMapNaviViewWrapper( AMapNaviView mapView ) { - this.mMapView = mapView; - mMapView.setOnMarkerClickListener( this ); - mMarkerClickHandler = new AMapMarkerClickHandler(); - mMapView.setOnMapLoadedListener( this ); - mMapView.setOnMapTouchListener( this ); - if ( mMapView.getMap() != null ) { - mMapView.getMap().setOnPOIClickListener( this ); - } - } - - @Override - public View getMapView() { - return mMapView; - } - - @Override - public IMogoMap getMap() { - if ( mMapView != null ) { - if ( mIMap == null ) { - mIMap = new AMapWrapper( mMapView.getMap() ); - } - } - return mIMap; - } - - @Override - public void onCreate( Bundle bundle ) { - if ( mMapView != null ) { - mMapView.onCreate( bundle ); - } - } - - @Override - public void onResume() { - if ( mMapView != null ) { - mMapView.onResume(); - } - } - - @Override - public void onPause() { - if ( mMapView != null ) { - mMapView.onPause(); - } - } - - @Override - public void onDestroy() { - if ( mMapView != null ) { - mMapView.onDestroy(); - } - } - - @Override - public void onSaveInstanceState( Bundle outState ) { - if ( mMapView != null ) { - mMapView.onSaveInstanceState( outState ); - } - } - - @Override - public void onLowMemory() { - } - - - /** - * 地图marker点击 - * - * @param marker - * @return - */ - @Override - public boolean onMarkerClick( Marker marker ) { - return mMarkerClickHandler.handleMarkerClicked( marker ); - } - - /** - * 地图加载完毕 - */ - @Override - public void onMapLoaded() { - MogoMapListenerHandler.getInstance().onMapLoaded(); - } - - /** - * 地图点击回调 - * - * @param motionEvent - */ - @Override - public void onTouch( MotionEvent motionEvent ) { - MogoMapListenerHandler.getInstance().onTouch( motionEvent ); - } - - /** - * POI 点击 - * - * @param poi - */ - @Override - public void onPOIClick( Poi poi ) { - MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) ); - } -} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java deleted file mode 100644 index 6c4173b521..0000000000 --- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.mogo.map.amap; - -import com.amap.api.maps.AMap; -import com.amap.api.maps.model.Marker; -import com.amap.api.maps.model.MarkerOptions; -import com.mogo.map.IMogoMap; -import com.mogo.map.IUiSettings; -import com.mogo.map.amap.marker.AMapInfoWindowAdapter; -import com.mogo.map.amap.marker.AMapMarkerWrapper; -import com.mogo.map.amap.utils.ObjectUtils; -import com.mogo.map.marker.IMogoMarker; -import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.map.marker.MogoMarkersHandler; - -import java.util.ArrayList; - -/** - * @author congtaowang - * @since 2019-12-18 - *
- * 代理高德AMap - */ -public class AMapWrapper implements IMogoMap { - - private AMap mAMap; - private IUiSettings mUiSettings; - - public AMapWrapper( AMap map ) { - this.mAMap = map; - // 设置实现自定义 info window - mAMap.setInfoWindowAdapter( new AMapInfoWindowAdapter() ); - } - - @Override - public IUiSettings getUiSettings() { - if ( mUiSettings == null ) { - mUiSettings = new AMapUiSettingsWrapper( mAMap.getUiSettings() ); - } - return mUiSettings; - } - - @Override - public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) { - if ( mAMap == null ) { - return null; - } - MarkerOptions markerOptions = ObjectUtils.fromMogo( options ); - if ( markerOptions == null ) { - return null; - } - final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ) ); - MogoMarkersHandler.getInstance().add( tag, mogoMarker ); - return mogoMarker; - } - - @Override - public ArrayList< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) { - if ( mAMap == null ) { - return null; - } - - if ( options == null || options.isEmpty() ) { - return null; - } - - ArrayList< Marker > markers = null; - ArrayList< MarkerOptions > markerOptions = new ArrayList<>(); - ArrayList< IMogoMarker > mogoMarkers = new ArrayList<>(); - - for ( MogoMarkerOptions option : options ) { - if ( option == null ) { - continue; - } - MarkerOptions mo = ObjectUtils.fromMogo( option ); - if ( mo == null ) { - continue; - } - markerOptions.add( mo ); - } - if ( markerOptions.isEmpty() ) { - return null; - } - markers = mAMap.addMarkers( markerOptions, moveToCenter ); - if ( markers == null || markers.isEmpty() ) { - return null; - } - for ( Marker marker : markers ) { - if ( marker == null ) { - continue; - } - mogoMarkers.add( new AMapMarkerWrapper( marker ) ); - } - MogoMarkersHandler.getInstance().add( tag, mogoMarkers ); - return mogoMarkers; - } - - @Override - public void clear() { - if ( mAMap != null ) { - mAMap.clear(); - } - } - - @Override - public void clear( boolean isKeepMyLocationOverlay ) { - if ( mAMap != null ) { - mAMap.clear( isKeepMyLocationOverlay ); - } - } - - @Override - public void setPointToCenter( int x, int y ) { - if ( mAMap != null ) { - mAMap.setPointToCenter( x, y ); - } - } - - @Override - public void setTouchPoiEnable( boolean touchPoiEnable ) { - if ( mAMap != null ) { - mAMap.setTouchPoiEnable( touchPoiEnable ); - } - } - - @Override - public void setTrafficEnable( boolean enable ) { - if ( mAMap != null ) { - mAMap.setTrafficEnabled( enable ); - } - } - - @Override - public void showBuildings( boolean enabled ) { - if ( mAMap != null ) { - mAMap.showBuildings( enabled ); - } - } - - @Override - public void showIndoorMap( boolean enable ) { - if ( mAMap != null ) { - mAMap.showIndoorMap( enable ); - } - } - - @Override - public void showMapText( boolean enable ) { - if ( mAMap != null ) { - mAMap.showMapText( enable ); - } - } - - @Override - public void stopAnimation() { - if ( mAMap != null ) { - mAMap.stopAnimation(); - } - } -} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarker.java b/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarker.java deleted file mode 100644 index 978642da00..0000000000 --- a/libraries/mogo-map/src/main/java/com/mogo/map/marker/MogoMarker.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mogo.map.marker; - -/** - * @author congtaowang - * @since 2019-12-20 - *
- * 描述 - */ -public class MogoMarker { -} diff --git a/modules/mogo-module-main/src/main/AndroidManifest.xml b/modules/mogo-module-main/src/main/AndroidManifest.xml index ffaf640efe..a793893503 100644 --- a/modules/mogo-module-main/src/main/AndroidManifest.xml +++ b/modules/mogo-module-main/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:launchMode="singleInstance" android:resizeableActivity="true" android:resumeWhilePausing="true" - android:screenOrientation="nosensor" + android:screenOrientation="landscape" android:stateNotNeeded="true" android:taskAffinity="" android:windowSoftInputMode="adjustPan"> diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java index 5a3fa11bb6..d23e3410f1 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java @@ -1,14 +1,10 @@ package com.mogo.module.main; -import android.view.MotionEvent; - import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.launcher.ARouter; import com.mogo.commons.mvp.MvpActivity; -import com.mogo.map.listener.IMogoMapListener; -import com.mogo.map.model.MogoPoi; import com.mogo.module.main.cards.MogoModulesHandler; import com.mogo.module.main.cards.MogoModulesManager; import com.mogo.service.MogoServicePaths; @@ -25,8 +21,8 @@ import java.util.Collection; */ public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView { - IMogoMapService ims; - MogoModulesHandler handler; + IMogoMapService mMogoMapService; + MogoModulesHandler mMogoModuleHandler; @Override protected int getLayoutId() { @@ -36,14 +32,15 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme @Override protected void initViews() { - handler = new MogoModulesManager( this ); - ims = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation(); - if ( ims != null ) { - ims.registerHostMapListener( handler ); + mMogoModuleHandler = new MogoModulesManager( this ); + mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation(); + if ( mMogoMapService != null ) { + mMogoMapService.registerHostMapListener( mMogoModuleHandler ); + mMogoMapService.registerHostNaviListener( mMogoModuleHandler ); } - handler.loadMap( R.id.module_main_id_fragment_container ); + mMogoModuleHandler.loadMap( R.id.module_main_id_map_container ); - Collection< IMogoModuleProvider > providers = handler.loadCards(); + Collection< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards(); for ( IMogoModuleProvider provider : providers ) { if ( provider == null ) { continue; @@ -57,7 +54,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme } } } - handler.setEnable( providers.iterator().next().getModuleName() ); + mMogoModuleHandler.setEnable( providers.iterator().next().getModuleName() ); } @NonNull diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java index f8a6de5414..75b3a462a9 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java @@ -1,6 +1,7 @@ package com.mogo.module.main.cards; import com.mogo.map.listener.IMogoMapListener; +import com.mogo.map.navi.IMogoNaviListener; import com.mogo.service.module.IMogoModuleProvider; import java.util.Collection; @@ -11,7 +12,7 @@ import java.util.Collection; *
* 卡片管理 */ -public interface MogoModulesHandler extends IMogoMapListener { +public interface MogoModulesHandler extends IMogoMapListener, IMogoNaviListener { /** * 加载卡片 diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java index 0b3d7a57e3..7ca2624f99 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java @@ -7,8 +7,12 @@ import android.view.MotionEvent; import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.map.MogoLatLng; import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.model.MogoPoi; +import com.mogo.map.navi.IMogoNaviListener; +import com.mogo.map.navi.MogoNaviInfo; +import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.module.common.MogoModulePaths; import com.mogo.module.main.MainActivity; import com.mogo.service.module.IMogoModuleProvider; @@ -26,7 +30,8 @@ import java.util.Set; *
* 卡片加载
*/
-public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener {
+public class MogoModulesManager implements MogoModulesHandler,
+ IMogoMapListener, IMogoNaviListener {
private static final String TAG = "MogoModulesManager";
@@ -67,6 +72,10 @@ public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener
}
+ private IMogoModuleProvider getModuleProvider( String tag ) {
+ return mCardProviders.get( tag );
+ }
+
@Override
public void loadMap( int containerId ) {
mMapProvider = load( MogoModulePaths.PATH_MODULE_MAP );
@@ -112,8 +121,9 @@ public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener
@Override
public void onMapLoaded() {
if ( mEnableModuleName != null ) {
- if ( mCardProviders.get( mEnableModuleName ) != null ) {
- mCardProviders.get( mEnableModuleName ).getMapListener().onMapLoaded();
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onMapLoaded();
}
}
}
@@ -121,8 +131,9 @@ public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener
@Override
public void onTouch( MotionEvent motionEvent ) {
if ( mEnableModuleName != null ) {
- if ( mCardProviders.get( mEnableModuleName ) != null ) {
- mCardProviders.get( mEnableModuleName ).getMapListener().onTouch( motionEvent );
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onTouch( motionEvent );
}
}
}
@@ -130,8 +141,91 @@ public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener
@Override
public void onPOIClick( MogoPoi poi ) {
if ( mEnableModuleName != null ) {
- if ( mCardProviders.get( mEnableModuleName ) != null ) {
- mCardProviders.get( mEnableModuleName ).getMapListener().onPOIClick( poi );
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onPOIClick( poi );
+ }
+ }
+ }
+
+ @Override
+ public void onMapClick( MogoLatLng latLng ) {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onMapClick( latLng );
+ }
+ }
+ }
+
+ @Override
+ public void onLockMap( boolean isLock ) {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onLockMap( isLock );
+ }
+ }
+ }
+
+ @Override
+ public void onMapModeChanged( EnumMapUI ui ) {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null ) {
+ provider.getMapListener().onMapModeChanged( ui );
+ }
+ }
+ }
+
+ @Override
+ public void onInitNaviFailure() {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null && provider.getNaviListener() != null ) {
+ provider.getNaviListener().onInitNaviFailure();
+ }
+ }
+ }
+
+ @Override
+ public void onInitNaviSuccess() {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null && provider.getNaviListener() != null ) {
+ provider.getNaviListener().onInitNaviSuccess();
+ }
+ }
+ }
+
+ @Override
+ public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null && provider.getNaviListener() != null ) {
+ provider.getNaviListener().onNaviInfoUpdate( naviinfo );
+ }
+ }
+ }
+
+ @Override
+ public void onStartNavi() {
+ Logger.i( TAG, "导航已开始" );
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null && provider.getNaviListener() != null ) {
+ provider.getNaviListener().onStartNavi();
+ }
+ }
+ }
+
+ @Override
+ public void onStopNavi() {
+ Logger.i( TAG, "导航已停止" );
+ if ( mEnableModuleName != null ) {
+ IMogoModuleProvider provider = getModuleProvider( mEnableModuleName );
+ if ( provider != null && provider.getNaviListener() != null ) {
+ provider.getNaviListener().onStopNavi();
}
}
}
diff --git a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
index f6668124ea..75738ffe4f 100644
--- a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
+++ b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
@@ -6,6 +6,15 @@
* 地图对外地接口 */ -public interface IMogoMapService extends IProvider, IMogoMapListenerRegister { +public interface IMogoMapService extends IProvider, IMogoMapListenerRegister, IMogoNaviListenerRegister { /** * 获取定位服务实例,全局唯一 @@ -34,24 +33,6 @@ public interface IMogoMapService extends IProvider, IMogoMapListenerRegister { */ IMogoLocationClient getSingletonLocationClient( Context context ); - /** - * 添加marker - * - * @param tag 标识调用者 - * @param options - * @return - */ - IMogoMarker addMarker( String tag, MogoMarkerOptions options ); - - /** - * 添加多个marker - * - * @param tag 标识调用者 - * @param options - * @return - */ - List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ); - /** * 获取关键字搜索地址服务 * @@ -70,17 +51,29 @@ public interface IMogoMapService extends IProvider, IMogoMapListenerRegister { IMogoGeoSearch getGeoSearch( Context context ); /** - * 注册地图事件 + * 注册地图事件,各业务模块不用关注 * * @param listener 回调事件 */ void registerHostMapListener( IMogoMapListener listener ); /** - * 反注册注册地图事件 + * 反注册注册地图事件,各业务模块不用关注 */ void unregisterHostMapListener(); + /** + * 注册导航回调,各业务模块不用关注 + * + * @param listener 回调函数 + */ + void registerHostNaviListener( IMogoNaviListener listener ); + + /** + * 注销导航回调,各业务模块不用关注 + */ + void unregisterHostNaviListener(); + /** * poi搜索服务 * @@ -91,14 +84,19 @@ public interface IMogoMapService extends IProvider, IMogoMapListenerRegister { IMogoPoiSearch getPoiSearch( Context context, MogoPoiSearchQuery query ); /** - * 移除某一个类、某个模块的markers + * 获取导航操作实例 * - * @param tag + * @param context + * @return */ - void removeMarkers( String tag ); + IMogoNavi getNavi( Context context ); /** - * 移除地图上所有markers + * marker 操作 + * + * @return */ - void removeMarkers(); + IMogoMarkerManager getMarkerManager(Context context); + + IMogoMapUIController getMapUIController(); } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java index f3157cb801..6587787850 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java @@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment; import com.alibaba.android.arouter.facade.template.IProvider; import com.mogo.map.listener.IMogoMapListener; +import com.mogo.map.navi.IMogoNaviListener; /** * @author congtaowang @@ -75,4 +76,11 @@ public interface IMogoModuleProvider extends IProvider { * @return */ int getType(); + + /** + * 导航监听 + * + * @return + */ + IMogoNaviListener getNaviListener(); } diff --git a/services/mogo-service/build.gradle b/services/mogo-service/build.gradle index 608da7776a..fe2fd5cbaa 100644 --- a/services/mogo-service/build.gradle +++ b/services/mogo-service/build.gradle @@ -40,7 +40,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(":libraries:mogo-map") + api project(":libraries:mogo-map") + implementation project(":libraries:mogo-map-api") implementation project(":foudations:mogo-utils") implementation project(":foudations:mogo-commons") implementation project(':services:mogo-service-api') diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java b/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java index 17113e8a7e..f189f3f55e 100644 --- a/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java +++ b/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java @@ -3,28 +3,29 @@ package com.mogo.service.impl.map; import android.content.Context; import com.alibaba.android.arouter.facade.annotation.Route; -import com.mogo.map.MogoMap; +import com.mogo.map.MogoGeoSearch; +import com.mogo.map.MogoInitor; +import com.mogo.map.MogoInputtipsSearch; +import com.mogo.map.MogoLocationClient; +import com.mogo.map.MogoMapUIController; +import com.mogo.map.MogoMarkerManager; +import com.mogo.map.MogoNavi; +import com.mogo.map.MogoPoiSearch; +import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.listener.MogoMapListenerHandler; import com.mogo.map.location.IMogoLocationClient; -import com.mogo.map.location.MogoLocationClient; -import com.mogo.map.marker.IMogoMarker; -import com.mogo.map.marker.MogoMarker; -import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.map.marker.MogoMarkersHandler; +import com.mogo.map.marker.IMogoMarkerManager; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.IMogoNaviListener; +import com.mogo.map.navi.MogoNaviListenerHandler; import com.mogo.map.search.geo.IMogoGeoSearch; import com.mogo.map.search.inputtips.IMogoInputtipsSearch; -import com.mogo.map.search.geo.MogoGeoSearch; -import com.mogo.map.search.inputtips.MogoInputtipsSearch; import com.mogo.map.search.inputtips.query.MogoInputtipsQuery; -import com.mogo.map.listener.IMogoMapListener; import com.mogo.map.search.poisearch.IMogoPoiSearch; -import com.mogo.map.search.poisearch.MogoPoiSearch; import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; -import com.mogo.service.map.IMogoMapService; +import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.service.MogoServicePaths; - -import java.util.ArrayList; -import java.util.List; +import com.mogo.service.map.IMogoMapService; /** * @author congtaowang @@ -40,24 +41,6 @@ public class MogoMapService implements IMogoMapService { return MogoLocationClient.getInstance( context ); } - @Override - public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) { - try { - return MogoMap.getInstance().getMogoMap().addMarker( tag, options ); - } catch ( Exception e ) { - return null; - } - } - - @Override - public List< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) { - try { - return MogoMap.getInstance().getMogoMap().addMarkers( tag, options, moveToCenter ); - } catch ( Exception e ) { - return null; - } - } - @Override public IMogoInputtipsSearch getInputtipsSearch( Context context, MogoInputtipsQuery query ) { return new MogoInputtipsSearch( context, query ); @@ -84,17 +67,32 @@ public class MogoMapService implements IMogoMapService { } @Override - public void removeMarkers( String tag ) { - MogoMarkersHandler.getInstance().remove( tag ); + public IMogoNavi getNavi( Context context ) { + return MogoNavi.getInstance( context ); } @Override - public void removeMarkers() { - MogoMarkersHandler.getInstance().removeAll(); + public IMogoMarkerManager getMarkerManager(Context context) { + return MogoMarkerManager.getInstance(context); + } + + @Override + public IMogoMapUIController getMapUIController() { + return MogoMapUIController.getInstance(); + } + + @Override + public void registerHostNaviListener( IMogoNaviListener listener ) { + MogoNaviListenerHandler.getInstance().registerHostNaviListener( listener ); + } + + @Override + public void unregisterHostNaviListener() { + MogoNaviListenerHandler.getInstance().unregisterHostNaviListener(); } @Override public void init( Context context ) { - + MogoInitor.init( context ); } } diff --git a/settings.gradle b/settings.gradle index 374dce85ee..a95ecf51ee 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,3 +9,6 @@ include ':modules:mogo-module-map' include ':modules:mogo-module-common' include ':modules:mogo-module-main' include ':demo:demo-module-map' +include ':libraries:map-amap' +//include ':libraries:map-baidu' +include ':libraries:mogo-map-api'