-
Notifications
You must be signed in to change notification settings - Fork 40
feat: Support globe view #908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
02d6e13
View model definitions
kylebarron ab8c55d
Allow none
kylebarron 71b0b4e
Pass in views to Map constructor
kylebarron 4bfd2ba
move html export to separate file
kylebarron f14cdba
move view_state down after view
kylebarron c490176
Set up maplibre basemap widet
kylebarron aaf66a3
Define split renderers
kylebarron ca7bfd4
Implement split renderers
kylebarron a043703
alphabetize
kylebarron fa0940c
Merge branch 'main' into kyle/view-basemap-refactor
kylebarron 879bff0
Merge branch 'main' into kyle/split-renderers2
kylebarron 08ce7f8
Merge branch 'kyle/split-renderers2' into kyle/view-basemap-refactor
kylebarron 18aacb4
Merge branch 'main' into kyle/view-basemap-refactor
kylebarron e185723
Merge branch 'main' into kyle/view-basemap-refactor
kylebarron 05b1ec2
Merge branch 'main' into kyle/view-basemap-refactor
kylebarron 3571acf
reduce diff
kylebarron 2e59606
Support deck views
kylebarron 6ff3540
Apply linear gradient background
kylebarron e846164
Add dark background when in globe view
kylebarron 8c88487
pass undefined when no views passed
kylebarron 188164c
Remove multi-view support for now
kylebarron 89d70eb
fix basemap when constructing `Map` without any parameters
kylebarron 582d606
Let `views` be None
kylebarron 9b8ebcc
remove accidental render_mode
kylebarron d72e7b7
reduce diff
kylebarron 5ff4d12
remove controller
kylebarron a273191
Merge branch 'main' into kyle/view-basemap-refactor
kylebarron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
move html export to separate file
- Loading branch information
commit 4bfd2ba95e134cca51d97eabe5cb73e0663a6956
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from io import StringIO | ||
| from typing import IO, TYPE_CHECKING, TextIO, overload | ||
|
|
||
| from ipywidgets.embed import dependency_state, embed_minimal_html | ||
|
|
||
| if TYPE_CHECKING: | ||
| from pathlib import Path | ||
|
|
||
| from lonboard import Map | ||
|
|
||
|
|
||
| # HTML template to override exported map as 100% height | ||
| _HTML_TEMPLATE = """<!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>{title}</title> | ||
| </head> | ||
| <style> | ||
| html {{ height: 100%; }} | ||
| body {{ height: 100%; overflow: hidden;}} | ||
| .widget-subarea {{ height: 100%; }} | ||
| .jupyter-widgets-disconnected {{ height: 100%; }} | ||
| </style> | ||
| <body> | ||
| {snippet} | ||
| </body> | ||
| </html> | ||
| """ | ||
|
|
||
|
|
||
| @overload | ||
| def map_to_html( | ||
| m: Map, | ||
| *, | ||
| filename: None = None, | ||
| title: str | None = None, | ||
| ) -> str: ... | ||
|
|
||
|
|
||
| @overload | ||
| def map_to_html( | ||
| m: Map, | ||
| *, | ||
| filename: str | Path | TextIO | IO[str], | ||
| title: str | None = None, | ||
| ) -> None: ... | ||
|
|
||
|
|
||
| def map_to_html( | ||
| m: Map, | ||
| *, | ||
| filename: str | Path | TextIO | IO[str] | None = None, | ||
| title: str | None = None, | ||
| ) -> str | None: | ||
| def inner(fp: str | Path | TextIO | IO[str]) -> None: | ||
| original_height = m.height | ||
| try: | ||
| with m.hold_trait_notifications(): | ||
| m.height = "100%" | ||
| embed_minimal_html( | ||
| fp, | ||
| views=[m], | ||
| title=title or "Lonboard export", | ||
| template=_HTML_TEMPLATE, | ||
| drop_defaults=False, | ||
| # Necessary to pass the state of _this_ specific map. Otherwise, the | ||
| # state of all known widgets will be included, ballooning the file size. | ||
| state=dependency_state((m), drop_defaults=False), | ||
| ) | ||
| finally: | ||
| # If the map had a height before the HTML was generated, reset it. | ||
| m.height = original_height | ||
|
|
||
| if filename is None: | ||
| with StringIO() as sio: | ||
| inner(sio) | ||
| return sio.getvalue() | ||
|
|
||
| else: | ||
| inner(filename) | ||
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.