目录
- 前言
- 首先,创建服务 2.1 创建圆形围栏 2.2 查询围栏
- 创建终端 4.1 创建轨迹(belong 终端) 4.2 上传位置到轨迹(belong 轨迹)
前言
猎鹰的性质, 应该是多对多, 不能直接查询某个坐标是否在围栏中; 而是要先创建终端, 再把终端的坐标传到终端上 , 然后通过API来判断终端是否在围栏中
官方文档: 任何的移动设备、车辆都可以被视为一个终端
1.首先. 创建服务 POST
bash
# 文档地址
https://developer.amap.com/api/track/lieying-kaifa/api/service
# API地址
https://tsapi.amap.com/v1/track/service/add
参数:
key: "你的amap key"
name: "server01" #名称
- 返回结果
js
{
"errcode": 10000,
"errmsg": "OK",
"data": {
"name": "server01",
"sid": 1008611 //serverId 后面有用
}
}
2.1 创建圆形fence POST
bash
https://tsapi.amap.com/v1/track/geofence/add/circle
key: "你的amap key"
sid: 1009348
name: geofence01 # fence的名称
center: 116.478935,39.997761 # 中心点的坐标
radius: 1000 # 半径,m
- 返回结果
bash
{
"errcode": 10000,
"errmsg": "OK",
"data": {
"gfid": 1153882 # 围栏ID
}
}
2.2 查询围栏 GET
bash
https://tsapi.amap.com/v1/track/geofence/list?key=you_amap_key&sid=1009348&gfids=1153882&outputshape=1
- 返回结果
js
{
"errcode": 10000,
"errmsg": "OK",
"data": {
"count": 1,
"results": [
{
"gfid": 1153882,
"name": "geofence01",
"shape": {
"center": "116.478935,39.997761",
"radius": 1000
},
"createtime": 1700106715060,
"modifytime": 1700106715060
}
]
}
}
3. 创建终端 POST
bash
https://tsapi.amap.com/v1/track/terminal/add
key:
sid:1009348
name:machine01
# 响应结果
{
"errcode": 10000,
"errmsg": "OK",
"data": {
"name": "machine01",
"tid": mk788485651,
"sid": 1009348
}
}
4.1 创建轨迹(belong to 终端)
makefile
https://tsapi.amap.com/v1/track/trace/add
key:
sid:1009348
tid: mk788485651
# 结果
{
"errcode": 10000,
"errmsg": "OK",
"data": {
"trid": 20
}
}
4.2 上传位置到轨迹(belong 轨迹) - 报unknow error, 还需要研究
makefile
文档
https://developer.amap.com/api/track/lieying-kaifa/api/track-sdk
接口
https://tsapi.amap.com/v1/track/point/upload
key:
sid:1009348
tid: mk788485651
trid: 20