visgl / visgl/deck.gl

[Feat] Add onTileLoading callback on TileLayers

Open
#8,359 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
14.6k
Forks
2.3k
Avg merge
2d 9h
Merged PRs (30d)
42

Description

Target Use Case

Atm, any sort of TileLayer is missing a callback to know when tiles starts fetching. This could help devs implement a loading indicator that could be paired with onViewportLoad / onTileLoad.

I managed to implement it like this atm

return new CustomTileLayer({
    ...
    onTilesLoading: () => setTilesLoading(mapId, layerId, true),
    onViewportLoad: () => setTilesLoading(mapId, layerId, false)
});

interface CustomTileLayerProps {
    onTilesLoading?: () => void;
}

class CustomTileLayer<DataT> extends TileLayer<DataT, CustomTileLayerProps> {
    getTileData(tile: TileLoadProps) {
        const {
            props: { onTilesLoading }
        } = this;
        onTilesLoading?.();

        return super.getTileData(tile) ;
    }
}
Proposal
new TileLayer({
    ...
    onTilesLoading: () => { /*show loading indicator here*/ },
    onViewportLoad: () => { /*hide loading indicator here*/ }
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TileLayer getTileData entry point shown in the issue and trace how tile fetching relates to onTileLoad and onViewportLoad. Add the proposed onTilesLoading callback to TileLayer's public API, then verify that it fires when tile fetching begins and can be used with the existing viewport-load callback.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.