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>
原文地址:https://www.cnblogs.com/xiuxiume/p/10087983.html
时间: 2024-11-13 09:06:00