简体   繁体   中英

How can I draw an animated line which illustrates flow between two points via OpenLayers?

I need to be able to illustrate water flowing from one point to another.

I have been trying to design a line similar to the progress bar from Bootstrap ( https://getbootstrap.com/docs/4.3/components/progress/#animated-stripes ) without luck. I have researched for quite a while and not able to find a way or extension which were able to solve my problem.

I am therefore asking an OpenLayers export for help.

You can do this by setting the line styles up in the following manner:

  1. Draw a solid stroke/line
  2. Draw a dashed stroke/line over the top with a smaller width
  3. On a timer, increment the lineDashOffset of the dashed line, which will give an animation effect

Example here: https://stackblitz.com/edit/ol-line-animation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM