<! DOCTYPE html>"Content-type"Content="text/html; Charset=utf-8"/> <script type="Text/javascript"Src="http://api.map.baidu.com/api?v=1.4"></script> <script type="Text/javascript"Src="Http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script> <script type="Text/javascript"Src="Http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script> <title> A.1 Bus Enquiry function </title>class="wrapper"> <divclass="Header"> Bus Enquiryclass="F-r"> .- on- -</span> Task Description:</p> <p>first, the surrounding query, such as "Primary school";<br/>then, click on any red callout;<br/>Pop-up Information window, enter the need to go to the address, such as "posts and telecommunications", click "Go", can appear bus ride route. </p> </div> <divclass="Container Clearfix"> <divclass="Clearfix"> <input id="Txtsearch"Type="text"Value="Primary School"/><input type="Button"Value="Enquiry"onclick="Search ()"/></div> <div style="Clear:both;"> <div style="Float:left, width:500px, height:340px, border:1px solid gray"Id="Container"> </div> <div id="Divresult"style="Float:left, width:500px, height:340px, background: #eee"> </div> </div> </div> </div></body>"Text/javascript">varMap =NewBmap.map ("Container"); Map.centerandzoom (NewBmap.point (116.330599,39.95536), -); varCurtitle =""; varTS =NewBmap.transitroute (map, {renderoptions: {map:map, Autoviewport:true, Panel:"Divresult" } }); function Search () {vars = document.getElementById ("Txtsearch"); varls =NewBmap.localsearch (map, {pagecapacity: -});//Local Search, providing location search services in a specific region, such as searching for "Parks" in Beijing. Ls.setsearchcompletecallback (function (result) {//Call Method when search is completemap.clearoverlays (); if(Ls.getstatus () = =bmap_status_success) { varCurnum =Result.getcurrentnumpois (); for(vari =0; i < Curnum; i++) { varPOI =Result.getpoi (i); varLNG =poi.point.lng; varLat =Poi.point.lat; vartitle =Poi.title; varPT =NewBmap.point (LNG, LAT); varMarker =NewBmap.marker (PT);//CalloutMarker.settitle (title); Marker.addeventlistener ("Click", Fnclick (marker));//Labeling Listener EventsMap.addoverlay (marker); } } }); Ls.searchinbounds (S.value, Map.getbounds ()); //Range Search will provide search results based on the field of vision you provide} function Fnclick (marker) {returnfunction () {Curtitle=Marker.gettitle (); varHTML ="from"+ Curtitle +"departure, sit <b> bus </b> to"+"<input id= ' txtdest ' type= ' text ' value= ' posts and telecommunications '/><input type= ' button ' value= ' query ' onclick= ' tsearch () '/ >"; varInfowin =NewBmap.infowindow (HTML);//Display InformationInfowin.addeventlistener ("Open", function () {document.getElementById ("txtdest"). focus (); }); Marker.openinfowindow (Infowin); }} function Tsearch () {if(Curtitle.length >0) { varDest = document.getElementById ("txtdest"). Value; Ts.search (Curtitle, dest); } } </script>
Baidu Map Bus Query function