We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesSite KitRESTPlace SearchAutocomplete

Autocomplete

Function

Returns a list of suggested places based on the entered keyword.

Restrictions

A maximum of 5 records can be returned.

Prototype

Protocol

HTTPS POST

Direction

Your server -> Map Kit server

URL

https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete?key=API KEY

NOTE
  1. For details about API KEY, please refer to Obtaining the API Key.
  2. You can use the API key in either of the following ways:

    2.1 Concatenating it into the URL: Call the URLEncoder.encode("Your API key", "UTF-8") method to encode the API key using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

    2.2 Placing it in the header: Refer to the Authorization field in Request Header. This way is recommended.

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request Parameters

Request Header

Expand

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

Expand

Parameter

Mandatory

Type

Description

query

Yes

String(<=512)

Search keyword.

location

No

Coordinate

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.

NOTICE

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.

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. POST https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete?key=
    API KEY
    HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5. "query": "
    hotel
    ",
  6. "location": {
  7. "lng":
    10.252502
    ,
  8. "lat":
    43.8739168
  9. },
  10. "language": "
    en
    ",
  11. "children":
    true
  12. }

Response Parameters

When the status code is 200:

Response Header

Expand

Parameter

Mandatory

Type

Description

Content-Type

Yes

application/json

Data format of a response.

Response Body

Expand

Parameter

Type

Description

returnCode

String

Result code. For details, please refer to Result Codes.

returnDesc

String

Result description.

predictions

AutocompletePrediction[]

Predicted place returned upon a successful search.

sites

Site[]

Autocomplete result returned upon a successful search.

Response Example

When the status code is 200:

Collapse
Word wrap
Dark theme
Copy code
  1. HTTP/1.1 200 OK
  2. Content-type: application/json
  3. {
  4. "returnCode": "0",
  5. "sites": [
  6. {
  7. "formatAddress": "Italy",
  8. "address": {
  9. "country": "Italy",
  10. "countryCode": "IT",
  11. "tertiaryAdminArea": "Viareggio",
  12. "postalCode": "55049",
  13. "adminArea": "Tuscany",
  14. "subAdminArea": "Lucca"
  15. },
  16. "distance": 943.2695317001346,
  17. "poi": {
  18. "hwPoiTypes": [
  19. "HOTEL"
  20. ],
  21. "photoUrls": [
  22. "https://dimg04.c-ctrip.com/images//220k0g0000007y0znCDE8_R_550_412.jpg",
  23. "https://dimg04.c-ctrip.com/images//22010g0000007y14h1E5D_R_550_412.jpg",
  24. "https://dimg04.c-ctrip.com/images//220l0z000000musza4484_R_550_412.jpg",
  25. "https://dimg04.c-ctrip.com/images//220g10000000p5jlyB20C_R_550_412.jpg",
  26. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M08/71/E3/CghzfFU7USaAXBaOAACQ77IUMG4744_R_550_412.jpg",
  27. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M08/74/E5/CghzgVU7USyAchhGAACvT8d5Q-0703_R_550_412.jpg",
  28. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M0B/68/BD/CghzfFVv8miAHpsbAABqFVlKrcY825_R_550_412.jpg",
  29. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M04/70/E7/CghzfVU7USOAIJ_nAACJRuKP4Q8893_R_550_412.jpg",
  30. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M03/75/C9/Cghzf1U7UMWAB-wKAABubfEqXMM695_R_550_412.jpg",
  31. "https://dimg04.c-ctrip.com/images//220g0g0000007xyxm677B_R_550_412.jpg",
  32. "https://dimg04.c-ctrip.com/images//220w0z000000n0o9y49DC_R_550_412.jpg",
  33. "https://dimg04.c-ctrip.com/images//220n180000014r4ez3166_R_550_412.jpg",
  34. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M06/4F/08/CghzflU7USiABglKAACLZBqC-qA929_R_550_412.jpg",
  35. "https://dimg04.c-ctrip.com/images//220q10000000oc3oxBE8A_R_550_412.jpg",
  36. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M03/4F/03/CghzflU7UROAReX8AADYuP9-ITM395_R_550_412.jpg",
  37. "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M09/4F/08/CghzflU7USqAUghlAABuFPsUudY020_R_550_412.jpg"
  38. ],
  39. "comments": {
  40. "commentInfo": {},
  41. "starInfo": {
  42. "averageRating": "3.9"
  43. }
  44. },
  45. "rating": 0.0,
  46. "icon": "https://lfcontentcenterdev.hwcloudtest.cn/pub_1/HuaweiMaps_camp_0_9/d6/v3/rBa78SNCTHaXf5E79CiImw/Lodging.png",
  47. "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.",
  48. "internationalPhone": "+390584962353",
  49. "pictures": [
  50. {
  51. "pictureId": "1",
  52. "pictureUrl": "https://dimg04.c-ctrip.com/images//220k0g0000007y0znCDE8_R_550_412.jpg",
  53. "pictureName": "Hotel Exterior",
  54. "source": "TRIP"
  55. },
  56. {
  57. "pictureId": "1",
  58. "pictureUrl": "https://dimg04.c-ctrip.com/images//22010g0000007y14h1E5D_R_550_412.jpg",
  59. "pictureName": "Hotel Exterior",
  60. "source": "TRIP"
  61. },
  62. {
  63. "pictureId": "2",
  64. "pictureUrl": "https://dimg04.c-ctrip.com/images//220l0z000000musza4484_R_550_412.jpg",
  65. "pictureName": "Hotel Interior/Public Areas",
  66. "source": "TRIP"
  67. },
  68. {
  69. "pictureId": "2",
  70. "pictureUrl": "https://dimg04.c-ctrip.com/images//220g10000000p5jlyB20C_R_550_412.jpg",
  71. "pictureName": "Hotel Interior/Public Areas",
  72. "source": "TRIP"
  73. },
  74. {
  75. "pictureId": "2",
  76. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M08/71/E3/CghzfFU7USaAXBaOAACQ77IUMG4744_R_550_412.jpg",
  77. "pictureName": "Hotel Interior/Public Areas",
  78. "source": "TRIP"
  79. },
  80. {
  81. "pictureId": "2",
  82. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M08/74/E5/CghzgVU7USyAchhGAACvT8d5Q-0703_R_550_412.jpg",
  83. "pictureName": "Hotel Interior/Public Areas",
  84. "source": "TRIP"
  85. },
  86. {
  87. "pictureId": "2",
  88. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M0B/68/BD/CghzfFVv8miAHpsbAABqFVlKrcY825_R_550_412.jpg",
  89. "pictureName": "Hotel Interior/Public Areas",
  90. "source": "TRIP"
  91. },
  92. {
  93. "pictureId": "2",
  94. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M04/70/E7/CghzfVU7USOAIJ_nAACJRuKP4Q8893_R_550_412.jpg",
  95. "pictureName": "Hotel Interior/Public Areas",
  96. "source": "TRIP"
  97. },
  98. {
  99. "pictureId": "2",
  100. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g2/M03/75/C9/Cghzf1U7UMWAB-wKAABubfEqXMM695_R_550_412.jpg",
  101. "pictureName": "Hotel Interior/Public Areas",
  102. "source": "TRIP"
  103. },
  104. {
  105. "pictureId": "2",
  106. "pictureUrl": "https://dimg04.c-ctrip.com/images//220g0g0000007xyxm677B_R_550_412.jpg",
  107. "pictureName": "Hotel Interior/Public Areas",
  108. "source": "TRIP"
  109. },
  110. {
  111. "pictureId": "5",
  112. "pictureUrl": "https://dimg04.c-ctrip.com/images//220w0z000000n0o9y49DC_R_550_412.jpg",
  113. "pictureName": "Others",
  114. "source": "TRIP"
  115. },
  116. {
  117. "pictureId": "5",
  118. "pictureUrl": "https://dimg04.c-ctrip.com/images//220n180000014r4ez3166_R_550_412.jpg",
  119. "pictureName": "Others",
  120. "source": "TRIP"
  121. },
  122. {
  123. "pictureId": "5",
  124. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M06/4F/08/CghzflU7USiABglKAACLZBqC-qA929_R_550_412.jpg",
  125. "pictureName": "Others",
  126. "source": "TRIP"
  127. },
  128. {
  129. "pictureId": "5",
  130. "pictureUrl": "https://dimg04.c-ctrip.com/images//220q10000000oc3oxBE8A_R_550_412.jpg",
  131. "pictureName": "Others",
  132. "source": "TRIP"
  133. },
  134. {
  135. "pictureId": "5",
  136. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M03/4F/03/CghzflU7UROAReX8AADYuP9-ITM395_R_550_412.jpg",
  137. "pictureName": "Others",
  138. "source": "TRIP"
  139. },
  140. {
  141. "pictureId": "5",
  142. "pictureUrl": "https://dimg04.c-ctrip.com/images//fd/hotelintl/g1/M09/4F/08/CghzflU7USqAUghlAABuFPsUudY020_R_550_412.jpg",
  143. "pictureName": "Others",
  144. "source": "TRIP"
  145. }
  146. ],
  147. "poiTypes": [
  148. "LODGING"
  149. ],
  150. "phone": "+390584962353",
  151. "childrenNodes": []
  152. },
  153. "name": "Hotel Stella Del Mare",
  154. "prediction": {
  155. "matchedKeywords": [
  156. {
  157. "offset": 0,
  158. "value": "Hotel"
  159. }
  160. ],
  161. "description": "Hotel Stella Del Mare Italy",
  162. "matchedWords": [
  163. {
  164. "offset": 0,
  165. "value": "Hotel Stella Del Mare"
  166. },
  167. {
  168. "offset": 22,
  169. "value": "Italy"
  170. }
  171. ]
  172. },
  173. "siteId": "192596846338646656",
  174. "location": {
  175. "lng": 10.241,
  176. "lat": 43.87217
  177. }
  178. },
  179. {
  180. "formatAddress": "Massimo d'Azeglio, Tuscany, Italy",
  181. "address": {
  182. "country": "Italy",
  183. "streetNumber": "20",
  184. "countryCode": "IT",
  185. "tertiaryAdminArea": "Viareggio",
  186. "postalCode": "55049",
  187. "locality": "Tuscany",
  188. "adminArea": "Tuscany",
  189. "subAdminArea": "Lucca",
  190. "thoroughfare": "Massimo d'Azeglio"
  191. },
  192. "distance": 921.8099108299633,
  193. "poi": {
  194. "hwPoiTypes": [
  195. "HOTEL"
  196. ],
  197. "comments": {
  198. "commentInfo": {},
  199. "starInfo": {
  200. "averageRating": "0.0"
  201. }
  202. },
  203. "rating": 0.0,
  204. "icon": "https://lfcontentcenterdev.hwcloudtest.cn/pub_1/HuaweiMaps_camp_0_9/d6/v3/rBa78SNCTHaXf5E79CiImw/Lodging.png",
  205. "internationalPhone": "+39058445295",
  206. "poiTypes": [
  207. "LODGING"
  208. ],
  209. "phone": "+39058445295",
  210. "childrenNodes": []
  211. },
  212. "name": "Hotel Liridi Viareggio",
  213. "prediction": {
  214. "matchedKeywords": [
  215. {
  216. "offset": 0,
  217. "value": "Hotel"
  218. }
  219. ],
  220. "description": "Hotel Liridi Viareggio Massimo d'Azeglio, Tuscany, Italy",
  221. "matchedWords": [
  222. {
  223. "offset": 0,
  224. "value": "Hotel Liridi Viareggio"
  225. },
  226. {
  227. "offset": 23,
  228. "value": "Massimo d'Azeglio"
  229. },
  230. {
  231. "offset": 42,
  232. "value": "Tuscany"
  233. },
  234. {
  235. "offset": 51,
  236. "value": "Italy"
  237. }
  238. ]
  239. },
  240. "siteId": "455000046945832704",
  241. "location": {
  242. "lng": 10.24448,
  243. "lat": 43.86799
  244. }
  245. }
  246. ],
  247. "returnDesc": "OK",
  248. "predictions": [
  249. {
  250. "matchedKeywords": [
  251. {
  252. "offset": 0,
  253. "value": "hotel"
  254. }
  255. ],
  256. "description": "hotel",
  257. "matchedWords": [
  258. {
  259. "offset": 0,
  260. "value": "hotel"
  261. }
  262. ]
  263. },
  264. {
  265. "matchedKeywords": [
  266. {
  267. "offset": 0,
  268. "value": "hotel"
  269. }
  270. ],
  271. "description": "hotell",
  272. "matchedWords": [
  273. {
  274. "offset": 0,
  275. "value": "hotell"
  276. }
  277. ]
  278. },
  279. {
  280. "matchedKeywords": [
  281. {
  282. "offset": 0,
  283. "value": "hotel"
  284. }
  285. ],
  286. "description": "hotelli",
  287. "matchedWords": [
  288. {
  289. "offset": 0,
  290. "value": "hotelli"
  291. }
  292. ]
  293. }
  294. ]
  295. }

