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

Show the loader when the map is initialised. #28

Open
arfa opened this issue Jan 22, 2016 · 3 comments
Open

Show the loader when the map is initialised. #28

arfa opened this issue Jan 22, 2016 · 3 comments
Labels
Milestone

Comments

@arfa
Copy link

arfa commented Jan 22, 2016

Hi,
I think that the loader must be displayed by default. Later when the layer is loaded, the event load will trigger and the event handler will hide the loader.

In fact the event loading is triggred before the method _addLayerListeners is called. so the plugin dosn't handle the first time the map is loading.

I suggest the following fix.

onAdd: function(map) {
    ...

    // Create the loading indicator
    var classes = 'leaflet-control-loading';

    ...
}

becomes

onAdd: function(map) {
    ...

    // Create the loading indicator
    var classes = 'leaflet-control-loading is-loading';

    ...
}

This way the loader appears when the map is loading for the first time.

@ebrelsford
Copy link
Owner

Yes, this has been on my mind, the only issue is that this solution assumes that a load event will be triggered at some point. That's impossible to ensure if we didn't detect loading initially.

I'd be interested to see if there's a way to add the event listeners early enough to ensure that we get all the loading events.

@ebrelsford ebrelsford added the bug label Feb 9, 2016
@ebrelsford ebrelsford modified the milestone: v1.0.0 Feb 9, 2016
@benjeffery
Copy link

I got around this by checking if the _loading flag is set. Prob a bit hacky but fixed the issue for me. See benjeffery@339c133

@ebrelsford
Copy link
Owner

If someone wanted to add this as an option and submit a PR I'd fold it in. I don't think we should rely on an internal member (_loading) by default.

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

No branches or pull requests

3 participants