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>