map: added OpenTopoMap layer
This commit is contained in:
parent
1793da1262
commit
33bdc41e7b
9 changed files with 35 additions and 6 deletions
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## <a id="unreleased"></a>[Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Map: OpenTopoMap layer
|
||||
|
||||
## <a id="v1.11.13"></a>[v1.11.13] - 2024-09-17
|
||||
|
||||
### Added
|
||||
|
|
|
@ -238,6 +238,7 @@
|
|||
"mapStyleGoogleNormal": "Google Maps",
|
||||
"mapStyleGoogleHybrid": "Google Maps (Hybrid)",
|
||||
"mapStyleGoogleTerrain": "Google Maps (Terrain)",
|
||||
"mapStyleOpenTopoMap": "OpenTopoMap",
|
||||
"mapStyleOsmHot": "Humanitarian OSM",
|
||||
"mapStyleStamenWatercolor": "Stamen Watercolor",
|
||||
|
||||
|
@ -1032,6 +1033,7 @@
|
|||
"mapZoomInTooltip": "Zoom in",
|
||||
"mapZoomOutTooltip": "Zoom out",
|
||||
"mapPointNorthUpTooltip": "Point north up",
|
||||
"mapAttributionOpenTopoMap": "Map data © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors • [SRTM](https://www.earthdata.nasa.gov/sensors/srtm) | Tiles by [OpenTopoMap](https://opentopomap.org/), [CC BY-SA](https://creativecommons.org/licenses/by-sa/3.0/)",
|
||||
"mapAttributionOsmHot": "Map data © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors • Tiles by [HOT](https://www.hotosm.org/) • Hosted by [OSM France](https://openstreetmap.fr/)",
|
||||
"mapAttributionStamen": "Map data © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors • Tiles by [Stamen Design](https://stamen.com), [CC BY 3.0](https://creativecommons.org/licenses/by/3.0)",
|
||||
"openMapPageTooltip": "View on Map page",
|
||||
|
|
|
@ -14,11 +14,12 @@ extension ExtraEntryMapStyle on EntryMapStyle {
|
|||
|
||||
bool get needMobileService {
|
||||
switch (this) {
|
||||
case EntryMapStyle.osmHot:
|
||||
case EntryMapStyle.stamenWatercolor:
|
||||
return false;
|
||||
default:
|
||||
case EntryMapStyle.googleNormal:
|
||||
case EntryMapStyle.googleHybrid:
|
||||
case EntryMapStyle.googleTerrain:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ extension ExtraEntryMapStyleView on EntryMapStyle {
|
|||
EntryMapStyle.googleNormal => l10n.mapStyleGoogleNormal,
|
||||
EntryMapStyle.googleHybrid => l10n.mapStyleGoogleHybrid,
|
||||
EntryMapStyle.googleTerrain => l10n.mapStyleGoogleTerrain,
|
||||
EntryMapStyle.openTopoMap => l10n.mapStyleOpenTopoMap,
|
||||
EntryMapStyle.osmHot => l10n.mapStyleOsmHot,
|
||||
EntryMapStyle.stamenWatercolor => l10n.mapStyleStamenWatercolor,
|
||||
};
|
||||
|
|
|
@ -16,6 +16,8 @@ class Attribution extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (style) {
|
||||
case EntryMapStyle.openTopoMap:
|
||||
return _buildAttributionMarkdown(context, context.l10n.mapAttributionOpenTopoMap);
|
||||
case EntryMapStyle.osmHot:
|
||||
return _buildAttributionMarkdown(context, context.l10n.mapAttributionOsmHot);
|
||||
case EntryMapStyle.stamenWatercolor:
|
||||
|
|
|
@ -185,6 +185,7 @@ class _GeoMapState extends State<GeoMap> {
|
|||
onMarkerTap: _onMarkerTap,
|
||||
onMarkerLongPress: onMarkerLongPress,
|
||||
);
|
||||
case EntryMapStyle.openTopoMap:
|
||||
case EntryMapStyle.osmHot:
|
||||
case EntryMapStyle.stamenWatercolor:
|
||||
child = EntryLeafletMap<AvesEntry>(
|
||||
|
|
|
@ -198,6 +198,8 @@ class _EntryLeafletMapState<T> extends State<EntryLeafletMap<T>> with TickerProv
|
|||
|
||||
Widget _buildMapLayer() {
|
||||
switch (widget.style) {
|
||||
case EntryMapStyle.openTopoMap:
|
||||
return const OpenTopoMapLayer();
|
||||
case EntryMapStyle.osmHot:
|
||||
return const OSMHotLayer();
|
||||
case EntryMapStyle.stamenWatercolor:
|
||||
|
|
|
@ -2,6 +2,20 @@ import 'package:aves/model/device.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
|
||||
class OpenTopoMapLayer extends StatelessWidget {
|
||||
const OpenTopoMapLayer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TileLayer(
|
||||
urlTemplate: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
|
||||
subdomains: const ['a', 'b', 'c'],
|
||||
retinaMode: MediaQuery.devicePixelRatioOf(context) > 1,
|
||||
userAgentPackageName: device.userAgent,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OSMHotLayer extends StatelessWidget {
|
||||
const OSMHotLayer({super.key});
|
||||
|
||||
|
@ -23,7 +37,6 @@ class StamenWatercolorLayer extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return TileLayer(
|
||||
urlTemplate: 'https://watercolormaps.collection.cooperhewitt.org/tile/watercolor/{z}/{x}/{y}.jpg',
|
||||
subdomains: const ['a', 'b', 'c', 'd'],
|
||||
retinaMode: MediaQuery.devicePixelRatioOf(context) > 1,
|
||||
userAgentPackageName: device.userAgent,
|
||||
);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
// OSM raster tile providers: https://wiki.openstreetmap.org/wiki/Raster_tile_providers
|
||||
// OSM vector tile providers: https://wiki.openstreetmap.org/wiki/Vector_tiles#Providers
|
||||
// Leaflet providers preview: https://leaflet-extras.github.io/leaflet-providers/preview/
|
||||
enum EntryMapStyle {
|
||||
// Google
|
||||
googleNormal,
|
||||
googleHybrid,
|
||||
googleTerrain,
|
||||
// Leaflet
|
||||
// browse providers at https://leaflet-extras.github.io/leaflet-providers/preview/
|
||||
openTopoMap,
|
||||
osmHot,
|
||||
stamenWatercolor,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue