目录

正地理编码

1. 使用样例

请求消息:

  1. POST https://siteapi.cloud.huawei.com/mapApi/v1/siteService/geocode?key=API KEY   HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "address": "Cleary Garden,Queen Victoria St,London",
  6.    "bounds": {
  7.        "northeast": {
  8.            "lng": "-0.0953",
  9.            "lat": "51.512"
  10.        },
  11.        "southwest": {
  12.            "lng": "-1.0953",
  13.            "lat": "50.512"
  14.        }
  15.    },
  16.    "language": "en",
  17.    "politicalView": "EN"
  18. }

响应消息:

  1. {
  2.    "returnCode": "0",
  3.    "sites": [
  4.        {
  5.            "formatAddress": "Queen Victoria Street, City of London, London, England, EC4V 4, the United Kingdom",
  6.            "address": {
  7.                "country": "the United Kingdom",
  8.                "countryCode": "GB",
  9.                "locality": "City of London",
  10.                "adminArea": "England",
  11.                "subAdminArea": "London",
  12.                "thoroughfare": "Queen Victoria Street",
  13.                "postalCode": "EC4V 4"
  14.            },
  15.            "viewport": {
  16.                "southwest": {
  17.                    "lng": -0.096741,
  18.                    "lat": 51.5107041
  19.                },
  20.                "northeast": {
  21.                    "lng": -0.0939118,
  22.                    "lat": 51.5132477
  23.                }
  24.            },
  25.            "name": "Cleary Garden",
  26.            "siteId": "2BAB93BEA76683B5178A744F287C7D93",
  27.            "location": {
  28.                "lng": -0.0953263,
  29.                "lat": 51.511976
  30.            }
  31.        },
  32.        {
  33.            "formatAddress": "Queen Victoria Street, City of London, London, England, the United Kingdom",
  34.            "address": {
  35.                "country": "the United Kingdom",
  36.                "countryCode": "GB",
  37.                "locality": "City of London",
  38.                "adminArea": "England",
  39.                "subAdminArea": "London",
  40.                "thoroughfare": "Queen Victoria Street"
  41.            },
  42.            "viewport": {
  43.                "southwest": {
  44.                    "lng": -0.0931563,
  45.                    "lat": 51.5116538
  46.                },
  47.                "northeast": {
  48.                    "lng": -0.0903271,
  49.                    "lat": 51.5141974
  50.                }
  51.            },
  52.            "name": "City of London, Bank Station Queen Victoria Street",
  53.            "siteId": "653ED37CEC70F1C898664B606E83923F",
  54.            "location": {
  55.                "lng": -0.0917416,
  56.                "lat": 51.5129256
  57.            }
  58.        },
  59.        {
  60.            "formatAddress": "Queen Victoria Street, City of London, London, England, the United Kingdom",
  61.            "address": {
  62.                "country": "the United Kingdom",
  63.                "countryCode": "GB",
  64.                "locality": "City of London",
  65.                "adminArea": "England",
  66.                "subAdminArea": "London",
  67.                "thoroughfare": "Queen Victoria Street",
  68.                "postalCode": "EC4V 4"
  69.            },
  70.            "viewport": {
  71.                "southwest": {
  72.                    "lng": -0.0925221,
  73.                    "lat": 51.5116525
  74.                },
  75.                "northeast": {
  76.                    "lng": -0.0896929,
  77.                    "lat": 51.5141961
  78.                }
  79.            },
  80.            "name": "City of London, Bank Station Queen Victoria Street",
  81.            "siteId": "B8A8BE102AF230D836F5FE9F3B86D88E",
  82.            "location": {
  83.                "lng": -0.0911075,
  84.                "lat": 51.5129243
  85.            }
  86.        },
  87.        {
  88.            "formatAddress": "Melbourne CBD, Melbourne, Ciudad Victoria, 3000, Australia",
  89.            "address": {
  90.                "country": "Australia",
  91.                "countryCode": "AU",
  92.                "subLocality": "Melbourne CBD",
  93.                "adminArea": "Victoria",
  94.                "subAdminArea": "Melbourne",
  95.                "postalCode": "3000"
  96.            },
  97.            "viewport": {
  98.                "southwest": {
  99.                    "lng": 144.968429,
  100.                    "lat": -37.8235692
  101.                },
  102.                "northeast": {
  103.                    "lng": 144.9722822,
  104.                    "lat": -37.8210256
  105.                }
  106.            },
  107.            "name": "Queen Victoria Gardens",
  108.            "siteId": "BC89FA4C95E190C0EC7FE7384EB3C8BD",
  109.            "location": {
  110.                "lng": 144.9703557,
  111.                "lat": -37.82229739999999
  112.            }
  113.        },
  114.        {
  115.            "formatAddress": "the United Kingdom",
  116.            "address": {
  117.                "country": "the United Kingdom",
  118.                "countryCode": "GB"
  119.            },
  120.            "viewport": {
  121.                "southwest": {
  122.                    "lng": -1.7055477,
  123.                    "lat": 51.9927943
  124.                },
  125.                "northeast": {
  126.                    "lng": -1.7022272,
  127.                    "lat": 51.994558
  128.                }
  129.            },
  130.            "name": "Queen Victoria's Garden",
  131.            "siteId": "E54BB0D3B4F253114574E00343E19072",
  132.            "location": {
  133.                "lng": -1.704096748253849,
  134.                "lat": 51.99367615
  135.            }
  136.        },
  137.        {
  138.            "formatAddress": "46th St, Sunnyside Gardens, Queens, New York, United States",
  139.            "address": {
  140.                "country": "United States",
  141.                "countryCode": "US",
  142.                "locality": "Sunnyside Gardens",
  143.                "adminArea": "New York",
  144.                "subAdminArea": "Queens",
  145.                "thoroughfare": "46th St"
  146.            },
  147.            "viewport": {
  148.                "southwest": {
  149.                    "lng": -73.9201214,
  150.                    "lat": 40.7465061
  151.                },
  152.                "northeast": {
  153.                    "lng": -73.9165448,
  154.                    "lat": 40.7490497
  155.                }
  156.            },
  157.            "name": "Sunnyside Gardens",
  158.            "siteId": "787EE94944ABB25B3AA8FCD567388F06",
  159.            "location": {
  160.                "lng": -73.918333,
  161.                "lat": 40.747778
  162.            }
  163.        },
  164.        {
  165.            "formatAddress": "13432, 217Th St, Springfield Gardens, Queens, New York, 11413, United States",
  166.            "address": {
  167.                "country": "United States",
  168.                "countryCode": "US",
  169.                "locality": "Springfield Gardens",
  170.                "adminArea": "New York",
  171.                "subAdminArea": "Queens",
  172.                "thoroughfare": "217Th St"
  173.                "streetNumber": "13432",
  174.                "postalCode": "11413"
  175.            },
  176.            "viewport": {
  177.                "southwest": {
  178.                    "lng": -73.7546834,
  179.                    "lat": 40.6780572
  180.                },
  181.                "northeast": {
  182.                    "lng": -73.7511008,
  183.                    "lat": 40.6806008
  184.                }
  185.            },
  186.            "name": "Merrick Gardens",
  187.            "siteId": "F4C51AA79346BA67256C6D265AB91C7B",
  188.            "location": {
  189.                "lng": -73.752892,
  190.                "lat": 40.67932900000001
  191.            }
  192.        },
  193.        {
  194.            "formatAddress": "14686, 181St St, Springfield Gardens, Queens, New York, 11413, United States",
  195.            "address": {
  196.                "country": "United States",
  197.                "countryCode": "US",
  198.                "locality": "Springfield Gardens",
  199.                "adminArea": "New York",
  200.                "subAdminArea": "Queens",
  201.                "thoroughfare": "181St St",
  202.                "streetNumber": "14686",
  203.                "postalCode": "11413"
  204.            },
  205.            "viewport": {
  206.                "southwest": {
  207.                    "lng": -73.7681175,
  208.                    "lat": 40.6593721
  209.                },
  210.                "northeast": {
  211.                    "lng": -73.7645333,
  212.                    "lat": 40.6619157
  213.                }
  214.            },
  215.            "name": "Garden Winser",
  216.            "siteId": "6C4CF26FAD3838D5A2A5180F757F7DF4",
  217.            "location": {
  218.                "lng": -73.7663254,
  219.                "lat": 40.660644
  220.            }
  221.        },
  222.        {
  223.            "formatAddress": "77th St, Garden Bay Manor, Queens, New York, United States",
  224.            "address": {
  225.                "country": "United States",
  226.                "countryCode": "US",
  227.                "locality": "Garden Bay Manor",
  228.                "adminArea": "New York",
  229.                "subAdminArea": "Queens",
  230.                "thoroughfare": "77th St"
  231.            },
  232.            "viewport": {
  233.                "southwest": {
  234.                    "lng": -73.8944874,
  235.                    "lat": 40.7682282
  236.                },
  237.                "northeast": {
  238.                    "lng": -73.8909128,
  239.                    "lat": 40.7707718
  240.                }
  241.            },
  242.            "name": "Garden Bay Manor",
  243.            "siteId": "6A8D838C5DA2AB678B4A01D003FC2130",
  244.            "location": {
  245.                "lng": -73.8927,
  246.                "lat": 40.7695
  247.            }
  248.        },
  249.        {
  250.            "formatAddress": "13604, 220th St, Springfield Gardens, Queens, New York, 11413, United States",
  251.            "address": {
  252.                "country": "United States",
  253.                "countryCode": "US",
  254.                "locality": "Springfield Gardens",
  255.                "adminArea": "New York",
  256.                "subAdminArea": "Queens",
  257.                "thoroughfare": "220th St",
  258.                "streetNumber": "13604",
  259.                "postalCode": "11413"
  260.            },
  261.            "viewport": {
  262.                "southwest": {
  263.                    "lng": -73.7531415,
  264.                    "lat": 40.6753222
  265.                },
  266.                "northeast": {
  267.                    "lng": -73.7495587,
  268.                    "lat": 40.6778658
  269.                }
  270.            },
  271.            "name": "Lifespire Springfield Gardens",
  272.            "siteId": "72980C86D13DC668C870AFE69735E049",
  273.            "location": {
  274.                "lng": -73.75135,
  275.                "lat": 40.676594
  276.            }
  277.        }
  278.    ],
  279.    "returnDesc": "OK"
  280. }

