The Baidu Map Web Services API provides developers with an HTTP interface, in which the developer initiates a retrieval request via HTTP, retrieving the retrieved data in JSON or XML format. Based on this, users can develop the map application of JavaScript, C #, C + +, Java and so on.
API website Description Link:
Http://developer.baidu.com/map/webservice.htm
Available Interface enumeration:
Get related address hint place suggestion
http://api.map.baidu.com/place/v2/suggestion?query= Metasequoia ®ion= Chengdu &output=json&ak= 42b8ececa9cd6fe72ae4cddd77c0da5d
Get coordinates geocoding
http://api.map.baidu.com/geocoder?address= Jinjiang District No. 299 Ling ' an road, &output=json&key=42b8ececa9cd6fe72ae4cddd77c0da5d
http://api.map.baidu.com/place/v2/search?ak=42b8ececa9cd6fe72ae4cddd77c0da5d&output=json&query= Blu-ray Coco Sands &page_size=10&page_num=0&scope=1®ion= Chengdu
{
"Status": 0,
"Message": "OK",
"Total": 2,
"Results": [
{
"Name": "Blu-ray Coco Sands",
"Location": {
"Lat": 30.687544,
"LNG": 103.996691
},
"Address": "West three ring outside the Jinsha West Source Avenue (It Avenue)",
"UID": "223992992C5EE7E0841541DF"
},
{
"Name": "Blu-ray Coco Sands Phase 2",
"Location": {
"Lat": 30.681123,
"LNG": 103.991123
},
"Address": "Qingyang District Sands it Boulevard",
"UID": "b7bb5abb1cd4982213293580"
}
]
}
Facilities navigation
http://api.map.baidu.com/place/v2/search?ak=42b8ececa9cd6fe72ae4cddd77c0da5d&output=json&query= Library &page_size=20&page_num=0&scope=2®ion= Chengdu
The results of obtaining the coordinate interface directly in the browser request are as follows:
The C # call gets the coordinate interface code as follows:
Create a new console program
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Net;
Namespace Test
{
class program
{
Private const String Baidu_app_key = " 42B8ECECA9CD6FE72AE4CDDD77C0DA5D ";
Private Const String A = "188th Metasequoia Street";
static void Main (string[] args)
{
WebClient client = new WebClient ();
String json = client. Downloadstring ("http://api.map.baidu.com/geocoder?address=" + A + "&output=json&key=" + baidu_app_key);
Client. Encoding = Utf8encoding.utf8;
Console.WriteLine (JSON);
Console.readkey ();}}
Run Result: