greensopinion / dart-vector-tile-renderer

A vector tile renderer for use in creating map tile images or writing to a canvas. Written in Dart to enable use of vector tiles with Flutter.
BSD 3-Clause "New" or "Revised" License
42 stars 24 forks source link

How to pass tiles map in Tileset class with mutiple tile layers. What should be the tiles key in that situation. #75

Closed dishant-livebird closed 1 year ago

dishant-livebird commented 1 year ago
class Tileset {
  final bool preprocessed;
  final Map<String, Tile> tiles;
  late final LayerFeatureResolver _resolver;

  Tileset(this.tiles) : preprocessed = false {
    _resolver = DefaultLayerFeatureResolver(this);
  }
}

This is multiple data layer in bytes array

var tileData1 = TileFactory(theme, const Logger.noop())
                  .createTileData(VectorTileReader().read(tileBytes1));

var tileData2 = TileFactory(theme, const Logger.noop())
                  .createTileData(VectorTileReader().read(tileBytes2));

final tile1 = tileData1.toTile();
final tile2 = tileData2.toTile();

 Map<String, Tile> tiles = {};
 tiles.putIfAbsent("openmaptiles", () => tile1);
 tiles.putIfAbsent("?", () => tile2);   // what should be the value of key in this situation

final tileset = TilesetPreprocessor(theme)
                  .preprocess(Tileset(tiles), zoom: tileZXYValue[0].toDouble());
greensopinion commented 1 year ago

The key should correspond to a layer in your style/theme. You'll find example usage in vector_map_tiles

It's unusual to use these APIs directly. Have you considered using https://pub.dev/packages/vector_map_tiles instead? What is your use-case?