Refactoring: add hotkeys to switch backgrounds
This commit is contained in:
parent
3c0a19ebc6
commit
ee4b0fd238
8 changed files with 63 additions and 20 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
export type EliCategory =
|
||||||
|
| "photo"
|
||||||
|
| "map"
|
||||||
|
| "historicmap"
|
||||||
|
| "osmbasedmap"
|
||||||
|
| "historicphoto"
|
||||||
|
| "qa"
|
||||||
|
| "elevation"
|
||||||
|
| "other"
|
||||||
export interface RasterLayerProperties {
|
export interface RasterLayerProperties {
|
||||||
/**
|
/**
|
||||||
* The name of the imagery source
|
* The name of the imagery source
|
||||||
|
@ -9,16 +18,7 @@ export interface RasterLayerProperties {
|
||||||
readonly id: string
|
readonly id: string
|
||||||
|
|
||||||
readonly url: string
|
readonly url: string
|
||||||
readonly category?:
|
readonly category?: string | EliCategory
|
||||||
| string
|
|
||||||
| "photo"
|
|
||||||
| "map"
|
|
||||||
| "historicmap"
|
|
||||||
| "osmbasedmap"
|
|
||||||
| "historicphoto"
|
|
||||||
| "qa"
|
|
||||||
| "elevation"
|
|
||||||
| "other"
|
|
||||||
|
|
||||||
readonly attribution?: {
|
readonly attribution?: {
|
||||||
readonly url?: string
|
readonly url?: string
|
||||||
|
|
|
@ -45,6 +45,7 @@ import { NewGeometryFromChangesFeatureSource } from "../Logic/FeatureSource/Sour
|
||||||
import OsmObjectDownloader from "../Logic/Osm/OsmObjectDownloader"
|
import OsmObjectDownloader from "../Logic/Osm/OsmObjectDownloader"
|
||||||
import ShowOverlayRasterLayer from "../UI/Map/ShowOverlayRasterLayer"
|
import ShowOverlayRasterLayer from "../UI/Map/ShowOverlayRasterLayer"
|
||||||
import { Utils } from "../Utils"
|
import { Utils } from "../Utils"
|
||||||
|
import { EliCategory } from "./RasterLayerProperties"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -291,14 +292,59 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
/*
|
|
||||||
Hotkeys.RegisterHotkey(
|
Hotkeys.RegisterHotkey(
|
||||||
{ shift: "O" },
|
{ shift: "O" },
|
||||||
Translations.t.hotkeyDocumentation.selectMapnik,
|
Translations.t.hotkeyDocumentation.selectMapnik,
|
||||||
() => {
|
() => {
|
||||||
this.state.backgroundLayer.setData(AvailableBaseLayers.osmCarto)
|
this.mapProperties.rasterLayer.setData(AvailableRasterLayers.osmCarto)
|
||||||
}
|
}
|
||||||
)//*/
|
)
|
||||||
|
const self = this
|
||||||
|
|
||||||
|
function setLayerCategory(category: EliCategory) {
|
||||||
|
const available = self.availableLayers.data
|
||||||
|
const matchingCategoryLayers = available.filter(
|
||||||
|
(l) => l.properties.category === category
|
||||||
|
)
|
||||||
|
const best =
|
||||||
|
matchingCategoryLayers.find((l) => l.properties.best) ?? matchingCategoryLayers[0]
|
||||||
|
const rasterLayer = self.mapProperties.rasterLayer
|
||||||
|
if (rasterLayer.data !== best) {
|
||||||
|
rasterLayer.setData(best)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// The current layer is already selected...
|
||||||
|
// We switch the layers again
|
||||||
|
|
||||||
|
if (category === "osmbasedmap") {
|
||||||
|
rasterLayer.setData(undefined)
|
||||||
|
} else {
|
||||||
|
// search the _second_ best layer
|
||||||
|
const secondbest = matchingCategoryLayers.find(
|
||||||
|
(l) => l.properties.best && l !== best
|
||||||
|
)
|
||||||
|
const secondNotBest = matchingCategoryLayers.find((l) => l !== best)
|
||||||
|
rasterLayer.setData(secondbest ?? secondNotBest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Hotkeys.RegisterHotkey(
|
||||||
|
{ nomod: "O" },
|
||||||
|
Translations.t.hotkeyDocumentation.selectOsmbasedmap,
|
||||||
|
() => setLayerCategory("osmbasedmap")
|
||||||
|
)
|
||||||
|
|
||||||
|
Hotkeys.RegisterHotkey({ nomod: "M" }, Translations.t.hotkeyDocumentation.selectMap, () =>
|
||||||
|
setLayerCategory("map")
|
||||||
|
)
|
||||||
|
|
||||||
|
Hotkeys.RegisterHotkey(
|
||||||
|
{ nomod: "P" },
|
||||||
|
Translations.t.hotkeyDocumentation.selectAerial,
|
||||||
|
() => setLayerCategory("photo")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -362,7 +362,6 @@
|
||||||
"intro": "MapComplete admet les tecles següents:",
|
"intro": "MapComplete admet les tecles següents:",
|
||||||
"key": "Combinació de tecles",
|
"key": "Combinació de tecles",
|
||||||
"openLayersPanel": "Obre el panell de fons, capes i filtres",
|
"openLayersPanel": "Obre el panell de fons, capes i filtres",
|
||||||
"selectBackground": "Seleccioneu una capa de fons de la categoria {category}",
|
|
||||||
"selectMapnik": "Estableix la capa de fons OpenStreetMap-carto",
|
"selectMapnik": "Estableix la capa de fons OpenStreetMap-carto",
|
||||||
"selectSearch": "Seleccioneu la barra de cerca per cercar ubicacions",
|
"selectSearch": "Seleccioneu la barra de cerca per cercar ubicacions",
|
||||||
"title": "Dreceres"
|
"title": "Dreceres"
|
||||||
|
|
|
@ -207,7 +207,6 @@
|
||||||
"intro": "MapComplete podporuje následující klávesy:",
|
"intro": "MapComplete podporuje následující klávesy:",
|
||||||
"key": "Kombinace kláves",
|
"key": "Kombinace kláves",
|
||||||
"openLayersPanel": "Otevře panel Pozadí, vrstvy a filtry",
|
"openLayersPanel": "Otevře panel Pozadí, vrstvy a filtry",
|
||||||
"selectBackground": "Vybrat vrstvu pozadí kategorie {category}",
|
|
||||||
"selectMapnik": "Nastaví vrstvu pozadí na OpenStreetMap-carto",
|
"selectMapnik": "Nastaví vrstvu pozadí na OpenStreetMap-carto",
|
||||||
"selectSearch": "Vybere vyhledávací řádek pro vyhledávání míst",
|
"selectSearch": "Vybere vyhledávací řádek pro vyhledávání míst",
|
||||||
"title": "Klávesové zkratky"
|
"title": "Klávesové zkratky"
|
||||||
|
|
|
@ -362,7 +362,6 @@
|
||||||
"intro": "MapComplete unterstützt folgende Tastaturbefehle:",
|
"intro": "MapComplete unterstützt folgende Tastaturbefehle:",
|
||||||
"key": "Tastenkombination",
|
"key": "Tastenkombination",
|
||||||
"openLayersPanel": "Öffnet das Bedienfeld Hintergrund, Ebenen und Filter",
|
"openLayersPanel": "Öffnet das Bedienfeld Hintergrund, Ebenen und Filter",
|
||||||
"selectBackground": "Wählen Sie eine Hintergrundebene der Kategorie {category} aus",
|
|
||||||
"selectMapnik": "Setzt die Hintergrundebene auf OpenStreetMap-carto",
|
"selectMapnik": "Setzt die Hintergrundebene auf OpenStreetMap-carto",
|
||||||
"selectSearch": "Suchleiste auswählen, um nach Orten zu suchen",
|
"selectSearch": "Suchleiste auswählen, um nach Orten zu suchen",
|
||||||
"title": "Tastaturbefehle"
|
"title": "Tastaturbefehle"
|
||||||
|
|
|
@ -386,8 +386,10 @@
|
||||||
"intro": "MapComplete supports the following keys:",
|
"intro": "MapComplete supports the following keys:",
|
||||||
"key": "Key combination",
|
"key": "Key combination",
|
||||||
"openLayersPanel": "Opens the Background, layers and filters panel",
|
"openLayersPanel": "Opens the Background, layers and filters panel",
|
||||||
"selectBackground": "Select a background layer of category {category}",
|
"selectAerial": "Set the background to aerial or satellite imagery. Toggles between the two best, available layers",
|
||||||
"selectMapnik": "Sets the background layer to OpenStreetMap-carto",
|
"selectMap": "Set the background to a map from external sources. Toggles between the two best, available layers",
|
||||||
|
"selectMapnik": "Set the background layer to OpenStreetMap-carto",
|
||||||
|
"selectOsmbasedmap": "Set the background layer to on OpenStreetMap-based map (or disable the background raster layer)",
|
||||||
"selectSearch": "Select the search bar to search locations",
|
"selectSearch": "Select the search bar to search locations",
|
||||||
"title": "Hotkeys"
|
"title": "Hotkeys"
|
||||||
},
|
},
|
||||||
|
|
|
@ -311,7 +311,6 @@
|
||||||
"closeSidebar": "Fermer la barre latérale",
|
"closeSidebar": "Fermer la barre latérale",
|
||||||
"key": "Combinaison de touches",
|
"key": "Combinaison de touches",
|
||||||
"openLayersPanel": "Ouvre le panneau fond-de-plan, couches et filtres",
|
"openLayersPanel": "Ouvre le panneau fond-de-plan, couches et filtres",
|
||||||
"selectBackground": "Sélectionnez un fond de carte de type {category}",
|
|
||||||
"selectMapnik": "Appliquer le fond de carte OpenStreetMap-carto",
|
"selectMapnik": "Appliquer le fond de carte OpenStreetMap-carto",
|
||||||
"selectSearch": "Sélectionner la barre de recherche de lieux",
|
"selectSearch": "Sélectionner la barre de recherche de lieux",
|
||||||
"title": "Raccourcis clavier"
|
"title": "Raccourcis clavier"
|
||||||
|
|
|
@ -362,7 +362,6 @@
|
||||||
"intro": "MapComplete ondersteunt de volgende sneltoetsen:",
|
"intro": "MapComplete ondersteunt de volgende sneltoetsen:",
|
||||||
"key": "Toets-combinatie",
|
"key": "Toets-combinatie",
|
||||||
"openLayersPanel": "Open het paneel met lagen, filters en achtergrondkaart",
|
"openLayersPanel": "Open het paneel met lagen, filters en achtergrondkaart",
|
||||||
"selectBackground": "Selecteer een achtergrondlaag van category {category}",
|
|
||||||
"selectMapnik": "Selecteer OpenStreetMap-carto als achtergrondlaag",
|
"selectMapnik": "Selecteer OpenStreetMap-carto als achtergrondlaag",
|
||||||
"selectSearch": "Selecteer de zoekbalk om locaties te zoeken",
|
"selectSearch": "Selecteer de zoekbalk om locaties te zoeken",
|
||||||
"title": "Sneltoetsen"
|
"title": "Sneltoetsen"
|
||||||
|
|
Loading…
Reference in a new issue