|
- <html>
-
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
- <style type="text/css">
- body,
- html,
- #allmap {
- width: 100%;
- height: 100%;
- overflow: hidden;
- margin: 0;
- font-family: "微软雅黑";
- }
- </style>
- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=lbnOVuOdm1XmZLkI38UKuvSw3DyHUltq"></script>
- <title>行程路线</title>
- </head>
-
- <body>
- <div id="allmap"></div>
- </body>
-
- </html>
- <script type="text/javascript" src="js/main.js" ></script>
- <script type="text/javascript">
- // 百度地图API功能
- var map = new BMap.Map("allmap"); // 创建Map实例
- map.centerAndZoom(new BMap.Point(121.480, 31.236), 11); // 初始化地图,设置中心点坐标和地图级别
- map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
-
-
- //获取缓存
- // setStorJson('goMapInfo',map_info);
- var mapInfo=getStorJson('goMapInfo');
- if(mapInfo==null){
- document.getElementById("allmap").innerHTML="暂不支持地图导航";
- }else{
- //得到经停
- var start_info=mapInfo['start'];
- var center_info = mapInfo['center'];
- var end_info = mapInfo['end'];
-
-
- // var p1 = new BMap.Point(121.480237, 31.236305);
- // var p2 = new BMap.Point(120.498776, 30.754146);
- var p1 = new BMap.Point(start_info['longitude'],start_info['latitude']);
- var p2 = new BMap.Point(end_info['longitude'],end_info['latitude']);
- var c_p = new Array();
- for (var i=0,m=center_info.length;i<m;i++) {
- var dict=center_info[i];
- var temp_p = new BMap.Point(dict['longitude'],dict['latitude']);
- c_p.push(temp_p);
- }
- var driving = new BMap.DrivingRoute(map, {
- renderOptions: {
- map: map,
- autoViewport: true
- }
- });
- driving.search(p1, p2, {
- waypoints: c_p
- });
- }
-
-
-
-
-
- </script>
|