mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-23 17:21:06 +10:00
add high dpi stadiamaps
This commit is contained in:
@@ -273,7 +273,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
),
|
),
|
||||||
buildDefaultDragHandles: false,
|
buildDefaultDragHandles: false,
|
||||||
itemCount: filteredChannels.length,
|
itemCount: filteredChannels.length,
|
||||||
onReorder: (oldIndex, newIndex) {
|
onReorderItem: (oldIndex, newIndex) {
|
||||||
if (newIndex > oldIndex) newIndex -= 1;
|
if (newIndex > oldIndex) newIndex -= 1;
|
||||||
final reordered = List<Channel>.from(
|
final reordered = List<Channel>.from(
|
||||||
filteredChannels,
|
filteredChannels,
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ enum MapRasterSourcePreset {
|
|||||||
|
|
||||||
enum MapRasterEndpointPreset {
|
enum MapRasterEndpointPreset {
|
||||||
standard('standard'),
|
standard('standard'),
|
||||||
eu('eu');
|
standard2x('standard_2x'),
|
||||||
|
eu('eu'),
|
||||||
|
eu2x('eu_2x');
|
||||||
|
|
||||||
const MapRasterEndpointPreset(this.id);
|
const MapRasterEndpointPreset(this.id);
|
||||||
|
|
||||||
@@ -67,12 +69,14 @@ class MapRasterEndpointDefinition {
|
|||||||
required this.label,
|
required this.label,
|
||||||
required this.description,
|
required this.description,
|
||||||
required this.host,
|
required this.host,
|
||||||
|
this.scaleSuffix = '',
|
||||||
});
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final String label;
|
final String label;
|
||||||
final String description;
|
final String description;
|
||||||
final String host;
|
final String host;
|
||||||
|
final String scaleSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MapRasterSourceCatalog {
|
class MapRasterSourceCatalog {
|
||||||
@@ -146,20 +150,44 @@ class MapRasterEndpointCatalog {
|
|||||||
description: 'Global CDN routing to the fastest Stadia server',
|
description: 'Global CDN routing to the fastest Stadia server',
|
||||||
host: 'tiles.stadiamaps.com',
|
host: 'tiles.stadiamaps.com',
|
||||||
);
|
);
|
||||||
|
static const MapRasterEndpointDefinition standard2x =
|
||||||
|
MapRasterEndpointDefinition(
|
||||||
|
id: 'standard_2x',
|
||||||
|
label: 'Standard Endpoint (@2x)',
|
||||||
|
description: 'Global Stadia endpoint with HiDPI raster tiles',
|
||||||
|
host: 'tiles.stadiamaps.com',
|
||||||
|
scaleSuffix: '@2x',
|
||||||
|
);
|
||||||
static const MapRasterEndpointDefinition eu = MapRasterEndpointDefinition(
|
static const MapRasterEndpointDefinition eu = MapRasterEndpointDefinition(
|
||||||
id: 'eu',
|
id: 'eu',
|
||||||
label: 'EU Endpoint',
|
label: 'EU Endpoint',
|
||||||
description: 'Route tile requests to Stadia EU servers',
|
description: 'Route tile requests to Stadia EU servers',
|
||||||
host: 'tiles-eu.stadiamaps.com',
|
host: 'tiles-eu.stadiamaps.com',
|
||||||
);
|
);
|
||||||
|
static const MapRasterEndpointDefinition eu2x = MapRasterEndpointDefinition(
|
||||||
|
id: 'eu_2x',
|
||||||
|
label: 'EU Endpoint (@2x)',
|
||||||
|
description: 'EU Stadia endpoint with HiDPI raster tiles',
|
||||||
|
host: 'tiles-eu.stadiamaps.com',
|
||||||
|
scaleSuffix: '@2x',
|
||||||
|
);
|
||||||
|
|
||||||
static const List<MapRasterEndpointDefinition> presets = [standard, eu];
|
static const List<MapRasterEndpointDefinition> presets = [
|
||||||
|
standard,
|
||||||
|
standard2x,
|
||||||
|
eu,
|
||||||
|
eu2x,
|
||||||
|
];
|
||||||
|
|
||||||
static MapRasterEndpointDefinition fromSettings(AppSettings settings) {
|
static MapRasterEndpointDefinition fromSettings(AppSettings settings) {
|
||||||
final preset = MapRasterEndpointPreset.fromId(settings.mapTileEndpointId);
|
final preset = MapRasterEndpointPreset.fromId(settings.mapTileEndpointId);
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
|
case MapRasterEndpointPreset.standard2x:
|
||||||
|
return standard2x;
|
||||||
case MapRasterEndpointPreset.eu:
|
case MapRasterEndpointPreset.eu:
|
||||||
return eu;
|
return eu;
|
||||||
|
case MapRasterEndpointPreset.eu2x:
|
||||||
|
return eu2x;
|
||||||
case MapRasterEndpointPreset.standard:
|
case MapRasterEndpointPreset.standard:
|
||||||
return standard;
|
return standard;
|
||||||
}
|
}
|
||||||
@@ -494,7 +522,8 @@ class MapTileCacheService extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
final endpoint = MapRasterEndpointCatalog.fromSettings(settings);
|
final endpoint = MapRasterEndpointCatalog.fromSettings(settings);
|
||||||
final apiKey = settings.mapTileApiKey?.trim();
|
final apiKey = settings.mapTileApiKey?.trim();
|
||||||
final base = 'https://${endpoint.host}/tiles/${source.id}/{z}/{x}/{y}.png';
|
final base =
|
||||||
|
'https://${endpoint.host}/tiles/${source.id}/{z}/{x}/{y}${endpoint.scaleSuffix}.png';
|
||||||
if (apiKey == null || apiKey.isEmpty) {
|
if (apiKey == null || apiKey.isEmpty) {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
@@ -513,7 +542,8 @@ class MapTileCacheService extends ChangeNotifier {
|
|||||||
final zoom = int.tryParse(segments[segments.length - 3]);
|
final zoom = int.tryParse(segments[segments.length - 3]);
|
||||||
final x = int.tryParse(segments[segments.length - 2]);
|
final x = int.tryParse(segments[segments.length - 2]);
|
||||||
final ySegment = segments.last;
|
final ySegment = segments.last;
|
||||||
final y = int.tryParse(ySegment.split('.').first);
|
final yString = ySegment.split('.').first.replaceAll('@2x', '');
|
||||||
|
final y = int.tryParse(yString);
|
||||||
|
|
||||||
if (zoom == null || x == null || y == null) {
|
if (zoom == null || x == null || y == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user