Small fixes, add geolocation feature switch

This commit is contained in:
Pieter Vander Vennet 2020-08-08 14:43:48 +02:00
parent 97a69ff903
commit de9bb13568
6 changed files with 38 additions and 6 deletions

View file

@ -0,0 +1,24 @@
import {TagRenderingOptions} from "../TagRenderingOptions";
import {LayerDefinition} from "../LayerDefinition";
export class CustomizationFromJSON {
public exampleLayer = {
id: "bookcases",
}
/*
public static LayerFromJson(spec: any) : LayerDefinition{
return new LayerDefinition(spec.id,{
})
}
*/
public static TagRenderingOptionsFromJson(spec: any) : TagRenderingOptions{
return new TagRenderingOptions(spec);
}
}

View file

@ -41,6 +41,7 @@ export class Layout {
*/ */
public widenFactor: number = 0.07; public widenFactor: number = 0.07;
public defaultBackground: string = "osm"; public defaultBackground: string = "osm";
public enableGeolocation: boolean = true;
/** /**
* *

View file

@ -79,14 +79,18 @@ export class GeoLocationHandler extends UIElement {
} }
InnerRender(): string { InnerRender(): string {
if(!State.state.featureSwitchGeolocation.data){
return "";
}
if (this._hasLocation.data) { if (this._hasLocation.data) {
return "<img src='assets/crosshair-blue.png' alt='locate me'>"; return "<img src='assets/crosshair-blue.svg' alt='locate me'>";
} }
if (this._isActive.data) { if (this._isActive.data) {
return "<img src='assets/crosshair-blue-center.png' alt='locate me'>"; return "<img src='assets/crosshair-blue-center.svg' alt='locate me'>";
} }
return "<img src='assets/crosshair.png' alt='locate me'>"; return "<img src='assets/crosshair.svg' alt='locate me'>";
} }

View file

@ -93,6 +93,7 @@ export class State {
public readonly featureSwitchIframe: UIEventSource<boolean>; public readonly featureSwitchIframe: UIEventSource<boolean>;
public readonly featureSwitchMoreQuests: UIEventSource<boolean>; public readonly featureSwitchMoreQuests: UIEventSource<boolean>;
public readonly featureSwitchShareScreen: UIEventSource<boolean>; public readonly featureSwitchShareScreen: UIEventSource<boolean>;
public readonly featureSwitchGeolocation: UIEventSource<boolean>;
/** /**
@ -152,6 +153,7 @@ export class State {
this.featureSwitchIframe = featSw("fs-iframe", () => false); this.featureSwitchIframe = featSw("fs-iframe", () => false);
this.featureSwitchMoreQuests = featSw("fs-more-quests", () => layoutToUse?.enableMoreQuests); this.featureSwitchMoreQuests = featSw("fs-more-quests", () => layoutToUse?.enableMoreQuests);
this.featureSwitchShareScreen = featSw("fs-share-screen", () => layoutToUse?.enableShareScreen); this.featureSwitchShareScreen = featSw("fs-share-screen", () => layoutToUse?.enableShareScreen);
this.featureSwitchGeolocation = featSw("fs-geolocation", () => layoutToUse?.enableGeolocation);
this.osmConnection = new OsmConnection( this.osmConnection = new OsmConnection(
QueryParameters.GetQueryParameter("test", "false").data === "true", QueryParameters.GetQueryParameter("test", "false").data === "true",

View file

@ -97,7 +97,8 @@ export class ShareScreen extends UIElement {
{urlName: "fs-search", human: "Enable search bar"}, {urlName: "fs-search", human: "Enable search bar"},
{urlName: "fs-welcome-message", human: "Enable the welcome message"}, {urlName: "fs-welcome-message", human: "Enable the welcome message"},
{urlName: "fs-layers", human: "Enable layer control"}, {urlName: "fs-layers", human: "Enable layer control"},
{urlName: "fs-add-new", human: "Enable the 'add new POI' button"} {urlName: "fs-add-new", human: "Enable the 'add new POI' button"},
{urlName: "fs-geolocation", human: "Enable the 'geolocate-me' button"}
] ]
@ -137,7 +138,7 @@ export class ShareScreen extends UIElement {
this._iframeCode = new VariableUiElement( this._iframeCode = new VariableUiElement(
url.map((url) => { url.map((url) => {
return `<span class='literal-code iframe-code-block'> return `<span class='literal-code iframe-code-block'>
&lt;iframe src="${url}" style="width:100%;height:100%" title="${layout.name} with MapComplete"&gt;&lt;/iframe&gt &lt;iframe src="${url}" width="100%" height="100%" title="${layout.name} with MapComplete"&gt;&lt;/iframe&gt
</span>` </span>`
}) })
); );

View file

@ -166,7 +166,7 @@ InitUiElements.OnlyIf(State.state.featureSwitchWelcomeMessage, () => {
InitUiElements.InitWelcomeMessage() InitUiElements.InitWelcomeMessage()
}); });
if ((window != window.top && !State.state.featureSwitchWelcomeMessage) || State.state.featureSwitchIframe.data) { if ((window != window.top && !State.state.featureSwitchWelcomeMessage.data) || State.state.featureSwitchIframe.data) {
new FixedUiElement(`<a href='${window.location}' target='_blank'><span class='iframe-escape'><img src='assets/pop-out.svg'></span></a>`).AttachTo("top-right") new FixedUiElement(`<a href='${window.location}' target='_blank'><span class='iframe-escape'><img src='assets/pop-out.svg'></span></a>`).AttachTo("top-right")
} }