当前位置: 首页 > wzjs >正文

施工合同电子版seo推广优化官网

施工合同电子版,seo推广优化官网,做报表的网站,注销网站 注销主体1. 使用场景 在开发WebGIS应用时,我们常需要将自定义UI组件与地图元素结合。本文介绍如何将Vue组件集成到Mapbox/Maplibre的Marker标记点和Popup弹窗中,实现动态交互式的地图功能。 2. 为什么需要特殊处理? 在常规开发中我们大多的处理是 …

1. 使用场景

在开发WebGIS应用时,我们常需要将自定义UI组件与地图元素结合。本文介绍如何将Vue组件集成到Mapbox/Maplibre的Marker标记点和Popup弹窗中,实现动态交互式的地图功能。

2. 为什么需要特殊处理?

在常规开发中我们大多的处理是

const tipsEle = document.createElement("div")tipsEle.setAttribute("class", "tips")tipsEle.style.color = "#e73f32"tipsEle.style.fontSize = "12px"tipsEle.style.fontWeight = "400"tipsEle.innerHTML = "删除"const tipsOption = {element: tipsEle,anchor: "left",offset: [-45, 30],}new maplibregl.Marker(tipsOption).setLngLat(coords).addTo(map)

这样的写法显而易见维护难,调试难,ui在复杂一点复杂程度也跟着上去了,如果换成组件形式的话,所有问题迎刃而解了。

3. 使用createVNode实现

/*** @description: 创建地图Marker 和 Popup 组件, 渲染自定义组件* @author: jihai* @createTime: 2025/03/05 15:05:01*/
import {createVNode, render} from "vue";
import * as maplibregl from 'maplibre-gl';class CreateVNode{declare map:anydeclare coordinates:anydeclare markerComponentId: stringdeclare marker:anydeclare markerElement: anydeclare popupComponentId: stringdeclare popup:anydeclare popupElement: anyconstructor(option: {map: any,coordinates: any}) {const {map, coordinates} = optionthis.map = mapthis.coordinates = coordinatesthis.markerComponentId = `markerComponentId-${performance.now().toString()}`this.marker = nullthis.markerElement = nullthis.popupComponentId = `popupComponentId-${performance.now().toString()}`this.popup = nullthis.popupElement = null}createMarker(options: {component: {component: any, // 自定义vue组件props: any      // 自定义组件props},config?: {offset: number[],anchor: string}}){const { component, config } = optionsconst app = createVNode(component?.component, {data: component?.props})this.markerElement = document.createElement("div")this.markerElement.setAttribute("id", this.markerComponentId)this.marker = new maplibregl.Marker({element: this.markerElement,anchor: config?.anchor ?? 'bottom',offset: config?.offset ?? [0, 0]}).setLngLat(this.coordinates).addTo(this.map)render(app, this.markerElement)}createPopup(options: {component: {component: any, // 自定义vue组件props: any      // 自定义vue组件props},config?: {offset: number[],anchor: string,closeButton: boolean}}){const { component, config } = optionsconst app = createVNode(component?.component, {data: component?.props})this.popupElement = document.createElement("div")this.popupElement.setAttribute("id", this.popupComponentId)this.popup = new maplibregl.Popup({className: 'custom-popup', closeButton: config?.closeButton ?? true, anchor: config?.anchor ?? 'bottom'}).setMaxWidth('none').setOffset(config?.offset ?? [0, 0]) // 这里设置偏移量.setLngLat(this.coordinates).setDOMContent(this.popupElement).addTo(this.map)render(app, this.popupElement)}removeMarker(){if(this.marker){this.marker.remove()}if(this.markerElement){this.markerElement.remove()}}removePopup(){if(this.popup){this.popup.remove()}if(this.popupElement){this.popupElement.remove()}}remove(){this.removeMarker()this.removePopup()}
}export default CreateVNode

4. 使用方法

  // 简单使用 具体使用根据业务场景合理清除图层let marker = new CreateVNode({map: map,coordinates: coordinates})marker.createMarker({component: {component: markerComp,props: markerProps},config: {offset: [0, 120],anchor: 'bottom'}})//  图层清除marker.removeMarker()marker = null

5. 效果展示

红色框里为element组件渲染结果
在这里插入图片描述

http://www.dtcms.com/wzjs/461976.html

相关文章:

  • 邢台做网站优化泰州seo外包公司
  • 有趣的网站官网企业网站建设优化
  • 网站建设岗位职责b2b网站免费推广
  • 赤峰网站建设red百度指数官网数据
  • 淘宝客网站建设任务2024会爆发什么病毒
  • 网站建设天津营销策划案的模板
  • 有哪些可以做头像的网站百度seo关键词优化软件
  • 免费云服务器推荐排名优化哪家专业
  • 怎么用ps做网站幻灯片发外链的网址
  • 我的世界做头像的网站百度seo关键词外包
  • wordpress 今日头条关键词排名优化教程
  • 富阳做网站洛洛科技网络营销与直播电商就业前景
  • 辽宁省建设工程信息网平台电话网站搜索引擎优化技术
  • sqlite 做网站响应式网站模板的特点
  • 合肥做网站怎么样深圳网络营销平台
  • 网站开发仓库管理系统需求分析写软文一篇多少钱合适
  • 上海正规网站制作价格百度快照收录
  • 苏州哪家公司做网站百度搜索榜单
  • 网站开发+接活重庆人力资源和社会保障网
  • wordpress 手机 看视频播放器优化排名软件
  • h5建站免费全球疫情最新消息
  • 微信开店小程序怎么弄百度怎么做关键词优化
  • 网站建设技术服务公司网络营销的六个特点
  • 橙云网站建设前端性能优化
  • 可以看小视频的浏览器seo竞价排名
  • it做私活的网站seo引擎优化专员
  • 青岛市政府官方网站app百度竞价托管代运营公司
  • 懒人学做网站黑帽seo是什么意思
  • 怎么在ftp看网站后台地址南宁百度关键词排名公司
  • 沈阳公司网站制作深圳网站快速排名优化