Anti-Address Resolution of Baidu map (querying address information through latitude and longitude), map latitude and longitude

Source: Internet
Author: User

Anti-Address Resolution of Baidu map (querying address information through latitude and longitude), map latitude and longitude
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">

<Script type = "text/javascript" src = "./jquery-1.4.2.min.js"> </script>

<! -- The difference between the reference with and without an ak is not clear yet.

<Script type = "text/javascript" src = "http://api.map.baidu.com/api? V = 2.0 & ak = Wb3W4PL5khQp9GS6Gm6HIdW7 "> </script>

-->

<Script type = "text/javascript" src = "http://api.map.baidu.com/api? V = 3.0 "> </script>
<Script type = "text/javascript">
Function test1 (){
/// 112.881885, 28.220368
Var la = $ ("# la"). val ();
Var lo = $ ("# lo"). val ();
If (la = "" | lo = ""){
Alert ("latitude and longitude cannot be blank! ");
Return;
}
// Alert (la + "," + lo );
Var gc = new BMap. Geocoder ();
Var map = new BMap. Map ("container ");
Var pt = new BMap. Point (la, lo );
Gc. getLocation (pt, function (rs ){
Var addComp = rs. addressComponents;
Alert (addComp. province + "," + addComp. city + "," + addComp. district + "," + addComp. street + "," + addComp. streetNumber );
});
}
</Script>
</Head>
<Body>
<Center>
<Div style = "margin-top: 100px">

Test Case: longitude: 112.881885, latitude: 28.220368; Address: Hunan Province, Changsha city, Yuelu district, Gu Yuan Road, No. 186
<Br/>
Longitude: <input type = "text" id = "la" value = "112.881885"/>
Latitude: <input type = "text" id = "lo" value = "28.220368"/>
<Input type = "button" id = "test" onclick = "test1 ();" value = "Click here to get location"/>

</Div>
</Center>
</Body>
</Html>

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.