Vue結(jié)合Openlayers使用Overlay添加Popup彈窗實(shí)現(xiàn)
最近使用 Vue 和 Openlayers 寫了一個(gè)簡單的小 dom ,用到了 Overlay 的彈窗功能,記錄一下!
實(shí)驗(yàn)數(shù)據(jù):test.xls

項(xiàng)目運(yùn)行效果

創(chuàng)建元素:
<div ref="popCon" id="popup" v-show="isShow"><!-- 彈出信息框 -->
<span class="iconfont icon-guanbi" @click="closePop"></span>
<ul id="info">
<h4>基本信息</h4>
<p>-------------------------------</p>
<p>名稱:{{name}}</p>
<p>面積:{{output}}</p>
</ul>
</div>引入依賴:
import 'ol/css';
import{ Overlay } from 'ol'添加事件:
getArea(){
let _this = this;
let sourceProj = this.map.getView().getProjection()//地圖數(shù)據(jù)源投影坐標(biāo)系4490
let select = new Select();
this.map.addInteraction(select);
select.on('select',function(e){
let area = Math.abs(getArea(e.selected[0].getGeometry(),{
"projection": sourceProj,
"radius": 6371008.8
}))
console.log(area);
_this.output = _this.formatArea(area);
console.log(_this.output);
let elPopup = _this.$refs.popCon;
let popup = new Overlay({
element: elPopup, //掛載元素
positioning:"center-center",
stopEvent: false,
offset:[0,-20]
})
_this.map.addOverlay(popup)
let center = getCenter(e.selected[0].getGeometry().getExtent())
if(center){
_this.isShow = true
popup.setPosition(center)
}else{
_this.isShow = false
}
})
},樣式信息:
<style>
#popup{
width: 200px;
background-color: white;
padding: 18px;
border-radius: 10px;
box-shadow: 0 0 15px rgb(177,177,177);
}
#popup span{
position: absolute;
top: 0%;
right: 0%;
}
#info{
font-size: 14px;
text-align: left;
}
</style>運(yùn)行結(jié)果:

dom下載鏈接:
到此這篇關(guān)于Vue結(jié)合Openlayers使用Overlay添加Popup彈窗實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Vue Openlayers添加Popup彈窗內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Vue利用openlayers實(shí)現(xiàn)點(diǎn)擊彈窗的方法詳解
- Vue使用openlayers實(shí)現(xiàn)繪制圓形和多邊形
- vue使用openlayers創(chuàng)建地圖
- Vue+Openlayers實(shí)現(xiàn)實(shí)時(shí)坐標(biāo)點(diǎn)展示
- vue利用openlayers加載天地圖和高德地圖
- Vue + OpenLayers 快速入門學(xué)習(xí)教程
- VUE + OPENLAYERS實(shí)現(xiàn)實(shí)時(shí)定位功能
- vue+openlayers繪制省市邊界線
- Vue openLayers實(shí)現(xiàn)圖層數(shù)據(jù)切換與加載流程詳解
相關(guān)文章
vue 實(shí)現(xiàn)滾動(dòng)到底部翻頁效果(pc端)
這篇文章主要介紹了pc端vue 滾動(dòng)到底部翻頁效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值 ,需要的朋友可以參考下2019-07-07
vue實(shí)現(xiàn)兩列水平時(shí)間軸的示例代碼
本文主要介紹了vue實(shí)現(xiàn)兩列水平時(shí)間軸的示例代碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11
vue實(shí)現(xiàn)三級(jí)導(dǎo)航展示和隱藏
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)三級(jí)導(dǎo)航展示和隱藏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08
使用D3.js+Vue實(shí)現(xiàn)一個(gè)簡單的柱形圖
這篇文章主要介紹了使用D3.js+Vue實(shí)現(xiàn)一個(gè)簡單的柱形圖,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-08-08
vue3+ts+echarts實(shí)現(xiàn)按需引入和類型界定方式
這篇文章主要介紹了vue3+ts+echarts實(shí)現(xiàn)按需引入和類型界定方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
Vue2.0學(xué)習(xí)之詳解Vue 組件及父子組件通信
本篇文章主要介紹了Vue2.0學(xué)習(xí)之詳解Vue 組件及父子組件通信,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-12-12

