npri-tools / npri

A Python package providing easy-to-use code that returns recently reported emissions from facilities, socio-economic information for places, emissions records for specific companies and industries, and emissions trends over time
GNU General Public License v3.0
0 stars 0 forks source link

return markers and polygons directly from mapping functions #13

Closed ericnost closed 8 months ago

ericnost commented 9 months ago

Instead of (just) returning a pre-made map, return also the set of styled markers or polygons themselves.

This would help with the npri-web-* Streamlit dashboards where the markers/polygons can then be pre-styled (consistently across uses) and added to a Folium FeatureGroup like so:

m = folium.Map(tiles="cartodb positron")
markers = fac.get_data_markers(attribute="NumberOfSubstances") # Return a list of markers
fg = folium.FeatureGroup(name="Facilities")
for marker in markers:
    fg.add_child(marker)
st_folium(
        m, #fac.show_data_map(attribute="NumberOfSubstances")
        feature_group_to_add=fg,
        returned_objects=[],
        use_container_width=True
    )

So maybe convert this marker generator to a separate general function get_data_markers() https://github.com/npri-tools/npri/blob/ec5ffe632878c6d64141c7659887159b3ff9e36b/npri/npri.py#L72