-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-bmap-line.html
81 lines (73 loc) · 2.19 KB
/
test-bmap-line.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script language="JavaScript" src="./dict/bankLocation.js"></script>
<script language="JavaScript" src="lib/utils.js"></script>
<title>BMap</title>
<style>
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
#map {
width: 100%;
height: 100%;
}
.anchorBL, .BMap_cpyCtrl {
display: none;
}
.BMap_stdMpZoom {
display: block;
}
</style>
</head>
<body>
<!--<img src="images/boc.png">-->
<div id="map"></div>
<script type="text/javascript">
function init() {
const MapOptions = {
minZoom: 8,
maxZoom: 20,
mapType: BMAP_NORMAL_MAP,
}
// '114.116414', '22.541189'
const transArr = qqMapToBMap('114.116414', '22.541189')
const map = new BMapGL.Map('map', MapOptions)
const point = new BMapGL.Point(Number(transArr[0]), Number(transArr[1]))// 深圳
// const point = new BMapGL.Point(114.064552, 22.548457)// 深圳
// const point = new BMapGL.Point(116.404, 39.915)// 北京
map.centerAndZoom(point, 14)
map.enableScrollWheelZoom(true)
// 图标
const icon = new BMapGL.Icon("./images/boc-location.png",
new BMapGL.Size(25, 25), {},
)
const marker = new BMapGL.Marker(point, {icon:icon})
map.addOverlay(marker)
// 线条
const polyline = new BMapGL.Polyline([
new BMapGL.Point(114.116414,22.541189),
new BMapGL.Point(114.116414,22.543289),
new BMapGL.Point(114.115414,22.548289),
],{
strokeColor: "blue",
strokeWeight: 2,
strokeOpacity: 0.5
})
map.addOverlay(polyline)
}
window.onload = function () {
var script = document.createElement('script')
script.src = 'https://api.map.baidu.com/api?v=1.0&type=webgl&ak=2bmncLvRzj6711pQ0LQnbfciTAe6CvLz&callback=init'
document.body.appendChild(script)
}
</script>
</body>
</html>