133.在 Vue3 中使用 OpenLayers 实现画多边形、任意编辑、遮罩与剪切处理功能

🎬 效果演示截图(先睹为快)

✨ 功能概览:

  • ✅ 鼠标画任意形状多边形;

  • ✏️ 点击“修改边界”可拖动顶点;

  • 🟥 点击“遮罩”后地图除多边形区域外变红;

  • ✂️ 点击“剪切”后仅显示选中区域;

  • ❌ 点击“取消”按钮恢复地图。

📸 示例截图如下(运行后效果类似):


🧭 项目背景

在地图可视化开发中,我们常常需要:

  • 用户绘制特定区域(如选区、高亮区);

  • 支持图形的交互编辑;

  • 结合遮罩或剪切来突出或限制显示区域。

本篇教程将通过 Vue3 + OpenLayers + ol-ext 来实现这套完整功能,适合用于城市规划、环境监控、园区展示等场景。


🧱 技术栈介绍

技术 说明
Vue 3
利用Openlayers4实现地图遮罩效果(二) 之前实现的遮罩效果,在深色背景的底图上,对要突出的区域采用半透明遮罩,以此来突出该区域。但是有时底图颜色偏白,这时候不再适合对要突出的区域采用遮罩,而是要对突出区域之外进行遮罩处理。两种效果的对比入下图: ... 阅读详情

相关推荐

Vue和OpenLayers实现画布遮罩效果的JavaScript

通过创建一个透明的PNG图片,并使用OpenLayers的图层功能,我们可以为地图创建自定义的遮罩层。在本文中,我们将使用Vue和OpenLayers库来实现一个画布遮罩效果。通过这个效果,我们可以在地图上创建一个自定义的遮罩层,以突出显示特定区域或隐藏敏感信息。上述代码中,我们首先导入了所需的OpenLayers模块,并创建了一个基本的地图实例。然后,我们添加了一个用于遮罩效果的图层。以上代码中,我们创建了一个id为’map’的元素作为地图容器,并设置了宽度为100%、高度为100vh的样式。

TechNovaX的博客 501

openlayers:实现地图遮罩效果(附完整源码)

