ChangeMap.vue
3.78 KB
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
<template>
<div>
<div id="changemap">
<div v-for="(n,i) in layerArr" :key="i">
<div :title="n.text" @click="change(i,n.basemap)">
<img :src="require('../../assets/images/map/'+n.img)" />
<span></span>
<span></span>
<span></span>
<span></span>
<span>{{n.text}}</span>
</div>
</div>
</div>
</div>
</template>
<script>
import {maps} from '@/libs/map/mapUtils'
export default {
props:{
viewId:{
type:String,
default:""
}
},
data() {
return {
layerArr: [
{
img: "shiliang.png",
text: "矢量图",
basemap: 'osm' //hybrid img
},
{
img: "yingxiang.png",
text: "影像图",
basemap: 'hybrid' //hybrid img
}
]
};
},
methods: {
change(index, basemap) {
var view = maps[this.viewId],map = null;
if(view){
map = view.map;
}else {
console.log("mapView不存在");
}
map.basemap = basemap; // streets
index > 0 && this.layerArr.unshift(this.layerArr.splice(index, 1)[0]);
}
}
};
</script>
<style scoped>
#changemap {
/* background-color: #0ff; */
display: flex;
flex-wrap: wrap-reverse;
flex-direction: row-reverse;
align-content: flex-start;
max-width: 75px;
max-height: 75px;
overflow: auto;
}
#changemap > div {
width: 75px;
height: 75px;
box-sizing: border-box;
padding: 5px;
}
#changemap:hover {
max-width: 300px;
max-height: 300px;
transition: max-height 0.3s linear 0s;
}
#changemap > div > div {
height: 100%;
width: 100%;
border: 1px solid #ccc;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
cursor: pointer;
}
#changemap > div > div > img {
height: 100%;
width: 100%;
display: block;
}
#changemap > div > div > span {
transition: all 0.4s linear 0s;
position: absolute;
height: 50%;
width: 50%;
background-color: rgba(0, 0, 0, 0.4);
}
#changemap > div > div > span:nth-of-type(1) {
top: 0px;
left: 0px;
}
#changemap > div > div > span:nth-of-type(2) {
top: 0px;
right: 0px;
}
#changemap > div > div > span:nth-of-type(3) {
bottom: 0px;
left: 0px;
}
#changemap > div > div > span:nth-of-type(4) {
bottom: 0px;
right: 0px;
}
#changemap > div > div > span:nth-of-type(5) {
width: 100%;
height: 30%;
bottom: 0px;
left: 0px;
color: #fafafa;
overflow: hidden;
/* text-align: center; */
font-size: 12px;
display: flex;
justify-content: center;
align-items: center;
}
#changemap > div > div:hover span:nth-of-type(1) {
left: -50%;
top: -50%;
}
#changemap > div > div:hover span:nth-of-type(2) {
top: -50%;
right: -50%;
}
#changemap > div > div:hover span:nth-of-type(3) {
bottom: -50%;
left: -50%;
}
#changemap > div > div:hover span:nth-of-type(4) {
bottom: -50%;
right: -50%;
}
</style>