Address Resolution and anti-Address Resolution-Baidu map API

Source: Internet
Author: User

Recently, I want to do something about the map. I simply read a few maps and found that Baidu maps are still good. Google maps are not charged. mapabc and mapbar only provide client interfaces. What is falsh? JavaScript, it seems that only Baidu map has a server interface.

Paste a demo written in Python :(

 #  Coding = UTF-8  Import  Urllib  Import  Urllib2map_api_url = '  Http://api.map.baidu.com/geocoder/v2?  '  AK = '  38dbc1cdbb8170d3f08a4db1_de55d2 '  #  Address Resolution  Def Geocoder (address, city = '  Beijing  '  ): Query_args = { '  Address  '  : Address,  '  City  '  : City, '  Output  ' : '  XML  '  ,  '  AK  '  : AK} encoded_args = Urllib. urlencode (query_args) render_url (map_api_url + Encoded_args)  #  Reverse Address Resolution Def Geodecoder (Lat, LNG, pois = 0): Location = "  % F, % F  " % (Lat, LNG) Output = '  XML  '  Query_args = '  Location = % S & aK = % S & Output = % S & pois = % d  ' %\ (Location, AK, output, pois) render_url (map_api_url + Query_args)  Def  Render_url (URL): Response = Urllib2.urlopen (URL) headers = Response.info () data = Response. Read () response. Close () show_response (headers, data)  Return  Data  Def  Show_response (headers, data ):  Print  '  Headers:  '      Print   '  ----------  '      Print  Headers  Print   '  Data:  '      Print   '  ----------  '     Print Data. Decode ( '  UTF-8  '  )  If   _ Name __ = '  _ Main __  '  : Geocoder (  '  Orange continent  ' , '  Changsha City  ' ) Lat = 28.175617295411 LNG = 112.96695042246 Geodecoder (Lat, LNG, 1)

 

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.