提交 33179313 authored 作者: 祁增奎's avatar 祁增奎

Merge branch 'v1.0.1' into 1.0.0

# Conflicts: # ios/amap_flutter_map.podspec
......@@ -10,3 +10,8 @@ build/
**/pubspec.lock
.settings/
.project
# FVM Version Cache
.fvm/
.fvmrc
/.vscode
......@@ -34,6 +34,6 @@ android {
dependencies {
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
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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,7 @@ class PolygonController implements PolygonOptionsSink{
public void setLineJoinType(AMapPara.LineJoinType joinType) {
//不支持动态修改
}
public boolean contains(LatLng latLng) {
return polygon.contains(latLng);
}
}
......@@ -29,4 +29,5 @@ interface PolygonOptionsSink {
//边框连接类型
void setLineJoinType(AMapPara.LineJoinType joinType);
}
......@@ -5,6 +5,7 @@ import android.text.TextUtils;
import androidx.annotation.NonNull;
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.PolygonOptions;
import com.amap.flutter.map.MyMethodCallHandler;
......@@ -37,11 +38,15 @@ public class PolygonsController
@Override
public void doMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
String methodId = call.method;
LogUtil.i(CLASS_NAME, "doMethodCall===>" +methodId);
LogUtil.i(CLASS_NAME, "doMethodCall===>" + methodId);
switch (methodId) {
case Const.METHOD_POLYGON_UPDATE:
invokePolylineOptions(call, result);
break;
case Const.METHOD_POLYGON_CONTAINS:
invokeContains(call, result);
}
}
......@@ -51,7 +56,6 @@ public class PolygonsController
}
/**
*
* @param methodCall
* @param result
*/
......@@ -68,6 +72,34 @@ public class PolygonsController
result.success(null);
}
public void invokeContains(MethodCall methodCall, MethodChannel.Result result) {
if (null == methodCall) {
return;
}
String dartId = methodCall.argument("id");
LatLng position = ConvertUtil.toLatLng(methodCall.argument("point"));
LogUtil.d(CLASS_NAME, "invokeContains===>" + position+" dartId===>"+dartId);
if (null != dartId) {
PolygonController controller = controllerMapByDartId.get(dartId);
LogUtil.d(CLASS_NAME, "invokeContains===>1");
if (null != controller) {
LogUtil.d(CLASS_NAME, "invokeContains===>2");
boolean bool = controller.contains(position);
result.success(bool);
LogUtil.d(CLASS_NAME, "invokeContains===>3");
return;
}
}
result.success(null);
}
public void addByList(List<Object> polygonsToAdd) {
if (polygonsToAdd != null) {
for (Object polygonToAdd : polygonsToAdd) {
......
......@@ -54,7 +54,8 @@ public class Const {
* polygons
*/
public static final String METHOD_POLYGON_UPDATE = "polygons#update";
public static final String[] METHOD_ID_LIST_FOR_POLYGON = {METHOD_POLYGON_UPDATE};
public static final String METHOD_POLYGON_CONTAINS = "polygon#containsPoint";
public static final String[] METHOD_ID_LIST_FOR_POLYGON = {METHOD_POLYGON_UPDATE, METHOD_POLYGON_CONTAINS};
/**
* polylines
......
......@@ -6,7 +6,7 @@
//
#import "AMapFlutterFactory.h"
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
#import "AMapViewController.h"
@implementation AMapFlutterFactory {
......
......@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -685,6 +685,9 @@
[dict setValue:address.towncode forKey:@"townCode"];
//回调
[arguments setValue:dict forKey:@"searchRegeocodeResult"];
// 增加经纬度
[arguments setValue:@(request.location.latitude) forKey:@"latitude"];
[arguments setValue:@(request.location.longitude) forKey:@"longitude"];
[_channel invokeMethod:@"camera#searchRegeocodeEvent" arguments:arguments];
} else {
NSMutableDictionary *arguments = [NSMutableDictionary dictionary];
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/5.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/10/30.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/9.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/12.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/12.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/9.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -5,7 +5,7 @@
// Created by lly on 2020/11/7.
//
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -6,7 +6,7 @@
//
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -6,7 +6,7 @@
//
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -12,6 +12,7 @@
#import "MAPolygonRenderer+Flutter.h"
#import "FlutterMethodChannel+MethodCallDispatch.h"
@interface AMapPolygonController ()
@property (nonatomic,strong) NSMutableDictionary<NSString*,AMapPolygon*> *polygonDict;
......@@ -50,10 +51,31 @@
}
result(nil);
}];
[_methodChannel addMethodName:@"polygon#containsPoint" withHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) {
id point = call.arguments[@"point"];
if (![point isKindOfClass:[NSArray class]]) {
result(false);
return;
}
NSArray *locationArray = (NSArray *)point;
if (locationArray.count < 2) {
result(false);
return;
}
CLLocationDegrees latitude = [locationArray[0] doubleValue];
CLLocationDegrees longitude = [locationArray[1] doubleValue];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
MAMapPoint mapPoint = MAMapPointForCoordinate(coordinate);
NSString *_id = call.arguments[@"id"];
AMapPolygon* polygon = [weakSelf polygonForId:_id];
result(@(MAPolygonContainsPoint(mapPoint,polygon.polygon.points, polygon.polygon.pointCount)));
}];
}
return self;
}
- (nullable AMapPolygon *)polygonForId:(NSString *)polygonId {
return _polygonDict[polygonId];
}
......
......@@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Flutter/Flutter.h>
#import <MAMapKit/MAMapKit.h>
#include <AMapNaviKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
......
......@@ -16,7 +16,6 @@ A new Flutter plugin.
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
# s.dependency 'AMap3DMap'
s.dependency 'AMapSearch'
s.static_framework = true
s.platform = :ios, '8.0'
......
......@@ -63,7 +63,7 @@ class AMapController {
}
if (_mapState.widget.onMapSearchRegeocode != null) {
_methodChannel.mapSearchRegeocode(mapId: mapId).listen(
(MapSearchRegeocodeEvent e) =>
(MapSearchRegeocodeEvent e) =>
_mapState.widget.onMapSearchRegeocode!(e.value));
}
if (_mapState.widget.onTap != null) {
......@@ -149,6 +149,11 @@ class AMapController {
return _methodChannel.takeSnapshot(mapId: mapId);
}
/// 判断点是否在多边形内
Future<bool?> containsPoint(LatLng point, id) {
return _methodChannel.containsPoint(point, id, mapId: mapId);
}
//地图可视区域
Future<dynamic> getVisibleRegion() {
return _methodChannel.getVisibleRegion(mapId: mapId);
......@@ -158,8 +163,10 @@ class AMapController {
// searchType
// 0 根据输入信息 获取poi点
// 1 根据经纬度 获取周边poi点
Future<void> searchPoi(String keyWord,int searchType,{latitude=0.0,double longitude=0.0}) {
return _methodChannel.searchPoi(keyWord,searchType, mapId: mapId,latitude: latitude,longitude: longitude);
Future<void> searchPoi(String keyWord, int searchType,
{latitude = 0.0, double longitude = 0.0}) {
return _methodChannel.searchPoi(keyWord, searchType,
mapId: mapId, latitude: latitude, longitude: longitude);
}
//搜索POI
......
......@@ -81,6 +81,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
void dispose({required int id}) {
if (_channels.containsKey(id)) {
......@@ -210,18 +219,23 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
}
break;
case 'camera#searchInputTipsEvent':
print('----- camera#searchInputTipsEvent result: ${call.arguments['searchInputTipsResult']}');
print(
'----- camera#searchInputTipsEvent result: ${call.arguments['searchInputTipsResult']}');
try {
_mapEventStreamController.add(MapSearchInputTipsEvent(mapId,
InputTipsResult.toInputTipsResult(call.arguments['searchInputTipsResult'])!));
_mapEventStreamController.add(MapSearchInputTipsEvent(
mapId,
InputTipsResult.toInputTipsResult(
call.arguments['searchInputTipsResult'])!));
} catch (e) {
print("camera#searchInputTipsEvent error===>" + e.toString());
}
break;
case 'camera#searchRegeocodeEvent':
try {
_mapEventStreamController.add(MapSearchRegeocodeEvent(mapId,
RegeocodeResult.toRegeocodeResult(call.arguments['searchRegeocodeResult'])!));
_mapEventStreamController.add(MapSearchRegeocodeEvent(
mapId,
RegeocodeResult.toRegeocodeResult(
call.arguments['searchRegeocodeResult'])!));
} catch (e) {
print("camera#searchRegeocodeEvent error===>" + e.toString());
}
......@@ -277,9 +291,9 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
}
/// 展示marker InfoWindow
Future<void> showInfoWindow(
String markerId, {required int mapId}) {
return channel(mapId).invokeMethod<void>('markers#showInfoWindow', <String, dynamic>{
Future<void> showInfoWindow(String markerId, {required int mapId}) {
return channel(mapId)
.invokeMethod<void>('markers#showInfoWindow', <String, dynamic>{
'markerId': markerId,
});
}
......@@ -310,7 +324,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)
.invokeMethod<dynamic>('camera#searchPOI', <String, dynamic>{
'query': query,
......@@ -329,7 +344,8 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
}
// 地图搜索regeocode
Future<void> searchRegeocode(double latitude,double longitude, {required int mapId}) {
Future<void> searchRegeocode(double latitude, double longitude,
{required int mapId}) {
return channel(mapId)
.invokeMethod<dynamic>('camera#searchRegeocode', <String, dynamic>{
'latitude': latitude,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论