According to the latitude and longitude of the city and the location to obtain latitude and longitude

Source: Internet
Author: User
Tags reserved urlencode

what is geocoding.

The Geocoding API is an HTTP form of map service interface for programmers to invoke. The main service for those non-web program calls. For example, C #, C + +, Java, and other development languages can send HTTP requests and receive returned data.

Users only need to be in the requested URL string splicing good keywords or latitude and longitude information, you can get the corresponding Baidu latitude or longitude or structured geographical information.

What functionality does the Geocoding API have?

The Geocoding API includes address resolution and inverse address resolution capabilities.

· Address resolution refers to the structure of the street from detailed to the address of the Baidu latitude and longitude information, and support sites, landmarks, the name of the direct analysis of the return of Baidu latitude and longitude. For example: "27th zhongguancun South Street, Haidian District, Beijing," The result of address resolution is "lng:116.31985,lat:39.959836", "Baidu Mansion" The result of address resolution is "lng:116.30815,lat:40.056885"

· Inverse address resolution refers to the information obtained from Baidu's latitude and longitude of the structured address. For example: "lat:31.325152,lng:120.558957" The result of the inverse address resolution is "Jiangsu province Suzhou Huqiu District Tower Park Road, No. No. 318."


Use Restrictions

There are no restrictions on use at this time. Please request key and then use this interface.

How to use

The first step, the application key, click here to obtain the key, the application key needs to register Baidu account;

The second step is to spell out the URL of the HTTP request, and note the key required to use the first step;

The third step is to receive the data returned by the HTTP request (supported in JSON and XML format).

Service Address

Service Address

· Address resolution: Get coordinates from address

http://api.map.baidu.com/geocoder?address= address &output= output format type &key= user key &city= city name

· Inverse Address Resolution: Get the address from the coordinates

http://api.map.baidu.com/geocoder?location= latitude, longitude &output= output format type &key= user key

Note:

1. City is an optional parameter, usually can not be used, if the resolution has no results, please try to increase this field.

2. Support the name of historical sites and landmarks to return Baidu latitude and longitude coordinates, such as address= "Baidu mansion."

3. Support the use of "* Road and * Road intersection" approach to return Baidu latitude and longitude coordinates, if the address library exists in this address description, return to Baidu latitude and longitude coordinates.

4. If parsing the Status field OK, if the result content is empty, reason analysis and can try method:

· There is no such data in the address library, and this result is empty.

· Add the City field to reparse;

· will be too detailed or simple to change the address to the provincial and municipal streets to be resolved;

5. Special reminder: Inverse Address Resolution location parameters passed in the parameter format is (latitude lat, longitude LNG).

Interface Parameters

Parameters

whether you must

Default Value

format Examples

meaning

Output

Whether

Json

JSON or XML

Output format is JSON or XML

Address

Is

No

No. 10th, 10 Street, Haidian District, Beijing

Anti-directional resolution of coordinates based on specified address

Location

Is

No

38.76623,116.43213
lat< Latitude >,lng< Longitude >

Address resolution based on specified coordinates

City

Whether

Beijing

"Guangzhou"

Name of the city where the address is located

Key

Is

No

8cb976834235d8cbcde2dce4835ae191

Key for user to apply for registration

The address and location two fields in the table above, if they occur at the same time, select Address to perform the geo-coding function. For the Address field may appear Chinese or some other special characters (such as: spaces), so for similar characters are encoded, encoded into a UTF-8 character of the two-character hexadecimal value, usually not in the table in the following characters are encoded.

Character Set combination

character

URL non-reserved word

A b c d e F g h i j k l m n o p q R S t u v w x y z A b c d E F g h i j k l m n o p q R S t u v w x y z 0 1 2 3 4 5 6 7 8 9-_. ~

URL reserved word

! * ' ( ) ; : @ & = + $,/? % # [ ]

Note:

(1) The encodeURIComponent function is commonly used in JavaScript to encode special characters.

(2) You can use function Urlencoder.encode to encode special characters in Java.

(3) C # can use function Httputility.urlencode to encode special characters.

(4) You can use function UrlEncode to encode special characters in PHP.

Return Data Description

return result (Result of address resolution)

{status: ' String state constant ', values are as follows:

OK success

Invilid_key illegal key

Invalid_parameters illegal parameter, parameter error time given.

Result: {

Location: {

Lat: Latitude: Numerical value,

LNG: Longitude: Numerical

},

Precise: ' Additional information on location, exact lookup ' (1 for exact lookup, 0 for imprecise lookup),

Confidence: credibility,

Level: ' Levels '

},

}

return result (result of inverse address resolution)

{status: ' String state constant ', values are as follows:

//ok Success

Invilid_key Illegal key

invalid_parameters illegal parameter, parameter error time given.

Result : {

Location: {

lat: Latitude: Numerical value,

LNG: Longitude: Numerical

 },

formatted_address: ' Detailed Address description ',

business: ' Around the Business Circle ',

addresscomponent:{

City: ' Names of cities ',

District: ' County name ',

province: ' Province name ',

Street: ' Name of the streets ',

streetnumber: ' House number '

 },

citycode: ' City Code '

 }

 }

Interface Example

get coordinates based on detailed address

http://api.map.baidu.com/geocoder?address=%e4%b8%8a%e5%9c%b0%e5%8d%81%e8%a1%9710%e5%8f%b7&output=json& key=37492c0ee6f924cb5e934fa08c6b1676

Returns the coordinates "lng:116.307175, lat:40.057098" in JSON format according to "10 Street 10th".

http://api.map.baidu.com/geocoder?address=%e4%b8%8a%e5%9c%b0%e5%8d%81%e8%a1%9710%e5%8f%b7&output=xml& key=37492c0ee6f924cb5e934fa08c6b1676

Returns the coordinates "lng:116.307175, lat:40.057098", according to "Upper 10 street Tenth", output in XML format

retrieve the coordinates of the detailed address in the specified city

http://api.map.baidu.com/geocoder?address=%e4%b8%8a%e5%9c%b0%e5%8d%81%e8%a1%9710%e5%8f%b7&output=json& key=37492c0ee6f924cb5e934fa08c6b1676&city=%e5%8c%97%e4%ba%ac%e5%b8%82

In the city of Beijing, according to "10 Street 10th," return coordinates "lng:116.307175, lat:40.057098", output in JSON format

http://api.map.baidu.com/geocoder?address=%e4%b8%8a%e5%9c%b0%e5%8d%81%e8%a1%9710%e5%8f%b7&output=xml& key=37492c0ee6f924cb5e934fa08c6b1676&city=%e5%8c%97%e4%ba%ac%e5%b8%82

In the city of Beijing, according to "10 Street 10th," return coordinates "lng:116.307175, lat:40.057098", output in JSON format

to get its coordinates from a particular building.

http://api.map.baidu.com/geocoder?address=%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6&output=json&key= 37492c0ee6f924cb5e934fa08c6b1676///According to "Baidu Mansion" name return coordinates "lng:116.307175, lat:40.057098", enter in JSON format

http://api.map.baidu.com/geocoder?address=%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6&output=xml&key= 37492c0ee6f924cb5e934fa08c6b1676///According to "Baidu Mansion" name return coordinates "lng:116.307175, lat:40.057098", enter in XML format

according to the "* Road and * Road intersection" type address description to obtain its coordinates

http://api.map.baidu.com/geocoder?address=%E5%8C%97%E4%B8%80%E7%8E%AF%E8%B7%AF%E5%92%8C%E9%98%9C%E9%98%B3%E8% b7%af%e7%9a%84%e4%ba%a4%e5%8f%89%e8%b7%af%e5%8f%a3&output=json&key=37492c0ee6f924cb5e934fa08c6b1676

According to "North and Fuyang Road intersection" name returns coordinates "lng:117.294364, lat:31.885558", entered in JSON format

http://api.map.baidu.com/geocoder?address=%E5%8C%97%E4%B8%80%E7%8E%AF%E8%B7%AF%E5%92%8C%E9%98%9C%E9%98%B3%E8% b7%af%e7%9a%84%e4%ba%a4%e5%8f%89%e8%b7%af%e5%8f%a3&output=xml&key=37492c0ee6f924cb5e934fa08c6b1676

According to "North and Fuyang Road intersection" name returns coordinates "lng:117.294364, lat:31.885558", entered in XML format

get its address based on coordinates.

http://api.map.baidu.com/geocoder?output=json&location=39.983424,%20116.322987&key= 37492c0ee6f924cb5e934fa08c6b1676

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.