Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
Python Leaflet/Folium how to create a layer control that also divides markers by colours?

I'm trying to add a layer control for data related to a specific column in my dataset. There are 5 types of it, and I would like people to be able to filter the markers and also see them divided into different colours. There are lots of resources but somehow the examples are either too simple or too complex. My code so far:

it_coords = [41.902782 , 12.496366]
m = folium.Map(location=it_coords, zoom_start=6,tiles='openstreetmap')
cluster = folium.plugins.MarkerCluster(name="Monumenti").add_to(m)


for i in range(0,len(df)):
    html=f"""
        <h2> {df.iloc[i]['Titolo']}</h2>
        """
    iframe = folium.IFrame(html=html, width=200, height=200)
    popup = folium.Popup(iframe, max_width=2650)
    for grp_name, df_grp in df.groupby('Tipologia personaggio'):
        feature_group = folium.FeatureGroup(grp_name)
        feature_group.add_to(m)

    folium.Marker(
        location=[df.iloc[i]['Latitude'], df.iloc[i]['Longitude']],
        popup=popup
    ).add_to(m)

folium.LayerControl().add_to(m)
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda