Skip to content

Commit

Permalink
pydeck: Enable custom_map_style and file encoding for HTML on Windows (
Browse files Browse the repository at this point in the history
  • Loading branch information
hokieg3n1us authored Sep 2, 2021
1 parent 5c748fc commit 017d960
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions bindings/pydeck/pydeck/bindings/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def __init__(
map_provider : str, default 'carto'
If multiple API keys are set (e.g., both Mapbox and Google Maps), inform pydeck which basemap provider to prefer.
Values can be ``carto``, ``mapbox`` or ``google_maps``
map_style : str, default 'dark'
One of 'light', 'dark', 'road', 'satellite', 'dark_no_labels', and 'light_no_labels', or
URI for basemap style, which varies by provider. The default is Carto's Dark Matter map.
For Mapbox examples, see Mapbox's `gallery <https://www.mapbox.com/gallery/>`_.
map_style : str or dict, default 'dark'
One of 'light', 'dark', 'road', 'satellite', 'dark_no_labels', and 'light_no_labels', a URI for a basemap
style, which varies by provider, or a dict that follows the Mapbox style `specification <https://docs.mapbox.com/mapbox-gl-js/style-spec/>`.
The default is Carto's Dark Matter map. For Mapbox examples, see Mapbox's `gallery <https://www.mapbox.com/gallery/>`.
If not using a basemap, set ``map_provider=None``.
initial_view_state : pydeck.ViewState, default ``pydeck.ViewState(latitude=0, longitude=0, zoom=1)``
Initial camera angle relative to the map, defaults to a fully zoomed out 0, 0-centered map
Expand Down Expand Up @@ -91,7 +91,13 @@ def __init__(
self.map_provider = str(map_provider).lower() if map_provider else None
self.deck_widget.map_provider = map_provider

self.map_style = get_from_map_identifier(map_style, map_provider)
custom_map_style_error = "The map_provider parameter must be 'mapbox' when map_style is provided as a dict."

if isinstance(map_style, dict):
assert map_provider == BaseMapProvider.MAPBOX.value, custom_map_style_error
self.map_style = map_style
else:
self.map_style = get_from_map_identifier(map_style, map_provider)

self.parameters = parameters

Expand Down
2 changes: 1 addition & 1 deletion bindings/pydeck/pydeck/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def deck_to_html(
)

if filename:
with open(filename, "w+") as f:
with open(filename, "w+", encoding="utf-8") as f:
f.write(html_str)

if open_browser:
Expand Down

0 comments on commit 017d960

Please sign in to comment.