Skip to content

How can I manually tell the TileLayerOptions to load and paint a tile? #966

@JaffaKetchup

Description

@JaffaKetchup

Discussed in #963

Originally posted by JaffaKetchup July 5, 2021
I need to do this as I'm implementing a way to remove grey tiles, but I can't change the base code in flutter_map. See JaffaKetchup/flutter_map_tile_caching#12.

My existing code:

@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
    // `preloadSurroundings` is a boolean dictating whether the grey tiles should be attempted to be removed
    if (preloadSurroundings) {
      for (double x = coords.x - 6; x < coords.x + 6; x++) {
        for (double y = coords.y - 6; y < coords.y + 6; y++) {
          /*_CachedTileImageProvider(
            getTileUrl(Coords<num>(x, y)..z = coords.z, options),
            Coords<num>(coords.x, coords.y)..z = coords.z,
            cacheName: cacheName,
          );*/
         // How can I manually load AND PAINT the image above
        }
      }
    }
    return _CachedTileImageProvider(
      getTileUrl(coords, options),
      Coords<num>(coords.x, coords.y)..z = coords.z,
      cacheName: cacheName,
    );
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions