<script type="Text/javascript">//Baidu Map API featuresfunction G (ID) {returndocument.getElementById (ID); } varMap =NewBmap.map ("L-map"); Map.centerandzoom ("Beijing", A);//initialize the map to set the city and map levels. varAC =NewBmap.autocomplete (//Create an auto-complete object{"input":"Suggestid" ," Location": Map}); Ac.addeventlistener ("Onhighlight", function (e) {//events on the drop-down list of the mouse varstr =""; var_value =E.fromitem.value; varValue =""; if(E.fromitem.index >-1) {Value= _value.province + _value.city + _value.district + _value.street +_value.business; } STR="fromitem<br/>index ="+ E.fromitem.index +"<br/>value ="+value; Value=""; if(E.toitem.index >-1) {_value=E.toitem.value; Value= _value.province + _value.city + _value.district + _value.street +_value.business; } STR+="<br/>toitem<br/>index ="+ E.toitem.index +"<br/>value ="+value; G ("Searchresultpanel"). InnerHTML =str; }); varmyvalue; Ac.addeventlistener ("onconfirm", function (e) {//event after mouse click on drop-down list var_value =E.item.value; MyValue= _value.province + _value.city + _value.district + _value.street +_value.business; G ("Searchresultpanel"). InnerHTML ="onconfirm<br/>index ="+ E.item.index +"<br/>myvalue ="+myvalue; Setplace (); }); function Setplace () {map.clearoverlays (); //clear all overlays on the mapfunction Myfun () {varpp = Local.getresults (). Getpoi (0). Point;//get the results of the first smart searchMap.centerandzoom (PP, -); Map.addoverlay (NewBmap.marker (PP));//Add a callout } varLocal =NewBmap.localsearch (map, {//Smart SearchOnsearchcomplete:myfun}); Local.search (myvalue); }</script>
Baidu Map Dynamic Display query structure