Call Example

Collapse
Word wrap
Dark theme
Copy code
  1. public class PlaceSearchService {
  2. public static final String ROOT_URL = "https://siteapi.cloud.huawei.com/mapApi/v1/siteService/queryAutoComplete";
  3. public static final String connection = "?key=";
  4. public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
  5. public static void queryAutoComplete(String apiKey) throws UnsupportedEncodingException {
  6. JSONObject json = new JSONObject();
  7. JSONObject location = new JSONObject();
  8. try {
  9. location.put("lng",
    2.4444
    );
  10. location.put("lat",
    48.8815
    );
  11. json.put("query", "
    hotel
    ");
  12. json.put("location", location);
  13. json.put("radius",
    10000
    );
  14. } catch (JSONException e) {
  15. Log.e("error", e.getMessage());
  16. }
  17. RequestBody body = RequestBody.create(JSON, String.valueOf(json));
  18. OkHttpClient client = new OkHttpClient();
  19. Request request =
  20. new Request.Builder().url(ROOT_URL + connection + URLEncoder.encode(apiKey, "UTF-8"))
  21. .post(body)
  22. .build();
  23. client.newCall(request).enqueue(new Callback() {
  24. @Override
  25. public void onFailure(Call call, IOException e) {
  26. Log.e("QueryAutoComplete", e.toString());
  27. }
  28. @Override
  29. public void onResponse(Call call, Response response) throws IOException {
  30. Log.d("QueryAutoComplete", response.body().string());
  31. }
  32. });
  33. }
  34. }
Search in References
Enter a keyword.