-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Post process tiles #582
Feature: Post process tiles #582
Conversation
It might be better to provide a TileBuilder API instead, where the builder is called for each Tile. |
Maybe someone can clarify this for me. I do not understand TileBuilder API (?). I would like to have this feature merged. |
TileBuilder API means: define custom function, here we pass typedef TileBuilder = Widget Function(Widget tileWidget, Tile tile); define a defaultbuilder which just returns Widget _defaultTileBuilder(Widget tileWidget, Tile tile) => tileWidget; In class TileLayerOptions extends LayerOptions {
...
// TODO: create some doc where you can write an example
final TileBuilder tileBuilder;
TileLayerOptions({
....
this.tileBuilder = _defaultTileBuilder,
rebuild,
}) ....
} In class AnimatedTile extends StatefulWidget {
final Tile tile;
final ImageProvider errorImage;
final TileBuilder tileBuilder;
AnimatedTile(
{Key key, @required this.tile, this.errorImage, @required this.tileBuilder}) In @override
Widget build(BuildContext context) {
final tileWidget = (widget.tile.loadError && widget.errorImage != null)
? Image(
image: widget.errorImage,
fit: BoxFit.fill,
)
: RawImage(
image: widget.tile.imageInfo?.image,
fit: BoxFit.fill,
);
return Opacity(
opacity: widget.tile.opacity,
child: widget.tileBuilder(tileWidget, widget.tile), // Here is our tile builder
);
} And finally we can pass our builder to TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
tileBuilder: (Widget tileWidget, Tile tile) {
if (tile.loadError) {
// apply red colorFilter or wrap widget with another custom Widget
}
return ColorFiltered(
colorFilter: const ColorFilter.matrix(<double>[
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0,
]),
child: tileWidget);
},
); I know currently you apply typedef TilesContainerBuilder = Widget Function(Widget container, List<Tile> tiles);
Widget _defaultTilesContainerBuilder(Widget container, List<Tile> tiles) => container; I think in this PR you can implement both |
Or maybe |
@maRci002 I see you did the work already in your head. You could also push on this PR. |
@mat8854 I think I cannot push to this PR however I can fork your fork and make pull request to your fork's branch. It would be nice if you could update your master because first step I'll make the branch up to with master. |
@maRci002 Okay, only maintainers can do that. It worked with another repo. |
@mat8854 I have updated your commit to the current master branch here: https://github.com/Femtopedia/flutter_map I could PR it into your repo, so you can update your branch, if you want. |
@mat8854 @maRci002 Hello! Is there any update on that feature? Really need TileBuilder API functionality. Is there possibility to get it any time soon? |
@DrNorton yes today I'll make a PR to @mat8854 's branch. I've some cool default |
…ess-tiles # Conflicts: # lib/src/layer/tile_layer.dart
Feature/post process tiles
@maRci002 Thank you, I approved your changes on my branch. They are now also visible here. @ThexXTURBOXx @DrNorton Note the new changes. |
@mat8854 can you take a look at the build and see if you can fix it? |
Idk but my PR builds also fails. import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import '../widgets/drawer.dart'; // this should be also package import! @mat8854 can you eliminate all relative imports from project maybe it helps? |
It's okay to use relative imports. In this case it looks like a problem with the example:
|
And This causes the error? |
@johnpryan for me 200400f and 239c151 fixed the problem. So mixing relative and package imports may cause wierd bugs in Dart. I think the best pattern is to only use package imports. Plot twist IDE's and manual dartanalyzer don't show these errors. I'll update this PR imports too. Edit: matthiasdittmer#4 this should fix the problem |
try to fix dartanalyzer for Travis
@johnpryan @maRci002 Travis is passing now. |
See #581