mapbox-texture-layer icon indicating copy to clipboard operation
mapbox-texture-layer copied to clipboard

Seems to be drawing tiles multiple times in a single render

Open maeneak opened this issue 6 years ago • 3 comments

This is evident when using alpha blend and zooming. Possibly in the getVisibleCoordinates call or possibly overlapping render calls. Investigating

maeneak avatar Sep 08 '19 07:09 maeneak

mapbox is returning 'parent tiles' in the visible tiles array which it uses for smooth scrolling and zooming. Need to find a way to either use these tiles properly or discard them. https://github.com/mapbox/mapbox-gl-js/blob/master/src/render/draw_raster.js

maeneak avatar Sep 09 '19 11:09 maeneak

Initial solution is to filter the parents and the children and use one of the collections for rendering.

        let zoom = this.map.getZoom();
        let tiles = this.sourceCache.getVisibleCoordinates().map(tileid => this.sourceCache.getTile(tileid));
        let children = tiles.filter(coord => {return coord.tileID.canonical.z == Math.round(zoom);})
        let parents = tiles.filter(tile => {return children.includes(tile)})

Using children gives better resolution but a jagged pan & zoom, while parents are overzoomed but give a better nav experience

maeneak avatar Sep 11 '19 13:09 maeneak

Another approach is to render a tile only if it doesn't have a parent:

let tiles = this.sourceCache.getVisibleCoordinates().map(tileid => this.sourceCache.getTile(tileid));
let tiles2Render = tiles.filter(t => !this.sourceCache.hasRenderableParent(t.tileID));

veloman-yunkan avatar Jan 31 '20 07:01 veloman-yunkan