欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue結(jié)合Openlayers使用Overlay添加Popup彈窗實(shí)現(xiàn)

 更新時(shí)間:2022年05月10日 09:36:24   作者:不情不愿  
本文主要介紹了Vue結(jié)合Openlayers使用Overlay添加Popup彈窗實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

最近使用 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下載鏈接:

Vue+Openlayers DOM 下載

到此這篇關(guān)于Vue結(jié)合Openlayers使用Overlay添加Popup彈窗實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Vue Openlayers添加Popup彈窗內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論