Skip to content

Commit 9f947ce

Browse files
author
潘卓然Y7000P
committed
【站点】【新增】【新增Vue-MapboxGL的卷帘组件】
1 parent 89045db commit 9f947ce

5 files changed

Lines changed: 137 additions & 219 deletions

File tree

website/public/static/demo/config/config-mapboxgl.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,14 @@
10061006
"detail": "",
10071007
"icon": "compare.png",
10081008
"update": "最后更新时间:2020-11-27"
1009+
},
1010+
{
1011+
"name": "卷帘组件-纵轴",
1012+
"file": "compare-hori",
1013+
"diffcult": "1",
1014+
"detail": "卷帘组件-纵轴",
1015+
"icon": "compare-hori.png",
1016+
"update": "最后更新时间:2020-12-30"
10091017
}
10101018
]
10111019
}

website/public/static/demo/mapboxgl/example/vue/vue-control/compare-diff.htm

Lines changed: 0 additions & 168 deletions
This file was deleted.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
6+
<title>Vue-卷帘</title>
7+
<script include="vue" exclude="plugin" src="./static/libs/include-mapboxgl-local.js"></script>
8+
<style type="text/css">
9+
body {
10+
margin: 0px !important;
11+
}
12+
#app {
13+
margin: 0 0;
14+
width: 100vw;
15+
height: 100vh;
16+
overflow: hidden;
17+
}
18+
.map {
19+
position: absolute; /* 只能是绝对布局 */
20+
top: 0;
21+
bottom: 0;
22+
height: 100%;
23+
width: 100%;
24+
}
25+
.custom-compare-toolbar {
26+
position: absolute;
27+
z-index: 9000;
28+
top: 20px;
29+
left: 20px;
30+
height: 36px;
31+
width: 36px;
32+
border-radius: 6px;
33+
background: #ffffff;
34+
color: #000000;
35+
line-height: 36px;
36+
}
37+
</style>
38+
</head>
39+
40+
<body>
41+
<div id="app">
42+
<mapbox-map
43+
id="left"
44+
class="map"
45+
ref="leftmap"
46+
:map-style="mapStyle"
47+
:zoom="mapZoom"
48+
:center="outerCenter"
49+
:crs="mapCrs"
50+
v-on:load="handleLeftMapLoad"
51+
>
52+
<mapbox-ogc-wmts-layer :layer="layerWmts" :layer-id="layerWmtsId" :source-id="sourceWmtsId" :url="wmtsurl1"> </mapbox-ogc-wmts-layer>
53+
<mapbox-compare ref="compare">
54+
<div class="custom-compare-toolbar" v-on:click="handleEnable">卷帘</div>
55+
</mapbox-compare>
56+
</mapbox-map>
57+
<mapbox-map
58+
id="right"
59+
class="map"
60+
:map-style="mapStyle"
61+
:zoom="mapZoom"
62+
:center="outerCenter"
63+
:crs="mapCrs"
64+
v-on:load="handleRightMapLoad"
65+
>
66+
<mapbox-ogc-wmts-layer :layer="layerWmts" :layer-id="layerWmtsId" :source-id="sourceWmtsId" :url="wmtsurl2"> </mapbox-ogc-wmts-layer>
67+
</mapbox-map>
68+
</div>
69+
<script>
70+
var leftMap, rightMap;
71+
new Vue({
72+
el: '#app',
73+
data() {
74+
return {
75+
left: 'left',
76+
right: 'right',
77+
mapStyle: {
78+
//设置版本号,一定要设置
79+
version: 8,
80+
//添加来源
81+
sources: {},
82+
//设置加载并显示来源的图层信息
83+
layers: []
84+
}, // 地图样式
85+
mapZoom: 2, // 地图初始化级数
86+
outerCenter: [116.39, 40.2], // 地图显示中心
87+
mapCrs: 'EPSG:4326',
88+
89+
layerWmts: {},
90+
layerWmtsId: 'ogcwmts_layerId',
91+
sourceWmtsId: 'ogcwmts_sourceId',
92+
wmtsurl1: 'http://t0.tianditu.com/DataServer?T=img_c&L={z}&Y={y}&X={x}&tk=9c157e9585486c02edf817d2ecbc7752',
93+
wmtsurl2: 'http://t0.tianditu.com/DataServer?T=vec_c&L={z}&Y={y}&X={x}&tk=9c157e9585486c02edf817d2ecbc7752'
94+
};
95+
},
96+
methods: {
97+
handleLeftMapLoad(payload) {
98+
leftMap = payload.map;
99+
},
100+
handleRightMapLoad(payload) {
101+
rightMap = payload.map;
102+
},
103+
handleEnable(e) {
104+
let compare = this.$refs.compare;
105+
let enable = compare.enable;
106+
console.log('compare', compare);
107+
if (enable) {
108+
compare.remove();
109+
} else {
110+
var container = '#comparison-container';
111+
let parent = this.$refs.leftmap.$parent.$el;
112+
compare.compare(leftMap, rightMap, parent, {
113+
// Set this to enable comparing two maps by mouse movement:
114+
// mousemove: true,
115+
orientation: 'horizontal'
116+
});
117+
}
118+
}
119+
}
120+
});
121+
</script>
122+
</body>
123+
</html>

0 commit comments

Comments
 (0)