From e98f96041a4a231639c1c641532660315b30d5d5 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 2 Dec 2020 21:23:23 +0100 Subject: [PATCH] Fix composibility of badges; update of charging station theme --- Customizations/JSON/LayerConfig.ts | 19 +++- Logic/Leaflet/GeoLocationHandler.ts | 7 +- State.ts | 2 +- Svg.ts | 14 ++- UI/UserBadge.ts | 4 +- assets/svg/circle.svg | 100 ++---------------- assets/tagRenderings/icons.json | 9 +- .../charging_stations/charging_station.svg | 60 ----------- .../charging_stations/charging_stations.json | 88 +++++++++++++-- 9 files changed, 126 insertions(+), 177 deletions(-) delete mode 100644 assets/themes/charging_stations/charging_station.svg diff --git a/Customizations/JSON/LayerConfig.ts b/Customizations/JSON/LayerConfig.ts index 56221acb0..218d16d43 100644 --- a/Customizations/JSON/LayerConfig.ts +++ b/Customizations/JSON/LayerConfig.ts @@ -13,6 +13,7 @@ import {Utils} from "../../Utils"; import Combine from "../../UI/Base/Combine"; import {VariableUiElement} from "../../UI/Base/VariableUIElement"; import {UIEventSource} from "../../Logic/UIEventSource"; +import {UIElement} from "../../UI/UIElement"; export default class LayerConfig { @@ -240,8 +241,8 @@ export default class LayerConfig { let htmlParts = []; let sourceParts = iconUrl.split(";"); - function genHtmlFromString(sourcePart: string, style?: string): string { - style = style ?? `width:100%;height:100%;rotate:${rotation};display:block;position: absolute; top: 0, left: 0`; + function genHtmlFromString(sourcePart: string): string { + const style = `width:100%;height:100%;rotate:${rotation};display:block;position: absolute; top: 0, left: 0`; let html = ``; const match = sourcePart.match(/([a-zA-Z0-9_]*):#([0-9a-fA-F]{3,6})/) if (match !== null && Svg.All[match[1] + ".svg"] !== undefined) { @@ -273,7 +274,18 @@ export default class LayerConfig { continue; } if (iconOverlay.badge) { - badges.push(genHtmlFromString(iconOverlay.then, "display: block;height:100%")) + const badgeParts: string[] = []; + const partDefs = iconOverlay.then.split(";"); + + for (const badgePartStr of partDefs) { + badgeParts.push(genHtmlFromString(badgePartStr)) + } + + const badgeCompound = new Combine(badgeParts) + .SetStyle("display:flex;position:relative;width:100%;height:100%;"); + + badges.push(badgeCompound) + } else { htmlParts.push(genHtmlFromString(iconOverlay.then)); } @@ -281,7 +293,6 @@ export default class LayerConfig { if (badges.length > 0) { const badgesComponent = new Combine(badges) - .SetStyle("display:flex;height:50%;width:100%;position:absolute;top:50%;left:50%;") .Render() diff --git a/Logic/Leaflet/GeoLocationHandler.ts b/Logic/Leaflet/GeoLocationHandler.ts index d91b2bdcb..e83c3b513 100644 --- a/Logic/Leaflet/GeoLocationHandler.ts +++ b/Logic/Leaflet/GeoLocationHandler.ts @@ -110,11 +110,8 @@ export class GeoLocationHandler extends UIElement { return ""; } if (State.state.currentGPSLocation.data !== undefined) { - State.state.bm.map.flyTo( - State.state.currentGPSLocation.data.latlng, 16, - { - duration: 0.25, - } + State.state.bm.map.setView( + State.state.currentGPSLocation.data.latlng, 16 ); } diff --git a/State.ts b/State.ts index ed637e591..143d4da21 100644 --- a/State.ts +++ b/State.ts @@ -23,7 +23,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.2.3a"; + public static vNumber = "0.2.3b"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/Svg.ts b/Svg.ts index 5010076ae..eeb11d098 100644 --- a/Svg.ts +++ b/Svg.ts @@ -44,7 +44,7 @@ export default class Svg { public static checkmark_svg() { return new FixedUiElement(Svg.checkmark);} public static checkmark_ui() { return new FixedUiElement(Svg.checkmark_img);} - public static circle = " image/svg+xml " + public static circle = " " public static circle_img = Img.AsImageElement(Svg.circle) public static circle_svg() { return new FixedUiElement(Svg.circle);} public static circle_ui() { return new FixedUiElement(Svg.circle_img);} @@ -219,6 +219,11 @@ export default class Svg { public static share_svg() { return new FixedUiElement(Svg.share);} public static share_ui() { return new FixedUiElement(Svg.share_img);} + public static square = " image/svg+xml " + public static square_img = Img.AsImageElement(Svg.square) + public static square_svg() { return new FixedUiElement(Svg.square);} + public static square_ui() { return new FixedUiElement(Svg.square_img);} + public static star = " Created by potrace 1.15, written by Peter Selinger 2001-2017 " public static star_img = Img.AsImageElement(Svg.star) public static star_svg() { return new FixedUiElement(Svg.star);} @@ -234,6 +239,11 @@ export default class Svg { public static up_svg() { return new FixedUiElement(Svg.up);} public static up_ui() { return new FixedUiElement(Svg.up_img);} + public static wikidata = " " + public static wikidata_img = Img.AsImageElement(Svg.wikidata) + public static wikidata_svg() { return new FixedUiElement(Svg.wikidata);} + public static wikidata_ui() { return new FixedUiElement(Svg.wikidata_img);} + public static wikimedia_commons_white = " Wikimedia Commons Logo " public static wikimedia_commons_white_img = Img.AsImageElement(Svg.wikimedia_commons_white) public static wikimedia_commons_white_svg() { return new FixedUiElement(Svg.wikimedia_commons_white);} @@ -244,4 +254,4 @@ export default class Svg { public static wikipedia_svg() { return new FixedUiElement(Svg.wikipedia);} public static wikipedia_ui() { return new FixedUiElement(Svg.wikipedia_img);} -public static All = {"add.svg": Svg.add,"addSmall.svg": Svg.addSmall,"ampersand.svg": Svg.ampersand,"arrow-left-smooth.svg": Svg.arrow_left_smooth,"arrow-right-smooth.svg": Svg.arrow_right_smooth,"bug.svg": Svg.bug,"camera-plus.svg": Svg.camera_plus,"checkmark.svg": Svg.checkmark,"circle.svg": Svg.circle,"close.svg": Svg.close,"compass.svg": Svg.compass,"cross_bottom_right.svg": Svg.cross_bottom_right,"crosshair-blue-center.svg": Svg.crosshair_blue_center,"crosshair-blue.svg": Svg.crosshair_blue,"crosshair.svg": Svg.crosshair,"delete_icon.svg": Svg.delete_icon,"direction.svg": Svg.direction,"direction_gradient.svg": Svg.direction_gradient,"down.svg": Svg.down,"envelope.svg": Svg.envelope,"floppy.svg": Svg.floppy,"gear.svg": Svg.gear,"help.svg": Svg.help,"home.svg": Svg.home,"home_white_bg.svg": Svg.home_white_bg,"josm_logo.svg": Svg.josm_logo,"layers.svg": Svg.layers,"layersAdd.svg": Svg.layersAdd,"logo.svg": Svg.logo,"logout.svg": Svg.logout,"mapillary.svg": Svg.mapillary,"no_checkmark.svg": Svg.no_checkmark,"or.svg": Svg.or,"osm-logo-us.svg": Svg.osm_logo_us,"osm-logo.svg": Svg.osm_logo,"pencil.svg": Svg.pencil,"phone.svg": Svg.phone,"pin.svg": Svg.pin,"pop-out.svg": Svg.pop_out,"reload.svg": Svg.reload,"search.svg": Svg.search,"send_email.svg": Svg.send_email,"share.svg": Svg.share,"star.svg": Svg.star,"statistics.svg": Svg.statistics,"up.svg": Svg.up,"wikimedia-commons-white.svg": Svg.wikimedia_commons_white,"wikipedia.svg": Svg.wikipedia};} +public static All = {"add.svg": Svg.add,"addSmall.svg": Svg.addSmall,"ampersand.svg": Svg.ampersand,"arrow-left-smooth.svg": Svg.arrow_left_smooth,"arrow-right-smooth.svg": Svg.arrow_right_smooth,"bug.svg": Svg.bug,"camera-plus.svg": Svg.camera_plus,"checkmark.svg": Svg.checkmark,"circle.svg": Svg.circle,"close.svg": Svg.close,"compass.svg": Svg.compass,"cross_bottom_right.svg": Svg.cross_bottom_right,"crosshair-blue-center.svg": Svg.crosshair_blue_center,"crosshair-blue.svg": Svg.crosshair_blue,"crosshair.svg": Svg.crosshair,"delete_icon.svg": Svg.delete_icon,"direction.svg": Svg.direction,"direction_gradient.svg": Svg.direction_gradient,"down.svg": Svg.down,"envelope.svg": Svg.envelope,"floppy.svg": Svg.floppy,"gear.svg": Svg.gear,"help.svg": Svg.help,"home.svg": Svg.home,"home_white_bg.svg": Svg.home_white_bg,"josm_logo.svg": Svg.josm_logo,"layers.svg": Svg.layers,"layersAdd.svg": Svg.layersAdd,"logo.svg": Svg.logo,"logout.svg": Svg.logout,"mapillary.svg": Svg.mapillary,"no_checkmark.svg": Svg.no_checkmark,"or.svg": Svg.or,"osm-logo-us.svg": Svg.osm_logo_us,"osm-logo.svg": Svg.osm_logo,"pencil.svg": Svg.pencil,"phone.svg": Svg.phone,"pin.svg": Svg.pin,"pop-out.svg": Svg.pop_out,"reload.svg": Svg.reload,"search.svg": Svg.search,"send_email.svg": Svg.send_email,"share.svg": Svg.share,"square.svg": Svg.square,"star.svg": Svg.star,"statistics.svg": Svg.statistics,"up.svg": Svg.up,"wikidata.svg": Svg.wikidata,"wikimedia-commons-white.svg": Svg.wikimedia_commons_white,"wikipedia.svg": Svg.wikipedia};} diff --git a/UI/UserBadge.ts b/UI/UserBadge.ts index 614c5c541..ff1c15d2d 100644 --- a/UI/UserBadge.ts +++ b/UI/UserBadge.ts @@ -1,5 +1,4 @@ import {UIElement} from "./UIElement"; -import * as L from "leaflet"; import {FixedUiElement} from "./Base/FixedUiElement"; import {VariableUiElement} from "./Base/VariableUIElement"; import Translations from "./i18n/Translations"; @@ -9,7 +8,6 @@ import {UIEventSource} from "../Logic/UIEventSource"; import Combine from "./Base/Combine"; import Svg from "../Svg"; import Link from "./Base/Link"; -import {Img} from "./Img"; import LanguagePicker from "./LanguagePicker"; /** @@ -61,7 +59,7 @@ export class UserBadge extends UIElement { if (home === undefined) { return; } - State.state.bm.map.flyTo([home.lat, home.lon], 18); + State.state.bm.map.setView([home.lat, home.lon], 16); }); } diff --git a/assets/svg/circle.svg b/assets/svg/circle.svg index c4463d66d..8e4192ed9 100644 --- a/assets/svg/circle.svg +++ b/assets/svg/circle.svg @@ -1,98 +1,14 @@ - - - - image/svg+xml - - - - - - + version="1.1" + viewBox="0 0 100 100" + height="100" + width="100"> - - - - - - - - - - - + r="50" + cy="50" + cx="50" /> diff --git a/assets/tagRenderings/icons.json b/assets/tagRenderings/icons.json index 8eb348064..350e2fc13 100644 --- a/assets/tagRenderings/icons.json +++ b/assets/tagRenderings/icons.json @@ -5,9 +5,12 @@ "mappings": [ { "if": { - "and": ["wikipedia=","wikidata~*"], - "then": "WD" - } + "and": [ + "wikipedia=", + "wikidata~*" + ] + }, + "then": "WD" } ] }, diff --git a/assets/themes/charging_stations/charging_station.svg b/assets/themes/charging_stations/charging_station.svg deleted file mode 100644 index 31f96bae3..000000000 --- a/assets/themes/charging_stations/charging_station.svg +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - diff --git a/assets/themes/charging_stations/charging_stations.json b/assets/themes/charging_stations/charging_stations.json index 7ec1ee944..25015704b 100644 --- a/assets/themes/charging_stations/charging_stations.json +++ b/assets/themes/charging_stations/charging_stations.json @@ -13,7 +13,7 @@ "en" ], "maintainer": "", - "icon": "./assets/themes/charging_stations/charging_station.svg", + "icon": "./assets/themes/charging_stations/logo.svg", "version": "0", "startLat": 0, "startLon": 0, @@ -44,14 +44,56 @@ "images", { "#": "Type", + "question": "Is this charging station meant for cars or bicycles?", "mappings": [ { - "if": "bicycle=yes", - "then": "This is a charging station for bicycles" + "if": { + "and": [ + "motorcar=yes", + "bicycle=yes" + ] + }, + "then": "This is a charging station for both bicycles and cars" }, { - "if": "motorcar=yes", - "then": "This is a charging station for electric vehicles" + "if": { + "and": [ + "motorcar=", + "car=", + "bicycle=yes" + ] + }, + "then": "This is a charging station exclusively for bicycles" + }, + { + "if": { + "and": [ + "motorcar=yes", + "car=", + "bicycle=" + ] + }, + "then": "This is a charging station exclusively for electric cars and similar vehicles" + }, + { + "if": { + "and": [ + "car=yes", + "bicycle=" + ] + }, + "then": "This is a charging station exclusively for electric cars", + "hideInAnswer": true + }, + { + "if": { + "and": [ + "car=yes", + "bicycle=yes" + ] + }, + "then": "This is a charging station for both electric cars and bicycles", + "hideInAnswer": true } ] }, @@ -189,13 +231,45 @@ ], "hideUnderlayingFeaturesMinPercentage": 0, "icon": { - "render": "./assets/themes/charging_stations/charging_station.svg" + "render": "pin:#fff;./assets/themes/charging_stations/plug.svg", + "mappings": [ + { + "if": "bicycle=yes", + "then": "pin:#fff;./assets/themes/charging_stations/bicycle.svg" + }, + { + "if": { + "or": [ + "car=yes", + "motorcar=yes" + ] + }, + "then": "pin:#fff;./assets/themes/charging_stations/car.svg" + } + ] }, + "iconOverlays": [ + { + "if": { + "and": [ + "bicycle=yes", + { + "or": [ + "motorcar=yes", + "car=yes" + ] + } + ] + }, + "then": "circle:#fff;./assets/themes/charging_stations/car.svg", + "badge": true + } + ], "width": { "render": "8" }, "iconSize": { - "render": "40,40,center" + "render": "50,50,bottom" }, "color": { "render": "#00f"