info: added map credits
This commit is contained in:
parent
6bc416b6b6
commit
f98400179b
1 changed files with 107 additions and 69 deletions
|
@ -4,8 +4,10 @@ import 'package:aves/widgets/common/icons.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/maps/scale_layer.dart';
|
import 'package:aves/widgets/fullscreen/info/maps/scale_layer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:latlong/latlong.dart';
|
import 'package:latlong/latlong.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../location_section.dart';
|
import '../location_section.dart';
|
||||||
|
|
||||||
|
@ -45,79 +47,85 @@ class EntryLeafletMapState extends State<EntryLeafletMap> with AutomaticKeepAliv
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
final accentColor = Theme.of(context).accentColor;
|
final accentColor = Theme.of(context).accentColor;
|
||||||
return Row(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Row(
|
||||||
child: GestureDetector(
|
children: [
|
||||||
onScaleStart: (details) {
|
Expanded(
|
||||||
// absorb scale gesture here to prevent scrolling
|
child: GestureDetector(
|
||||||
// and triggering by mistake a move to the image page above
|
onScaleStart: (details) {
|
||||||
},
|
// absorb scale gesture here to prevent scrolling
|
||||||
child: ClipRRect(
|
// and triggering by mistake a move to the image page above
|
||||||
borderRadius: BorderRadius.circular(16),
|
},
|
||||||
child: Container(
|
child: ClipRRect(
|
||||||
color: Colors.white70,
|
borderRadius: BorderRadius.circular(16),
|
||||||
height: 200,
|
child: Container(
|
||||||
child: FlutterMap(
|
color: Colors.white70,
|
||||||
options: MapOptions(
|
height: 200,
|
||||||
center: widget.latLng,
|
child: FlutterMap(
|
||||||
zoom: widget.initialZoom,
|
options: MapOptions(
|
||||||
interactive: false,
|
center: widget.latLng,
|
||||||
),
|
zoom: widget.initialZoom,
|
||||||
children: [
|
interactive: false,
|
||||||
_buildMapLayer(),
|
|
||||||
ScaleLayerWidget(
|
|
||||||
options: ScaleLayerOptions(),
|
|
||||||
),
|
|
||||||
MarkerLayerWidget(
|
|
||||||
options: MarkerLayerOptions(
|
|
||||||
markers: [
|
|
||||||
Marker(
|
|
||||||
width: markerSize,
|
|
||||||
height: markerSize,
|
|
||||||
point: widget.latLng,
|
|
||||||
builder: (ctx) {
|
|
||||||
return Icon(
|
|
||||||
Icons.place,
|
|
||||||
size: markerSize,
|
|
||||||
color: accentColor,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
anchorPos: AnchorPos.align(AnchorAlign.top),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
children: [
|
||||||
|
_buildMapLayer(),
|
||||||
|
ScaleLayerWidget(
|
||||||
|
options: ScaleLayerOptions(),
|
||||||
|
),
|
||||||
|
MarkerLayerWidget(
|
||||||
|
options: MarkerLayerOptions(
|
||||||
|
markers: [
|
||||||
|
Marker(
|
||||||
|
width: markerSize,
|
||||||
|
height: markerSize,
|
||||||
|
point: widget.latLng,
|
||||||
|
builder: (ctx) {
|
||||||
|
return Icon(
|
||||||
|
Icons.place,
|
||||||
|
size: markerSize,
|
||||||
|
color: accentColor,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
anchorPos: AnchorPos.align(AnchorAlign.top),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
mapController: _mapController,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
mapController: _mapController,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(width: 8),
|
||||||
|
TooltipTheme(
|
||||||
|
data: TooltipTheme.of(context).copyWith(
|
||||||
|
preferBelow: false,
|
||||||
|
),
|
||||||
|
child: Column(children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(AIcons.zoomIn),
|
||||||
|
onPressed: _mapController == null ? null : () => _zoomBy(1),
|
||||||
|
tooltip: 'Zoom in',
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(AIcons.zoomOut),
|
||||||
|
onPressed: _mapController == null ? null : () => _zoomBy(-1),
|
||||||
|
tooltip: 'Zoom out',
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(AIcons.openInNew),
|
||||||
|
onPressed: () => AndroidAppService.openMap(widget.geoUri),
|
||||||
|
tooltip: 'Show on map...',
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
_buildAttribution(),
|
||||||
TooltipTheme(
|
|
||||||
data: TooltipTheme.of(context).copyWith(
|
|
||||||
preferBelow: false,
|
|
||||||
),
|
|
||||||
child: Column(children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(AIcons.zoomIn),
|
|
||||||
onPressed: _mapController == null ? null : () => _zoomBy(1),
|
|
||||||
tooltip: 'Zoom in',
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(AIcons.zoomOut),
|
|
||||||
onPressed: _mapController == null ? null : () => _zoomBy(-1),
|
|
||||||
tooltip: 'Zoom out',
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(AIcons.openInNew),
|
|
||||||
onPressed: () => AndroidAppService.openMap(widget.geoUri),
|
|
||||||
tooltip: 'Show on map...',
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -135,6 +143,39 @@ class EntryLeafletMapState extends State<EntryLeafletMap> with AutomaticKeepAliv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildAttribution() {
|
||||||
|
final attribution = _getAttributionMarkdown();
|
||||||
|
return attribution != null
|
||||||
|
? Markdown(
|
||||||
|
data: attribution,
|
||||||
|
selectable: true,
|
||||||
|
styleSheet: MarkdownStyleSheet(
|
||||||
|
a: TextStyle(color: Theme.of(context).accentColor),
|
||||||
|
p: TextStyle(fontSize: 13, fontFamily: 'Concourse'),
|
||||||
|
),
|
||||||
|
onTapLink: (url) async {
|
||||||
|
if (await canLaunch(url)) {
|
||||||
|
await launch(url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
||||||
|
shrinkWrap: true,
|
||||||
|
)
|
||||||
|
: SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getAttributionMarkdown() {
|
||||||
|
switch (widget.style) {
|
||||||
|
case EntryMapStyle.osmHot:
|
||||||
|
return '© [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors, Tiles style by [Humanitarian OpenStreetMap Team](https://www.hotosm.org/) hosted by [OpenStreetMap France](https://openstreetmap.fr/)';
|
||||||
|
case EntryMapStyle.stamenToner:
|
||||||
|
case EntryMapStyle.stamenWatercolor:
|
||||||
|
return 'Map tiles by [Stamen Design](http://stamen.com), [CC BY 3.0](http://creativecommons.org/licenses/by/3.0) — Map data © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _zoomBy(double amount) {
|
void _zoomBy(double amount) {
|
||||||
final endZoom = (settings.infoMapZoom + amount).clamp(1.0, 16.0);
|
final endZoom = (settings.infoMapZoom + amount).clamp(1.0, 16.0);
|
||||||
settings.infoMapZoom = endZoom;
|
settings.infoMapZoom = endZoom;
|
||||||
|
@ -162,7 +203,6 @@ class OSMHotLayer extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TileLayerWidget(
|
return TileLayerWidget(
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
// attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Tiles style by <a href="https://www.hotosm.org/" target="_blank">Humanitarian OpenStreetMap Team</a> hosted by <a href="https://openstreetmap.fr/" target="_blank">OpenStreetMap France</a>'
|
|
||||||
urlTemplate: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
|
urlTemplate: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
|
||||||
subdomains: ['a', 'b', 'c'],
|
subdomains: ['a', 'b', 'c'],
|
||||||
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
||||||
|
@ -176,7 +216,6 @@ class StamenTonerLayer extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TileLayerWidget(
|
return TileLayerWidget(
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
// attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
||||||
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png',
|
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png',
|
||||||
subdomains: ['a', 'b', 'c', 'd'],
|
subdomains: ['a', 'b', 'c', 'd'],
|
||||||
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
||||||
|
@ -190,7 +229,6 @@ class StamenWatercolorLayer extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TileLayerWidget(
|
return TileLayerWidget(
|
||||||
options: TileLayerOptions(
|
options: TileLayerOptions(
|
||||||
// attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
||||||
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
|
urlTemplate: 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
|
||||||
subdomains: ['a', 'b', 'c', 'd'],
|
subdomains: ['a', 'b', 'c', 'd'],
|
||||||
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
retinaMode: MediaQuery.of(context).devicePixelRatio > 1,
|
||||||
|
|
Loading…
Reference in a new issue