1. 程式人生 > >百度地圖輸入一個位置到另一個位置的路線

百度地圖輸入一個位置到另一個位置的路線

span search put pan div rand 2.0 lac earch

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>駕車途經點</title>
 6     <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
 7     <script type="text/javascript"
src="http://api.map.baidu.com/api?v=2.0&ak="></script> 8 </head> 9 <body> 10 <div class="message"> 11 <input placeholder="起點" id="start" /> 12 <input type="" name="end" id="end" value="" placeholder="終點" /> 13 <button id="search">
搜索</button> 14 </div> 15 <div id="container" style="height: 500px;;"></div> 16 </body> 17 </html> 18 <script> 19 var map = new BMap.Map("container"); 20 map.centerAndZoom(new BMap.Point(114.064552,22.548457), 11); 21 var transit = new BMap.TransitRoute(map, {
22 renderOptions: {map: map} 23 }); 24 25 $("#search").click(function(){ 26 var start = $("#start").val(); 27 var end = $("#end").val(); 28 29 transit.search(start, end); 30 }); 31 32 </script>

百度地圖輸入一個位置到另一個位置的路線