-
-
Notifications
You must be signed in to change notification settings - Fork 860
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace TileLayer's error image option with a placeholder image option
When a tile fails to load and there are no existing loaded tiles which overlay with it from another zoom level we are left with a blank portion on the map. When there are no loaded tiles visible, for example because of a network problem, there is no visual feedback when zooming/panning/rotating because the map is just a single solid color. This prompted me to add a placeholder image. We already have an error image implementation but the error image will not show up until loading fails which, in the case of a poor network connection, can take quite a while. The placeholder implementation gives visual feedback both whilst loading and when loading fails. Note that the current implementation just fills the viewport with the placeholder tile behind all other tiles. It would be more efficient to avoid adding placeholder tiles which are completely obscured by other visual tiles but my attempts to do this were unsuccessful due to the complex nature of tile pruning.
- Loading branch information
1 parent
991f53c
commit 08cb80d
Showing
13 changed files
with
299 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
lib/src/layer/tile_layer/controller/tile_layer_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:async'; | ||
|
||
sealed class TileLayerController { | ||
factory TileLayerController() => TileLayerControllerImpl(); | ||
|
||
/// Trigger reloading of tiles which failed to load. | ||
void reloadErrorTiles(); | ||
|
||
/// Dispose of this controller, should be called when this TileLayerController | ||
/// is no longer used. | ||
void dispose(); | ||
} | ||
|
||
class TileLayerControllerImpl implements TileLayerController { | ||
final StreamController<void> _streamController; | ||
|
||
TileLayerControllerImpl() : _streamController = StreamController.broadcast(); | ||
|
||
Stream<void> get stream => _streamController.stream; | ||
|
||
@override | ||
void reloadErrorTiles() { | ||
_streamController.add(null); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_streamController.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.