You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

71 lines
1.8 KiB

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <style type="text/css">
  6. body,
  7. html,
  8. #allmap {
  9. width: 100%;
  10. height: 100%;
  11. overflow: hidden;
  12. margin: 0;
  13. font-family: "微软雅黑";
  14. }
  15. </style>
  16. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=lbnOVuOdm1XmZLkI38UKuvSw3DyHUltq"></script>
  17. <title>行程路线</title>
  18. </head>
  19. <body>
  20. <div id="allmap"></div>
  21. </body>
  22. </html>
  23. <script type="text/javascript" src="js/main.js" ></script>
  24. <script type="text/javascript">
  25. // 百度地图API功能
  26. var map = new BMap.Map("allmap"); // 创建Map实例
  27. map.centerAndZoom(new BMap.Point(121.480, 31.236), 11); // 初始化地图,设置中心点坐标和地图级别
  28. map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
  29. //获取缓存
  30. // setStorJson('goMapInfo',map_info);
  31. var mapInfo=getStorJson('goMapInfo');
  32. if(mapInfo==null){
  33. document.getElementById("allmap").innerHTML="暂不支持地图导航";
  34. }else{
  35. //得到经停
  36. var start_info=mapInfo['start'];
  37. var center_info = mapInfo['center'];
  38. var end_info = mapInfo['end'];
  39. // var p1 = new BMap.Point(121.480237, 31.236305);
  40. // var p2 = new BMap.Point(120.498776, 30.754146);
  41. var p1 = new BMap.Point(start_info['longitude'],start_info['latitude']);
  42. var p2 = new BMap.Point(end_info['longitude'],end_info['latitude']);
  43. var c_p = new Array();
  44. for (var i=0,m=center_info.length;i<m;i++) {
  45. var dict=center_info[i];
  46. var temp_p = new BMap.Point(dict['longitude'],dict['latitude']);
  47. c_p.push(temp_p);
  48. }
  49. var driving = new BMap.DrivingRoute(map, {
  50. renderOptions: {
  51. map: map,
  52. autoViewport: true
  53. }
  54. });
  55. driving.search(p1, p2, {
  56. waypoints: c_p
  57. });
  58. }
  59. </script>