-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
57 lines (52 loc) · 1.7 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hello, World</title>
<style type="text/css">
html {
height: 100%;
}
body {
height: 100%;
margin: 0px;
padding: 0px;
}
#container {
height: 100%;
}
</style>
<script type="text/javascript" src="bmap_load.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
var outputPath = 'tiles/' //地图瓦片所在的文件夹
var fromat = '.jpg' //格式
/*var tileLayer = new BMap.TileLayer();
tileLayer.getTilesUrl = function (tileCoord, zoom) {
var x = tileCoord.x;
var y = tileCoord.y;
var url = outputPath + zoom + '/' + x + '/' + y + fromat;
return url;
}
var tileMapType = new BMap.MapType('tileMapType', tileLayer);*/
var map = new BMap.Map('container')
var point = new BMap.Point(116.404, 39.915) // 创建点坐标
map.centerAndZoom(point, 6) // 初始化地图,设置中心点坐标和地图级别
//添加地图类型控件
map.addControl(
new BMap.MapTypeControl({
mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP]
})
)
map.setCurrentCity('北京') // 设置地图显示的城市 此项是必须设置的
map.enableScrollWheelZoom(true) //开启鼠标滚轮缩放
//单击获取点击的经纬度
map.addEventListener('click', function(e) {
alert(e.point.lng + ',' + e.point.lat)
})
</script>
</body>
</html>