@@ -197,35 +197,19 @@ class TileLayer extends StatefulWidget {
197197 /// Only load tiles that are within these bounds
198198 final LatLngBounds ? tileBounds;
199199
200- /// This transformer modifies how/when tile updates and pruning are triggered
201- /// based on [MapEvent] s. It is a StreamTransformer and therefore it is
202- /// possible to filter/modify/throttle the [TileUpdateEvent] s. Defaults to
203- /// [TileUpdateTransformers.ignoreTapEvents] which disables loading/pruning
204- /// for map taps, secondary taps and long presses. See TileUpdateTransformers
205- /// for more transformer presets or implement your own.
200+ /// Restricts and limits [TileUpdateEvent] s (which are emitted 'by'
201+ /// [MapEvent] s), which cause tiles to update.
206202 ///
207- /// Note: Changing the [tileUpdateTransformer] after TileLayer is created has
208- /// no affect.
209- final TileUpdateTransformer tileUpdateTransformer;
210-
211- /// Defines the minimum delay time from last map event before the tile layers
212- /// are updated. This delay acts as a debounce period to prevent frequent
213- /// reloading of tile layers in response to rapid, successive events
214- /// (e.g., zooming or panning).
215- ///
216- /// 16ms could be a good starting point for most applications.
217- /// This at 60fps this will wait one frame after the last event.
203+ /// For more information, see [TileUpdateTransformer] .
218204 ///
219- /// By setting this delay, we ensure that map layer updates are performed
220- /// only after a period of inactivity, enhancing performance and user
221- /// experience on lower performance devices .
205+ /// Defaults to [TileUpdateTransformers.ignoreTapEvents] , which disables
206+ /// updates for map taps, secondary taps and long presses, which alone should
207+ /// not cause the camera to change position .
222208 ///
223- /// - If multiple events occur within this delay period, only the last event
224- /// triggers the tile layer update, reducing unnecessary processing and
225- /// network requests.
226- /// - If the [loadingDelay] is `Duration.zero` , the delay is completely
227- /// disabled and the tile layer will update as soon as possible.
228- final Duration loadingDelay;
209+ /// Note that changing this after the layer has already been built will have
210+ /// no effect. If necessary, force a rebuild of the entire layer by changing
211+ /// the [key] .
212+ final TileUpdateTransformer tileUpdateTransformer;
229213
230214 /// Create a new [TileLayer] for the [FlutterMap] widget.
231215 TileLayer ({
@@ -258,7 +242,6 @@ class TileLayer extends StatefulWidget {
258242 this .evictErrorTileStrategy = EvictErrorTileStrategy .none,
259243 this .reset,
260244 this .tileBounds,
261- this .loadingDelay = Duration .zero,
262245 TileUpdateTransformer ? tileUpdateTransformer,
263246 String userAgentPackageName = 'unknown' ,
264247 }) : assert (
@@ -353,9 +336,6 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
353336 TileRangeCalculator (tileSize: widget.tileSize);
354337 late TileScaleCalculator _tileScaleCalculator;
355338
356- /// Delay Timer for [TileLayer.loadingDelay]
357- Timer ? _delayTimer;
358-
359339 // We have to hold on to the mapController hashCode to determine whether we
360340 // need to reinitialize the listeners. didChangeDependencies is called on
361341 // every map movement and if we unsubscribe and resubscribe every time we
@@ -370,26 +350,8 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
370350 _loadAndPruneInVisibleBounds (MapCamera .of (context));
371351 });
372352
373- /// This method is used to delay the execution of a function by the specified
374- /// [TileLayer.loadingDelay] . This is useful to prevent frequent reloading
375- /// of tile layers in response to rapid, successive events (e.g., zooming
376- /// or panning).
377- void _loadingDelay (VoidCallback action) {
378- //execute immediately if delay is zero.
379- if (widget.loadingDelay == Duration .zero) {
380- action ();
381- return ;
382- }
383-
384- // Cancel the previous timer if it is still active.
385- _delayTimer? .cancel ();
386-
387- // Reset the timer to wait for the debounce duration
388- _delayTimer = Timer (widget.loadingDelay, action);
389- }
390-
391353 // This is called on every map movement so we should avoid expensive logic
392- // where possible.
354+ // where possible, or filter as necessary
393355 @override
394356 void didChangeDependencies () {
395357 super .didChangeDependencies ();
@@ -404,7 +366,7 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
404366 _tileUpdateSubscription = mapController.mapEventStream
405367 .map ((mapEvent) => TileUpdateEvent (mapEvent: mapEvent))
406368 .transform (widget.tileUpdateTransformer)
407- .listen ((event) => _loadingDelay (() => _onTileUpdateEvent (event)) );
369+ .listen (_onTileUpdateEvent);
408370 }
409371
410372 var reloadTiles = false ;
@@ -499,7 +461,6 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
499461 _resetSub? .cancel ();
500462 _pruneLater? .cancel ();
501463 widget.tileProvider.dispose ();
502- _delayTimer? .cancel ();
503464 super .dispose ();
504465 }
505466
0 commit comments