添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
cnpm install ol

<div class="ship-content sourceList" v-show="portId&&sourceDataList.length>0" :class={portLine:portId}>
    <van-pull-refresh v-model="isSourceLoading" @refresh="onSourceRefresh" class="content" success-text="刷新成功">
                    <van-list v-if="sourceDataList.length>0" v-model="sourceLoading" :finished="sourceFinished" :immediate-check="false" finished-text="我也是有底线的"
                      @load="onSourceLoad" :offset="10">
                      <div v-for="source in sourceDataList" :key="source.sourceId" class=" pb15">
                        <span>{{source.unlimitedLoading=="0"?source.cargoWeight+"吨":"随船装"}}/{{source.cargoName}}</span>
                    </van-list>  
    </van-pull-refresh>
.sourceList{
  max-height:100px;
  overflow-y: auto;
**引用DragPan**
import DragPan from 'ol/interaction/DragPan';
data定义:
dragPan:null
watch: {
    // 监听货源列表是否启用地图拖动
     sourceDataList(){
       this.sourceDataList.length>3?this.disableMove():this.onMove();

会用的地方还有弹窗关闭的时候调用启用方法,具体使用还要根据项目需要去添加调用禁用启用的方法。

// 禁用拖动
    disableMove(){
      this.map.getInteractions().forEach((interaction)=>{
        if(interaction instanceof DragPan){
          this.dragPan = interaction;
      if(this.dragPan){
        this.map.removeInteraction(this.dragPan)
    // 启用拖动
    onMove(){
      this.map.getInteractions().forEach((interaction)=>{
        if(interaction instanceof DragPan){
          this.dragPan = interaction;
      if(this.dragPan){
        this.map.addInteraction(this.dragPan)

相关文章推荐:

# vue使用vant-ui、天地图、Openlayers实现轨迹查询,点击事件信息弹窗,列表加载刷新,复位功能

# vue使用天地图、openlayers实现多个底图叠加显示

# vue使用高德地图搜索地址添加标记marker,定位,拖拽选址功能

# vue3.0 setup语法糖

# echarts vue element-ui 实现根据选择项年月日时间切换数据显示折线图,vue页面监听自适应

  •