使用前先到这里申请相关key。相关步骤如下:
在Appcloud中填写'BAIDUMAP_KEY_IOS'、'BAIDUMAP_KEY_ANDRIOD'需填写为4段位; `'BAIDUMAP_ALLOW_BACKGROUND_LOCATION':默认不添加后台定位,因为鹰眼需要 用到后台定位功能,可将此值设为true
MBaiDuMap.getCurrentPosition(success,error);
参数 | 类型 | 作用 |
---|---|---|
success(result) | function | 执行成功回调,result是json对象 |
error | function | 执行错误回调。error的参数obj为json对象,代表具体的错误信息. 格式为{"errCode": -1, "errMsg": "some description of error".错误码参考百度定位相关信息错误码}; |
result结构示例
参数 | 类型 | 作用 |
---|---|---|
latitude | float | 纬度 |
longitude | float | 经度 |
address | String | 地址名称 |
addressDetail | json | 层次化地址信息,请参照下方说明 |
addressDetail结构示例
参数 | 类型 | 作用 |
---|---|---|
country | String | 国家 |
province | String | 省份名称 |
city | String | 城市名称 |
district | String | 区县名称 |
streetName | String | 街道名称 |
streetNumber | String | 街道号码 |
代码示例
MBaiDuMap.getCurrentPosition(
function(result){
},
function(err){
});
使用说明
使用鹰眼前需先通过entity/add添加entity。 iOS要求8.0以上系统方能使用鹰眼功能。请至config.xml中确认deployment-target的值。
MYingyan.startTrace(entityName, serviceId, operationMode, customAttr, success, error, androidText);
参数 | 类型 | 作用 |
---|---|---|
entityName | string | 必须。entity标识 |
serviceId | int | 必须。鹰眼服务ID |
operationMode | int | 必须。轨迹服务类型。 0:不建立长连接(即不上传轨迹,也不接收服务端推送消息); 1:只建立长连接(即只接收服务端推送消息,不上传轨迹); 2:建立长连接,上传轨迹并接收报警推送消息。 建议设置为 2 |
customAttr | json对象 | 自定义字段。必须先通过entity/addcolumn创建过才有效 |
success(result) | function | 成功回调。返回数组。[0,"success"] |
error | function | 失败回调 |
androidText | string | 仅android有效。 开启轨迹追踪成功时将在通过栏中显示 |
MYingyan.stopTrace(success, error);
参数 | 类型 | 作用 |
---|---|---|
success(result) | function | 成功回调。返回字符串,OK |
error | function | 失败回调 |
MYingyan.setInterval(gatherInterval, packInterval, success, error);
参数 | 类型 | 作用 |
---|---|---|
gatherInterval | int | 采集时间间隔,单位:秒。 最小为2秒,最大为5分钟,否则设置不成功,默认值为5s |
packInterval | int | 打包时间间隔,单位:秒。 打包时间间隔必须为采集时间间隔的整数倍,且最大不能超过5分钟,否则设置不成功,默认值为30s |
success(result) | function | 成功回调。返回字符串,OK |
error | function | 失败回调 |
使用要点
MYingyan.setLocationMode(mode, success, error);
参数传值说明: 0-高精度(GPS与网络综合定位),1-低功耗,2-仅使用设备(GPS)定位
参数 | 类型 | 作用 |
---|---|---|
mode | int | 定位模式。默认0 |
success(result) | function | 成功回调。返回字符串,OK |
error | function | 失败回调 |
MYingyan.setProtocolType(type, success, error);
参数 | 类型 | 作用 |
---|---|---|
type | int | 请求协议类型。1:https,0:http,默认为1 |
success(result) | function | 成功回调。返回字符串,OK |
error | function | 失败回调 |
MYingyan.getTrackHistory(entityName,serviceId,startTime,endTime,simpleReturn,isProcessed,pageSize,pageIndex, processOption,supplementMode,sortType,success, error);
参数 | 类型 | 作用 |
---|---|---|
entityName | string | 必须。entity标识 |
serviceId | int | 必须。轨迹服务标识 |
startTime | int | 必须。开始时间(Unix时间戳) |
endTime | int | 必须。结束时间(Unix时间戳) |
simpleReturn | int | 是否返回精简结果。 0:否 1:仅返回轨迹点的经纬度 2:仅返回轨迹点的里程数 |
isProcessed | int | 是否返回纠偏后轨迹 轨迹纠偏功能包括去噪、抽稀、绑路三个步骤 0:否,1:是 |
processOption | string | 纠偏选项,仅在is_processed=1时生效 通过为纠偏选项赋1(需要)或0(不需要)来设置是否需要该项数据处理,多选项设置时用英文逗号","分割,若不设置某选项则按默认值处理。 need_denoise:去噪 need_vacuate:抽稀 need_mapmatch:绑路(仅适用驾车) |
pageSize | int | 分页大小 |
pageIndex | int | 分页索引,1开始 |
supplementMode | string | 可选。里程补偿方式 在里程计算时,两个轨迹点定位时间间隔5分钟以上,被认为是中断。 中断轨迹提供以下5种里程估算方式: no_supplement:不补充,中断两点间距离不记入里程; straight:使用直线距离补充; driving:使用最短驾车路线距离补充; riding:使用最短骑行路线距离补充; walking:使用最短步行路线距离补充. 默认值为:no_supplement |
sortType | int | 排序规则,默认值是0:返回轨迹点按loc_time从大到小排序;当设为1时,则反之 |
success(result) | function | 成功回调 |
error | function | 失败回调 |
返回示例
{
"status": 0,
"size": 0,
"total": 0,
"entity_name": "mtest",
"distance": 0,
"toll_distance": 0,
"start_point": {
"longitude": 0,
"latitude": 0,
"coord_type": 3,
"loc_time": 0
},
"end_point": {
"longitude": 0,
"latitude": 0,
"coord_type": 3,
"loc_time": 0
},
"points": [
{
"location": [
116.1556024,
40.0820658,
],
"create_time": "2014-09-13 18:23:45",
"loc_time": "1442139825",
"direction": 240,
"speed": 0.9,
"radius": 5,
"dispatch_state": "not"
},
{
"location": [
116.3579834,
40.0280849,
],
"create_time": "2014-09-13 18:24:45",
"loc_time": 1442139885,
"direction":240,
"speed": 0.9,
"radius": 5,
"dispatch_state": "not"
}
],
"message": "成功"
}
MYingyan.queryEntityList(entityNames,serviceId,columnKey,activeTime,returnType,pageSize,pageIndex, success, error);
使用要点
参数 | 类型 | 作用 |
---|---|---|
entityNames | string | entity标识列表(多个entityName,以英文逗号"," 分隔) |
serviceId | int | 轨迹服务标识 |
columnKey | string | 属性名称(格式为 : "key1=value1,key2=value2,.....") |
activeTime | string | 活跃时间(指定该字段时,返回从该时间点之后仍有位置变动的entity的实时点集合) |
returnType | int | 返回结果类型。0:返回全部结果,1:只返回entityName的列表 |
pageSize | int | 分页大小 |
pageIndex | int | 分页索引 |
success(result) | function | 成功回调 |
error | function | 失败回调 |
返回示例
{
"status": 0,
"message": "成功",
"size": 1,
"total": 1,
"entities": [
{
"entity_name": "mtest",
"create_time": "2017-01-03 19:34:42",
"modify_time": "2017-01-04 16:54:26",
"realtime_point": {
"loc_time": 1483520065,
"location": [
113.95925090006,
22.543710733578
],
"direction": 0,
"height": 35,
"radius": 65,
"speed": 3.6
}
}
]
}
MYingyan.isTraceRunning(success, error);
参数 | 类型 | 作用 |
---|---|---|
success(result) | function | 成功回调,result是true/false |
error | function | 错误回调 |
MYingyan.isGpsOpen(success, error);
参数 | 类型 | 作用 |
---|---|---|
success(result) | function | 成功回调,result是true/false |
error | function | 错误回调 |
MYingyan.openGps(success, error);
参数 | 类型 | 作用 |
---|---|---|
success | function | 成功回调 |
error | function | 错误回调 |