makinacorpus / Leaflet.FileLayer

Loads files locally (GeoJSON, KML, GPX) as layers using HTML5 File API
http://makinacorpus.github.io/Leaflet.FileLayer/
MIT License
270 stars 91 forks source link

Load different layers with random colors #44

Open agentili opened 7 years ago

agentili commented 7 years ago

I have a visualization problem when an user try to load more than 1 layer falling in the same location. As per actual configuration in my web page I'm not able to assign different colors respect to layers loaded.

Is there any way to change color of layer during the loading??

E.g.

  1. First layer loaded -> green
  2. Second Layer loaded -> red
  3. Third Layer loaded -> blue
  4. Fourth Layer loaded -> any random color

Thanks for your answers

johnd0e commented 5 years ago

Is there any way to change color of layer during the loading??

Sure.

var style = { color: 'green' };
var control = L.Control.fileLayerLoad({ layerOptions: {style: style} }).addTo(map);
control.loader.on('data:loaded', function (e) {
  style.color = 'red'; // change to cycle/random colors
});