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
WMS and/or Tile layer animations #745
Comments
#583 / #745 asked for detect url changes, and PR #584 which is approved detects url changes so if you change The default behavior when url changed (for a moment map will be gray):
There is another behavior if you set
In summary you show one layer and change it's |
@maRci002 thank you very much. I have been playing around a little with this and it looks like it could work for me. Am I correct in saying that e.g. #584 is only available in the git master branch and not in the 0.10.0 package? Currently I am relying on the new |
#584 avaible in 0.10.0 |
I have now implemented the changing of urlTemplate at runtime and it works really well the first time a URL is loaded. Each new URL is loaded, creating a nice time lapse. However, when then looping backwards and re-using a URL that was loaded before, the layer is not visible on the map until I e.g. move the map by sliding it or something else causes the map to be re-drawn. It could be my not implementing setState properly, but it's confusing as it works well the first time... Any bright ideas? |
Yes it is fixed with #715 in |
I've upgraded to |
I tested:
Here is my demo which covers all possibilities, change import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong/latlong.dart';
import '../widgets/drawer.dart';
class WMSLayerPage extends StatefulWidget {
static const String route = 'WMS layer';
@override
_WMSLayerPageState createState() => _WMSLayerPageState();
}
class _WMSLayerPageState extends State<WMSLayerPage> {
final _layers = [
's2cloudless-2018_3857',
'overlay_base_bright_3857',
'overlay_3857',
];
var _counter = 0;
var _overrideTilesWhenUrlChanges = false;
var _tileFadeInStartWhenOverride = 0.0;
void _changeLayer() {
++_counter;
setState(() {});
}
void _changeOverrideMode() {
_overrideTilesWhenUrlChanges = !_overrideTilesWhenUrlChanges;
setState(() {});
}
void _changeFadeInStart() {
_tileFadeInStartWhenOverride =
_tileFadeInStartWhenOverride == 0.0 ? 1.0 : 0.0;
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
FloatingActionButton(
heroTag: 'Icons.layers',
onPressed: _changeLayer,
child: Icon(Icons.layers),
),
SizedBox(height: 8),
FloatingActionButton.extended(
heroTag: 'Icons.flash_on',
onPressed: _changeOverrideMode,
icon: Icon(_overrideTilesWhenUrlChanges
? Icons.flash_off
: Icons.flash_on),
label: _overrideTilesWhenUrlChanges
? Text('Disable override')
: Text('Enable override'),
),
SizedBox(height: 8),
FloatingActionButton.extended(
heroTag: 'Icons.timelapse',
backgroundColor: _overrideTilesWhenUrlChanges ? null : Colors.grey,
onPressed: _overrideTilesWhenUrlChanges ? _changeFadeInStart : null,
icon: Icon(_tileFadeInStartWhenOverride == 1.0
? Icons.timer_off
: Icons.timelapse),
label: Text(
'Current fade start when override: $_tileFadeInStartWhenOverride'),
),
],
),
appBar: AppBar(title: Text('WMS Layer')),
drawer: buildDrawer(context, WMSLayerPage.route),
body: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Text('This is a map that is showing (42.58, 12.43).'),
),
Flexible(
child: FlutterMap(
options: MapOptions(
center: LatLng(42.58, 12.43),
zoom: 6.0,
),
layers: [
TileLayerOptions(
wmsOptions: WMSTileLayerOptions(
baseUrl: 'https://{s}.s2maps-tiles.eu/wms/?',
layers: [_layers[_counter % 3]],
),
tileFadeInDuration: 800,
subdomains: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
overrideTilesWhenUrlChanges: _overrideTilesWhenUrlChanges,
tileFadeInStartWhenOverride: _tileFadeInStartWhenOverride,
)
],
),
),
],
),
),
);
}
} Note: |
If above code works but your code doesn't then change |
Thank you very much, I got it working now. I cannot explain it, but in my case I had to set |
However the default behavior ( |
How would one go about creating an animation of several WMS and/or Tile layers? The use could e.g. be to show graphical weather data (satellite/radar) as it moves in time. Each layer would present the same type of data but from different points in time.
The text was updated successfully, but these errors were encountered: