当前位置: 首页 > 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/480051.html

相关文章:

  • 集团网站设计特性免费网络推广网站
  • 南通营销网站制作重庆网站制作系统
  • 做网站的做app的查企业信息查询平台
  • 做网站哪些软件百度云搜索
  • 五大搜索引擎 三大门户网站如何使用免费b站推广网站
  • 好的模板网站百度网页广告怎么做
  • 微商的自己做网站叫什么名字百度seo新算法
  • ssh做的大型网站买链接官网
  • 房地产网站推荐建立网站的几个步骤
  • 太仓网站优化百度刷seo关键词排名
  • 手机网站后台源码新东方教育机构官网
  • 青岛网站建设兼职刷关键词排名软件有用吗
  • a做爰网站网站优化的方式有哪些
  • 精品课程网站建设现状标题seo是什么意思
  • 网站建设加盟2022新闻热点10条
  • 温州免费做网站hyein seo
  • 网站经营许可备案中国十大企业培训机构排名
  • 专门做物业催收的网站sem推广是什么
  • 网站上的图片怎么替换百度网络营销中心app
  • 石家庄做淘宝网站谷歌推广公司
  • 网站后台管理生成器青岛官网seo公司
  • 建立个人网站服务器惠州seo外包
  • 如何判断一个网站是恶意网站抖音搜索关键词推广
  • 经营购物网站营销对企业的重要性
  • ps中怎样做网站轮播图片饥饿营销案例
  • 在韩国申请网站域名需要什么百度网页版登录入口官网
  • 织梦网站被挂马怎么处理免费发布信息的网站平台
  • 怎样注册免费网站东莞seo公司
  • 怎么做类似淘宝网站seo搜索引擎优化实训报告
  • 我要做网站推广真正免费建站网站