openlayers:实现地图遮罩效果(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 977

openlayers全面教程306+【目录】

vue+openlayers系列教程旨在为开发者提供简单快捷的示例。在每一个示例中,解释相应的API知识点。

大剑师兰特的GIS世界 2万+

Vue3+Openlayers教程导航页【目录】

欢迎来到 Vue3+Openlayers 系列教程,这里是我在 CSDN 编写的所有 Vue3+Openlayers 系列相关文章的索引页,适合初学者到进阶用户系统阅读。👀 更多教程正在持续更新中,欢迎关注我,一起探索 Openlayers 的强大魅力!

小彭的博客 1290

049:vue+openlayers 鼠标pointermove显示城市名片

本示例的目的是介绍演示如何在vue+openlayers中采用overlay实现城市名片的效果,移动鼠标到相应的位置点,出现城市的信息。

大剑师兰特的GIS世界 2962

132.在 Vue3 中使用 OpenLayers 实现地图剪切与遮罩效果

本文介绍了如何在Vue3中使用OpenLayers和ol-ext插件实现地图遮罩与裁剪功能。通过加载中国边界GeoJSON数据,可进行三种操作:点击"遮罩"按钮对指定区域进行灰色半透明遮罩;点击"剪切"按钮仅显示选定区域;点击"取消"恢复原始地图。技术栈包含Vue3 Composition API、OpenLayers地图渲染、ol-ext特效处理以及ElementPlus和TailwindCSS。核心代码展示了地图初始化、遮罩/裁剪功能实现逻辑,

小彭的博客 663

134:vue+openlayers 编辑事件modifystart和modifyend(示例代码)

本示例的目的是介绍如何在vue+openlayer中使用draw来绘制多边形,并通过modify修改多边形。同时在modifystart和modifyend中设置了提示信息。点击查看本专栏内容目录列表。

大剑师兰特的GIS世界 1059

openlayers遮罩示例

一个基于openlayer创建地图遮罩的前端代码示例。 使用方法 1. 安装依赖 npm i 2. 项目启动 npm start

软件测试--用例篇(测试用例的好处、测试用例的七种设计方法、测试用例的粒度、测试用例的评价)

作为软件测试工程师,最主要的工作就是:编写测试用例,那么为什么要编写测试用例?它有什么好处?如何编写测试用例?测试用例写简单好还是复杂好?如何评价测试用例的质量? 天呐撸!能说不会吗?! 作为倾向软件测试工程师的老铁们,还是一起来学习吧! 一、编写测试用例的好处 测试用例是测试者的依据 测试用例使得工作可重复,是自动化测试的基础 补充:自动化测试的前提条件是:功能比较稳定,页面...

cherrydreamsover的博客 3738

字符串相似度比较算法:Jaro–Winkler similarity的原理及实现

前言 在前面的文章中,笔者有对编辑距离以及Levenshtein距离进行详细的说明,其实levenshtein距离是编辑距离的其中一种定义,本文所说的Jaro距离是编辑距离的另外一种定义,它也是对两个字符串的相似度进行衡量,以得出两字符串的相似程度。下面我们一起来学习这个算法的原理以及实现吧。 标题算法定义 下面先说说Jaro distance(又称Jaro similarity),这是由Matt...

蓝天白云梦的csdn博客 1万+

基于互相关(NCC)模板匹配——find_ncc_model_defocused.hdev

相关性原理:仅在NCC(r,c) = ±1时,模板与图像完全匹配; NCC绝对值越大,表示模板与正在检测部分图像越接近; NCC绝对值越接近于零,表示模板与图像越不一致。 线性光照变化不会影响NCC计算结果。 重要函数一: 创建模板:create_ncc_model( Template : : NumLevels, AngleStart, AngleExtent, AngleStep, Metric : ModelID) 参数列表: Template(in):单通道灰度图像,它的区域可被创建为模板。 Num

m0_51271525的博客 3416

立创开源:基于STM32F103与ADS1256的六维力传感器低成本实现方案

本文详细介绍了一种基于STM32F103微控制器与ADS1256高精度ADC的低成本六维力传感器实现方案。该方案通过3D打印的六梁弹性体结构结合应变片,将多维力信号转换为电信号,并由24位ADC进行高精度采集。文章涵盖了硬件选型、电路设计、嵌入式软件驱动及上位机数据可视化全流程,为机器人、精密测量等领域的爱好者提供了一个可复现的开源实践参考。

weixin_34718952的博客 399

Android 14.0 SystemUI下拉通知栏通知去掉长按事件

在14.0的系统rom产品定制化开发中,在systemui模块中关于下拉状态栏这块也是非常重要的部分,最近在关于systemui下拉通知栏的每条通知部分 要求去掉通知栏通知的长按事件,不需要长按功能,所以就需要分析下关于长按事件是在哪里注册的,然后去掉就可以了,接下来分析实现 相关功能

安卓兼职framework和app工程师的博客 281

深度揭秘!用 DeepSeek 打造超智能电商客服系统全流程

摘要:本文围绕使用 DeepSeek 开发电商智能客服展开详细教程。先介绍前期准备,包括了解 DeepSeek、获取 API 权限与搭建开发环境。接着阐述数据收集预处理,结合电商业务逻辑实现商品与订单信息查询。还提及优化性能的方法,如模型微调、多轮对话管理和错误处理。然后说明了基于 Web 和云平台的部署方案。最后强调持续监控和改进的重要性,通过设置监控指标、收集分析用户反馈来优化系统,助力开发者打造高效电商智能客服。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 7820

SAP 打印输出中 `#` 字符替代日文汉字的根本原因与全面解决方案

只要认清设备类型 / 字符集 / 字体三角关系,并合理利用PDFUCSWINCF或 UPE + URDT,LP01里那些恼人的就会彻底消失,日文汉字将在纸面与 PDF 中如预览一样完美呈现。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 826

麒麟操作系统提示“默认密钥环已上锁”的解决办法

麒麟操作系统提示“默认密钥环已上锁”的解决办法

太极淘的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

上一篇: 132.在 Vue3 中使用 OpenLayers 实现地图剪切与遮罩效果
下一篇: 134.在 Vue3 中使用 OpenLayers 根据坐标点数组绘制多边形并显示面积数
吉檀迦俐
吉檀迦俐 新星创作者: 前端开发技术领域 新星创作者: 前端开发技术领域
博客等级 码龄4年 4142粉丝 300原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吉檀迦俐

你的鼓励奖是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址