From b6586b10f60c3602b7f7332daca48e331e7c3514 Mon Sep 17 00:00:00 2001 From: Crystal Kwok Date: Wed, 14 Aug 2024 14:16:08 +0200 Subject: [PATCH] add configuration for current_location --- README.md | 17 ++++++++++++++++- src/components/baseClass.js | 2 +- src/observed_properties.js | 2 +- wcs-manifest.json | 11 ++++++++++- work/index.html | 6 ++++-- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2b111fe..27b5015 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ The data source for the components is the [Open Data Hub](https://opendatahub.co - [Options](#options) - [Translations](#translations) - [Logo](#logo) + - [Marker](#marker) - [Styling](#styling) - [Getting started](#getting-started) - [Prerequisites](#prerequisites) @@ -41,6 +42,7 @@ The data source for the components is the [Open Data Hub](https://opendatahub.co - [Documentation](#documentation) - [Boilerplate](#boilerplate) - [License](#license) + - [REUSE](#reuse) @@ -72,6 +74,14 @@ URL of an icon, that will be shown in the lower left corner. ``` +#### Marker + +To configure desired starting location with marker, add `current_location` attribute. `lat` and `lng` will be the Latitude and Longitude coordinates of your desired location, respectively. + +```html + +``` + ### Styling This web component has only one style variable, namely @@ -85,7 +95,12 @@ For example: } - + ``` The width of this component reacts on regular css rules. Configure the `display` diff --git a/src/components/baseClass.js b/src/components/baseClass.js index 1554573..925aa53 100644 --- a/src/components/baseClass.js +++ b/src/components/baseClass.js @@ -27,7 +27,6 @@ export class BaseClass extends LitElement { this.current_station = {}; this.userMarker = null; this.is_loading = false; - this.current_location = { lat: 46.479, lng: 11.331 }; this.showFilters = false; this.filters = { radius: 0, @@ -53,6 +52,7 @@ export class BaseClass extends LitElement { /* Parameters */ const [language] = (window.navigator.userLanguage || window.navigator.language).split('-'); this.language = language; + this.current_location = { lat: 46.479, lng: 11.331 }; /* Bindings */ this.render__search_box = render__search_box.bind(this); this.render__details_box = render__details_box.bind(this); diff --git a/src/observed_properties.js b/src/observed_properties.js index b13a4d8..281d1cd 100644 --- a/src/observed_properties.js +++ b/src/observed_properties.js @@ -8,7 +8,6 @@ export const observed_properties = { is_loading: { type: Boolean }, message: { type: String }, current_station: { type: Object }, - current_location: { type: Object }, showFilters: { type: Boolean }, filters: { type: Object }, visibleStations: { type: Number }, @@ -28,5 +27,6 @@ export const observed_properties = { // Parameters logo: { type: String }, language: { type: String }, + current_location: { type: Object }, mobileFullScreen: { type: Boolean } }; diff --git a/wcs-manifest.json b/wcs-manifest.json index 5578063..7182fda 100644 --- a/wcs-manifest.json +++ b/wcs-manifest.json @@ -65,7 +65,16 @@ "options": { "default": true } - } + }, + { + "key": "current_location", + "type": "text", + "label": "Coordinates of the current location in the following format: { \"lat\": 46.479, \"lng\": 11.331 }", + "required": true, + "options": { + "default": "{ \"lat\": 46.479, \"lng\": 11.331 }" + } + } ] } } diff --git a/work/index.html b/work/index.html index 092778c..c154ac6 100644 --- a/work/index.html +++ b/work/index.html @@ -28,8 +28,9 @@

Snippet

- + language="it" + current_location='{ "lat": 46.5, "lng": 11.33 }' +> @@ -67,6 +68,7 @@

Snippet

class="two" logo="https://www.greenmobility.bz.it/typo3conf/ext/interho/Resources/Public/Img/logo.png" language="it" + current_location='{ "lat": 46.5, "lng": 11.36 }' >