<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>可拖拽的路线规划</title>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/AMap.DrivingRender1120.css"/>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.1&key=0b5456ba06f351ea83333333689ff3333333db927a630&plugin=AMap.Driving"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/DrivingRender1230.js"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<style>
#panel {
z-index: 999;
position: relative;
background-color: white;
max-height: 100%;
overflow-y: auto;
right: 0;
width: 280px;
}
</style>
</head>
<body>
<div id="container" style="width:800px;"></div>
<div id="panel" style="width:100px;"></div>
<div id="tip">请拖拽路径试试</div>
<script type="text/javascript">
var map, route, marker;
//基本地图加载
map = new AMap.Map("container", {
resizeEnable: true
});
//绘制初始路径
var path = [];
path.push([116.30, 39.98]);
path.push([116.32, 39.90]);
path.push([116.41, 39.99]);
map.plugin("AMap.DragRoute", function() {
route = new AMap.DragRoute(map, path, AMap.DrivingPolicy.LEAST_TIME); //构造拖拽导航类
route.search(); //查询导航路径并开启拖拽导航
route.on('complete',function(data){
console.log(data);
// (new Lib.AMap.DrivingRender()).autoRender({
// data: data.data,
// map: map,
// panel: "panel"
// });
})
});
</script>
</body>
</html>
如上所示,使用数据自我展示之后,路径不可拖拽了