vue+leaflet动态画圆 并且显示geojson数据点,给点绑定点击事件完整代码

文章展示了如何在Vue项目中结合Leaflet库动态地在地图上画圆并显示GeoJSON数据点,同时给数据点绑定点击事件。主要涉及的地图操作包括绘制圆、删除圆、显示和删除GeoJSON点,以及处理点击事件来展示详细信息。
摘要由CSDN通过智能技术生成

vue+leaflet动态画圆 并且显示geojson数据点,给点绑定点击事件完整代码

效果如下图所示:

在这里插入图片描述
在这里插入图片描述

上图所示完整代码

需要安装leaflet框架和引入

npm install leaflet --save
npm install leaflet.wmts --save

main.js引入

//Leaflet全局配置
import L from 'leaflet'
import 'leaflet/dist/leaflet.css'
import 'leaflet.wmts'
Vue.use(L)

html部分完整代码

<template>
  <div class="showslicecacheMapCtn4">
    <div class="txt1">提示:在地图绘制圆,鼠标左键点下为圆心,移动鼠标,鼠标抬起的时候圆自动生成</div>
    <div class="showslicecacheMapCtn">
      <div id="viewDiv7" class="viewDiv">
      </div>
      <div class="latlon" v-if="currentLongitude">经度:{
  { currentLongitude.toFixed(2) }},纬度:{
  {
          currentLatitude.toFixed(2)
        }}
      </div>
    </div>
    <div class="timediv2 runCtn">
      <div class="btn2">
        <el-button type="primary" @click="drawCircle">绘制圆</el-button>
        <el-button type="primary" @click="removeCircle">删除圆</el-button>
        <el-button type="primary" @click="deleteGeoJsonDotFn">删除geojson点</el-button>
        <el-button type="primary" @click="runBtn" :loading="isRes">运行</el-button>
      </div>
    </div>
    <div class="runCtn">
      <div class="btnctn">
        <div class="paddingLeft20">
          <el-button type="primary" @click="closeAllBtn">全部折叠</el-button>
        </div>
        <div class="paddingLeft20">
          <el-button type="primary" @click="expandBtn">全部展开</el-button>
        </div>
        <div class="clearCtn">
          <el-button type="primary" @click="clearBtn">清空</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

js部分完整代码

<script>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

青儿吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值