on-internet
← Community

Adding colormap legend to Folium map

Stack Overflow ·

I'm trying to make a map in Folium with multiple layers, each consisting of shaded areas (using GeoJSON) with colors given by a colormap. I'd like to add legends to my layers. I found a first solution here, but the problem with this solution were that the legend is fixed at the top right and more importantly, that it's always there. Instead, I'd like a legend that is only shown when the corresponding layer is shown. Here is some example code that I tried (where m is my Folium map and cm1 and cm2 are color maps): folium.GeoJson(data['Temp'], name='Temp', style_function=lambda x: { 'fillColor':

Comments

Sign in or sign up to comment and upvote.

No comments yet.