maps: added google map styles

This commit is contained in:
Thibault Deckers 2020-08-21 12:50:23 +09:00
parent 508a356dc7
commit df8d48cd19
2 changed files with 33 additions and 3 deletions

View file

@ -94,7 +94,7 @@ class _LocationSectionState extends State<LocationSection> {
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<LocationSection> {
}
// 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;
}
}
}

View file

@ -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<EntryGoogleMap> 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<EntryGoogleMap> 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;
}