智能客服
你问我答,随时在线为你解决问题
主要实现了定位请求功能,包含了室内定位、室外定位。提供HTTPS接口,数据为JSON格式。
在Web页面端可以通过发送请求获取定位数据。
| 承载协议 | HTTPS POST |
|---|---|
| 接口方向 | 开发者 -> 华为定位服务器 |
| 接口URL | {rootUrl}/networklocation/v1/geoLocation 说明 当前rootUrl使用域名:locationapi-drcn.cloud.huawei.com。 |
| 数据格式 | 请求消息:Content-Type: application/json 响应消息:Content-Type: application/json |
Request Header
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| Authorization | 是 | String | 业务签名,用于认证鉴权,格式为:Bearer+空格+API Key。 示例:Bearer CgB6e3x9JPgs67R9。 |
| Content-Type | 是 | String | 固定值:application/json。 |
| X-Request-ID | 否 | String | 请求事务标识,用于端到端关联场景,可用UUID生成。 示例:182c1658-120c-4c42-b113-ec33d8f5b9ce。 |
| Accept-Encoding | 否 | String | 填gzip,表示能接受返回值为gzip的压缩数据。 |
| x-forwarded-for | 是 | String | 将IP通过x-forwarded-for传递(仅开启IP定位需要)。 |
| Content-Encoding | 否 | String | 填gzip,表示此次请求数据已经过gzip压缩。 |
| X-Device-Type | 否 | String | 设备类型(枚举值)。
|
Request Body
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| boottime | 是 | long | 发起定位时的手机开机时间,单位:微秒。 |
| indoorMode | 否 | int |
默认值为0。 |
| considerIp | 否 | String | 在没有Wi-Fi和基站信号的情况下是否使用IP定位能力。
如果使用IP定位,需要将IP通过x-forwarded-for传递,返回值为所属城市中心的经纬度信息。 |
| networkType | 否 | int | 移动网络接入时需要添加cellInfos参数,Wi-Fi接入时需要添加wifiInfos参数。
默认不填。 |
| wifiInfos | 1、indoorMode为1时,wifiInfos必选。 2、indoorMode为0且considerIp为空时,wifiInfos与cellInfos不能同时为空。 3、indoorMode为0且considerIp不为空时,wifiInfos与cellInfos可以为空。 | List<WifiInfo> | Wi-Fi热点对象的数组,最大取值为120个。 |
| cellInfos | List<CellInfo> | 多卡的Cell指纹信息,定位时只要找到其中一个即可,最大取值为3个。 | |
| needAddress | 否 | String | 是否需要逆地理编码,传1时表示需要逆地理编码结果。 |
| reverseGeocode | 否 | ReverseGeocode | 逆地理编码相关参数,如果不传,使用默认值。 |
WifiInfo
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| mac | 是 | long | 路由器MAC地址,去冒号后16进制转10进制的结果。 |
| rssi | 是 | int | 路由器RSSI。 |
| time | 是 | long | 发起定位时的手机开机到请求定位的时间,单位:微秒。 |
| frequency | 否 | int | 扫描到的Wi-Fi频段信息。
|
CellInfo
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| currentCell | 是 | CurrentCellEntity | 卡1服务小区对象。 |
| neighborCells | 否 | List<NeighborCell> | 卡1周边基站的对象数组,数组最多传8个对象。 建议尽量多的添加,以提高定位精度。 |
CurrentCellEntity
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| mcc | 是 | int(length<3) | 移动国家码。取值范围:[0,999)。 |
| mnc | 是 | int(length<2) | 移动网络码。取值范围:[0,999)。 |
| lac | 是 | int(length<11) | 区域码。 取值范围:5G:[0,16777215],非5G:[0,65535]。 |
| cellId | 是 | long | 小区ID。 取值范围:5G:[0,68719476735],4G:[0,268435455],3G:0,268435455],2G:[0,65535]。 |
| rssi | 是 | int(length<3) | 信号强度,取值范围:(-140, 0),单位:dB。 值越大,信号越强。 |
| rat | 是 | int(length<1) | 网络制式,1表示2G,2表示3G,3表示4G,4代表5G。 |
NeighborCell
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| rssi | 是 | int(length<3) | 信号强度,取值范围:(-140, 0),单位:dB。值越大,信号越强。 |
| cNum | 是 | int(length<11) | Channel number,通道号。 |
| pId | 是 | int(length<11) | physicalIdentity,物理标识。 |
ReverseGeocode
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| language | 否 | String | 搜索结果返回的语言。如果不传,返回地点的当地语言。 |
| radius | 否 | int | POI、门址召回范围半径,单位:米 。取值范围:[0, 50]。 |
| returnPoi | 否 | String | 是否返回POI,默认为true。 取值范围:0 / false:不返回POI,1 / true:返回POI。 |
- POST /networklocation/v1/geoLocation HTTPS/1.1
- Authorization: ***
- Content-Type: application/json
- {
- "boottime":21003173582,
- "indoorMode":0,
- "cellInfos":[
- {
- "currentCell":{
- "cellId":93734471,
- "lac":9798,
- "mcc":460,
- "mnc":0,
- "rat":3,
- "rssi":-88
- }
- }
- ],
- "wifiInfos":[
- {"mac":137179207280289,"rssi":-66,"time":21003173582},
- {"mac":137179207265777,"rssi":-79,"time":21003145372},
- {"mac":137179207266930,"rssi":-88,"time":21003134322},
- {"mac":137179207265570,"rssi":-65,"time":21003127590},
- {"mac":39678750262768,"rssi":-71,"time":21002554597}
- ]
- }
Response Header
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| Content-Type | 是 | String | 固定值:application/json。 |
| Content-Encoding | 否 | String | 使用gzip压缩时会返回。 |
| content-length | 是 | Integer | 取值不固定。 |
Response Body
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| errorCode | 是 | String | 返回码,具体请参见错误码。 |
| errorMsg | 是 | String | 返回值描述。 |
| locateType | 否 | String | 本次定位的类型。 |
| indoor | 否 | Integer | 是否室内。
|
| position | 否 | Location | 响应的定位信息。 |
| extraInfo | 否 | OnlineLocationResponseExtraInfo | 在线定位的附加信息。 |
| sites | 否 | List<Site> | 逆地理编码信息。 |
Location
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| lat | 否 | Double | 纬度。 |
| lon | 否 | Double | 经度。 |
| acc | 否 | Float | 精度。 |
| speed | 否 | Double | 速度,单位:米。 |
| bearing | 否 | Float | 方向角,取值范围:[0°, 360°)。 |
| buildingId | 否 | String | 室内定位,建筑物ID。 |
| floor | 否 | Integer | 室内定位,楼层ID。 |
| floorAcc | 否 | Integer | 室内定位,楼层置信度。 |
| time | 否 | Long | 手机开机时间。 |
| flags | 否 | Integer | 描述各位置参数是否有效,0表示无效,1表示有效。从右向左:
示例:数值17对应二进制10001,表示lat_lon和acc参数有效,其他参数无效。 |
| indoorFlag | 否 | Integer | 室内结果标志位,透传上次室内定位结果中的此字段值。 |
| mode | 否 | Integer | 定位模式。(0:室外,1:室内)。 |
| locateType | 否 | String | 定位类型(Wifi/Cell)。 |
OnlineLocationResponseExtraInfo
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| cellExtraInfo | 否 | CellExtraInfo | Cell定位附加信息。 |
| wifiExtraInfo | 否 | WifiExtraInfo | Wi-Fi定位附加信息。 |
| indoorLocalLocation | 否 | Location | 室内定位局部定位结果,复用Location类,speed和bearing为空或为0.0。 |
| indoorGlobalLocation | 否 | Location | 室内定位全局定位结果,复用Location类,speed和bearing为空或为0.0。 |
| optionalLocation | 否 | List<Location> | 不同定位方式的定位结果。当定位结果>1个时存在该字段。 |
CellExtraInfo
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| resultCode | 否 | Integer | 响应码。 |
| extraPosition | 否 | Location | Cell定位结果。 |
| cellDetails | 否 | List<Integer> | 表示哪些Cell参与了定位,对应请求体中Cell的index。 |
WifiExtraInfo
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| resultCode | 否 | Integer | 响应码。 |
| extraPosition | 否 | Location | Wi-Fi定位结果。 |
| macDetails | 否 | List<Integer> | 表示哪些Wi-Fi参与了定位,对应请求体中Wi-Fi的index。 |
Site
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| siteId | 是 | String | 地点的唯一主键。 |
| name | 否 | String | 地点名称。 |
| formatAddress | 是 | String | 格式化的地点详细地址。 |
| aoiFlag | 否 | boolean | 如果地点是AOI数据(带有面属性的POI数据),则该字段标识为true。 |
| address | 是 | AddressDetail | 地址详细信息。 |
| location | 否 | Coordinate | 地点的经纬度。 |
| viewport | 否 | CoordinateBounds | 地点的视口范围。 |
| poi | 否 | Poi | 如果地点是POI类型,返回POI信息。 |
AddressDetail
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| countryCode | 否 | String | 国家/地区码,采用ISO 3166-1 alpha-2。 |
| country | 否 | String | 国家名。 |
| adminArea | 否 | String | 国家下面的一级行政区,一般是省/州。 |
| subAdminArea | 否 | String | 国家下面的二级行政区,一般是市。 |
| tertiaryAdminArea | 否 | String | 国家下面的三级行政区。 |
| city | 否 | String | 城市,推荐使用city。 |
| locality | 否 | String | 城市。 |
| subLocality | 否 | String | 区/县。 |
| streetNumber | 否 | String | 街道号。 |
| thoroughfare | 否 | String | 街道名。 |
| postalCode | 否 | String | 邮政编码。 |
Corrdinate
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| lat | 是 | double | 纬度,取值范围:[-90, 90]。 |
| lng | 是 | double | 经度,取值范围:[-180, 180]。 |
CorrdinateBounds
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| northeast | 是 | Coordinate | 东北角的位置。 |
| southwest | 是 | Coordinate | 西南角的位置。 |
Poi
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| poiTypes | 是 | String[] | POI类型。 |
| hwPoiTypes | 是 | String[] | 华为POI分类体系,取值范围请参见HwLocationType。 |
| phone | 否 | String | 电话号码。 |
| internationalPhone | 否 | String | 国际电话号码。 |
| rating | 否 | double | 评分。 |
| websiteUrl | 否 | String | 网址。 |
| openingHours | 否 | OpeningHours | 营业时间。 |
| photoUrls | 否 | String[] | 图片地址。 图片存在小,中,大三种规格,通过拼接后缀访问,拼接示例:photoUrl/small.jpg。
|
| childrenNodes | 否 | ChildrenNode[] | POI的子节点信息。 |
| icon | 否 | String | POI图标地址。 |
| comments | 否 | POI的评论信息。 |
OpeningHours
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| texts | 是 | String[] | 每个星期的开放时间段的描述。 |
| periods | 是 | Period[] | 开放时间段的详细说明。 |
Period
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| open | 是 | TimeOfWeek | 开放时间。 |
| close | 否 | TimeOfWeek | 关闭时间。 |
TimeOfWeek
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| week | 是 | int |
|
| time | 是 | String | 24小时制时间,hhmm格式。 |
ChildrenNode
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| siteId | 是 | String | 位置ID。 |
| name | 是 | String | 地点名称。 |
| formatAddress | 是 | String | 格式化的地点详细地址。 |
| location | 是 | Coordinate | 地点的经纬度。 |
| hwPoiTypes | 是 | String[] | 华为分类体系。 |
| domeAndInt | 否 | String | 航站楼的国内/国际信息,取值包括:
|
| depAndArr | 否 | String | 航站楼的出发/到达信息,取值包括:
|
Comment
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| starInfo | 否 | StarInfo | 评分统计信息。 |
| commentInfo | 否 | CommentInfo | 评论信息。 |
StarInfo
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| averageRating | 否 | String | 平均分。 |
CommentInfo
| 参数 | 是否必选 | 类型 | 说明 |
|---|---|---|---|
| total | 否 | int | 总数。 |
- POST /networklocation/v1/geoLocation HTTPS/1.1
- Authorization: ***
- Content-Type: application/json
- {
- "indoor": 1,
- "errorCode": "0",
- "position": {
- "acc": 2.0327091,
- "bearing": 0.0,
- "floorAcc": 100,
- "flags": 17,
- "lon": 113.86621853300373,
- "speed": 0.0,
- "buildingId": "0113866338022881255",
- "mode": 0,
- "time": 21002864090,
- "floor": 1,
- "indoorFlag": 0,
- "lat": 22.880871929243877
- },
- "locateType": "Wifi",
- "extraInfo": {
- "indoorGlobalLocation": {
- "acc": 2.0327091,
- "floorAcc": 100,
- "flags": 0,
- "lon": 113.86621853300373,
- "buildingId": "0113866338022881255",
- "mode": 0,
- "time": 21002864090,
- "floor": 1,
- "lat": 22.880871929243877
- },
- "optionalLocation": [
- {
- "acc": 28.174469,
- "lon": 113.86617278408688,
- "locateType": "Wifi",
- "mode": 0,
- "lat": 22.88106407226497
- }
- ]
- },
- "sites": [
- {
- "formatAddress": "环湖路15",
- "address": {
- "country": "中国",
- "city": "东莞市",
- "countryCode": "CN",
- "tertiaryAdminArea": "松山湖",
- "adminArea": "广东省",
- "subAdminArea": "东莞市",
- "thoroughfare": "环湖路"
- },
- "viewport": {
- "southwest": {
- "lng": 113.86457594697711,
- "lat": 22.879518266794406
- },
- "northeast": {
- "lng": 113.86733685302289,
- "lat": 22.88206193320559
- }
- },
- "name": "华为溪流背坡村A区A4栋",
- "aoiFlag": false,
- "siteId": "542350318413311232",
- "location": {
- "lng": 113.8659564,
- "lat": 22.8807901
- },
- "poi": {
- "hwPoiTypes": [
- "COMMERCIAL_BUILDING"
- ],
- "rating": 0.0,
- "icon": "https://contentcenter-drcn.dbankcdn.com/pub_1/HuaweiMaps_camp_0_9/36/v3/WCMal0QwQzm1zkJrnlpFOA/Large_Building.png",
- "internationalPhone": "",
- "poiTypes": [
- "POINT_OF_INTEREST"
- ]
- }
- }
- ]
- "errorMsg": "Success"
- }