Skip to content

Commit

Permalink
Pass basemap details (url, attribution) to Vue components via env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored and soxofaan committed Jan 6, 2022
1 parent f480815 commit 2709f06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add experimental support for `chunk_polygon` process ([Open-EO/openeo-processes#287](https://github.com/Open-EO/openeo-processes/issues/287))
- Add support for `spatial_extent`, `temporal_extent` and `bands` to `Connection.load_result()`

- Setting the environment variable `OPENEO_JUPYTER_BASEMAP_URL` allows to set a new templated URL to a XYZ basemap for the Vue Components library, `OPENEO_JUPYTER_BASEMAP_ATTRIBUTION` allows to set the attribution for the basemap ([#260](https://github.com/Open-EO/openeo-python-client/issues/260))

### Changed

### Removed
Expand Down
13 changes: 12 additions & 1 deletion openeo/internal/jupyter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os

from openeo.rest import OpenEoApiError

Expand Down Expand Up @@ -85,8 +86,18 @@ def render_component(component: str, data = None, parameters: dict = None):
# Special handling for batch job results, show either item or collection depending on the data
if component == "batch-job-result":
component = "item" if data["type"] == "Feature" else "collection"
elif component == "data-table":

if component == "data-table":
parameters['columns'] = TABLE_COLUMNS[parameters['columns']]
elif (component in ['collection', 'collections', 'item', 'items']):
url = os.environ.get("OPENEO_JUPYTER_BASEMAP_URL")
attribution = os.environ.get("OPENEO_JUPYTER_BASEMAP_ATTRIBUTION")
parameters['mapOptions'] = {}
if url:
parameters['mapOptions']['basemap'] = url
if attribution:
parameters['mapOptions']['attribution'] = attribution


# Set the data as the corresponding parameter in the Vue components
key = COMPONENT_MAP.get(component, component)
Expand Down

0 comments on commit 2709f06

Please sign in to comment.