Copy Code code as follows:
<title> latitude and longitude according to the address of the query </title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=1.3 "></script>
<body style= "background: #CBE1FF" >
<div style= "Width:730px;margin:auto;" >
To query the address: <input id= "Text_" type= "text" value= "Xuzhou ancient Peng Square" style= "margin-right:100px;" />
Query results (latitude and longitude): <input id= "Result_" type= "text"/>
<input type= "button" value= "Query" onclick= "Searchbystationname ();" />
<div id= "Container"
Style= "Position:absolute;
margin-top:30px;
width:730px;
height:590px;
top:50;
border:1px solid Gray;
Overflow:hidden; " >
</div>
</div>
</body>
<script type= "Text/javascript" >
var map = new Bmap.map ("container");
Map.centerandzoom ("Xuzhou", 12);
Map.enablescrollwheelzoom (); Enable wheel zoom out, default disabled
Map.enablecontinuouszoom (); Enable map inertia drag, default disabled
Map.addcontrol (New Bmap.navigationcontrol ()); Add default zoom translation control
Map.addcontrol (New Bmap.overviewmapcontrol ()); Add default thumbnail map control
Map.addcontrol (New Bmap.overviewmapcontrol ({isopen:true, anchor:bmap_anchor_bottom_right})); Lower right corner, open
var localsearch = new Bmap.localsearch (map);
Localsearch.enableautoviewport (); Allow the form size to be automatically adjusted
function Searchbystationname () {
Map.clearoverlays ()//Empty the original callout
var keyword = document.getElementById ("Text_"). Value;
Localsearch.setsearchcompletecallback (function (SearchResult) {
var poi = searchresult.getpoi (0);
document.getElementById ("Result_"). Value = Poi.point.lng + "," + Poi.point.lat;
Map.centerandzoom (Poi.point, 13);
var marker = new Bmap.marker (new Bmap.point (POI.POINT.LNG, Poi.point.lat)); Create a callout that corresponds to the latitude and longitude of the place to be queried
Map.addoverlay (marker);
var content = document.getElementById ("Text_"). Value + "<br/><br/> Longitude:" + poi.point.lng + "<br/> Latitude:" + P Oi.point.lat;
var Infowindow = new Bmap.infowindow ("<p style= ' font-size:14px; ') > "+ content +" </p> ");
Marker.addeventlistener ("click", Function () {This.openinfowindow (Infowindow);});
Marker.setanimation (bmap_animation_bounce); Bouncing animations
});
Localsearch.search (keyword);
}
</script>
The above is the entire content of the code, small partners can be used directly in the project Oh, do not tell me thank you, please call me Lei Feng Big ~