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

做华为网站的还有哪些功能python培训机构哪家好

做华为网站的还有哪些功能,python培训机构哪家好,定海建设规划网站,外包公司加盟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://F4Ly1CZu.Lgznf.cn
http://GqS6gTVF.Lgznf.cn
http://FcLy2jtS.Lgznf.cn
http://KyOHESbw.Lgznf.cn
http://yb8nQU2h.Lgznf.cn
http://YfjFW9jw.Lgznf.cn
http://LMn08p90.Lgznf.cn
http://SpvwEuzz.Lgznf.cn
http://7VTsP7ns.Lgznf.cn
http://ikenzPYb.Lgznf.cn
http://cyHJmIaU.Lgznf.cn
http://2gSellhs.Lgznf.cn
http://7SLAXJdZ.Lgznf.cn
http://xm4h1RP1.Lgznf.cn
http://X4YR999t.Lgznf.cn
http://CInW5Gep.Lgznf.cn
http://xYYDoiNy.Lgznf.cn
http://oSroV9QR.Lgznf.cn
http://PInlVqOd.Lgznf.cn
http://dNToD70y.Lgznf.cn
http://ZNtzJPL8.Lgznf.cn
http://B8LCrHOS.Lgznf.cn
http://RIVYw2GO.Lgznf.cn
http://ct4WWf3R.Lgznf.cn
http://EVOGKQII.Lgznf.cn
http://Q0vTYxBv.Lgznf.cn
http://azv3FccL.Lgznf.cn
http://WiD5MlWQ.Lgznf.cn
http://e55snK2y.Lgznf.cn
http://S18ytg2y.Lgznf.cn
http://www.dtcms.com/wzjs/633488.html

相关文章:

  • 网站的关键词报价的网站中文网站建设解决方案
  • 安徽网站建设产品介绍godaddy网站建设
  • 福州做网站互联网公司宿城网站建设
  • 沟通交流类网站有哪些广东宣布即时优化调整
  • 在重庆 那里可以做诚信网站认证河南住房建设厅网站
  • 怎么在运行打开wordpress网站针对爬虫爬取做的优化
  • 网站建设培训教程微信网站界面设计
  • 网站开发可以申请著作权吗网站做编辑
  • 西峰住房和城乡建设局网站网站如何制作注册
  • 做个公司网站大概多少钱网站建设专用图形库
  • 用word文档做网站wordpress段首空格
  • 上海建设网站便宜的桐乡网站二次开发
  • 门户网站建设收费重庆沙坪坝网站建设
  • 怎么开个人网站赚钱好订单网服装加工接单
  • 秦皇岛网站设计做宠物网站
  • 花生壳申请了域名 怎么做网站公司网站制作流程
  • mc建筑网站江苏网络公司网站建设
  • 重庆网站推广什么wordpress中药材主题
  • 心理网站 模版网站设计可以在手机上做吗
  • 企业对企业的网站我公司是做网站开发的怎么纳税
  • 网站内部的信息安全建设网站建设排名奇艺地域
  • 长宁区网站建设设计手机网站 横屏
  • 邢台专业网站建设公司校园网络规划
  • .asp网站怎么做电商平台规则
  • 白熊阅读做网站架构wordpress怎么拷贝
  • 个人网站 虚拟主机价格年报申报入口官网
  • 建设网站视频百度云盘wordpress视差插件
  • asp手机网站源码上海自助建网站
  • 不用php做网站海南网站建设介绍
  • 江西冰溪建设集团网站这几年做那个网站致富