Skip to content
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
9 changes: 6 additions & 3 deletions flutter_map/lib/src/layer/tile_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:latlong/latlong.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:flutter_map/src/core/bounds.dart';
import 'package:flutter_map/src/core/point.dart';
import 'package:flutter_map/src/map/map.dart';
Expand All @@ -19,6 +20,7 @@ class TileLayerOptions extends LayerOptions {
final double zoomOffset;
final List<String> subdomains;
final Color backgroundColor;
ImageProvider placeholderImage;
Map<String, String> additionalOptions;

TileLayerOptions({
Expand All @@ -30,6 +32,7 @@ class TileLayerOptions extends LayerOptions {
this.additionalOptions = const <String, String>{},
this.subdomains = const <String>[],
this.backgroundColor = Colors.grey[300],
this.placeholderImage,
});
}

Expand Down Expand Up @@ -324,7 +327,6 @@ class _TileLayerState extends State<TileLayer> {
var pos = (tilePos).multiplyBy(level.scale) + level.translatePoint;
var width = tileSize.x * level.scale;
var height = tileSize.y * level.scale;
var blankImageBytes = new Uint8List(0);

return new Positioned(
left: pos.x.toDouble(),
Expand All @@ -335,8 +337,9 @@ class _TileLayerState extends State<TileLayer> {
child: new FadeInImage(
fadeInDuration: const Duration(milliseconds: 100),
key: new Key(_tileCoordsToKey(coords)),
// here `bytes` is a Uint8List containing the bytes for the in-memory image
placeholder: new MemoryImage(blankImageBytes),
placeholder: options.placeholderImage != null
? options.placeholderImage
: new MemoryImage(kTransparentImage),
image: new NetworkImage(getTileUrl(coords)),
fit: BoxFit.fill,
),
Expand Down
1 change: 1 addition & 0 deletions flutter_map/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dependencies:
latlong: ^0.4.0
tuple: ^1.0.0
quiver: ^0.28.0
transparent_image: ^0.1.0