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

Map.addlegent not working #2160

Closed
spaceie08 opened this issue Oct 24, 2024 · 1 comment
Closed

Map.addlegent not working #2160

spaceie08 opened this issue Oct 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@spaceie08
Copy link

Environment Information

`Date: Fri Oct 25 01:45:18 2024 W. Europe Daylight Time

            OS : Windows (10 10.0.22631 SP0 Multiprocessor Free)
        CPU(s) : 12
       Machine : AMD64
  Architecture : 64bit
           RAM : 30.8 GiB
   Environment : Python

Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64
bit (AMD64)]

        geemap : 0.34.3
            ee : 1.1.5
    ipyleaflet : 0.19.2
        folium : 0.18.0
    jupyterlab : Module not found
      notebook : Module not found
     ipyevents : 2.0.2
     geopandas : 0.13.2`

Description

I am trying to add the legend for a vector styled layer. But it throws an error. I have tried adding the built in legends as well and it still does not work.

`colors = ['#FF0000', '#0000FF', '#00FF00', '#FFFF00']
labels = ['barren', 'builtup', 'vegetation', 'water']

fillColor = [c + "A8" for c in colors]

styled_fc = geemap.ee_vector_style(
fc, column="Class", labels=labels, fillColor=fillColor, color="00000000"
)
Map1.add_legend(title="Class Type", layer_name= styled_fc , labels=labels, colors=colors, position = "bottomright")


TypeError Traceback (most recent call last)
File c:\Users\jazib\Documents\M-GEO\Big_Geo_Data\GEE\gee_env\lib\site-packages\geemap\geemap.py:887, in Map.add_legend(self, title, legend_dict, keys, colors, position, builtin_legend, layer_name, add_header, widget_args, **kwargs)
886 try:
--> 887 legend = self._add_legend(
888 title,
889 legend_dict,
890 keys,
891 colors,
892 position,
893 builtin_legend,
894 layer_name,
895 add_header,
896 widget_args,
897 **kwargs,
898 )
899 self._legend = legend

File c:\Users\jazib\Documents\M-GEO\Big_Geo_Data\GEE\gee_env\lib\site-packages\geemap\core.py:1167, in Map._add_legend(self, title, legend_dict, keys, colors, position, builtin_legend, layer_name, add_header, widget_args, **kwargs)
1147 """Adds a customized legend to the map.
1148
1149 Args:
(...)
1165 widget_template() function. Defaults to {}.
1166 """
...
903 self.legends.append(legend)
904 except Exception as e:
--> 905 raise Exception(e)

Exception: argument of type 'NoneType' is not iterable

`

@spaceie08 spaceie08 added the bug Something isn't working label Oct 24, 2024
@giswqs
Copy link
Member

giswqs commented Oct 25, 2024

This issue was already fixed in #2143. Please make sure you update geemap to the latest version.

pip install -U geemap

@giswqs giswqs closed this as completed Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants