xbr_gaode_location 2.0.3
xbr_gaode_location: ^2.0.3 copied to clipboard
高德地图flutter地位内插件,amap_flutter,配合 xbr_gaode_amap 和 xbr_gaode_search 使用
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:xbr_gaode_location/core/location.dart';
import 'package:xbr_gaode_location/xbr_gaode_location.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
void init(){
//初始化 建议在App启动时完成
XbrGaodeLocation.initKey( androidKey:"", iosKey:"");
//显示用户协议 建议在嵌软件使用协议 用户查看协议时调用
XbrGaodeLocation.updatePrivacy( hasContains:true, hasShow:true,hasAgree: true);
//注意这里没有做任何权限,直接启动不会成功
}
void startLocation(){
XbrGaodeLocation.instance().startTimeLocation(callback: (LocationInfo? locationInfo){
//连续定位根据配置时间间隔返回
//建议在地图控件中测试 dev搜索 xbr_gaode_amap
});
}
void startOnceLocation(){
XbrGaodeLocation.instance().execOnceLocation(callback: (LocationInfo? locationInfo){
//单次定位返回一次
//建议在地图控件中测试 dev搜索 xbr_gaode_amap
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('建议在地图控件中测试'),
),
body: Center(
child: Text('建议在地图控件中测试 dev搜索 xbr_gaode_amap'),
),
),
);
}
}