当前位置:网站首页>Leaflet that supports canvas Path. Dashflow dynamic flow direction line
Leaflet that supports canvas Path. Dashflow dynamic flow direction line
2022-06-12 23:48:00 【GIS weapon warehouse】
Through to leaflet And its plug-in learning , We learned to use Leaflet.Path.DashFlow The plug-in can realize dynamic display of trajectory 、 Dynamic display of pipeline flow direction 、 Dynamic display of river flow , To enhance the visual display effect . The plug-in is very simple to use , Just add lines normally , Join in dashArray and dashSpeed Parameters can be . The core code is as follows :

Be careful , stay
dashSpeedWhen it is negative , The line is a positive flow .
The effect is as follows :

But in the process of using , There is a drawback to the plug-in , It's when you use Canvas How to map ( Initialize map preferCanvas Parameter is true) when , Dynamic effects are not available . How to solve this problem ?
Through to Leaflet.Path.DashFlow as well as leaflet Source code research , It is found that the effect of dynamic line is mainly through dynamic refresh dashOffset The value of the parameter , To change the style of a line .

L.SVG stay _updateStyle When , Updated dashOffset Parameters , however L.Canvas stay _updateStyle when , No updates dashOffset Parameters . This is in Canvas The reason why there is no dynamic effect when drawing with .
L.SVG:

L.Canvas:

thus , We found a solution , That is to say L.Canvas Of _updateStyle In the method , Reference resources L.SVG Treatment mode , Add pair dashOffset Parameter control . The core code is as follows :

For ease of use , We will L.Path.DashFlow Plug in repackaging , This plug-in is cited , Can be in Canvas and SVG Use this plug-in in in two ways .
summary
- Use
Leaflet.Path.DashFlowThe plug-in can realize dynamic display of trajectory 、 Dynamic display of pipeline flow direction, etc . - The default plug-in uses
CanvasHow to map ( Initialize mappreferCanvasParameter istrue) when , Dynamic effects are not available . - By modifying the
L.CanvasIn the code , Can be inCanvasMode to achieve dynamic line effect . - take
L.Path.DashFlowPlug in repackaging , Reference plug-ins , Can be inCanvasandSVGTwo ways to achieve dynamic line effect .
Online example
Original address :http://gisarmory.xyz/blog/index.html?blog=LeafletPathDashFlow.
Focus on 《GIS Zeughaus 》 official account , The first time to get more high quality GIS article .

This article adopts Creative Commons signature - Noncommercial use - Share in the same way 4.0 International licensing agreement Licensing . Welcome to reprint 、 Use 、 Re release , But be sure to keep the signature of the article 《GIS Zeughaus 》( Include links : http://gisarmory.xyz/blog/), Not for commercial purposes , Based on this revised work must be released with the same license .
边栏推荐
猜你喜欢

Redis实现短信验证码登录

如何实现OSM地图本地发布并自定义配图

How to package a colorpicker component for color selection?

2022年G3锅炉水处理考题模拟考试平台操作

Pytorch loading model error resolution

Actual combat | inductance element positioning -- detailed explanation of Halcon and opencv implementation (with source code)

2022年R2移动式压力容器充装考试题及在线模拟考试

NCF 的Dapr应用实例的运行

Using baserecyclerviewadapterhelper to implement tree structure

Redis realizes SMS verification code login
随机推荐
Based on three JS offshore wind power digital twin 3D effect
CST learning: four element array design of circular patch antenna (III) array formation and parallel excitation
基于Three.js海上风电数字孪生三维效果
[matlab] two dimensional curve
Mgr and greatsql resource summary
21 Chundong University blasting safety online peacetime operation 123 [standard answer]
SAP Business Technology Platform (BTP) workflow function introduction
移动安全必备之CS呢【NETHUNTER】
2022 operation of simulated examination platform for hoisting machinery command certificate
How to publish OSM maps locally and customize the mapping
H5時代leaflet中還在用DivIcon?
2022 electrician (elementary) operation certificate examination question bank and online simulation examination
Modify the text color of the menu on the right of toobar
QT actual combat case (38) -- using qpprocess class to realize the function of starting process
Redis realizes SMS verification code login
2202-簡曆制作
Case sharing of online real queuing system reconfiguration -- practical part
Leetcode 2164. 对奇偶下标分别排序(可以,一次过)
C # graphic tutorial (Fourth Edition) chapter7-7.6.1 virtual and override
2022年3月11日记:王老师的春天,奇异的模板模式