Skip to content

Commit

Permalink
Add open_gps_trace function (#988)
Browse files Browse the repository at this point in the history
* Add open_gps_trace function

* Update edit_gps_trace function
  • Loading branch information
giswqs authored Nov 19, 2024
1 parent 9d20287 commit a099839
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 16 deletions.
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

0 comments on commit a099839

Please sign in to comment.