This commit is contained in:
wangcongtao
2020-10-25 15:51:28 +08:00
40 changed files with 946 additions and 92 deletions

View File

@@ -1,6 +1,7 @@
package com.mogo.map;
import android.content.Context;
import android.opengl.Visibility;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.impl.amap.location.ALocationClient;
@@ -33,8 +34,14 @@ class MogoMapDelegateFactory {
private static final String TAG = "MogoMapDelegateFactory";
private static boolean useCustom = false;
public static boolean isUseCustom() {
return useCustom;
}
public static IMogoGeoSearch getGeoSearchDelegate( Context context ) {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoGeoSearch" );
return new com.mogo.map.impl.custom.search.GeocodeSearchClient( context );
}
@@ -42,7 +49,7 @@ class MogoMapDelegateFactory {
}
public static IMogoInputtipsSearch getInputtipsSearchDelegate( Context context, MogoInputtipsQuery query ) {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoInputtipsSearch" );
return new com.mogo.map.impl.custom.search.InputtipsSearch( context, query );
}
@@ -50,7 +57,7 @@ class MogoMapDelegateFactory {
}
public static IMogoLocationClient getLocationClientDelegate( Context context ) {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoLocationClient" );
return new com.mogo.map.impl.custom.location.ALocationClient( context );
}
@@ -58,7 +65,7 @@ class MogoMapDelegateFactory {
}
public static IMogoMapUIController getMapUIControllerDelegate() {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoMapUIController" );
return com.mogo.map.impl.custom.uicontroller.AMapUIController.getInstance();
}
@@ -72,16 +79,16 @@ class MogoMapDelegateFactory {
} else if ( AppUtils.isAppInstalled( context, "com.autonavi.amapauto" ) ) {
return AutoNaviClient.getInstance( context );
} else {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoNavi" );
return com.mogo.map.impl.custom.navi.NaviClient.getInstance( context );
}
return NaviClient.getInstance( context );
}
return NaviClient.getInstance( context );
}
public static IMogoPoiSearch getPoiSearchClientDelegate( Context context, MogoPoiSearchQuery query ) {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoPoiSearch" );
return new com.mogo.map.impl.custom.search.PoiSearchClient( context, query );
}
@@ -89,7 +96,7 @@ class MogoMapDelegateFactory {
}
public static IMogoRoadSearch getRoadSearchDelegate() {
if ( DebugConfig.isUseCustomMap() ) {
if ( useCustom ) {
Logger.d( TAG, "use custom IMogoRoadSearch" );
return new com.mogo.map.impl.custom.search.RoadSearchClient();
}

View File

@@ -40,32 +40,35 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
@Override
protected void addDleMaps() {
mAMapView = new AMapBaseMapView().create( getContext() );
mCustomMapView = new CustomMapView().create( getContext() );
if ( mAMapView != null ) {
final View mapView = mAMapView.getMapView();
if ( mapView != null ) {
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
if ( !MogoMapDelegateFactory.isUseCustom() ) {
mAMapView = new AMapBaseMapView().create( getContext() );
if ( mAMapView != null ) {
final View mapView = mAMapView.getMapView();
if ( mapView != null ) {
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
} else {
Logger.e( TAG, "create MapView instance failed." );
}
} else {
Logger.e( TAG, "create MapView instance failed." );
Logger.e( TAG, "create IMogoMapView instance failed." );
}
mMapView = mAMapView;
} else {
Logger.e( TAG, "create IMogoMapView instance failed." );
mCustomMapView = new CustomMapView().create( getContext() );
if ( mCustomMapView != null ) {
final View mapView = mCustomMapView.getMapView();
if ( mapView != null ) {
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
} else {
Logger.e( TAG, "create MapView instance failed." );
}
} else {
Logger.e( TAG, "create IMogoMapView instance failed." );
}
mMapView = mCustomMapView;
}
// if ( mCustomMapView != null ) {
// final View mapView = mCustomMapView.getMapView();
// if ( mapView != null ) {
// addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
// } else {
// Logger.e( TAG, "create MapView instance failed." );
// }
// } else {
// Logger.e( TAG, "create IMogoMapView instance failed." );
// }
mMapView = mAMapView;
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
}