Skip to content

Let user manually show/hide spinner #44

@nenadvicentic

Description

@nenadvicentic

I have use case where I want to show spinner only during loading of application data on the map. I am not concerned with progress of tiles and other layers loading, since data on those layers is not crucial to the user.

I achieved this with a bit of hacking, using "private" methods _showIndicator and _hideIndicator and unregistering event listeners immediately after control is added to the map:

    // Initialization logic
    this._loadingControl = L.Control.loading({ separate: true, delayIndicator: 300 });
    this._map.addControl(this._loadingControl);
    // remove layer and basemap event listeners, we want only our logic to show spinner.
    this._loadingControl.onRemove(this._map); 
    private async loadMyData(filter) {
        this._loadingControl._showIndicator();

        try {
            // Data loading logic here
        } finally {
            this._loadingControl._hideIndicator();
        }
    }

It would be nice to have official support for this use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions