amap_flutter_sdk

统一高德 Flutter 插件:地图 + 定位 + 搜索(Android / iOS 原生 SDK)。

非高德官方插件,与高德地图无隶属关系。使用前请自行在 高德开放平台 申请 Key,并遵守高德 SDK 与隐私合规要求。宿主 App 须在用户同意隐私政策后再调用 AMapSdk.init

功能

模块 能力
Map AMapView / AMapWidget、相机、Marker/Polyline/Polygon、截图、POI 点击等
Location 单次/连续定位、逆地理回传、隐私合规、iOS 精度授权
Search POI 关键字/周边/ID、输入提示 InputTips、地理编码、逆地理、行政区域

接入

1. 依赖

dependencies:
  amap_flutter_sdk: ^0.1.5

本地开发也可使用 path / git 依赖。

2. 初始化(用户同意隐私政策之后)

await AMapSdk.init(
  androidKey: '你的 Android Key',
  iosKey: '你的 iOS Key',
  privacy: const AMapPrivacy(hasContains: true, hasShow: true, hasAgree: true),
);

地图页 build 中建议再调用:

AMapSdk.ensureMapReady(context, androidKey: '...', iosKey: '...');

3. 权限

  • Android:ACCESS_COARSE_LOCATION / ACCESS_FINE_LOCATION(及按需后台定位)
  • iOS:NSLocationWhenInUseUsageDescription 等 Info.plist 文案
  • 运行时权限建议用 permission_handler,插件不主动弹权限

4. 示例用法

地图

AMapView(
  initialCameraPosition: CameraPosition(target: LatLng(39.9, 116.3), zoom: 12),
  markers: {...},
  onMapCreated: (controller) { /* moveCamera 等 */ },
);

定位

final client = AMapLocationClient();
client.onLocationChanged().listen((r) {
  if (r.isSuccess) print('${r.latitude}, ${r.longitude} ${r.address}');
});
await client.setLocationOption(AMapLocationOption(onceLocation: true, needAddress: true));
await client.startLocation();

搜索

final pois = await AMapSearchClient.searchPoi(keyword: '超市', city: '北京');
final tips = await AMapSearchClient.inputTips(
  keyword: '成',
  city: '成都',
  location: LatLng(30.57, 104.06),
);
final geo = await AMapSearchClient.geocode(address: '北京市东城区...', city: '北京');
final re = await AMapSearchClient.regeocode(location: LatLng(39.9, 116.3));
final dist = await AMapSearchClient.searchDistrict(keyword: '北京市');

Channel 约定

  • amap_flutter_sdk — 核心
  • amap_flutter_sdk/location + amap_flutter_sdk/location_stream — 定位
  • amap_flutter_sdk/search — 搜索
  • com.amap.flutter.map / amap_map_{id} — 地图 PlatformView(兼容移植实现)

原生依赖

  • Android:com.amap.api:3dmap-location-search:10.1.200_loc6.4.9_sea9.7.4
    • 插件已配置 armeabi-v7a / arm64-v8a,打包时剔除 x86 / x86_64
    • 宿主 App 仍建议保留同样的 abiFilters / packaging.jniLibs.excludes(Maven 传递 AAR 最终在 App 侧合并)
  • iOS Pods:AMap3DMapAMapLocationAMapSearch(static_framework)

Example

example/,替换 YOUR_ANDROID_KEY / YOUR_IOS_KEY 后运行。

Libraries

amap_flutter_sdk