tiny commit (TBD)
This commit is contained in:
@ -13,6 +13,7 @@ import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.AMapOptions;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.flutter.map.core.MapController;
|
||||
import com.amap.flutter.map.core.MapsInitializerController;
|
||||
import com.amap.flutter.map.overlays.marker.MarkersController;
|
||||
import com.amap.flutter.map.overlays.polygon.PolygonsController;
|
||||
import com.amap.flutter.map.overlays.polyline.PolylinesController;
|
||||
@ -20,6 +21,7 @@ import com.amap.flutter.map.utils.LogUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
@ -43,6 +45,8 @@ public class AMapPlatformView
|
||||
private static final String CLASS_NAME = "AMapPlatformView";
|
||||
private final MethodChannel methodChannel;
|
||||
private final Map<String, MyMethodCallHandler> myMethodCallHandlerMap;
|
||||
|
||||
private MapsInitializerController mapsInitializerController;
|
||||
private MapController mapController;
|
||||
private MarkersController markersController;
|
||||
private PolylinesController polylinesController;
|
||||
@ -58,11 +62,12 @@ public class AMapPlatformView
|
||||
|
||||
methodChannel = new MethodChannel(binaryMessenger, "amap_map_" + id);
|
||||
methodChannel.setMethodCallHandler(this);
|
||||
myMethodCallHandlerMap = new HashMap<String, MyMethodCallHandler>(8);
|
||||
myMethodCallHandlerMap = new HashMap<>(8);
|
||||
|
||||
try {
|
||||
mapView = new TextureMapView(context, options);
|
||||
AMap amap = mapView.getMap();
|
||||
mapsInitializerController = new MapsInitializerController(methodChannel);
|
||||
mapController = new MapController(methodChannel, mapView);
|
||||
markersController = new MarkersController(methodChannel, amap);
|
||||
polylinesController = new PolylinesController(methodChannel, amap);
|
||||
@ -82,6 +87,13 @@ public class AMapPlatformView
|
||||
}
|
||||
}
|
||||
|
||||
methodIdArray = mapsInitializerController.getRegisterMethodIdArray();
|
||||
if (null != methodIdArray) {
|
||||
for (String methodId : methodIdArray) {
|
||||
myMethodCallHandlerMap.put(methodId, mapsInitializerController);
|
||||
}
|
||||
}
|
||||
|
||||
methodIdArray = markersController.getRegisterMethodIdArray();
|
||||
if (null != methodIdArray) {
|
||||
for (String methodId : methodIdArray) {
|
||||
@ -127,7 +139,7 @@ public class AMapPlatformView
|
||||
LogUtil.i(CLASS_NAME, "onMethodCall==>" + call.method + ", arguments==> " + call.arguments);
|
||||
String methodId = call.method;
|
||||
if (myMethodCallHandlerMap.containsKey(methodId)) {
|
||||
myMethodCallHandlerMap.get(methodId).doMethodCall(call, result);
|
||||
Objects.requireNonNull(myMethodCallHandlerMap.get(methodId)).doMethodCall(call, result);
|
||||
} else {
|
||||
LogUtil.w(CLASS_NAME, "onMethodCall, the methodId: " + call.method + ", not implemented");
|
||||
result.notImplemented();
|
||||
|
@ -6,6 +6,7 @@ import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.MyLocationStyle;
|
||||
|
||||
/**
|
||||
* @author kuloud
|
||||
* @author whm
|
||||
* @date 2020/10/29 9:56 AM
|
||||
* @mail hongming.whm@alibaba-inc.com
|
||||
@ -13,9 +14,9 @@ import com.amap.api.maps.model.MyLocationStyle;
|
||||
*/
|
||||
public interface AMapOptionsSink {
|
||||
|
||||
public void setCamera(CameraPosition camera);
|
||||
void setCamera(CameraPosition camera);
|
||||
|
||||
public void setMapType(int mapType);
|
||||
void setMapType(int mapType);
|
||||
|
||||
public void setCustomMapStyleOptions(CustomMapStyleOptions customMapStyleOptions);
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.amap.flutter.map.core;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.amap.api.maps.MapsInitializer;
|
||||
import com.amap.flutter.map.MyMethodCallHandler;
|
||||
import com.amap.flutter.map.utils.Const;
|
||||
import com.amap.flutter.map.utils.LogUtil;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
|
||||
/**
|
||||
* AMap 全局控制器
|
||||
*/
|
||||
public class MapsInitializerController implements MyMethodCallHandler {
|
||||
private static final String CLASS_NAME = MapsInitializerController.class.getSimpleName();
|
||||
private final MethodChannel methodChannel;
|
||||
|
||||
public MapsInitializerController(MethodChannel methodChannel) {
|
||||
this.methodChannel = methodChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||
switch (call.method) {
|
||||
case Const.METHOD_SET_TERRAIN_ENABLE:
|
||||
MapsInitializer.setTerrainEnable(call.argument(""));
|
||||
result.success(null);
|
||||
break;
|
||||
default:
|
||||
LogUtil.w(CLASS_NAME, "onMethodCall not find methodId:" + call.method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRegisterMethodIdArray() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ public class Const {
|
||||
public static final String METHOD_MAP_TO_SCREEN_COORDINATE = "map#toScreenCoordinate";
|
||||
public static final String METHOD_MAP_FROM_SCREEN_COORDINATE = "map#fromScreenCoordinate";
|
||||
|
||||
public static final String METHOD_SET_TERRAIN_ENABLE = "#setTerrainEnable";
|
||||
|
||||
public static final String[] METHOD_ID_LIST_FOR_MAP = {
|
||||
METHOD_MAP_CONTENT_APPROVAL_NUMBER,
|
||||
METHOD_MAP_SATELLITE_IMAGE_APPROVAL_NUMBER,
|
||||
@ -33,7 +35,7 @@ public class Const {
|
||||
METHOD_MAP_CLEAR_DISK,
|
||||
METHOD_MAP_TO_SCREEN_COORDINATE,
|
||||
METHOD_MAP_FROM_SCREEN_COORDINATE
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,7 @@ dependencies:
|
||||
# provider: ^6.1.1
|
||||
# x_amap_base:
|
||||
# path: ../x_amap_base
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
Reference in New Issue
Block a user