-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.html
85 lines (81 loc) · 2.76 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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>地面图片叠加层</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<style>
body,
html,
#container {
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
font-family: "微软雅黑";
}
</style>
<script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=QXtzrZOE57w779ooLpehwjNIFUSmrg0b"></script>
</head>
<body>
<label>x <input type="number" id="x" step="0.001" onchange="redraw()" value="1.271" /> </label>
<label>y <input type="number" id="y" step="0.001" onchange="redraw()" value="0.64" /> </label>
<label>flattening <input type="number" id="flattening" step="0.001" onchange="redraw()" value="0.782" /> </label>
<label>size <input type="number" id="size" value="2.122" onchange="redraw()" step="0.001" /> </label>
<label>opacity <input type="number" id="opacity" value="0.6" onchange="redraw()" step="0.1" /> </label>
<button onclick="redraw()">绘图</button>
<div id="container"></div>
</body>
</html>
<script>
var map = new BMapGL.Map('container');
var x = 1.271; // 地铁图x位移
var y = 0.64; // 地铁图y位移
var opacity = 0.6 // 图层透明度
var rate = 3511 / 2482; // https://www.chengdurail.com/underline.html 原始图片分辨率
var e1 = 104.072618 - x; // 成都初始坐标
var e2 = 30.664593 - y; // 成都初始坐标
var e3;
var e4;
var pStart;
var pEnd;
var bounds;
var size = 2.122; // 地铁图放大率
var imgOverlay = null;
map.centerAndZoom(new BMapGL.Point(e1, e2), 12);
map.enableScrollWheelZoom(true);
map.setDisplayOptions({
poiText: true,
// 隐藏poi标注
poiIcon: false,
// 隐藏poi图标
building: false // 隐藏楼块
});
redraw = function() {
if (imgOverlay) {
map.removeOverlay(imgOverlay);
}
x = document.getElementById("x").value;
y = document.getElementById("y").value;
flattening = document.getElementById("flattening").value ;
size = document.getElementById("size").value;
opacity = document.getElementById("opacity").value;
e1 = 104.072618 - x;
e2 = 30.664593 - y;
e3 = e1 + size * rate * flattening;
e4 = e2 + size * 1;
pStart = new BMapGL.Point(e1, e2);
pEnd = new BMapGL.Point(e3, e4);
console.log(e1, e2, e3, e4);
bounds = new BMapGL.Bounds(new BMapGL.Point(pStart.lng, pEnd.lat), new BMapGL.Point(pEnd.lng, pStart.lat));
imgOverlay = new BMapGL.GroundOverlay(bounds, {
type: 'image',
url: 'https://raw.githubusercontent.com/cmoseses/chengdu_railway_2021/main/chengdu_railway_2021_far.jpg',
opacity: opacity*1
});
map.addOverlay(imgOverlay);
}
redraw()
</script>