Skip to content

Commit 74a94d0

Browse files
authored
Fix solara app issue (#2019)
1 parent 500c7b7 commit 74a94d0

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

geemap/common.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12481,7 +12481,10 @@ def classify(
1248112481

1248212482
if cmap is None:
1248312483
cmap = "Blues"
12484-
cmap = plt.cm.get_cmap(cmap, k)
12484+
try:
12485+
cmap = plt.get_cmap(cmap, k)
12486+
except:
12487+
cmap = plt.cm.get_cmap(cmap, k)
1248512488
if colors is None:
1248612489
colors = [mpl.colors.rgb2hex(cmap(i))[1:] for i in range(cmap.N)]
1248712490
colors = ["#" + i for i in colors]
@@ -13278,7 +13281,10 @@ def get_palette_colors(cmap_name=None, n_class=None, hashtag=False):
1327813281
import matplotlib as mpl
1327913282
import matplotlib.pyplot as plt
1328013283

13281-
cmap = plt.cm.get_cmap(cmap_name, n_class)
13284+
try:
13285+
cmap = plt.get_cmap(cmap_name, n_class)
13286+
except:
13287+
cmap = plt.cm.get_cmap(cmap_name, n_class)
1328213288
colors = [mpl.colors.rgb2hex(cmap(i))[1:] for i in range(cmap.N)]
1328313289
if hashtag:
1328413290
colors = ["#" + i for i in colors]
@@ -15673,9 +15679,23 @@ def widget_template(
1567315679
)
1567415680
close_button_args["icon"] = close_button_icon
1567515681

15676-
toolbar_button = widgets.ToggleButton(**widget_args)
15682+
try:
15683+
toolbar_button = widgets.ToggleButton(**widget_args)
15684+
except:
15685+
widget_args.pop("layout")
15686+
toolbar_button = widgets.ToggleButton(**widget_args)
15687+
toolbar_button.layout.width = "28px"
15688+
toolbar_button.layout.height = "28px"
15689+
toolbar_button.layout.padding = "0px 0px 0px 4px"
1567715690

15678-
close_button = widgets.ToggleButton(**close_button_args)
15691+
try:
15692+
close_button = widgets.ToggleButton(**close_button_args)
15693+
except:
15694+
close_button_args.pop("layout")
15695+
close_button = widgets.ToggleButton(**close_button_args)
15696+
close_button.layout.width = "28px"
15697+
close_button.layout.height = "28px"
15698+
close_button.layout.padding = "0px 0px 0px 4px"
1567915699

1568015700
toolbar_widget = widgets.VBox()
1568115701
toolbar_widget.children = [toolbar_button]

geemap/toolbar.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,10 @@ def classes_changed(change):
28842884
if selected != "Any":
28852885
n_class = int(classes.value)
28862886

2887-
colors = plt.cm.get_cmap(colormap.value, n_class)
2887+
try:
2888+
colors = plt.get_cmap(colormap.value, n_class)
2889+
except:
2890+
colors = plt.cm.get_cmap(colormap.value, n_class)
28882891
cmap_colors = [
28892892
mpl.colors.rgb2hex(colors(i))[1:] for i in range(colors.N)
28902893
]
@@ -2965,7 +2968,10 @@ def colormap_changed(change):
29652968
if classes.value != "Any":
29662969
n_class = int(classes.value)
29672970

2968-
colors = plt.cm.get_cmap(colormap.value, n_class)
2971+
try:
2972+
colors = plt.get_cmap(colormap.value, n_class)
2973+
except:
2974+
colors = plt.cm.get_cmap(colormap.value, n_class)
29692975
cmap_colors = [mpl.colors.rgb2hex(colors(i))[1:] for i in range(colors.N)]
29702976

29712977
_, ax = plt.subplots(figsize=(6, 0.4))

0 commit comments

Comments
 (0)