Skip to content

Commit

Permalink
add configuration for current_location
Browse files Browse the repository at this point in the history
  • Loading branch information
kytcrystal committed Aug 14, 2024
1 parent 167fa4f commit b6586b1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -72,6 +74,14 @@ URL of an icon, that will be shown in the lower left corner.
<e-mobility-map-widget logo="https://www.example.com/your-logo.png"></e-mobility-map-widget>
```

#### 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
<e-mobility-map-widget current_location='{ "lat": 46.5, "lng": 11.33 }'></e-mobility-map-widget>
```

### Styling

This web component has only one style variable, namely
Expand All @@ -85,7 +95,12 @@ For example:
}
</style>

<e-mobility-map-widget class="YOUR_CLASS_NAME" logo="logo.png" language="it"></e-mobility-map-widget>
<e-mobility-map-widget
class="YOUR_CLASS_NAME"
logo="logo.png"
language="it"
current_location='{ "lat": 46.5, "lng": 11.33 }'
></e-mobility-map-widget>
```

The width of this component reacts on regular css rules. Configure the `display`
Expand Down
2 changes: 1 addition & 1 deletion src/components/baseClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/observed_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -28,5 +27,6 @@ export const observed_properties = {
// Parameters
logo: { type: String },
language: { type: String },
current_location: { type: Object },
mobileFullScreen: { type: Boolean }
};
11 changes: 10 additions & 1 deletion wcs-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }"
}
}
]
}
}
6 changes: 4 additions & 2 deletions work/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ <h2>Snippet</h2>
<e-mobility-map-widget
class="YOUR_CLASS_NAME"
logo="https://www.greenmobility.bz.it/typo3conf/ext/interho/Resources/Public/Img/logo.png"
language="it">
</e-mobility-map-widget>
language="it"
current_location='{ "lat": 46.5, "lng": 11.33 }'
></e-mobility-map-widget>

<script src="./scripts/map_widget.js"></script>
</xmp>
Expand Down Expand Up @@ -67,6 +68,7 @@ <h2>Snippet</h2>
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 }'
></e-mobility-map-widget>
</div>

Expand Down

0 comments on commit b6586b1

Please sign in to comment.