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

openLayers切换基于高德、天地图切换矢量、影像、地形图层

1、需要先加载好地图,具体点此链接

openLayers添加天地图WMTS、XYZ瓦片服务图层、高德地图XYZ瓦片服务图层-CSDN博客文章浏览阅读31次。本文介绍了基于OpenLayers的地图交互功能实现,主要包括以下内容: 地图初始化:支持天地图XYZ/WMTS瓦片服务和高德地图两种底图加载方式,可通过配置参数控制不同图层的显示。 交互功能: 标记点添加:支持动态创建可拖拽的标记点 折线绘制:提供平滑曲线功能,使用chaikin-smooth算法优化线条效果 轨迹模拟:实现路径动画效果,可设置航向角和轨迹线 知识图谱式交互:由静态线条和可拖拽点构成 实现细节: 使用ol/layer/Vector管理矢量图层 通过ol/interaction/Transl https://blog.csdn.net/ssy001128/article/details/148759666

2、加载完成后,搭建切换图层页面,并实现切换功能

图片自行下载

<template><div class="map-array" :style="{ width: targetWidth + 'px' }"><divclass="layers"@click="setFloatDiv(item, index)"v-for="(item, index) in mapArray":key="index":title="item.text"><img :src="item.img" alt="" ref="img" /><p>{{ item.text }}</p></div></div><div class="staic" @mouseenter="handleHover()"><img :src="mapArray[activeIndex].img" alt="" ref="img" /><p>{{ mapArray[activeIndex].text }}</p></div>
</template><script>
import * as mapUtils from "../components/mapUtils";
import shiliang from "../assets/shiliang.png";
import yingxiang from "../assets/yingxiang.png";
import dixing from "../assets/dixing.png";
export default {data() {return {mapArray: [{img: shiliang,text: "矢量地图",type: "VECTOR",},{img: yingxiang,text: "影像地图",type: "RASTER",},{img: dixing,text: "地形地图",type: "TOPOGRAPHY",},],activeIndex: 0,maptype: "VECTOR",targetWidth: 0,};},methods: {setFloatDiv(id, index) {this.maptype = id.type;this.activeIndex = index;const mark = id.type + "MARK";const layers = mapUtils.getMap().getLayers().getArray().filter((layer) => layer.getProperties().layerId === "TileLayers");layers.forEach((item) => {item.setVisible(false);if (item.values_.id === id.type || item.values_.id === mark) {item.setVisible(true);this.targetWidth = 0;}});},handleHover() {this.targetWidth = 300;},},
};
</script><style lang="scss">
.map-array {position: absolute;z-index: 1;display: flex;width: 0px;height: 64px;bottom: 2%;right: 116px;overflow: hidden;transition: width 0.3s ease; // 添加过渡效果.layers {width: 100px;position: relative;cursor: pointer;img {width: 100px;height: 100%;object-fit: cover; // 确保图片正确填充}p {position: absolute;bottom: 0;margin: 0;background-color: rgba(0, 0, 0, 0.5);text-align: center;width: 100%;color: #fff;}}
}
.staic {position: absolute;z-index: 1;bottom: 2%;right: 16px;height: 64px;img {width: 100px;height: 100%;object-fit: cover; // 确保图片正确填充}p {position: absolute;bottom: 0;margin: 0;background-color: rgba(0, 0, 0, 0.5);text-align: center;width: 100%;color: #fff;}
}
</style>

 

http://www.lryc.cn/news/572184.html

相关文章:

  • Zabbix监控系统安装部署(图文)
  • Linux简单了解以及VM虚拟机的安装使用(后端程序员)
  • 探秘阿里云EBS存储:云计算的存储基石
  • LINUX 619 NFS rsync
  • 深度学习-164-MCP技术之开发本地MCP服务器和异步客户端
  • LTC3130EMSE#TRPBF ADI电子元器件深度解析 物联网/工业传感器首选!
  • AWS GuardDuty邮件推送设置
  • 刘波卸任OPPO法定代表人、经理等职务,段要辉“接棒”
  • C++ 互斥量
  • 【Python】python系列之函数作用域
  • 微信小程序获取指定元素,滚动页面到指定位置
  • Maven镜像
  • ssh配置sftp,实现上传下载文件
  • uni-app总结4-项目配置+HBuilder插件使用+uni插件使用
  • 正则表达式一些例子
  • 视频续播功能实现 - 断点续看从前端到 Spring Boot 后端
  • 【Bug:docker】--Docker同时部署Dify和RAGFlow出现错误
  • web3 浏览器注入 (如 MetaMask)
  • 无人机电调技术要点与突破解析!
  • 插值与模板字符串
  • 宇鹿家政服务系统小程序ThinkPHP+UniApp
  • Spring Boot 工程启动以后,我希望将数据库中已有的固定内容,打入到 Redis 缓存中,请问如何处理?
  • WEB安全--WAF的绕过思路
  • Flutter中FutureBuilder和StreamBuilder
  • 对gateway和nocas的理解
  • DeepSeek 助力 Vue3 开发:打造丝滑的日历(Calendar),日历_项目里程碑示例(CalendarView01_22)
  • 局域网即时通讯软件评测:4款支持私有化部署的通讯软件对比
  • 2025 Java EasyExcel 基于Excel模板填充数据 SpringBoot+Mybatis-Flex
  • el-image在表格中显示,弹出的预览图片被遮挡,如何解决
  • 【网络空间安全】数据安全