Skip to content

Commit 50479e7

Browse files
committed
feat: setup amap
1 parent 62000a0 commit 50479e7

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

static/partials/map.html

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
7+
<title>ntnyq.com - map</title>
8+
<style>
9+
html,
10+
body,
11+
#container {
12+
position: relative;
13+
width: 100%;
14+
height: 100%;
15+
margin: 0;
16+
overflow: hidden;
17+
}
18+
19+
.amap-logo,
20+
.amap-toolbar,
21+
.amap-copyright {
22+
display: none !important;
23+
}
24+
</style>
25+
</head>
26+
27+
<body>
28+
<div id="container"></div>
29+
<script src="https://webapi.amap.com/maps?v=1.4.15&key=3fd367ad19a9adf8cc31beadb1fcdf8a"></script>
30+
<script>
31+
var map = new AMap.Map('container', {
32+
resizeEnabled: true,
33+
center: [108.88000, 34.22667],
34+
zoom: 10
35+
})
36+
37+
map.setLang('zh_CN')
38+
39+
var contextMenu = new AMap.ContextMenu()
40+
41+
contextMenu.addItem('放大一级', function() {
42+
map.zoomIn()
43+
}, 0)
44+
45+
contextMenu.addItem('缩小一级', function() {
46+
map.zoomOut()
47+
}, 0)
48+
49+
contextMenu.addItem('缩至全国', function() {
50+
map.setZoomAndCenter(4, [108.946609, 34.262324])
51+
})
52+
53+
map.on('rightclick', function(evt) {
54+
contextMenu.open(map, evt.lnglat)
55+
})
56+
57+
var marker = new AMap.Marker({
58+
position: map.getCenter(),
59+
draggable: false,
60+
cursor: 'move'
61+
})
62+
63+
map.setMapStyle('default')
64+
marker.setMap(map)
65+
marker.setAnimation('AMAP_ANIMATION_BOUNCE')
66+
</script>
67+
</body>
68+
69+
</html>

0 commit comments

Comments
 (0)