refactored to minimize changes of leaflet.filelayer.js