forked from kevin/meshtastic_mqtt_server
支持图源切换
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getDefaultMapSource } from './api'
|
||||
import { getDefaultMapSource, getEnabledMapSources } from './api'
|
||||
import type { PublicMapTileSource } from './types'
|
||||
|
||||
export const fallbackMapSource: PublicMapTileSource = {
|
||||
@@ -17,3 +17,12 @@ export async function loadDefaultMapSource(): Promise<PublicMapTileSource> {
|
||||
return fallbackMapSource
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadEnabledMapSources(): Promise<PublicMapTileSource[]> {
|
||||
try {
|
||||
const response = await getEnabledMapSources()
|
||||
return response.items.length > 0 ? response.items : [fallbackMapSource]
|
||||
} catch {
|
||||
return [fallbackMapSource]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user