Skip to content
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

Simplify background colouring when specifying multiple TileLayers #1578

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/src/layer/tile_layer/tile_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:math' as math;

import 'package:collection/collection.dart' show MapEquality;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map/src/layer/tile_layer/tile.dart';
import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds.dart';
Expand Down Expand Up @@ -104,6 +103,11 @@ class TileLayer extends StatefulWidget {
final TileDisplay tileDisplay;

/// Color shown behind the tiles
@Deprecated(
'Prefer `MapOptions.backgroundColor`. '
'This property has been removed simplify interaction when using multiple `TileLayer`s. '
'This property is deprecated since v6.',
)
final Color backgroundColor;

/// Provider with which to load map tiles
Expand Down Expand Up @@ -231,7 +235,7 @@ class TileLayer extends StatefulWidget {
this.subdomains = const <String>[],
this.keepBuffer = 2,
this.panBuffer = 0,
this.backgroundColor = const Color(0xFFE0E0E0),
this.backgroundColor = Colors.transparent,
this.errorImage,
TileProvider? tileProvider,
this.tms = false,
Expand Down Expand Up @@ -474,7 +478,8 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {

_tileScaleCalculator.clearCacheUnlessZoomMatches(map.zoom);

return Container(
return ColoredBox(
// ignore: deprecated_member_use_from_same_package
color: widget.backgroundColor,
child: Stack(
children: [
Expand Down
3 changes: 3 additions & 0 deletions lib/src/map/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class MapOptions {
final double? minZoom;
final double? maxZoom;

final Color backgroundColor;

/// see [InteractiveFlag] for custom settings
final int? _interactiveFlags;

Expand Down Expand Up @@ -212,6 +214,7 @@ class MapOptions {
double? scrollWheelVelocity,
this.minZoom,
this.maxZoom,
this.backgroundColor = const Color(0xFFE0E0E0),
this.onTap,
this.onSecondaryTap,
this.onLongPress,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/map/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class FlutterMapStateContainer extends State<FlutterMap> {
child: ClipRect(
child: Stack(
children: [
Positioned.fill(
child: ColoredBox(color: options.backgroundColor),
),
OverflowBox(
minWidth: camera.size.x,
maxWidth: camera.size.x,
Expand Down