mapcomplete/Customizations/Layout.ts

87 lines
3.3 KiB
TypeScript
Raw Normal View History

2020-07-05 18:59:47 +02:00
import {LayerDefinition} from "./LayerDefinition";
import {UIElement} from "../UI/UIElement";
2020-07-21 01:37:48 +02:00
import Translations from "../UI/i18n/Translations";
2020-07-05 18:59:47 +02:00
/**
* A layout is a collection of settings of the global view (thus: welcome text, title, selection of layers).
*/
export class Layout {
2020-07-05 18:59:47 +02:00
public name: string;
public icon: string = "./assets/logo.svg";
2020-07-20 12:39:43 +02:00
public title: UIElement;
public maintainer: string;
2020-07-29 15:48:21 +02:00
public description: string | UIElement;
public socialImage: string = "";
2020-07-05 18:59:47 +02:00
public layers: LayerDefinition[];
2020-07-20 12:39:43 +02:00
public welcomeMessage: UIElement;
2020-07-21 01:37:48 +02:00
public gettingStartedPlzLogin: UIElement;
public welcomeBackMessage: UIElement;
public welcomeTail: UIElement;
2020-07-05 18:59:47 +02:00
public startzoom: number;
2020-07-21 00:07:04 +02:00
public supportedLanguages: string[];
2020-07-05 18:59:47 +02:00
public startLon: number;
public startLat: number;
public locationContains: string[];
2020-08-07 00:45:33 +02:00
public enableAdd: boolean = true;
public enableUserBadge: boolean = true;
public enableSearch: boolean = true;
public enableLayers: boolean = true;
2020-08-07 00:45:33 +02:00
public enableMoreQuests: boolean = true;
public enableShareScreen: boolean = true;
public hideFromOverview: boolean = false;
2020-07-15 11:23:35 +02:00
/**
* The BBOX of the currently visible map are widened by this factor, in order to make some panning possible.
* This number influences this
*/
2020-08-07 00:45:33 +02:00
public widenFactor: number = 0.07;
public defaultBackground: string = "osm";
public enableGeolocation: boolean = true;
2020-07-15 11:23:35 +02:00
/**
*
* @param name: The name used in the query string. If in the query "quests=<name>" is defined, it will select this layout
* @param title: Will be used in the <title> of the page
* @param layers: The layers to show, a list of LayerDefinitions
* @param startzoom: The initial starting zoom of the map
* @param startLat:The initial starting latitude of the map
* @param startLon: the initial starting longitude of the map
* @param welcomeMessage: This message is shown in the collapsable box on the left
* @param gettingStartedPlzLogin: This is shown below the welcomemessage and wrapped in a login link.
* @param welcomeBackMessage: This is shown when the user is logged in
* @param welcomeTail: This text is shown below the login message. It is ideal for extra help
*/
2020-07-05 18:59:47 +02:00
constructor(
name: string,
2020-07-21 00:07:04 +02:00
supportedLanguages: string[],
2020-07-20 12:39:43 +02:00
title: UIElement | string,
2020-07-05 18:59:47 +02:00
layers: LayerDefinition[],
startzoom: number,
startLat: number,
startLon: number,
2020-07-20 12:39:43 +02:00
welcomeMessage: UIElement | string,
gettingStartedPlzLogin: UIElement | string = Translations.t.general.getStarted,
welcomeBackMessage: UIElement | string = Translations.t.general.welcomeBack,
2020-07-21 01:37:48 +02:00
welcomeTail: UIElement | string = ""
2020-07-05 18:59:47 +02:00
) {
2020-07-21 00:07:04 +02:00
this.supportedLanguages = supportedLanguages;
2020-07-25 18:00:08 +02:00
this.title = Translations.W(title)
2020-07-05 18:59:47 +02:00
this.startLon = startLon;
this.startLat = startLat;
this.startzoom = startzoom;
this.name = name;
this.layers = layers;
this.welcomeMessage = Translations.W(welcomeMessage)
2020-07-21 01:37:48 +02:00
this.gettingStartedPlzLogin = Translations.W(gettingStartedPlzLogin);
this.welcomeBackMessage = Translations.W(welcomeBackMessage);
this.welcomeTail = Translations.W(welcomeTail);
2020-07-05 18:59:47 +02:00
}
}