Showing
2 changed files
with
13 additions
and
4 deletions
This diff is collapsed. Click to expand it.
| 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-06-02 17:37:17 | 4 | + * @LastEditTime: 2023-06-05 11:38:09 |
| 5 | * @FilePath: /map-demo/src/views/index.vue | 5 | * @FilePath: /map-demo/src/views/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | - <div style="height: 100vh; position: relative; overflow: hidden;"> | 9 | + <div ref="root" style="height: 100vh; position: relative; overflow: hidden;"> |
| 10 | <div id="container"></div> | 10 | <div id="container"></div> |
| 11 | <div class="nav-bar-wrapper"> | 11 | <div class="nav-bar-wrapper"> |
| 12 | <div class="hideScrollBar" | 12 | <div class="hideScrollBar" |
| ... | @@ -92,7 +92,7 @@ | ... | @@ -92,7 +92,7 @@ |
| 92 | 92 | ||
| 93 | <!-- 自定义组件InfoWindow,初始时需要隐藏 --> | 93 | <!-- 自定义组件InfoWindow,初始时需要隐藏 --> |
| 94 | <!-- 隐藏不要使用v-if,因为我们需要渲染完成后的原生html结构作为信息框的dom对象使用 --> | 94 | <!-- 隐藏不要使用v-if,因为我们需要渲染完成后的原生html结构作为信息框的dom对象使用 --> |
| 95 | - <InfoWindow v-show="showInfoWindow" ref="infoWindow" :info-window="infoWindow" :title="infoWindowTitle"></InfoWindow> | 95 | + <InfoWindow v-show="showInfoWindow" ref="infoWindow" :info-window="infoWindow" :title="infoWindowTitle" :rect="rect"></InfoWindow> |
| 96 | </div> | 96 | </div> |
| 97 | </template> | 97 | </template> |
| 98 | 98 | ||
| ... | @@ -105,6 +105,7 @@ import _ from 'lodash'; | ... | @@ -105,6 +105,7 @@ import _ from 'lodash'; |
| 105 | import $ from 'jquery'; | 105 | import $ from 'jquery'; |
| 106 | //引入定义的信息窗组件 | 106 | //引入定义的信息窗组件 |
| 107 | import InfoWindow from '@/components/InfoWindow' | 107 | import InfoWindow from '@/components/InfoWindow' |
| 108 | +import { useRect } from '@vant/use'; | ||
| 108 | 109 | ||
| 109 | const GPS = { | 110 | const GPS = { |
| 110 | PI: 3.14159265358979324, | 111 | PI: 3.14159265358979324, |
| ... | @@ -215,7 +216,8 @@ export default { | ... | @@ -215,7 +216,8 @@ export default { |
| 215 | showInfoWindow: false, | 216 | showInfoWindow: false, |
| 216 | infoWindow: {}, | 217 | infoWindow: {}, |
| 217 | infoWindowTitle: '', | 218 | infoWindowTitle: '', |
| 218 | - navBarList: [] | 219 | + navBarList: [], |
| 220 | + rect: {} | ||
| 219 | } | 221 | } |
| 220 | }, | 222 | }, |
| 221 | mounted() { | 223 | mounted() { |
| ... | @@ -252,6 +254,13 @@ export default { | ... | @@ -252,6 +254,13 @@ export default { |
| 252 | $('.vjs-tech')[0].currentTime = 0; | 254 | $('.vjs-tech')[0].currentTime = 0; |
| 253 | }) | 255 | }) |
| 254 | } | 256 | } |
| 257 | + }, | ||
| 258 | + showInfoWindow (val) { | ||
| 259 | + if (val) { | ||
| 260 | + // 元素的大小及其相对于视口的位置 | ||
| 261 | + const rect = useRect(this.$refs.root); | ||
| 262 | + this.rect = rect; | ||
| 263 | + } | ||
| 255 | } | 264 | } |
| 256 | }, | 265 | }, |
| 257 | methods: { | 266 | methods: { | ... | ... |
-
Please register or login to post a comment