1.1.0 • Published 5 years ago

react-leaflet-ant-path v1.1.0

Weekly downloads
1,141
License
MIT
Repository
github
Last release
5 years ago

React Leaflet Ant Path

A port of Leaflet AntPath for React Leaflet

Demo of the Leaflet AntPath
Original plugin

Now supporting react-leaflet version 2!

Contributing

Want to help? Open a issue or make a PR!
Also, see the guide on how to contribute.

Installing

Via NPM:

 npm install leaflet-ant-path react-leaflet-ant-path

Or Yarn

 yarn add leaflet-ant-path react-leaflet-ant-path

Requirements

Using the plugin

The AntPath component is exported by default:

    import AntPath from "react-leaflet-ant-path";

    // ...
    <AntPath positions={latLngs} options={antPathOptions} />    

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

Parameters

The same as the original plugin.

nametypeexampledescription
latlngsL.LatLng[] or Array[number, number][ [0, 10], [-20, 0], ... ]A path (depends on vector used, default as in polyline constructor )
optionsObject{color: 'red', weight: 5, ...}Same as the vector choosen (default to polyline ) plus the extra options bellow
options.useVector Layer factoryVector to use (default to L.polyline)The vector to enhance with the ant-path animation (check the compatibilty)
options.pausedbooleantrue/falseStarts with the animation paused (default: false)
options.reversebooleantrue/falseDefines if the flow follows or not the path order
options.hardwareAcceleratedbooleantrue/falseMakes the animation run with hardware acceleration (default: false)
options.pulseColorstring#FF00FFAdds a color to the dashed flux (default: 'white')
options.delaystring120Add a delay to the animation flux (default: 400)
options.dashArraynumber, number or string15, 30The size of the animated dashes (default: "10, 20"). See also the pattern

License

This project is under the MIT LICENSE