All Projects β†’ rubenspgcavalcante β†’ Leaflet Ant Path

rubenspgcavalcante / Leaflet Ant Path

Licence: mit
🌿🐜 Creates a leaflet polyline with a 'ant-path' animated flux

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Leaflet Ant Path

Geopackage Js
GeoPackage JavaScript Library
Stars: ✭ 191 (-35.47%)
Mutual labels:  leaflet-plugins, leaflet
leaflet.tilelayer.gloperations
Custom Leaflet TileLayer using WebGL to do operations on and colorize floating-point pixels
Stars: ✭ 15 (-94.93%)
Mutual labels:  leaflet, leaflet-plugins
Ngx Leaflet Starter
A soup of Angular and Leaflet
Stars: ✭ 208 (-29.73%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.layergroup.collision
Leaflet plugin for uncluttering L.Markers using basic collision detection.
Stars: ✭ 82 (-72.3%)
Mutual labels:  leaflet-plugins, leaflet
leaflet-area-select
Control to just select an area and provide bbox for it
Stars: ✭ 27 (-90.88%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: ✭ 90 (-69.59%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.pixioverlay
Bring Pixi.js power to Leaflet maps
Stars: ✭ 264 (-10.81%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.extras2
Extra functionality for leaflet R package.
Stars: ✭ 37 (-87.5%)
Mutual labels:  leaflet-plugins, leaflet
esri-leaflet-vector
Display ArcGIS Online vector basemaps w/ Esri Leaflet
Stars: ✭ 39 (-86.82%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.TileLayer.Fallback
Replaces missing Tiles by scaled lower zoom Tiles
Stars: ✭ 29 (-90.2%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.featuregroup.subgroup
Creates a Feature Group that adds its child layers into a parent group when added to a map (e.g. through L.Control.Layers)
Stars: ✭ 79 (-73.31%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.MarkerCluster.LayerSupport
Sub-plugin for Leaflet.markercluster plugin; brings compatibility with Layers Control and other plugins
Stars: ✭ 53 (-82.09%)
Mutual labels:  leaflet, leaflet-plugins
Leaflet.path.drag
Drag functionality for Leaflet vector layers
Stars: ✭ 72 (-75.68%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.browser.print
A leaflet plugin which allows users to print the map directly from the browser
Stars: ✭ 94 (-68.24%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Geoman
πŸ‚πŸ—ΊοΈ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+267.57%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet Panel Layers
Leaflet Control Layers extended with support groups and icons
Stars: ✭ 210 (-29.05%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.flowecharts
leaflet plugin for Baidu Echarts
Stars: ✭ 17 (-94.26%)
Mutual labels:  leaflet-plugins, leaflet
Leaflet.markercluster.freezable
Adds ability to freeze clusters at specified zoom
Stars: ✭ 21 (-92.91%)
Mutual labels:  leaflet-plugins, leaflet
leaflet-defaulticon-compatibility
Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS.
Stars: ✭ 71 (-76.01%)
Mutual labels:  leaflet, leaflet-plugins
harp-leaflet
Leaflet plugin for harp.gl
Stars: ✭ 16 (-94.59%)
Mutual labels:  leaflet, leaflet-plugins

Leaflet Ant Path

leaflet-ant-path logo
Build Status NPM Downloads Codacy Badge npm version Bower version Greenkeeper badge

Creates a leaflet polyline with a 'ant-path' animated flux

Live demo here
example of the animation

Installing

Via NPM:

 npm install --save leaflet-ant-path 

Via Yarn:

 yarn add leaflet-ant-path

Via Bower:

 bower install leaflet-ant-path

Or just download this source code

Requirements

  • Leaflet >= 1

Browsers support

IE / EdgeIE / Edge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari SamsungSamsung OperaOpera
IE10-11, Edge => 12 >= 3 >= 8 >= 6 >= 6 >= 4 >= 10

*This list is based on the feature SVG filter

UMD compatible

Can be used with asynchronous module loaders and CommonJS packers

Using the plugin

It's just like a polyline:

    // Using the constructor...
    let antPolyline = new L.Polyline.AntPath(latlngs, options);
    
    // ... or use the factory
    antPolyline = L.polyline.antPath(latlngs, options);
    
    antPolyline.addTo(map);

Update: Using more Vectors

On this version you now can use diferent vector other than polyline, passing the factory to the option.use. Currently tested support:

// Using a polygon
const antPolygon = antPath([
  [51.509, -0.08],
  [51.503, -0.06],
  [51.51, -0.047]
], { use: L.polygon, fillColor: "red" });

// Using a circle
const antCircle = antPath(
  [51.508, -0.11],
  {
    use: L.circle
    color: 'red',
    fillColor: '#f03',
    fillOpacity: 0.5,
    radius: 500
  }
);

// Using a curve (Leaflet.curve plugin)
const antCurve = antPath([
  "M",
  [50.54136296522163, 28.520507812500004],
  
  "C",
  [52.214338608258224, 28.564453125000004],
  [48.45835188280866, 33.57421875000001],
  [50.680797145321655, 33.83789062500001],
  
  "V",
  [48.40003249610685],
  
  "L",
  [47.45839225859763, 31.201171875],
  [48.40003249610685, 28.564453125000004],
  
  "Z"
  ],
  {use: L.curve, color: "red", fill: true })

Importing

Using with ES6 imports

    import { AntPath, antPath } from 'leaflet-ant-path';
    
    // Usethe constructor...
    let antPolyline = new AntPath(latlngs, options);
    
    // ... or use the factory
    antPolyline = antPath(latlngs, options);   
    
    antPolyline.addTo(map);

Using with AMD:

require(['leaflet-ant-path'], function(AntPathModule) {
    // Use the constructor ...
    let antPolyline = new AntPathModule.AntPath(latlngs, options);
    
    // ... or use the factory
    antPolyline = AntPathModule.antPath(latlngs, options);
    
    antPolyline.addTo(map);
});

Using with browserify:

    const { AntPath, antPath } = require('leaflet-ant-path');

Parameters

The AntPath extends from the FeatureGroup and implements the Path interface. Initialise with the same options of a common Polyline, with some extra options, like the flux color.

name type example description
latlngs L.LatLng[] or Array[number, number] [ [0, 10], [-20, 0], ... ] A path (depends on vector used, default as in polyline constructor )
options Object {color: 'red', weight: 5, ...} Same as the vector choosen (default to polyline ) plus the extra options bellow
options.use Vector Layer factory Vector to use (default to L.polyline) The vector to enhance with the ant-path animation (check the compatibilty)
options.paused boolean true/false Starts with the animation paused (default: false)
options.reverse boolean true/false Defines if the flow follows or not the path order
options.hardwareAccelerated boolean true/false Makes the animation run with hardware acceleration (default: false)
options.pulseColor string #FF00FF Adds a color to the dashed flux (default: 'white')
options.delay string 120 Add a delay to the animation flux (default: 400)
options.dashArray [number, number] or string [15, 30] The size of the animated dashes (default: "10, 20"). See also the pattern

Methods

name returns description
pause() boolean Stops the animation
resume() booelan Resume the animation
reverse() this instance Reverses the animation flow
map(callback) new AntPath or extended class Iterates over the latlngs

Also have the same as the L.Polyline API and with the same behaviour. See it here.


Extras!

ES6/ES2015 features

Thinking in the new features of JavaScript, and its new way of programing, AntPath has some nicely features to work with ES6.

spreadable

When spread the path, you will receive it lat/lngs array;

    //...
    const antPathLayer = new AntPath(path, options);
    const anotherAntPath = new AntPath(path2, options);
    
    const latLngs = [...antPathLayer, ...anotherAntPath];

iterable

Use a for ... of ... to iterate over the path coordinates

for(let latLng of antPath) {
    // do something with it latLngs ...
}

extensible

You can create you custom 'class' based on the AntPath:

class CustomAntPath extends AntPath {
    //...
}

map method

AntPath has a map method as the Array, returning a new instance of AntPath (or the child class which extends it, because of its Functor property):

//New path with translated path
const newAnthPath = myAntPath.map(pos => latLng(pos.lat + 1, pos.lng + 1));

With or without polyfills

The module provide two bundles, the full one, with some es6 polyfills (loaded by default when importing) and the lighter one without the polyfills. If you're already uses the following polyfills in your project:

  • core-js/es6/symbol
  • core-js/es6/reflect

Just use the lighter version (leaflet-ant-path.es6.js). If not, just use the full bundle.

Contributing

Find any bug? Open a issue or make a PR!
Also, see the guide on how to contribute.

License

This project is under the MIT LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].