Vue LeafletJS Maker信息窗口 点线面 卷帘效果

Maker信息窗口

1.MakerCmp组件

  1. 添加地图注记方法

       /*** 添加标记点 图片+文本* @param {*} lng  经度* @param {*} lat  纬度* @param {*} iconurl  图片地址* @param {*} iconwidth 图片宽度* @param {*} iconheight  图片高度* @param {*} label  需要显示的注记,传一个div 可配置样式* @param {*} labelwidth  label的最大宽度* @param {*} labelheight  label的最大高度* @param {*} labeloffsetx  label左右偏移* @param {*} labeloffsety  label上下偏移* @param {*} classname  传过来div的class* @param feature*/addbillboard(lng, lat, iconurl, iconwidth, iconheight, label, labelwidth, labelheight, labeloffsetx, labeloffsety, classname,feature) {//单独展示图片 并绑定点击展示的起泡内容  bubble (可以为一个html 或者dom  或者单独的文本)let marker = L.marker([lat, lng], {icon: L.icon({iconUrl: iconurl,iconSize: [iconwidth, iconheight],}),feature:feature}).addTo(this.querygroup).bindPopup('气泡展示')marker.on('click', (e) => {//   图片的点击事件let feature = e.target.options.feature// debugger})//展示文本L.marker([lat, lng], {icon: L.divIcon({html: label,className: classname,iconSize: [labelwidth, labelheight],iconAnchor: [labeloffsetx, labeloffsety]})}).addTo(this.querygroup)}

2.调用方法

    this.addbillboard(112.9, 28.68, require('@/assets/sign113.png'), 80, 80, `<div style="border-radius: 5px;background-color: #0b88e9ba;padding: 3px;text-align: center;" class='leaflet-label'>标记点</div>`, 45, 20, 22, 45, "leaflet-marker",'frature')

2.Vue父组件使用

<MakerCmp :data="data"></MakerCmp>

3.MakerCmp组件使用

props: {data: {type: Object,default: ()=>{}}}

循环调用方法

for (var i of data){addbillboardbeidou(JSON.stringify(i),i.lng, i.lat,  i.img, 45, 45, `<div class='leaflet-label'>${i.name}</div>`, 200, 20, 100, 45, "leaflet-marker")}

完整代码

<template><div><div id="map"></div></div>
</template><script>
export default {data() {return {map: "",querygroup:null};},mounted() {//地图初始化this.initDate();//循环调用此方法this.addbillboard(112.9, 28.68, require('@/assets/sign113.png'), 80, 80, `<div style="border-radius: 5px;background-color: #0b88e9ba;padding: 3px;text-align: center;" class='leaflet-label'>标记点</div>`, 45, 20, 22, 45, "leaflet-marker",'frature')},methods: {initDate() {this.map = L.map("map", {center: [27.68, 112],zoom: 6.5,maxZoom: 20,minZoom: 5,attributionControl: false, // 移除右下角leaflet标识zoomControl: false,///编辑插件editable: true,crs: L.CRS.EPSG4326,});var tiandituimg = L.tileLayer("http://t1.tianditu.com/img_c/wmts?layer=img&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}&tk=6c6c18e4ec555ea8f0976ec71960021f",{maxNativeZoom: 17,maxZoom: 23,tileSize: 256,zoomOffset: 1,}).addTo(this.map);var tianditucia = L.tileLayer("http://t1.tianditu.com/cia_c/wmts?layer=cia&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}&tk=6c6c18e4ec555ea8f0976ec71960021f",{maxNativeZoom: 17,maxZoom: 23,tileSize: 256,zoomOffset: 1,}).addTo(this.map).setZIndex(10);this.querygroup = L.layerGroup().addTo(this.map)},/*** 添加标记点 图片+文本* @param {*} lng  经度* @param {*} lat  纬度* @param {*} iconurl  图片地址* @param {*} iconwidth 图片宽度* @param {*} iconheight  图片高度* @param {*} label  需要显示的注记,传一个div 可配置样式* @param {*} labelwidth  label的最大宽度* @param {*} labelheight  label的最大高度* @param {*} labeloffsetx  label左右偏移* @param {*} labeloffsety  label上下偏移* @param {*} classname  传过来div的class* @param feature*/addbillboard(lng, lat, iconurl, iconwidth, iconheight, label, labelwidth, labelheight, labeloffsetx, labeloffsety, classname,feature) {//单独展示图片 并绑定点击展示的起泡内容  bubble (可以为一个html 或者dom  或者单独的文本)let marker = L.marker([lat, lng], {icon: L.icon({iconUrl: iconurl,iconSize: [iconwidth, iconheight],}),feature:feature}).addTo(this.querygroup).bindPopup('气泡展示')marker.on('click', (e) => {//   图片的点击事件let feature = e.target.options.feature// debugger})//展示文本L.marker([lat, lng], {icon: L.divIcon({html: label,className: classname,iconSize: [labelwidth, labelheight],iconAnchor: [labeloffsetx, labeloffsety]})}).addTo(this.querygroup)}}
};
</script><style  scoped>
#map {width: 100%;height: calc(100vh);z-index: 1;
}
.leaflet-label {border-radius: 5px;background-color: #0b88e9ba;padding: 3px;text-align: center;
}
.leaflet-marker {color: antiquewhite;
}
.sideMap{position: absolute;top: 20px;left: 20px;z-index: 9999;
}
</style>

点线面手动绘制操作

1.添加点方法

    addOpint(){this.map.on('click', (evt) => {console.log(evt.latlng)let opint =evt.latlngthis.addbillboard(opint.lng, opint.lat, require('@/assets/sign113.png'), 80, 80, `<div class='leaflet-fly'>ces </div>`, 55, 20, 28, 45, "leaflet-marker",name)})},

2.添加线方法

   addLine(){this.flyroad = null//定义点组和线let points = []this.map.on('click', (evt) => {points.push(evt.latlng)//其他的则直接添加this.map.on('mousemove', mousemove);//因为会移动let that =thisfunction mousemove(e) {points.push(e.latlng)if (that.flyroad) that.map.removeLayer(that.flyroad)that.flyroad = L.polyline(points, {color: '#00CED1',})that.flyroad.addTo(that.querygroup)points.pop()}that.map.on('dblclick', (e) => {console.log(e)if (that.flyroad) that.map.removeLayer(that.flyroad)//是否要中间线that.flyroad.addTo(that.querygroup)that.map.off('click').off('mousemove').off('dblclick');})})},

3.添加面方法

    addPolygon(){let points = [], drawpolygonthis.map.on('click', (evt) => {points.push(evt.latlng)//移动线this.map.on('mousemove', (e) => {points.push(e.latlng)if (drawpolygon)  this.map.removeLayer(drawpolygon)drawpolygon = L.polygon(points, {color: '#00CED1',fillColor: '#000000',fillOpacity: 0.3})drawpolygon.addTo(this.querygroup)points.pop()})this.map.on('dblclick', (e) => {if (drawpolygon)  this.map.removeLayer(drawpolygon)drawpolygon.addTo(this.querygroup)this.map.off('click').off('mousemove').off('dblclick');//执行查询功能})})},

线面显示操作

线数据显示

let points= [] //经纬度 [27.68, 112]
polyline = L.polyline(points, {color: '#00CED1',}).addTo(querygroup);

面数据显示

let aa= [] //经纬度 [27.68, 112]
polygon = L.polygon(points, {color: '#00CED1',fillColor: '#000000',fillOpacity: 0.3}).addTo(querygroup);

卷帘效果

npm 安装 npm install leaflet-side-by-side --save

在main.js中引入 import 'leaflet-side-by-side'

//addTileMap()方法为调取图层方法
function sideBySide() {let mapleft = addTileMap("http://222.244.103.77:8081/hnlydsj/tsc/img-server/v1?layer=WXYGYX_XQ_1M_2021&Tilematrix={z}&Tilecol={x}&TileRow={y}", '湖南卫星地图', '分屏加载')let mapright = addTileMap(" http://222.244.103.77:8081/hnlydsj/tsc/mapeditor/mapserver/layer/WMTS/1.0/2013年湖南二调小班/默认/getTile/{z}/{y}/{x}", '2013年森林资源二调数据', '分屏加载')side = L.control.sideBySide(mapleft, mapright).addTo(map);
}let Tilemap = [], sidemap = [] //存储已经添加的图层
function addTileMap(mapurl, mapname, addtype) {let addmap = L.tileLayer(mapurl,{maxNativeZoom: 17,maxZoom: 23,tileSize: 256,zoomOffset: 1,}).addTo(map);if (addtype == '地图加载') {Tilemap.push({ name: mapname, layer: addmap });} else {sidemap.push({ name: mapname, layer: addmap });}return addmap
}

**Vue LeafletJS Maker信息窗口 点线面 卷帘效果**相关推荐

  1. vue使用高德地图实现多车定位和信息窗口:

    1.思路: [1]先获取key=>官网:https://lbs.amap.com/?ref=https://console.amap.com [2]下载并导入依赖=>npm install ...

  2. vue中使用google地图(自定义label、信息窗口)

    最近公司爱尔兰项目需要使用google地图,项目还是用vue写的,那我就寻思找个vue能用的google地图的插件吧,找了vue2-google-maps,这个插件确实还行,而且github上还有ap ...

  3. vue 使用高德地图给海量点标记,并点击标记弹出信息窗口,信息窗口绑定点击事件

    目录 一.需求 二.引入高德地图 2.1.将高德地图引入到项目中 2.2.查看官网快速上手,熟悉高德地图的主要API 2.3.海量点标注要用到的API文档 2.4.全部代码 其他: 一.需求 因为不知 ...

  4. vue项目打开新窗口并打印信息

    vue项目打开新窗口 1,vue项目另开一个新的窗口,可传参 let routeData = this.$router.resolve({path: "/consoleOrderDetail ...

  5. DOM 案例——(美团外卖下拉框菜单、半透明——信息滑入、模态窗口拖拽效果、放大镜效果、滚动条滑到一定位置的固定导航栏、12306购票网站多级联动、斗鱼TV无规则弹幕特效、百度搜索条动态输入下拉瀑布)

    目录 1.缓动动画--美团外卖下拉框菜单 2.半透明--信息滑入 3.模态窗口拖拽效果 4.放大镜效果 5.滚动条滑到一定位置的固定导航栏 6.12306购票网站多级联动 7.斗鱼TV无规则弹幕特效 ...

  6. html仿微信滑动删除,使用Vue实现移动端左滑删除效果附源码

    左滑删除在移动端是很常见的一种操作,常见于删除购物车中的商品,删除收藏夹中文章等等场景.我们只需要手指按住要删除的对象,然后轻轻向左滑动,便会出现删除按钮,然后点击删除按钮即可删除对象. 点击下载源码 ...

  7. 监听关闭页面事件 ajax,Vue 实现监听窗口关闭事件,并在窗口关闭前发送请求

    网上很多博客说监听窗口关闭事件使用window.beforeunload,但是这个监听事件也会在页面刷新的时候执行,经过百度和自己的实际测试, 终于解决了这个问题,代码如下: mounted() { ...

  8. java清除运行窗口内容,Java实现软件运行时启动信息窗口的方法

    本文实例形式详述了Java实现一个程序运行时的启动窗口效果,如常用的Microsoft Word. Borland JBuilder 等,这样的窗口称为信息窗口.使用信息窗口的好处是可以使用户在等待软 ...

  9. 关于Google Map 叠加层之Polyline(折线)、Polygon(多边形)、InfoWindow(信息窗口)

    转载至 http://scorpio-jh.blog.sohu.com/156761136.html 示例 ------ Polyline 折线 // 1. 从雍和宫–东直门画一条折线 // 路径 v ...

  10. 百度地图api html信息窗口,百度地图 javascript api自定义信息窗口

    百度 js api中存在infoWindow的类,就是marker 点击后显示的信息窗口, 他存在一下问题 1.在map中只能显示一个infowindow, 2.该信息窗口的样式无法修改,显示的内容具 ...

最新文章

  1. HttpURLConnection IllegalStateException
  2. linux深度定制,专为国人订制!Linux Deepin新版发布
  3. 生产制造类企业从企业邮箱切换到自建系统的方案
  4. 私有属性和方法-伪私有属性和方法
  5. php用go做跳转翻页,go.php跳转不输出权重的跳转方式真的有用么?
  6. C 语言调用CPU指令,CPU 1214C中 TSEND_C指令 最多可以使用几次-工业支持中心-西门子中国...
  7. Java中带标签的break,continue
  8. 【翻译】ANDROID KTX – 使用Kotlin进行Android开发
  9. python从tushare获取数据_python调用tushare获取股票月线数据
  10. Jenkins 插件安装方式全攻略
  11. 数据挖掘对客户进行深入分析
  12. Android API 级别
  13. ADB登录验证暴力破解工具
  14. html5做一个动画qq彩贝,HTML 第九章 作业
  15. 华为设备配置VRRP冗余链路 防止单点故障
  16. linux下载flink安装包
  17. android factorymode下回路测试无声音问题解析
  18. javaBean本质
  19. 学大伟业 Day 1 培训总结
  20. 介绍几个常用的免费的Web前端开发工具

热门文章

  1. npm模块包批量安装_为什么在安装npm软件包或模块之前应该三思而后行
  2. JAVA基础学习博客010
  3. 贵州事业单位计算机专业测试,必看!贵州省各地区事业单位考试重要信息!!!...
  4. [官方培训]15-UE场景搭建和管理 Epic 戴浩军 笔记
  5. 基于nestJS的旅游APP设计与实现
  6. 区块链时代的财富代码——AngelToken
  7. LaTeX 快速入门
  8. Pytorch卷积神经网络经典Backbone(骨干网络)——(VGG)
  9. 嵌入式程序设计学习(4)
  10. 中国的顶级程序员和国外的顶级程序员差距有多大?