Skip to content

Allow custom done callback for RasterTileSource.loadTile #3123

@timiyay

Description

@timiyay

I have a use case that requires me to make a custom SourceType, for which I was hoping to inherit from RasterTileSource.

I'm integrating an external WMS into our mapbox-gl-js project, as they provide high-quality aerial imagery for my area of interest.

The issue is that the WMS will always return a 200. When tiles are missing for high zoom levels, the WMS return a 200 and a blank white tile.

I need a custom SourceType so that I can programatically-detect these blank tiles, and prevent them being rendered.

I realise there are current issues and PRs looking at custom SourceTypes. Nonetheless, for my use case, I would be greatly aided if RasterTileSource.loadTile was refactored into separate methods: https://github.com/mapbox/mapbox-gl-js/blob/master/js/source/raster_tile_source.js#L49

If I was able to override the done() function and then, on success, pass my img object to a separate function that called the GL rendering code from line 59 (https://github.com/mapbox/mapbox-gl-js/blob/master/js/source/raster_tile_source.js#L59), then it'd be an easy switch.

As it stands, I'll have to cut'n'paste all of code from loadTile into my own version of the function.

Would there be any support for this change within the master mapbox-gl-js repo, or do you see this use case as being better-solved by existing/upcoming capabilities of custom SourceTypes?

I'm happy to whip up a PR, if there's support for this change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions