Skip to content
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

Add open_gps_trace function #988

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions leafmap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def safe_extract(
print("Data downloaded to: {}".format(final_path))


def create_download_link(filename, title="Click here to download: "):
def create_download_link(filename, title="Click here to download: ", basename=None):
"""Downloads a file from voila. Adopted from https://github.com/voila-dashboards/voila/issues/578

Args:
Expand All @@ -683,7 +683,8 @@ def create_download_link(filename, title="Click here to download: "):
data = open(filename, "rb").read()
b64 = base64.b64encode(data)
payload = b64.decode()
basename = os.path.basename(filename)
if basename is None:
basename = os.path.basename(filename)
html = '<a download="{filename}" href="data:text/csv;base64,{payload}" style="color:#0000FF;" target="_blank">{title}</a>'
html = html.format(payload=payload, title=title + f" {basename}", filename=basename)
return HTML(html)
Expand Down
1 change: 1 addition & 0 deletions leafmap/leafmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from box import Box
from IPython.display import display

from .basemaps import xyz_to_leaflet
from .legends import builtin_legends
from . import common
Expand Down
Loading