I have 3 categories of data :
- Hospitals
- Schools
- Parks
For each category I have the locations of these features and a 500m walking pedshed. I need to put all hospital locations and their pedsheds in one folium subGroup (and so on for the other 2 categories as well).
The problem is that the pins are coming out as different colours but the polygons are not. I need the pins and the polygons both to have the same colour.
Here, 'sgroup' is the key in the dictionary which takes values 'Hospital', 'Pri School', and 'Park' while the 'data' is the corresponding geodataframe.
for sgroup, data in group_dict.items():
cat = sgroup
sgroup = plugins.FeatureGroupSubGroup(all_subgroups, f'{sgroup}s')
feature_style = {'color': icon_dict.get(cat)[2], 'weight': 0.5, 'fillOpacity': 0.25}
# folium.GeoJson(data.to_crs(4326).dissolve(), style_function=lambda x: feature_style).add_to(sgroup)
for poly in data.to_crs(4326).geometry:
folium.GeoJson(poly, style_function=lambda x: feature_style).add_to(sgroup)
point_locs = ITC_locs_in_the_ward.query("type == @cat").to_crs(4326)
for lat, long, text in zip(point_locs['Latitude'], point_locs['Longitude'], point_locs['Name']):
folium.Marker(location=[lat, long],
popup=text,
icon=folium.Icon(icon=icon_dict.get(cat)[0],
color=icon_dict.get(cat)[2],
prefix=icon_dict.get(cat)[1])
).add_to(sgroup)
map_with_subgroups.add_child(sgroup)