示例#1
0
def test_float_image():
    m = folium.Map([45., 3.], zoom_start=4)
    url = 'https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png'
    szt = plugins.FloatImage(url, bottom=60, left=70)
    m.add_child(szt)
    m._repr_html_()

    out = m._parent.render()

    # Verify that the div has been created.
    tmpl = Template("""
        <img id="{{this.get_name()}}" alt="float_image"
        src="https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png"
        style="z-index: 999999">
        </img>
    """)
    assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())

    # Verify that the style has been created.
    tmpl = Template("""
        <style>
            #{{this.get_name()}} {
                position:absolute;
                bottom:60%;
                left:70%;
                }
        </style>
    """)
    assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
示例#2
0
            'Establecimiento Sin Atención Covid-19',
            [['Nombre', 'nombre_establecimiento'], ['Tipo', 'tipo'],
             ['Nivel', 'nivel'], ['Subsector', 'subsector'],
             ['Dependencia', 'dependencia'], ['Número', 'numero_contacto']],
            '#c9d7bf', 7)
draw_points(pd.read_csv('data/farmacias.csv'), 'Farmacia',
            [['Nombre', 'nombre_farmacia'], ['Número', 'numero_contacto']],
            '#b8a7ea', 6)
draw_points(pd.read_csv('data/laboratorios.csv'), 'Laboratorio',
            [['Nombre', 'nombre_laboratorio'], ['Subsector', 'subsector'],
             ['Número', 'numero_contacto'], ['Método de Prueba', 'metodo']],
            '#b7e0dc', 7)
draw_points(pd.read_csv('data/medicina_tradicional.csv'),
            'Medicina Tradicional',
            [['Nombre', 'nombre_proveedor'], ['Número', 'numero_contacto']],
            '#d1a0bd', 6)

plugins.LocateControl(
    drawCircle=False,
    drawMarker=False,
    setView='once',
    initialZoomLevel=17,
    strings={
        'title': 'Ir a mi ubicación',
        'popup': "Estás a {distance} metros de este punto"
    },
).add_to(folium_map)

plugins.FloatImage('leyenda.png', bottom=2, left=2).add_to(folium_map)

folium_map.save('docs/index.html')

#df_traffic = pd.read_csv('../input/ukTrafficAADF.csv')
# df_acc = pd.read_csv('accidents_2005_to_2007.csv', dtype=object)

t_list = ["Stamen Terrain", "Stamen Toner", "MapQuest Open Aerial"]
tea_map = folium.Map(location=[6.957236, 80.618474],
                     tiles=t_list[0],
                     zoom_start=13)

# Adds tool to the top right
tea_map.add_child(plugins.MeasureControl())

# Add logo or image
img_path = ('sheflogo.png')
plugins.FloatImage(img_path, bottom=5, left=5).add_to(tea_map)

# for Heat Maps:
# # Ensure you're handing it floats
# df_acc['Latitude'] = df_acc['Latitude'].astype(float)
# df_acc['Longitude'] = df_acc['Longitude'].astype(float)

# # Filter the DF for rows, then columns, then remove NaNs
# heat_df = df_acc[df_acc['Speed_limit']=='30'] # Reducing data size so it runs faster
# heat_df = heat_df[heat_df['Year']=='2007'] # Reducing data size so it runs faster
# heat_df = heat_df[['Latitude', 'Longitude']]
# # drop rows with null values using .dropna():
# # more info: https://www.geeksforgeeks.org/python-pandas-dataframe-dropna/
# heat_df = heat_df.dropna(axis=0, subset=['Latitude','Longitude'])

# # List comprehension to make out list of lists