Trying to create a transparent GeoJson, i only want to see the tooltips over a choropleth.
Trying the below, but getting nowhere.
style_function = {'fillColor': '#00FFFFFF',
'lineColor': '#00FFFFFF'}
folium.GeoJson(combined,
tooltip=folium.GeoJsonTooltip(fields=['LGA','MBRS'],
aliases=['Location','Members']),
style_function=style_function).add_to(m)
folium.LayerControl().add_to(m)
Can you tell me how to make the GeoJson layer transparent?
Thanks.
Jack.
Hey @jackemcpherson, the issue is that your style function is a dictionary instead of a function returning a dictionary.
Rewrite it like this:
style = {'fillColor': '#00FFFFFF', 'lineColor': '#00FFFFFF'}
folium.GeoJson(combined,
tooltip=folium.GeoJsonTooltip(fields=['LGA','MBRS'],
aliases=['Location','Members']),
style_function=lambda x: style).add_to(m)
or:
def style_function():
return {'fillColor': '#00FFFFFF', 'lineColor': '#00FFFFFF'}
folium.GeoJson(combined,
tooltip=folium.GeoJsonTooltip(fields=['LGA','MBRS'],
aliases=['Location','Members']),
style_function=style_function).add_to(m)
and that should be good. Hope this helps!
Thanks a lot for getting back to me, both options worked!
Just for anybody finding this in future: replace the dict from my code with:
{'fillColor': '#00000000', 'color': '#00000000'}
@jtbaker maybe assert style_function is callable, raise a meaningful error otherwise? What do you think, user-friendly or overkill?
@Conengmo good thinking! I like it. I've PR'd a fix in #1024.
I came across a similar problem like yours. Try to set the 'fillOpacity' property in your style function. Because according to the original Leaflet documentation, the default value is 0.2. I hope it helps.
Most helpful comment
Thanks a lot for getting back to me, both options worked!
Just for anybody finding this in future: replace the dict from my code with:
{'fillColor': '#00000000', 'color': '#00000000'}