Skip to content

A Leaflet plugin to create wind arrows with direction and velocity (wind barbs)

License

Notifications You must be signed in to change notification settings

rikimarutsui/Leaflet.windbarb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leaflet.windbarb

A small Leaflet plugin to generate wind barbs / wind arrows

Leaflet.idw generates wind barbs according to the wind barb standard shown [here] (https://commons.wikimedia.org/wiki/Wind_speed).

Requirements

This plugin needs Leaflet version v1.0.0beta2 or above.

Demos

  • Example (Mobile: Working on Samsung Galaxy s4)

Examples

Image of wind barbs

Example of changed colour (Kudos Rickyars):

Image of wind barbs with colour change

Basic Usage

var icon = L.WindBarb.icon({lat: 40, deg: 90, speed: 20, pointRadius: 5, strokeLength: 20});
var marker = L.marker([lat,long], {icon: icon}).addTo(map);

Example of how to mirror velocity indication on southern hemisphere

            if(latitude<0){
              var icon = L.WindBarb.icon({mirrorVel: true, deg: p[3], speed: p[2]});  
            }else{
              var icon = L.WindBarb.icon({lat: p[0], deg: p[3], speed: p[2]});
            }
  • The lat is used to see if point is on north or south hemisphere

Example of how to change the icon options

			var icon = L.WindBarb.icon({fillColor: '#FFFFFF', strokeColorCircle: '#666666', deg: p[3], speed: p[2]});  
  • You may also setup the global options and append with the windbarb data

To include the plugin, just use leaflet-windbarb.js from the src folder:

<script src="leaflet-windbarb.js"></script>

Options

Generates a wind barb / wind arrow icon with the following options:

pointRadius - Radius of point in the middle; Default = 8
strokeColorCircle - The circle stroke line color; Default: #010101
strokeColorPath - The Path of the stroke line color; Default: #000000
flagFillColor - The Flag Color; Default: #000000
strokeWidth - Stroke width; Default = 2
strokeLength - Length of the main stroke, to which the barbs are connected; Default = 15
barbSpaceing - Spacing between the barbs; Default = 5
barbHeight - Height of 10kn adn 50kn barbs, 5kn barbs will be 50%; Default = 15
forceDir - If set to "true" the direction will always be shown, even if speed < 2.5kn; Default = false
fillColor - Set the fill colour of the circle - Default = #2B85C7 (Thanks  Rickyars (https://github.com/rickyars))
mirrorVel - mirrors velocity indication; default = false        

Changelog

0.0.6 - February, 2019

Add change stroke and flag color ability into the script

0.0.5 - March 30, 2017

Velocity indication should always point to equator

0.0.4 - March 30, 2017

Rickyars kindly added option to change fill colour

0.0.3 - January 30, 2017

Updated to current Leaflet version (1.0.3). Fixed marker offset issue.

0.0.1 — May 28, 2016

Initial release.

About

A Leaflet plugin to create wind arrows with direction and velocity (wind barbs)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 84.6%
  • HTML 15.4%