From 23bcd475a00299a949bd8542af41ec0563808025 Mon Sep 17 00:00:00 2001 From: David Green Date: Sat, 9 Dec 2023 11:42:04 -0800 Subject: [PATCH] fix issue with map rotation in raster mode avoid double-rotating raster map layer fixes #188 --- CHANGELOG.md | 4 +++ example/pubspec.lock | 2 +- lib/src/grid/grid_layer.dart | 66 +++++++++++++++++------------------- pubspec.yaml | 2 +- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d79cefd..12a9642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.0.1 + +* fix [issue 188](https://github.com/greensopinion/flutter-vector-map-tiles/issues/188) where raster mode map would be rotated incorrectly + ## 7.0.0 * update `flutter_map` dependency to 6.1.0 diff --git a/example/pubspec.lock b/example/pubspec.lock index cef63f9..f3500bb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -374,7 +374,7 @@ packages: path: ".." relative: true source: path - version: "6.0.2" + version: "7.0.0" vector_math: dependency: transitive description: diff --git a/lib/src/grid/grid_layer.dart b/lib/src/grid/grid_layer.dart index 7fa25fa..a097c89 100644 --- a/lib/src/grid/grid_layer.dart +++ b/lib/src/grid/grid_layer.dart @@ -124,7 +124,6 @@ class _VectorTileCompositeLayerState extends State Widget build(BuildContext context) { final options = widget.options; final backgroundTheme = options.backgroundTheme; - final layers = []; if (options.layerMode == VectorTileLayerMode.raster) { final maxZoom = options.maximumZoom ?? 18; @@ -138,52 +137,51 @@ class _VectorTileCompositeLayerState extends State options.tileDelay, options.concurrency); _tileProvider = tileProvider; - layers.add(TileLayer( + return TileLayer( key: Key("${theme.id}_v${theme.version}_VectorTileLayer"), maxZoom: maxZoom, maxNativeZoom: maxZoom.ceil(), evictErrorTileStrategy: EvictErrorTileStrategy.notVisible, - tileProvider: tileProvider)); + tileProvider: tileProvider); } - if (options.layerMode == VectorTileLayerMode.vector) { - layers.add(_VectorTileLayer( - Key("${theme.id}_v${theme.version}_VectorTileLayer"), - _LayerOptions(theme, + final layers = []; + if (backgroundTheme != null) { + final background = _VectorTileLayer( + Key( + "${backgroundTheme.id}_v${theme.version}_background_VectorTileLayer"), + _LayerOptions(backgroundTheme, caches: _caches, - symbolTheme: symbolTheme, - sprites: options.sprites, showTileDebugInfo: options.showTileDebugInfo, - paintBackground: backgroundTheme == null, - maxSubstitutionDifference: - options.maximumTileSubstitutionDifference, - paintNoDataTiles: false, + paintBackground: true, + maxSubstitutionDifference: 0, + paintNoDataTiles: true, tileOffset: widget.options.tileOffset, - tileZoomSubstitutionOffset: 0, + tileZoomSubstitutionOffset: 4, mapZoom: _zoom, rotation: _rotation), widget.mapCamera, _mapChanged.stream, - _tileSupplier)); - if (backgroundTheme != null) { - final background = _VectorTileLayer( - Key( - "${backgroundTheme.id}_v${theme.version}_background_VectorTileLayer"), - _LayerOptions(backgroundTheme, - caches: _caches, - showTileDebugInfo: options.showTileDebugInfo, - paintBackground: true, - maxSubstitutionDifference: 0, - paintNoDataTiles: true, - tileOffset: widget.options.tileOffset, - tileZoomSubstitutionOffset: 4, - mapZoom: _zoom, - rotation: _rotation), - widget.mapCamera, - _mapChanged.stream, - _tileSupplier); - layers.insert(0, background); - } + _tileSupplier); + layers.add(background); } + layers.add(_VectorTileLayer( + Key("${theme.id}_v${theme.version}_VectorTileLayer"), + _LayerOptions(theme, + caches: _caches, + symbolTheme: symbolTheme, + sprites: options.sprites, + showTileDebugInfo: options.showTileDebugInfo, + paintBackground: backgroundTheme == null, + maxSubstitutionDifference: + options.maximumTileSubstitutionDifference, + paintNoDataTiles: false, + tileOffset: widget.options.tileOffset, + tileZoomSubstitutionOffset: 0, + mapZoom: _zoom, + rotation: _rotation), + widget.mapCamera, + _mapChanged.stream, + _tileSupplier)); return MobileLayerTransformer(child: Stack(children: layers)); } diff --git a/pubspec.yaml b/pubspec.yaml index 0b98dad..6a346d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: vector_map_tiles description: A plugin for `flutter_map` that enables the use of vector tiles. -version: 7.0.0 +version: 7.0.1 homepage: https://github.com/greensopinion/flutter-vector-map-tiles environment: