如何更改叶片/ geojson颜色

问题描述 投票:0回答:1

我希望在不同的图层中使其颜色不同,因此,请像我在Google上那样使用style_function,如下所示:

style1 = {'fillColor': '#228B22', 'lineColor': '#228B22'}
style2 = {'fillColor': '#00FFFFFF', 'lineColor': '#00FFFFFF'}

test1=gpd.read_file('file2.geojson')
folium.GeoJson(test1,name='test1',style_function=lambda x:style).add_to(mainmap)

test2=gpd.read_file('file1.geojson')
folium.GeoJson(test2,name='test2', style_function=lambda x:style2).add_to(mainmap)

但是,它在行上不起作用,仍然是默认的蓝色。

python geojson folium
1个回答
0
投票

一种简单的方法是替换

style1 = {'fillColor': '#228B22', 'lineColor': '#228B22'}
style2 = {'fillColor': '#00FFFFFF', 'lineColor': '#00FFFFFF'}

作者

style1 = {'fillColor': '#228B22', 'color': '#228B22'}
style2 = {'fillColor': '#00FFFFFF', 'color': '#00FFFFFF'}
© www.soinside.com 2019 - 2024. All rights reserved.