gmm_amap_flutter_base
高德地图 Flutter 插件 - 基础库(已适配 Flutter 3.35+ / Dart 3.9+)
本插件是基于 amap_flutter_base 的改进版本,修复了在新版本 Flutter/Dart 上的兼容性问题。
功能特性
- ✅ 提供高德地图相关的基础类和数据模型
- ✅ 支持 Flutter 3.35+ 和 Dart 3.9+
- ✅ 修复了废弃 API 的兼容性问题
- ✅ 提供统一的坐标系、API Key、隐私合规等配置
安装
在 pubspec.yaml 中添加依赖:
dependencies:
gmm_amap_flutter_base: ^3.1.4
然后运行:
flutter pub get
使用示例
配置 API Key
import 'package:gmm_amap_flutter_base/gmm_amap_flutter_base.dart';
// 创建 API Key 配置
const apiKey = AMapApiKey(
androidKey: '您的Android Key',
iosKey: '您的iOS Key',
);
隐私合规配置
// 隐私合规声明(高德 SDK 要求)
const privacyStatement = AMapPrivacyStatement(
hasContains: true, // 隐私政策中是否包含高德相关说明
hasShow: true, // 是否已向用户展示隐私政策
hasAgree: true, // 用户是否已同意隐私政策
);
使用坐标类
// 创建经纬度坐标
const latLng = LatLng(39.909187, 116.397451);
// 获取坐标值
print('纬度: ${latLng.latitude}');
print('经度: ${latLng.longitude}');
相关插件
- gmm_amap_flutter_map - 高德地图组件
- gmm_amap_flutter_location - 高德定位插件
许可证
MIT License - 详见 LICENSE 文件
致谢
本插件基于高德官方 amap_flutter_base 改进,感谢高德开放平台的支持。