flutter_amap_track

pub 
package

本插件为高德猎鹰Api的搬运和实现

Android猎鹰文档

iOS猎鹰文档

Android

配置高德key

为了保证高德 Android SDK 的功能正常使用,您需要申请高德 Key 并且配置到项目中。在项目的 “AndroidManifest.xml” 文件中,添加如下代码:

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" > 
    <meta-data 
        android:name="com.amap.api.v2.apikey" 
        android:value="请输入您的用户Key"/> 
        …… 
</application>

iOS

更改info.plist 及 配置后台定位

在info.plist的字段添加定位权限的申请及配置后台定位能力,配置方式请参考iOS 猎鹰SDK 手动部署部分说明

设置apikey

AmapTrack.getInstance().setIOSApiKey('xxx');

使用

全局设置serviceId并初始化猎鹰组件

    AmapTrack.getInstance().initWithServiceId(xxx);

终端管理

  1. 查询终端
try {
	var response = await AmapTrack.getInstance()
		.queryTerminal(QueryTerminalRequest(
			terminal: terminalName));
	...
  } on ErrorResponse catch (e) {
	print('${e.errorCode} | ${e.errorMsg} | ${e.errorDetail}');
  }
  1. 创建终端
try {
	var response = await AmapTrack.getInstance()
		.addTerminal(
			AddTerminalRequest(terminal: terminalName));
	...
  } on ErrorResponse catch (e) {
	...
  }

轨迹上报

  1. 开启轨迹服务
await AmapTrack.getInstance().startTrack(TrackParam(tid:  tid,trid: trid));
  1. 开启定位采集
await AmapTrack.getInstance().startGather();
  1. 结束定位采集
await AmapTrack.getInstance().stopGather();
  1. 结束轨迹服务
await AmapTrack.getInstance().stopTrack(TrackParam(tid: tid,trid: trid));

轨迹查询

  1. 查询终端实时位置
var latestPoint = await AmapTrack.getInstance().queryLatestPoint(LatestPointRequest(tid: tid));
  1. 查询终端行驶里程
var distanceResponse = await AmapTrack.getInstance().queryDistance(DistanceRequest(...));
  1. 查询终端所有轨迹点
var historyTrackResponse = await AmapTrack.getInstance().queryHistoryTrack(HistoryTrackRequest(...));
  1. 查询终端某个轨迹的轨迹点
var queryTrackResponse = await AmapTrack.getInstance().queryTerminalTrack(QueryTrackRequest(...));

本插件API更多参考的是官方Android猎鹰API,兼容了iOS部分,更多api及参数可前往官网查询

Libraries

accuracy_mode
add_terminal_request
add_terminal_response
add_track_request
add_track_response
correct_mode
delete_track_request
distance_request
distance_response
drive_mode
error_response
flutter_amap_track
history_track
history_track_request
history_track_response
ios_cl_activity_type
latest_point_request
latest_point_response
lifecycle_response
location_mode
order_mode
point
protocol_type
query_terminal_request
query_terminal_response
query_track_request
query_track_response
recoup_mode
track
track_param