hookehuyr

infoWindow组件优化

1 <template> 1 <template>
2 - <div> 2 + <div style="position: relative;">
3 - <div class="box-card" style="padding: 0 80 30 80;width: 400px;border-radius: 10px;"> 3 + <div class="info-window-wrapper">
4 + <div class="t-popup-content">
5 + <div class="popup-content" style="height: 13.5rem;">
6 + <div style="position: relative;">
7 + <h3 class="view-name">三宝楼</h3>
8 + <van-icon @click="close" name="cross" size="1.25rem" style="position: absolute; right: 0.75rem; top: 0.75rem;" />
9 + </div>
10 + <img class="view-photo"
11 + src="https://img0.baidu.com/it/u=3974116483,397969091&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=496">
12 + <p class="introduction" style="padding: 0.5rem; padding-bottom: 0;">尊敬的游客朋友们您好,欢迎来到西园寺,您现在所到的地方是“三宝楼......</p>
13 + <div class="control-play"><span></span></div>
14 + <div @click="showDetail" class="show-details" style="color: white; text-align: center; line-height: 3rem;">详情</div>
15 + </div>
16 + </div>
17 + </div>
18 + <div class="leaflet-popup-tip-container" style="left: 50%; position: relative;"><div class="leaflet-popup-tip"></div></div>
4 19
5 - {{ title }} 20 + <van-popup teleport="body" v-model:show="show_popup" position="bottom" :overlay="true" :style="{ padding: '1rem', height: '100%' }">
6 - <div id="del-div"> 21 + <van-icon name="cross" size="1.35rem" @click="show_popup = false" style="float: right; color: gray;" />
7 - <div type="primary" icon="el-icon-close" @click="close()">123</div> 22 + <div class="popup-wrapper">
23 + <div class="title">
24 + {{ popup_title }}
8 </div> 25 </div>
9 - <div style="text-align: center;"> 26 + <div class="content" v-html="popup_content">
10 - <button type="primary">主要按钮</button>
11 </div> 27 </div>
28 + <video-player ref="videoPlayer" style="width: 100%; height: 10rem;"
29 + poster="https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100"
30 + :src="video_src" class="video-player vjs-big-play-centered" controls :loop="true" :volume="0.6"></video-player>
12 </div> 31 </div>
32 + </van-popup>
13 </div> 33 </div>
14 </template> 34 </template>
15 35
...@@ -25,27 +45,128 @@ export default { ...@@ -25,27 +45,128 @@ export default {
25 default: '' 45 default: ''
26 } 46 }
27 }, 47 },
48 + data () {
49 + return {
50 + show_popup: false,
51 + popup_title: '',
52 + popup_content: '',
53 + video_src: '',
54 + }
55 + },
28 methods: { 56 methods: {
29 // 关闭 57 // 关闭
30 close() { 58 close() {
31 // 高德地图信息窗关闭的api 59 // 高德地图信息窗关闭的api
32 this.infoWindow.close() 60 this.infoWindow.close()
33 }, 61 },
34 - edit() { 62 + showDetail () {
35 - console.log('编辑按钮测试') 63 + this.show_popup = true;
36 - }, 64 + this.popup_title = '三宝楼';
37 - del() { 65 + this.popup_content = '尊敬的游客朋友们您好,欢迎来到西园寺,您现在所到的地方是“三宝楼......';
38 - console.log('删除按钮测试') 66 + this.video_src = 'https://video.pearvideo.com/mp4/short/20200209/cont-1650197-14888002-hd.mp4'
39 } 67 }
40 } 68 }
41 } 69 }
42 </script> 70 </script>
43 71
44 -<style lang="less" scoped> 72 +<style lang="less">
45 -#del-div { 73 +.info-window-wrapper {
46 - position: absolute; 74 + background: #fff;
47 - right: 20; 75 + color: #333;
48 - top: 20; 76 + -webkit-box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
49 - transform: scale(1.2); 77 + box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
78 + text-align: left;
79 + border-radius: 12px;
80 + padding: 0;
81 +
82 + .t-popup-content {
83 + position: relative;
84 + width: 25rem;
85 + padding: 0;
86 + margin: 0;
87 + border-radius: 0.1rem;
88 + background: rgba(255, 255, 255, 0.9);
89 + -webkit-box-shadow: 0 0.02rem 0.05rem 0 rgba(0, 0, 0, 0.1);
90 + box-shadow: 0 0.02rem 0.05rem 0 rgba(0, 0, 0, 0.1);
91 + line-height: 1.4;
92 +
93 + .view-name {
94 + margin: 0;
95 + padding: 0.5rem;
96 + width: 25rem;
97 + height: 2.5rem;
98 + font-size: 1.2rem;
99 + text-indent: 0.2rem;
100 + white-space: nowrap;
101 + text-overflow: ellipsis;
102 + color: #5b5b5b;
103 + -webkit-box-sizing: border-box;
104 + box-sizing: border-box;
105 + border-bottom: solid 1px #e8e8e8;
106 + border-radius: 0.1rem 0.1rem 0 0;
107 + background: #f7f7f7;
108 + overflow: hidden;
109 + }
110 +
111 + .view-photo {
112 + display: block;
113 + float: left;
114 + margin: 0.5rem;
115 + height: 100%;
116 + width: 9rem;
117 + height: 9rem;
118 + border-radius: 3px;
119 + }
120 +
121 + .introduction {
122 + float: left;
123 + margin: 0.2rem 0;
124 + width: 13.5rem;
125 + height: 6.75rem;
126 + font-size: 0.9rem;
127 + color: #202020;
128 + overflow: hidden;
129 + }
130 +
131 + .control-play {
132 + display: block;
133 + float: left;
134 + margin-right: 0.5rem;
135 + width: 7rem;
136 + height: 3rem;
137 + border-radius: 2px;
138 + background: #ffdd02 center no-repeat;
139 + background-size: 6.5rem 3rem;
140 + }
141 +
142 + .show-details {
143 + display: block;
144 + float: left;
145 + width: 7rem;
146 + height: 3rem;
147 + border-radius: 2px;
148 + background: #9196a9 center no-repeat;
149 + background-size: 6.5rem 3rem;
150 + }
151 + }
152 +}
153 +
154 +.leaflet-popup-tip-container {
155 + margin-top: -1px;
156 + width: 2rem;
157 + height: 2rem;
158 + margin-left: -20px;
159 + overflow: hidden;
160 + pointer-events: none;
161 +}
162 +
163 +.leaflet-popup-tip {
164 + width: 1rem;
165 + height: 1rem;
166 + -webkit-transform: rotate(0);
167 + transform: rotate(0);
168 + background: transparent url(https://map.365daoyou.cn/web/images/info-sharp.png) center no-repeat;
169 + background-size: 1rem 1rem;
170 + box-shadow: none;
50 } 171 }
51 </style> 172 </style>
......
1 <!-- 1 <!--
2 * @Date: 2023-05-19 14:54:27 2 * @Date: 2023-05-19 14:54:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-05-30 18:09:09 4 + * @LastEditTime: 2023-05-31 13:11:26
5 * @FilePath: /map-demo/src/views/index.vue 5 * @FilePath: /map-demo/src/views/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
78 </div> 78 </div>
79 </div> 79 </div>
80 </div> 80 </div>
81 - <van-popup v-model:show="show_popup" position="bottom" :overlay="true" :style="{ padding: '1rem' }"> 81 + <van-popup v-model:show="show_popup" position="bottom" :overlay="true" :style="{ padding: '1rem', height: '100%' }">
82 <van-icon name="cross" size="1.35rem" @click="show_popup = false" style="float: right; color: gray;" /> 82 <van-icon name="cross" size="1.35rem" @click="show_popup = false" style="float: right; color: gray;" />
83 <div class="popup-wrapper"> 83 <div class="popup-wrapper">
84 <div class="title"> 84 <div class="title">
...@@ -825,6 +825,8 @@ export default { ...@@ -825,6 +825,8 @@ export default {
825 " ] 的位置单击了地图!当前层级" + 825 " ] 的位置单击了地图!当前层级" +
826 zoom; 826 zoom;
827 console.warn(text); 827 console.warn(text);
828 + // 点击空白处 关闭弹框
829 + this.$refs['infoWindow'].close()
828 }, 830 },
829 setWalkRoute() { 831 setWalkRoute() {
830 //步行导航 832 //步行导航
...@@ -877,13 +879,13 @@ export default { ...@@ -877,13 +879,13 @@ export default {
877 positionMarker() { 879 positionMarker() {
878 // this.setInfoWindow([120.587519, 31.315924]) 880 // this.setInfoWindow([120.587519, 31.315924])
879 // 点击后创建自定义信息窗口 881 // 点击后创建自定义信息窗口
880 - this.setInfoWindows('title', 'content', [120.587519, 31.315924]) 882 + this.setInfoWindows([120.587519, 31.315924])
881 // 把地图中心点设置为当前点击的标记点 883 // 把地图中心点设置为当前点击的标记点
882 this.map.setZoomAndCenter(this.zoom, [120.587519, 31.315924]); 884 this.map.setZoomAndCenter(this.zoom, [120.587519, 31.315924]);
883 // 885 //
884 this.show_nav_popup = false; 886 this.show_nav_popup = false;
885 }, 887 },
886 - setInfoWindows(title, content, position) { 888 + setInfoWindows(position) {
887 // 此时需要把组件的样式设置为可见 889 // 此时需要把组件的样式设置为可见
888 this.showInfoWindow = true 890 this.showInfoWindow = true
889 // 设置marker头部的标题信息窗口 891 // 设置marker头部的标题信息窗口
...@@ -990,6 +992,7 @@ export default { ...@@ -990,6 +992,7 @@ export default {
990 top: 10%; 992 top: 10%;
991 width: 20px; 993 width: 20px;
992 height: auto; 994 height: auto;
995 + z-index: 100;
993 996
994 .box-wrapper { 997 .box-wrapper {
995 display: flex; 998 display: flex;
......