添加依赖
dependencies:
flutter:
sdk: flutter
amap_map_fluttify: ^x.x.x
###初始化服务
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
await AmapService.init(
iosKey: '7axxxxxxxxxxxxxxxxxxxxxxxxxxf4',
androidKey: '7cxxxxxxxxxxxxxxxxxxxxxxxxx7fa',
webApiKey: 'e6xxxxxxxxxxxxxxxxxxxxxxxxxaa2',
);
显示地图
如果你同时使用了高德定位或高德搜索,那么需要在AndroidManifest.xml中配置app key!
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
class MapScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('地图')),
body: AmapView(),
);
}
}