diff --git a/lib/widgets/fullscreen/info/location_section.dart b/lib/widgets/fullscreen/info/location_section.dart index 18c9221be..223735da6 100644 --- a/lib/widgets/fullscreen/info/location_section.dart +++ b/lib/widgets/fullscreen/info/location_section.dart @@ -94,7 +94,7 @@ class _LocationSectionState extends State { if (notification is MapStyleChangedNotification) setState(() {}); return false; }, - child: settings.infoMapStyle == EntryMapStyle.google + child: settings.infoMapStyle.isGoogleMaps ? EntryGoogleMap( markerId: entry.uri ?? entry.path, latLng: entry.latLng, @@ -136,13 +136,17 @@ class _LocationSectionState extends State { } // browse providers at https://leaflet-extras.github.io/leaflet-providers/preview/ -enum EntryMapStyle { google, osmHot, stamenToner, stamenWatercolor } +enum EntryMapStyle { googleNormal, googleHybrid, googleTerrain, osmHot, stamenToner, stamenWatercolor } extension ExtraEntryMapStyle on EntryMapStyle { String get name { switch (this) { - case EntryMapStyle.google: + case EntryMapStyle.googleNormal: return 'Google Maps'; + case EntryMapStyle.googleHybrid: + return 'Google Maps (Hybrid)'; + case EntryMapStyle.googleTerrain: + return 'Google Maps (Terrain)'; case EntryMapStyle.osmHot: return 'Humanitarian OpenStreetMap'; case EntryMapStyle.stamenToner: @@ -153,4 +157,15 @@ extension ExtraEntryMapStyle on EntryMapStyle { return toString(); } } + + bool get isGoogleMaps { + switch (this) { + case EntryMapStyle.googleNormal: + case EntryMapStyle.googleHybrid: + case EntryMapStyle.googleTerrain: + return true; + default: + return false; + } + } } diff --git a/lib/widgets/fullscreen/info/maps/google_map.dart b/lib/widgets/fullscreen/info/maps/google_map.dart index fdc2faff6..6b83f0362 100644 --- a/lib/widgets/fullscreen/info/maps/google_map.dart +++ b/lib/widgets/fullscreen/info/maps/google_map.dart @@ -1,4 +1,5 @@ import 'package:aves/model/settings.dart'; +import 'package:aves/widgets/fullscreen/info/location_section.dart'; import 'package:aves/widgets/fullscreen/info/maps/common.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -67,6 +68,7 @@ class EntryGoogleMapState extends State with AutomaticKeepAliveC onMapCreated: (controller) => setState(() => _controller = controller), compassEnabled: false, mapToolbarEnabled: false, + mapType: _toMapStyle(settings.infoMapStyle), rotateGesturesEnabled: false, scrollGesturesEnabled: false, zoomControlsEnabled: false, @@ -91,6 +93,19 @@ class EntryGoogleMapState extends State with AutomaticKeepAliveC _controller.animateCamera(CameraUpdate.zoomBy(amount)); } + MapType _toMapStyle(EntryMapStyle style) { + switch (style) { + case EntryMapStyle.googleNormal: + return MapType.normal; + case EntryMapStyle.googleHybrid: + return MapType.hybrid; + case EntryMapStyle.googleTerrain: + return MapType.terrain; + default: + return MapType.none; + } + } + @override bool get wantKeepAlive => true; }