From 102758365fc0c58f7ad263401d443e3a4b09e279 Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Wed, 27 Nov 2024 00:11:56 -0500 Subject: [PATCH] Add support for pathlib Path --- leafmap/maplibregl.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/leafmap/maplibregl.py b/leafmap/maplibregl.py index 22fa4fdb8d..defcba3724 100644 --- a/leafmap/maplibregl.py +++ b/leafmap/maplibregl.py @@ -3613,6 +3613,8 @@ def add_gps_trace( None """ + from pathlib import Path + if add_draw_control: if draw_control_args is None: draw_control_args = { @@ -3621,6 +3623,12 @@ def add_gps_trace( } self.add_draw_control(**draw_control_args) + if isinstance(data, Path): + if data.exists(): + data = str(data) + else: + raise FileNotFoundError(f"File not found: {data}") + if isinstance(data, str): gdf = common.points_from_xy(data, x=x, y=y) elif isinstance(data, gpd.GeoDataFrame): @@ -3999,6 +4007,7 @@ def edit_gps_trace( Any: The main widget containing the map and the editing interface. """ + from pathlib import Path from datetime import datetime from bqplot import LinearScale, Figure, PanZoom import bqplot as bq @@ -4015,6 +4024,12 @@ def edit_gps_trace( else: from bqplot import Scatter + if isinstance(filename, Path): + if filename.exists(): + filename = str(filename) + else: + raise FileNotFoundError(f"File not found: {filename}") + output = widgets.Output() download_widget = widgets.Output()