<! Doctype HTML>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Administrative Region tool </title>
<SCRIPT type = "text/JavaScript" src = "http://api.map.baidu.com/api? V = 1.2 "> </SCRIPT>
</Head>
<Body>
<Div style = "width: 520px; Height: 340px; Border: 1px solid gray" id = "Container"> </div>
<P> <input id = "startbtn" type = "button" onclick = "starttool (); "value =" enable vertex fetch tool "/> <input type =" button "onclick =" map. clearoverlays (); document. getelementbyid ('info '). innerhtml = ''; points = [];" value = "clear"/> </P>
<Div id = "info"> </div>
</Body>
</Html>
<SCRIPT type = "text/JavaScript">
VaR map = new bmap. Map ("Container"); // create a map instance
Map. centerandzoom ("Kunming", 12); // initializes the map and sets the coordinates of the center and map level.
Var key = 1; // Switch
VaR newpoint; // a latitude and longitude
VaR points = []; // array, with latitude and longitude information
VaR polyline = new bmap. polyline (); // line covering
Function starttool () {// switch the Function
If (Key = 1 ){
Document. getelementbyid ("startbtn"). style. Background = "green ";
Document. getelementbyid ("startbtn"). style. color = "white ";
Document. getelementbyid ("startbtn"). value = "enabled ";
Key = 0;
}
Else {
Document. getelementbyid ("startbtn"). style. Background = "red ";
Document. getelementbyid ("startbtn"). value = "disabled ";
Key = 1;
}
}
Map. addeventlistener ("click", function (e) {// click a map to form a line covering
Newpoint = new bmap. Point (E. Point. lng, E. Point. LAT );
If (Key = 0 ){
// If (points [points. Length]. lng = points [points. Length-1]. lng) {alert (111 );}
Points. Push (newpoint); // Add a vertex to the array.
Polyline. setpath (points); // sets the Dot Array of the line
Map. addoverlay (polyline); // Add the line to the map
Document. getelementbyid ("info "). innerhtml + = "New bmap. point ("+ E. point. LNG + "," + E. point. lat + "), </BR>"; // output the longitude and latitude of the array
}
});
Map. addeventlistener ("dblclick", function (e) {// double-click the map to form a polygon covering.
If (Key = 0 ){
Map. disabledoubleclickzoom (); // close double-click to zoom in
VaR polygon = new bmap. polygon (points );
Map. addoverlay (polygon); // Add the line to the map
}
});
</SCRIPT>
<! Doctype HTML>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Search for 62 bus routes </title>
<SCRIPT type = "text/JavaScript" src = "http://api.map.baidu.com/api? V = 1.2 "> </SCRIPT>
</Head>
<Body>
<P> <span style = "display: inline-block; width: 200px;"> & nbsp; </span> <input type = "text" value = "62" id = "busid"/> Bus & nbsp; <input type = "button" value = "query" onclick = "bussearch ();"/> </P>
<Div style = "clear: both"> & nbsp; </div>
<Div style = "float: Left; width: 600px; Height: 500px; Border: 1px solid gray" id = "Container"> </div>
<Div id = "Results" style = "float: Left; width: 300px; Height: 500px; font-size: 13px;"> </div>
</Body>
</Html>
<SCRIPT type = "text/JavaScript">
VaR map = new bmap. Map ("Container ");
Map. centerandzoom (New bmap. Point (102.731417, 25.063555), 12 );
VaR busline = new bmap. buslinesearch (MAP ,{
Renderoptions: {map: map, panel: "Results "},
Ongetbuslistcomplete: function (result ){
If (result ){
VaR fstline = result. getbuslistitem (0); // obtain the first bus list and display it on map.
Busline. getbusline (fstline );
}
}
});
Function bussearch (){
VaR busname = Document. getelementbyid ("busid"). value;
Busline. getbuslist (busname );
}
</SCRIPT>