Baidu Maps Web Service API - Forward/Reverse Geocoding Service

The forward/reverse geocoding service (also known as Geocoding API) is a kind of Web API interface service; the
forward geocoding service provides the conversion of structured address data (such as: No. 10, Shangdi 10th Street, Haidian District, Beijing) into corresponding coordinate points (latitude and longitude) function; the
reverse geocoding service provides the function of converting coordinate points (latitude and longitude) into corresponding location information (such as the administrative division where it is located, the distribution of surrounding landmark points).

Reverse geocoding official reference link: http://api.map.baidu.com/geocoder/v2/?callback=renderReverse&location=39.934,116.329&output=json&pois=1&ak=your ak //GET request

parameter:

  1. callback: The return value in json format is returned through the callback function to realize the jsonp function. If the jsonp format is not required, it can be added.
  2. location: latitude and longitude coordinates, format - latitude, longitude.
  3. output: The output format, which can be json or xml, the default is xml.
  4. pois: When the value is 1, the poi within 1000 meters of the surrounding area is displayed by default; when it is 0, it is not displayed.
  5. ak: The key for the user to apply for Baidu developer registration, the parameter has been changed to "ak" since v2, and the parameter of the previous version was "key"  to apply for ak

Return example:

Add callback=renderReverse parameter

renderReverse&&renderReverse({"status":0,"result":{"location":{"lng":116.32899999999994,"lat":39.93400007551505},"formatted_address":"北京市海淀区增光路35-6号","business":"航天桥,甘家口,车公庄","addressComponent":{"country":"中国","country_code":0,"country_code_iso":"CHN","country_code_iso2":"CN","province":"北京市","city":"北京市","city_level":2,"district":"海淀区","town":"","adcode":"110108","street":"增光路","street_number":"35-6号","direction":"附近","distance":"13"},"pois":[],"roads":[],"poiRegions":[],"sematic_description":"8 meters near China Construction Bank (Zengguang Road Sub-branch)","cityCode":131}})

Do not add callback=renderReverse parameter

{"status":0,"result":{"location":{"lng":116.32899999999994,"lat":39.93400007551505},"formatted_address":"北京市海淀区增光路35-6号","business":"航天桥,甘家口,车公庄","addressComponent":{"country":"中国","country_code":0,"country_code_iso":"CHN","country_code_iso2":"CN","province":"北京市","city":"北京市","city_level":2,"district":"海淀区","town":"","adcode":"110108","street":"增光路","street_number":"35-6号","direction":"附近","distance":"13"},"pois":[],"roads":[],"poiRegions":[],"sematic_description":"8 meters near China Construction Bank (Zengguang Road Sub-branch)","cityCode":131}}

  • //Set the return result of sending a request to the interface link as findings, and the result can be converted into json format
  • JSONObject parseObject = JSON.parseObject(findings);
  • //Get the return result result result set, continue to convert to json format
  • JSONObject jsonObject = parseObject.getJSONObject("result");
  • //The important attributes in the example result can be obtained by key
  • jsonObject.getString("formatted_address");
  • jsonObject.getString("business");
  • jsonObject.getString("sematic_description"));

Positive geocoding is similar, simpler, and will not be detailed here.

For more details, please check the official service documentation: http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325357235&siteId=291194637