Skip to content

Commit 2baa05a

Browse files
committed
Improve the add_raster method
1 parent e35e0a7 commit 2baa05a

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

leafmap/common.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -2865,9 +2865,9 @@ def get_local_tile_layer(
28652865
)
28662866

28672867
if "max_zoom" not in kwargs:
2868-
kwargs["max_zoom"] = 100
2868+
kwargs["max_zoom"] = 30
28692869
if "max_native_zoom" not in kwargs:
2870-
kwargs["max_native_zoom"] = 100
2870+
kwargs["max_native_zoom"] = 30
28712871
if "cmap" in kwargs:
28722872
colormap = kwargs.pop("cmap")
28732873
if "palette" in kwargs:
@@ -2899,17 +2899,17 @@ def get_local_tile_layer(
28992899
TileClient,
29002900
)
29012901

2902-
if "show_loading" not in kwargs:
2903-
kwargs["show_loading"] = False
2902+
# if "show_loading" not in kwargs:
2903+
# kwargs["show_loading"] = False
29042904

29052905
if isinstance(source, str):
29062906
if not source.startswith("http"):
29072907
if source.startswith("~"):
29082908
source = os.path.expanduser(source)
2909-
else:
2910-
source = os.path.abspath(source)
2911-
if not os.path.exists(source):
2912-
raise ValueError("The source path does not exist.")
2909+
# else:
2910+
# source = os.path.abspath(source)
2911+
# if not os.path.exists(source):
2912+
# raise ValueError("The source path does not exist.")
29132913
else:
29142914
source = github_raw_url(source)
29152915
elif isinstance(source, TileClient) or isinstance(

leafmap/foliumap.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,9 @@ def add_tile_layer(
483483
API_key (str, optional): – API key for Cloudmade or Mapbox tiles. Defaults to True.
484484
"""
485485
if "max_zoom" not in kwargs:
486-
kwargs["max_zoom"] = 100
486+
kwargs["max_zoom"] = 30
487487
if "max_native_zoom" not in kwargs:
488-
kwargs["max_native_zoom"] = 100
488+
kwargs["max_native_zoom"] = 30
489489

490490
try:
491491
folium.raster_layers.TileLayer(
@@ -2558,14 +2558,14 @@ def split_map(
25582558
right_args (dict, optional): The arguments for the right tile layer. Defaults to {}.
25592559
"""
25602560
if "max_zoom" not in left_args:
2561-
left_args["max_zoom"] = 100
2561+
left_args["max_zoom"] = 30
25622562
if "max_native_zoom" not in left_args:
2563-
left_args["max_native_zoom"] = 100
2563+
left_args["max_native_zoom"] = 30
25642564

25652565
if "max_zoom" not in right_args:
2566-
right_args["max_zoom"] = 100
2566+
right_args["max_zoom"] = 30
25672567
if "max_native_zoom" not in right_args:
2568-
right_args["max_native_zoom"] = 100
2568+
right_args["max_native_zoom"] = 30
25692569

25702570
if "layer_name" not in left_args:
25712571
left_args["layer_name"] = "Left Layer"

leafmap/leafmap.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ def add_tile_layer(
542542
shown (bool, optional): A flag indicating whether the layer should be on by default. Defaults to True.
543543
"""
544544
if "max_zoom" not in kwargs:
545-
kwargs["max_zoom"] = 100
545+
kwargs["max_zoom"] = 30
546546
if "max_native_zoom" not in kwargs:
547-
kwargs["max_native_zoom"] = 100
547+
kwargs["max_native_zoom"] = 30
548548
try:
549549
tile_layer = ipyleaflet.TileLayer(
550550
url=url,
@@ -1398,14 +1398,14 @@ def split_map(
13981398
widget_layout (dict, optional): The layout for the widget. Defaults to None.
13991399
"""
14001400
if "max_zoom" not in left_args:
1401-
left_args["max_zoom"] = 100
1401+
left_args["max_zoom"] = 30
14021402
if "max_native_zoom" not in left_args:
1403-
left_args["max_native_zoom"] = 100
1403+
left_args["max_native_zoom"] = 30
14041404

14051405
if "max_zoom" not in right_args:
1406-
right_args["max_zoom"] = 100
1406+
right_args["max_zoom"] = 30
14071407
if "max_native_zoom" not in right_args:
1408-
right_args["max_native_zoom"] = 100
1408+
right_args["max_native_zoom"] = 30
14091409

14101410
if "layer_name" not in left_args:
14111411
left_args["layer_name"] = "Left Layer"
@@ -2201,7 +2201,6 @@ def add_raster(
22012201
zoom_to_layer (bool, optional): Whether to zoom to the extent of the layer. Defaults to True.
22022202
visible (bool, optional): Whether the layer is visible. Defaults to True.
22032203
"""
2204-
22052204
tile_layer, tile_client = get_local_tile_layer(
22062205
source,
22072206
indexes=indexes,
@@ -2217,7 +2216,6 @@ def add_raster(
22172216
tile_layer.visible = visible
22182217

22192218
self.add(tile_layer)
2220-
22212219
bounds = tile_client.bounds() # [ymin, ymax, xmin, xmax]
22222220
bounds = (
22232221
bounds[2],
@@ -4669,14 +4667,14 @@ def split_map(
46694667
m = Map(**kwargs)
46704668

46714669
if "max_zoom" not in left_args:
4672-
left_args["max_zoom"] = 100
4670+
left_args["max_zoom"] = 30
46734671
if "max_native_zoom" not in left_args:
4674-
left_args["max_native_zoom"] = 100
4672+
left_args["max_native_zoom"] = 30
46754673

46764674
if "max_zoom" not in right_args:
4677-
right_args["max_zoom"] = 100
4675+
right_args["max_zoom"] = 30
46784676
if "max_native_zoom" not in right_args:
4679-
right_args["max_native_zoom"] = 100
4677+
right_args["max_native_zoom"] = 30
46804678

46814679
if "layer_name" not in left_args:
46824680
left_args["layer_name"] = "Left Layer"

0 commit comments

Comments
 (0)