Protocol | HTTPS POST |
|---|---|
Direction | Your server -> Map Kit server |
URL | https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete?key=API KEY NOTE:
|
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Request Header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Authorization | Yes | String | Service signature, which is used for authentication. The value is in Bearer+Space+API key format. Example: Bearer ABC/DFG+ |
Content-Type | Yes | application/json | Data format of a request. |
Request Body
Parameter | Mandatory | Type | Description |
|---|---|---|---|
query | Yes | String(<=512) | Search keyword. |
location | No | Longitude and latitude to which search results need to be biased. | |
radius | No | int | Search radius, in meters. The value ranges from 1 to 50,000. The default value is 50000. |
language | No | String(<=16) | Language in which search results are displayed. For details, please refer to Supported Languages. If this parameter is not passed, the local language will be used. |
politicalView | No | String(=2) | Political view. The value is a two-letter country/region code complying with ISO 3166-1 alpha-2. CAUTION: This parameter has been deprecated. |
children | No | boolean | Indicates whether to return information about child nodes. The default value is false. If this parameter is set to true, IDs of child nodes will be returned. |
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 }
When the status code is 200:
Response Header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Content-Type | Yes | application/json | Data format of a response. |
Response Body
Parameter | Type | Description |
|---|---|---|
returnCode | String | Result code. For details, please refer to Result Codes. |
returnDesc | String | Result description. |
predictions | Predicted place returned upon a successful search. | |
sites | Site[] | Autocomplete result returned upon a successful search. |
When the status code is 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());
}
});
}
}