Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-ant-path

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-ant-path

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

  • 0.6.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.8K
increased by29.94%
Maintainers
1
Weekly downloads
 
Created
Source

Leaflet Ant Path

leaflet-ant-path logo
Build Status Codacy Badge npm version Bower version

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

Live demo here
example of the animation

Contributing

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

Installing

Via NPM:

 npm install leaflet-ant-path

Via Bower:

 bower install leaflet-ant-path

Or just download this source code

Requirements

  • Leaflet >= 1

UMD compatible

Can be used with asynchronous module loaders and CommonJS packers

Important!

MultiAntPath was removed, and now AntPath doesn't support the legacy version anymore (0.7.7). If you're still using MultiAntPath and Leaflet 0.7, use older AntPath versions than 0.6

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);

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.

nametypeexampledescription
latlngsL.LatLng[] or Array[number, number][ [0, 10], [-20, 0], ... ]A array of latitude and longitudes (same as used in Polyline constructor )
optionsObject{color: 'red', weight: 5, ...}Same as the Polyline options plus the extra options bellow
options.pausedbooleantrue/falseStarts with the animation paused (default: false)
options.pulseColorstring#FF00FFAdds a color to the dashed flux (default: 'white')
options.delaystring120Add 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

namereturnsdescription
pause()booleanStops the animation
resume()booelanResume the animation
map(callback)new AntPath or extended classIterates 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:

  • regenerator-runtime
  • 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.

License

This project is under the MIT LICENSE

Keywords

FAQs

Package last updated on 08 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc