惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
T
Tenable Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
W
WeLiveSecurity
D
DataBreaches.Net
Attack and Defense Labs
Attack and Defense Labs
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
AI
AI
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Schneier on Security
Schneier on Security
T
Threatpost
GbyAI
GbyAI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Help Net Security
F
Full Disclosure
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
M
MIT News - Artificial intelligence
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
Y
Y Combinator Blog
腾讯CDC
The Hacker News
The Hacker News
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园_首页
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 最新话题
Security Latest
Security Latest
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
SegmentFault 最新的问题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LangChain Blog
Vercel News
Vercel News
Cisco Talos Blog
Cisco Talos Blog
量子位
P
Proofpoint News Feed
H
Hacker News: Front Page
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
Project Zero
Project Zero
C
Cisco Blogs

博客园 - 莫小龙

uniapp之plus.downloader.createDownload下载文件传参 谷歌之将网页保存为图片 elementui之table中相同数据的单元格合并 krpano之使用教程 threejs之灯光不跟随OrbitControls控制器旋转 threejs之将张纹理图片组成材质组 canvas之修改Base64图片中不透明部分的颜色 threejs之将PlaneGeometry转换为BufferGeometry threejs之利用shape通过线绘制面和体 threejs之添加渐变背景 threejs之创建发光墙体 paperjs之fitBounds适应区域前后屏幕坐标和输入坐标的转换 arcmap之通过点数据获取等值线 uniapp之安卓APP打开百度地图、高德地图APP geoserver之图片图标样式 SHP转WKT文件工具 openlayers之geoserver的wms图层mysql数据源数据修改后更新问题 通过日照时数计算每天RAD(太阳辐射)值 Uniapp之安卓签名证书(.keystore)生成
openlayer之添加带箭头的线
莫小龙 · 2025-04-16 · via 博客园 - 莫小龙

openlayer之添加带箭头的线

样式代码:

resolution参数用于控制箭头之间的间距
var styles = function(resolution) {
                    var geometry = this.getGeometry();
                    var length = geometry.getLength(); //获取线段长度
                    var radio = (25 * resolution) / length;
                    var dradio = 1; //投影坐标系,如3857等,在EPSG:4326下可以设置dradio=10000
                    var styles = [
                        new ol.style.Style({
                            stroke: new ol.style.Stroke({
                                color: "green",
                                width: 10,
                            })
                        })
                    ];
                    for (var i = 0; i <= 1; i += radio) {
                        var arrowLocation = geometry.getCoordinateAt(i);
                        geometry.forEachSegment(function(start, end) {
                            if (start[0] == end[0] || start[1] == end[1]) return;
                            var dx1 = end[0] - arrowLocation[0];
                            var dy1 = end[1] - arrowLocation[1];
                            var dx2 = arrowLocation[0] - start[0];
                            var dy2 = arrowLocation[1] - start[1];
                            if (dx1 != dx2 && dy1 != dy2) {
                                if (Math.abs(dradio * dx1 * dy2 - dradio * dx2 * dy1) < 0.001) {
                                    var dx = end[0] - start[0];
                                    var dy = end[1] - start[1];
                                    var rotation = Math.atan2(dy, dx);
                                    styles.push(new ol.style.Style({
                                        geometry: new ol.geom.Point(arrowLocation),
                                        image: new ol.style.Icon({
                                            src: 'static/icon/routearrow.png',
                                            anchor: [0.5, 0.5],
                                            scale: 0.075,
                                            rotateWithView: false,
                                            rotation: -rotation + 0.5* Math.PI
                                        })
                                    }));
                                }
                            }
                        });
                    }
                    return styles;
                }

样式调用:

图片文件:

效果:

钻研不易,转载请注明出处。。。。。。