-
Notifications
You must be signed in to change notification settings - Fork 4
/
map.html
155 lines (142 loc) · 4.09 KB
/
map.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>虎师罗盘</title>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<!-- <script type="text/javascript" src="//api.map.baidu.com/api?ak=MFt7pjr6XeaF1u986MPYmfZOwBPStUoW&type=lite&v=1.0"></script> -->
<style type="text/css">
#allmap {
width: 100%;
height: 100%;
position: absolute;
top: 0;
}
.deg-img {
display: none;
}
.noAllow {
pointer-events: none !important;
}
.tools li p {
color: #fff;
}
</style>
</head>
<body>
<div class="scroll">
<div id="allmap"></div>
<!-- header -->
<div class="header">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/logo2.png">
</div>
<!-- top-tool -->
<div class="top-tool">
</div>
<!-- pan -->
<div class="pan noAllow">
<!-- jia&jian -->
<div class="jia_btn">+</div>
<div class="jian_btn">-</div>
<!-- line -->
<span class="line line-heng"></span>
<span class="line line-shu"></span>
<img class="main-pan" id="compass" src="http://ii.sinelinked.com/miniProgramAssets/compass/pan-map-yellow.png">
<img class="deg-img" src="./img/a2.png" alt="" srcset="">
<img class="zhen-img" src="./img/a3.png" alt="" srcset="">
</div>
<!-- tools -->
<ul class="tools">
<li id="switch">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/001.png">
</div>
<p>模式</p>
</li>
<li id="lock">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/004.png">
</div>
<p>锁定</p>
</li>
<li id="manual">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/005.png">
</div>
<p>手动</p>
</li>
<li id="fold">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/003.png">
</div>
<p>收起</p>
</li>
<li id="change">
<div class="top">
<img src="http://ii.sinelinked.com/miniProgramAssets/compass/002.png">
</div>
<p>换盘</p>
</li>
</ul>
</div>
<script src="js/switch.js" type="text/javascript" charset="utf-8"></script>
<script src="js/map.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=FdGp9hXQHaWCaXy6wohRZFWZFjQP791a"></script>
<script>
var map = new BMap.Map("allmap", {
mapType: BMAP_HYBRID_MAP
});
var point = new BMap.Point(116.404, 39.915);
map.setCurrentCity("北京");
map.centerAndZoom(point, 15);
// 添加带有定位的导航控件
map.addControl(new BMap.NavigationControl({
// LARGE类型
type: BMAP_NAVIGATION_CONTROL_LARGE,
// 启用显示定位
enableGeolocation: true
}));
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_HYBRID_MAP
]
}));
var geolocationControl = new BMap.GeolocationControl();
map.addControl(geolocationControl);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
// alert('您的位置:' + r.point.lng + ',' + r.point.lat);
} else {
// alert('failed' + this.getStatus());
}
}, {
enableHighAccuracy: true
})
var change = document.getElementById('change')
var compass = document.getElementById('compass')
var panBg = [
'http://ii.sinelinked.com/miniProgramAssets/compass/pan-map-yellow.png',
'http://ii.sinelinked.com/miniProgramAssets/compass/pan-map.png',
'http://ii.sinelinked.com/miniProgramAssets/compass/pan.png'
]
var num = 0
change.addEventListener('touchstart', function() {
this.children[0].classList.add('active')
})
change.addEventListener('touchend', function() {
num++
if (num >= panBg.length) {
num = 0
}
compass.src = panBg[num]
this.children[0].classList.remove('active')
})
</script>
</body>
</html>