2. 请求参数

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


注意:
使用API KEY需要进行encodeURI编码。例如:原始API KEY:ABC/DFG+ ,转换结果:ABC%2FDFG%2B。


参数名称

必选(M)/可选(O)

参数类型

参数说明

address

M

String(<=512)

地点信息。

bounds

O

CoordinateBounds

查询结果偏向的搜索范围。

language

O

String(<=6)

搜索结果的语种。如果不传,使用地点的当地语言。

语种取值请参考语种映射列表。

politicalViewOString(=2)政治观点参数,采用ISO 3166-1-alpha-2规范的2位国家码。

3. 返回参数

参数名称

必选(M)/可选(O)

参数类型

参数说明

returnCode

M

String

返回码,具体请参考“返回码”。

returnDesc

O

String

返回值描述。

sites

O

Site[]

如果查询成功,返回搜索结果。如果没有结果,返回空数组。

注意Site对象不返回POI信息。

逆地理编码

1. 使用样例

 请求消息:

  1. POST https://siteapi.cloud.huawei.com/mapApi/v1/siteService/reverseGeocode?key=API KEY   HTTP/1.1  
  2. Content-Type: application/json  
  3. Accept: application/json  
  4. {
  5.    "location": {
  6.        "lng": 77.2155,
  7.        "lat": 18.0527
  8.    },
  9.    "language": "en",
  10.    "politicalView": "CN",
  11.    "returnPoi": true
  12. }

 响应消息:

  1. {
  2.    "returnCode": "0",
  3.    "sites": [
  4.        {
  5.            "formatAddress": "Bhalki, Bidar, Karnataka, India",
  6.            "address": {
  7.                "country": "India",
  8.                "countryCode": "IN",
  9.                "locality": "Bhalki",
  10.                "adminArea": "Karnataka",
  11.                "subAdminArea": "Bidar"
  12.            },
  13.            "viewport": {
  14.                "southwest": {
  15.                    "lng": 77.21601340436659,
  16.                    "lat": 18.047203360252986
  17.                },
  18.                "northeast": {
  19.                    "lng": 77.21979263425037,
  20.                    "lat": 18.050796621388685
  21.                }
  22.            },
  23.            "name": "",
  24.            "siteId": "0BC2A43E59A2433F058836FED1CFEA50",
  25.            "location": {
  26.                "lng": 77.217903,
  27.                "lat": 18.049
  28.            }
  29.        },
  30.        {
  31.            "formatAddress": "Bidar, Karnataka, India",
  32.            "address": {
  33.                "country": "India",
  34.                "countryCode": "IN",
  35.                "adminArea": "Karnataka",
  36.                "subAdminArea": "Bidar"
  37.            },
  38.            "viewport": {
  39.                "southwest": {
  40.                    "lng": 77.24675971115403,
  41.                    "lat": 18.019168660268228
  42.                },
  43.                "northeast": {
  44.                    "lng": 77.25053833900586,
  45.                    "lat": 18.022761921403927
  46.                }
  47.            },
  48.            "name": "",
  49.            "siteId": "2444F4ABC13BEEFDA1AC75CD9BD3FD44",
  50.            "location": {
  51.                "lng": 77.2486490058066,
  52.                "lat": 18.0209653
  53.            }
  54.        },
  55.        {
  56.            "formatAddress": "Karnataka, India",
  57.            "address": {
  58.                "country": "India",
  59.                "countryCode": "IN",
  60.                "adminArea": "Karnataka"
  61.            },
  62.            "viewport": {
  63.                "southwest": {
  64.                    "lng": 76.16582923864172,
  65.                    "lat": 14.708474755022333
  66.                },
  67.                "northeast": {
  68.                    "lng": 76.1695442701685,
  69.                    "lat": 14.712068016158103
  70.                }
  71.            },
  72.            "name": "",
  73.            "siteId": "76633A6DA68C893C9AE654C7FF506F97",
  74.            "location": {
  75.                "lng": 76.16768673911331,
  76.                "lat": 14.7102713929855
  77.            }
  78.        },
  79.        {
  80.            "formatAddress": "India",
  81.            "address": {
  82.                "country": "India",
  83.                "countryCode": "IN"
  84.            },
  85.            "viewport": {
  86.                "southwest": {
  87.                    "lng": 79.5577310167445,
  88.                    "lat": 22.57606210771953
  89.                },
  90.                "northeast": {
  91.                    "lng": 79.56162252858664,
  92.                    "lat": 22.579655368855118
  93.                }
  94.            },
  95.            "name": "",
  96.            "siteId": "A44719C2043653BB06204386B976C7BC",
  97.            "location": {
  98.                "lng": 79.55967674729584,
  99.                "lat": 22.57785875
  100.            }
  101.        }
  102.    ],
  103.    "returnDesc": "OK"
  104. }

2. 请求参数

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


注意:
使用API KEY需要进行encodeURI编码。例如:原始API KEY:ABC/DFG+ ,转换结果:ABC%2FDFG%2B。


参数名称

必选(M)/可选(O)

参数类型

参数说明

location

M

Coordinate

经纬度。

language

O

String(<=6)

搜索结果的语种。如果不传,使用地点的当地语言。

语种取值请参考语种映射列表。

politicalViewOString(=2)政治观点参数,采用ISO 3166-1-alpha-2规范的2位国家码。
returnPoiO

boolean

是否返回POI的地点名称,默认是true。

3. 返回参数

参数名称

必选(M)/可选(O)

参数类型

参数说明

returnCode

M

String

返回码,具体请参考“返回码”。

returnDesc

O

String

返回值描述。

sites

O

Site[]

如果查询成功,返回搜索结果。如果没有结果,返回空数组。

注意:如果returnPoi是false,不返回Site的Poi对象。