承载协议 | HTTPS POST |
|---|---|
接口方向 | 开发者 -> 华为地图服务器 |
接口URL | https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete?key=API KEY 说明:
|
数据格式 | 请求消息:Content-Type: application/json 响应消息:Content-Type: application/json |
Request Header
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
Authorization | 是 | String | 业务签名,用于认证鉴权,格式为:Bearer+空格+API Key。 示例:Bearer ABC/DFG+。 |
Content-Type | 是 | application/json | 请求消息的数据格式。 |
Request Body
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
query | 是 | String(<=512) | 搜索关键字。 |
location | 否 | 搜索结果偏向的经纬度。 | |
radius | 否 | int | Location的搜索半径,单位:米。取值范围:[1, 50000],默认50000米。 |
language | 否 | String(<=16) | 搜索结果返回的语言,语种取值请参见支持的语言列表。如果不传,返回地点的当地语言。 |
politicalView | 否 | String(=2) | 政治观点,采用ISO 3166-1 alpha-2规范的2位国家/地区码。 注意: 该参数已废弃。 |
children | 否 | boolean | 是否返回子节点,默认为false。传入children为true,返回子节点的siteId。 |
POST https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete?key=API KEY HTTP/1.1 Content-Type: application/json Accept: application/json { "query": "hotel", "location": { "lng": 10.252502, "lat": 43.8739168 }, "language": "en", "children": true }
状态码为200时:
Response Header
参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
Content-Type | 是 | application/json | 响应消息的数据格式。 |
Response Body
状态码为200时:
HTTP/1.1 200 OK
Content-type: application/json
{
"returnCode": "0",
"sites": [
{
"formatAddress": "Italy",
"address": {
"country": "Italy",
"countryCode": "IT",
"tertiaryAdminArea": "Viareggio",
"postalCode": "55049",
"adminArea": "Tuscany",
"subAdminArea": "Lucca"
},
"distance": 943.2695317001346,
"poi": {
"hwPoiTypes": [
"HOTEL"
],
"photoUrls": [
"https://dimg04.c-ctrip.com/images//220k0g0000007y0znCDE8_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//22010g0000007y14h1E5D_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220l0z000000musza4484_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220g10000000p5jlyB20C_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M08/71/E3/CghzfFU7USaAXBaOAACQ77IUMG4744_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M08/74/E5/CghzgVU7USyAchhGAACvT8d5Q-0703_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M0B/68/BD/CghzfFVv8miAHpsbAABqFVlKrcY825_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M04/70/E7/CghzfVU7USOAIJ_nAACJRuKP4Q8893_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M03/75/C9/Cghzf1U7UMWAB-wKAABubfEqXMM695_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220g0g0000007xyxm677B_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220w0z000000n0o9y49DC_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220n180000014r4ez3166_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M06/4F/08/CghzflU7USiABglKAACLZBqC-qA929_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//220q10000000oc3oxBE8A_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M03/4F/03/CghzflU7UROAReX8AADYuP9-ITM395_R_550_412.jpg",
"https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M09/4F/08/CghzflU7USqAUghlAABuFPsUudY020_R_550_412.jpg"
],
"comments": {
"commentInfo": {},
"starInfo": {
"averageRating": "3.9"
}
},
"rating": 0.0,
"icon": "https://lfcontentcenterdev.hwcloudtest.cn/pub_1/HuaweiMaps_camp_0_9/d6/v3/rBa78SNCTHaXf5E79CiImw/Lodging.png",
"description": "Located a few steps from Viareggio's sandy beach, Hotel Stella Del Mare is about 200 metres from the pinewood. Both Viareggio Train Station and the city centre are a 15-minute walk away.\n\nOffering free Wi-Fi, guest rooms include a TV, a private bathroom and either air conditioning or a ceiling fan. Most rooms have a balcony and some offer views of the sea.\n\nOn-site facilities at the Stella Del Mare include an inner garden and a relaxing outdoor verandah, plus a restaurant and bar. Bikes can be rented on site.\n\nThe hotel's restaurant is specialised in homemade cuisine with local fish and seafood. A breakfast buffet of sweet and savoury food is served in the restaurant hall or in the verandah.",
"internationalPhone": "+390584962353",
"pictures": [
{
"pictureId": "1",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220k0g0000007y0znCDE8_R_550_412.jpg",
"pictureName": "Hotel Exterior",
"source": "TRIP"
},
{
"pictureId": "1",
"pictureUrl": "https://dimg04.c-ctrip.com/images//22010g0000007y14h1E5D_R_550_412.jpg",
"pictureName": "Hotel Exterior",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220l0z000000musza4484_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220g10000000p5jlyB20C_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M08/71/E3/CghzfFU7USaAXBaOAACQ77IUMG4744_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M08/74/E5/CghzgVU7USyAchhGAACvT8d5Q-0703_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M0B/68/BD/CghzfFVv8miAHpsbAABqFVlKrcY825_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M04/70/E7/CghzfVU7USOAIJ_nAACJRuKP4Q8893_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M03/75/C9/Cghzf1U7UMWAB-wKAABubfEqXMM695_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "2",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220g0g0000007xyxm677B_R_550_412.jpg",
"pictureName": "Hotel Interior/Public Areas",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220w0z000000n0o9y49DC_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220n180000014r4ez3166_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M06/4F/08/CghzflU7USiABglKAACLZBqC-qA929_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//220q10000000oc3oxBE8A_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M03/4F/03/CghzflU7UROAReX8AADYuP9-ITM395_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
},
{
"pictureId": "5",
"pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M09/4F/08/CghzflU7USqAUghlAABuFPsUudY020_R_550_412.jpg",
"pictureName": "Others",
"source": "TRIP"
}
],
"poiTypes": [
"LODGING"
],
"phone": "+390584962353",
"childrenNodes": []
},
"name": "Hotel Stella Del Mare",
"prediction": {
"matchedKeywords": [
{
"offset": 0,
"value": "Hotel"
}
],
"description": "Hotel Stella Del Mare Italy",
"matchedWords": [
{
"offset": 0,
"value": "Hotel Stella Del Mare"
},
{
"offset": 22,
"value": "Italy"
}
]
},
"siteId": "192596846338646656",
"location": {
"lng": 10.241,
"lat": 43.87217
}
},
{
"formatAddress": "Massimo d'Azeglio, Tuscany, Italy",
"address": {
"country": "Italy",
"streetNumber": "20",
"countryCode": "IT",
"tertiaryAdminArea": "Viareggio",
"postalCode": "55049",
"locality": "Tuscany",
"adminArea": "Tuscany",
"subAdminArea": "Lucca",
"thoroughfare": "Massimo d'Azeglio"
},
"distance": 921.8099108299633,
"poi": {
"hwPoiTypes": [
"HOTEL"
],
"comments": {
"commentInfo": {},
"starInfo": {
"averageRating": "0.0"
}
},
"rating": 0.0,
"icon": "https://lfcontentcenterdev.hwcloudtest.cn/pub_1/HuaweiMaps_camp_0_9/d6/v3/rBa78SNCTHaXf5E79CiImw/Lodging.png",
"internationalPhone": "+39058445295",
"poiTypes": [
"LODGING"
],
"phone": "+39058445295",
"childrenNodes": []
},
"name": "Hotel Liridi Viareggio",
"prediction": {
"matchedKeywords": [
{
"offset": 0,
"value": "Hotel"
}
],
"description": "Hotel Liridi Viareggio Massimo d'Azeglio, Tuscany, Italy",
"matchedWords": [
{
"offset": 0,
"value": "Hotel Liridi Viareggio"
},
{
"offset": 23,
"value": "Massimo d'Azeglio"
},
{
"offset": 42,
"value": "Tuscany"
},
{
"offset": 51,
"value": "Italy"
}
]
},
"siteId": "455000046945832704",
"location": {
"lng": 10.24448,
"lat": 43.86799
}
}
],
"returnDesc": "OK",
"predictions": [
{
"matchedKeywords": [
{
"offset": 0,
"value": "hotel"
}
],
"description": "hotel",
"matchedWords": [
{
"offset": 0,
"value": "hotel"
}
]
},
{
"matchedKeywords": [
{
"offset": 0,
"value": "hotel"
}
],
"description": "hotell",
"matchedWords": [
{
"offset": 0,
"value": "hotell"
}
]
},
{
"matchedKeywords": [
{
"offset": 0,
"value": "hotel"
}
],
"description": "hotelli",
"matchedWords": [
{
"offset": 0,
"value": "hotelli"
}
]
}
]
} public class PlaceSearchService {
public static final String ROOT_URL = "https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete";
public static final String connection = "?key=";
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
public static void queryAutoComplete(String apiKey) throws UnsupportedEncodingException {
JSONObject json = new JSONObject();
JSONObject location = new JSONObject();
try {
location.put("lng", 2.4444);
location.put("lat", 48.8815);
json.put("query", "hotel");
json.put("location", location);
json.put("radius", 10000);
} catch (JSONException e) {
Log.e("error", e.getMessage());
}
RequestBody body = RequestBody.create(JSON, String.valueOf(json));
OkHttpClient client = new OkHttpClient();
Request request =
new Request.Builder().url(ROOT_URL + connection + URLEncoder.encode(apiKey, "UTF-8"))
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("QueryAutoComplete", e.toString());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
Log.d("QueryAutoComplete", response.body().string());
}
});
}
}