Improve subdomain notation, fix error catching for xyz in tile URL

This commit is contained in:
stopflock committed 2025-11-22 22:26:04 -06:00
1 parent 52af77e1ed
commit 3868236816
12 files changed
+106 -35

No files matched your search

+21 -6
View File
@@ -318,9 +318,15 @@ class _TileTypeDialogState extends State<_TileTypeDialog> {
),
validator: (value) {
if (value?.trim().isEmpty == true) return locService.t('tileTypeEditor.urlTemplateRequired');
if (!value!.contains('{z}') || !value.contains('{x}') || !value.contains('{y}')) {
// Check for either quadkey OR x+y+z placeholders
final hasQuadkey = value!.contains('{quadkey}');
final hasXYZ = value.contains('{x}') && value.contains('{y}') && value.contains('{z}');
if (!hasQuadkey && !hasXYZ) {
return locService.t('tileTypeEditor.urlTemplatePlaceholders');
}
return null;
},
),
@@ -403,11 +409,20 @@ class _TileTypeDialogState extends State<_TileTypeDialog> {
});
try {
// Use a sample tile from configured preview location
final url = _urlController.text
.replaceAll('{z}', kPreviewTileZoom.toString())
.replaceAll('{x}', kPreviewTileX.toString())
.replaceAll('{y}', kPreviewTileY.toString());
// Create a temporary TileType to use the getTileUrl method
final tempTileType = TileType(
id: 'preview',
name: 'Preview',
urlTemplate: _urlController.text.trim(),
attribution: 'Preview',
);
final url = tempTileType.getTileUrl(
kPreviewTileZoom,
kPreviewTileX,
kPreviewTileY,
apiKey: null, // Don't use API key for preview
);
final response = await http.get(Uri.parse(url));