提交 c3d6b021 authored 作者: 张国庆's avatar 张国庆

feat:1.修改地图库依赖方式2,增加一个判断点是否在多边形的方法

上级 72db3daa
...@@ -10,3 +10,8 @@ build/ ...@@ -10,3 +10,8 @@ build/
**/pubspec.lock **/pubspec.lock
.settings/ .settings/
.project .project
# FVM Version Cache
.fvm/
.fvmrc
/.vscode
...@@ -34,6 +34,6 @@ android { ...@@ -34,6 +34,6 @@ android {
dependencies { dependencies {
compileOnly 'com.amap.api:3dmap:8.1.0' compileOnly 'com.amap.api:3dmap:8.1.0'
implementation 'com.amap.api:search:8.1.0' compileOnly 'com.amap.api:search:8.1.0'
} }
...@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
...@@ -59,4 +59,9 @@ class PolygonController implements PolygonOptionsSink{ ...@@ -59,4 +59,9 @@ class PolygonController implements PolygonOptionsSink{
public void setLineJoinType(AMapPara.LineJoinType joinType) { public void setLineJoinType(AMapPara.LineJoinType joinType) {
//不支持动态修改 //不支持动态修改
} }
@Override
public boolean contains(LatLng latLng) {
return polygon.contains(latLng);
}
} }
...@@ -29,4 +29,7 @@ interface PolygonOptionsSink { ...@@ -29,4 +29,7 @@ interface PolygonOptionsSink {
//边框连接类型 //边框连接类型
void setLineJoinType(AMapPara.LineJoinType joinType); void setLineJoinType(AMapPara.LineJoinType joinType);
// 判断坐标是否在多边形内部
boolean contains(LatLng latLng);
} }
...@@ -5,6 +5,7 @@ import android.text.TextUtils; ...@@ -5,6 +5,7 @@ import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.amap.api.maps.AMap; import com.amap.api.maps.AMap;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Polygon; import com.amap.api.maps.model.Polygon;
import com.amap.api.maps.model.PolygonOptions; import com.amap.api.maps.model.PolygonOptions;
import com.amap.flutter.map.MyMethodCallHandler; import com.amap.flutter.map.MyMethodCallHandler;
...@@ -42,6 +43,10 @@ public class PolygonsController ...@@ -42,6 +43,10 @@ public class PolygonsController
case Const.METHOD_POLYGON_UPDATE: case Const.METHOD_POLYGON_UPDATE:
invokePolylineOptions(call, result); invokePolylineOptions(call, result);
break; break;
case Const.METHOD_POLYGON_CONTAINS:
invokeContains(call, result);
} }
} }
...@@ -66,6 +71,25 @@ public class PolygonsController ...@@ -66,6 +71,25 @@ public class PolygonsController
Object listIdToRemove = methodCall.argument("polygonIdsToRemove"); Object listIdToRemove = methodCall.argument("polygonIdsToRemove");
removeByIdList((List<Object>) listIdToRemove); removeByIdList((List<Object>) listIdToRemove);
result.success(null); result.success(null);
}
public void invokeContains(MethodCall methodCall, MethodChannel.Result result) {
if (null == methodCall) {
return;
}
String id = methodCall.argument("id");
LatLng position= ConvertUtil.toLatLng(methodCall.argument("point"));
LogUtil.w("123",id);
LogUtil.w("123",position.toString());
result.success(null);
} }
public void addByList(List<Object> polygonsToAdd) { public void addByList(List<Object> polygonsToAdd) {
......
...@@ -54,6 +54,7 @@ public class Const { ...@@ -54,6 +54,7 @@ public class Const {
* polygons * polygons
*/ */
public static final String METHOD_POLYGON_UPDATE = "polygons#update"; public static final String METHOD_POLYGON_UPDATE = "polygons#update";
public static final String METHOD_POLYGON_CONTAINS = "polygons#contains";
public static final String[] METHOD_ID_LIST_FOR_POLYGON = {METHOD_POLYGON_UPDATE}; public static final String[] METHOD_ID_LIST_FOR_POLYGON = {METHOD_POLYGON_UPDATE};
/** /**
......
...@@ -82,6 +82,15 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { ...@@ -82,6 +82,15 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
); );
} }
///判断 点坐标是否在polygon 多边形内
///@param point 点坐标
Future<bool?> containsPoint(LatLng point, String id, {required int mapId}) {
return channel(mapId).invokeMethod<bool>(
'polygon#containsPoint',
<String, dynamic>{'point': point.toJson(), 'id': id},
);
}
@override @override
void dispose({required int id}) { void dispose({required int id}) {
if (_channels.containsKey(id)) { if (_channels.containsKey(id)) {
...@@ -213,18 +222,23 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { ...@@ -213,18 +222,23 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
} }
break; break;
case 'camera#searchInputTipsEvent': case 'camera#searchInputTipsEvent':
print('----- camera#searchInputTipsEvent result: ${call.arguments['searchInputTipsResult']}'); print(
'----- camera#searchInputTipsEvent result: ${call.arguments['searchInputTipsResult']}');
try { try {
_mapEventStreamController.add(MapSearchInputTipsEvent(mapId, _mapEventStreamController.add(MapSearchInputTipsEvent(
InputTipsResult.toInputTipsResult(call.arguments['searchInputTipsResult'])!)); mapId,
InputTipsResult.toInputTipsResult(
call.arguments['searchInputTipsResult'])!));
} catch (e) { } catch (e) {
print("camera#searchInputTipsEvent error===>" + e.toString()); print("camera#searchInputTipsEvent error===>" + e.toString());
} }
break; break;
case 'camera#searchRegeocodeEvent': case 'camera#searchRegeocodeEvent':
try { try {
_mapEventStreamController.add(MapSearchRegeocodeEvent(mapId, _mapEventStreamController.add(MapSearchRegeocodeEvent(
RegeocodeResult.toRegeocodeResult(call.arguments['searchRegeocodeResult'])!)); mapId,
RegeocodeResult.toRegeocodeResult(
call.arguments['searchRegeocodeResult'])!));
} catch (e) { } catch (e) {
print("camera#searchRegeocodeEvent error===>" + e.toString()); print("camera#searchRegeocodeEvent error===>" + e.toString());
} }
...@@ -280,9 +294,9 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { ...@@ -280,9 +294,9 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
} }
/// 展示marker InfoWindow /// 展示marker InfoWindow
Future<void> showInfoWindow( Future<void> showInfoWindow(String markerId, {required int mapId}) {
String markerId, {required int mapId}) { return channel(mapId)
return channel(mapId).invokeMethod<void>('markers#showInfoWindow', <String, dynamic>{ .invokeMethod<void>('markers#showInfoWindow', <String, dynamic>{
'markerId': markerId, 'markerId': markerId,
}); });
} }
...@@ -313,7 +327,8 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { ...@@ -313,7 +327,8 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
} }
// 地图可视区域 // 地图可视区域
Future<void> searchPoi(String query,int searchType, {required int mapId,double latitude=0.0,double longitude=0.0}) { Future<void> searchPoi(String query, int searchType,
{required int mapId, double latitude = 0.0, double longitude = 0.0}) {
return channel(mapId) return channel(mapId)
.invokeMethod<dynamic>('camera#searchPOI', <String, dynamic>{ .invokeMethod<dynamic>('camera#searchPOI', <String, dynamic>{
'query': query, 'query': query,
...@@ -332,7 +347,8 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { ...@@ -332,7 +347,8 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
} }
// 地图搜索regeocode // 地图搜索regeocode
Future<void> searchRegeocode(double latitude,double longitude, {required int mapId}) { Future<void> searchRegeocode(double latitude, double longitude,
{required int mapId}) {
return channel(mapId) return channel(mapId)
.invokeMethod<dynamic>('camera#searchRegeocode', <String, dynamic>{ .invokeMethod<dynamic>('camera#searchRegeocode', <String, dynamic>{
'latitude': latitude, 'latitude': latitude,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论