-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointsLine.html
96 lines (88 loc) · 3.26 KB
/
pointsLine.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!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>
<style type="text/css">
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
<style type="text/css">
#panel {
position: fixed;
background-color: white;
max-height: 90%;
overflow-y: auto;
top: 10px;
right: 10px;
width: 280px;
}
#panel .amap-call {
background-color: #009cf9;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
#panel .amap-lib-driving {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
overflow: hidden;
}
</style>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=14bf343951d675f8da27c1d6544e5efb&plugin=AMap.Driving"></script>
<script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<div id="panel">
<textarea id="muliteLineText" placeholder="请输入地址列表,一行一个,开头和结尾为起点和终点。" rows=5 cols=36></textarea>
<button name="subButton" onclick="subButtonClick()" style="width:275px;height:20px">确认</button>
</div>
<script type="text/javascript">
//基本地图加载
var map = new AMap.Map("container", {
resizeEnable: true,
center: [121.475681, 31.230349],//地图中心点
zoom: 13 //地图显示的缩放级别
});
//构造路线导航类
var driving = new AMap.Driving({
map: map,
panel: "panel"
});
window.addressDictList = []
// 提交按钮处理
function subButtonClick() {
var inputText = document.getElementById("muliteLineText").value
// 输出获取的字符串
// console.log(inputText)
// 字符串处理
var addressList = inputText.split("\n")
// 创建字典
for (var index in addressList) {
// console.log(addressList[index])
addressDictList.push(
{ keyword: addressList[index], city: "上海" }
)
}
// 根据起终点名称规划驾车导航路线
driving.search(window.addressDictList, function (status, result) {
console.log(result.value)
if (status === 'complete') {
log.success('绘制驾车路线完成')
} else {
log.error('获取驾车数据失败:' + result)
}
});
}
</script>
</body>
</html>