Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileLayerLoad() returns undefined property 'loader' #64

Open
mwolfhoffman opened this issue Jan 26, 2019 · 3 comments
Open

fileLayerLoad() returns undefined property 'loader' #64

mwolfhoffman opened this issue Jan 26, 2019 · 3 comments

Comments

@mwolfhoffman
Copy link

I am getting errors that I cannot read the 'on' property of undefined.
Therefore, in the example below (copied from the Readme's event example), control.loader is undefined.

    var control = L.Control.fileLayerLoad();
    control.loader.on('data:loaded', function (event) {
        // event.layer gives you access to the layers you just uploaded!

        // Add to map layer switcher
        layerswitcher.addOverlay(event.layer, event.filename);
    });
@leplatrem
Copy link
Collaborator

This plugin probably needs to be updated with latest versions of Leaflet...

@johnd0e
Copy link

johnd0e commented Mar 26, 2019

This example is broken indeed.
Actually loader property is available only after we add control to map.

So this should work:

 var control = L.Control.fileLayerLoad().addTo(map);

@johnd0e
Copy link

johnd0e commented Mar 29, 2019

BTW, I think that loader could be initialized immediately on control creation (loader._map can be initialized later).

If user tries to use loader before adding control to map it may throw error.
But actually I do not see any reason why loader should strictly require map: options.addToMap can be false.

P.S.
Also I suppose that L.FileLayer.FileLoader has not to be extended from L.Layer as it's not layer, and does not benefit from any L.Layer-specific properties/methods/events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants