Example #1
0
def test_marker_popups():
    m = Map()
    features.Marker([45, -180], popup='-180').add_to(m)
    features.Marker([45, -120], popup=Popup('-120')).add_to(m)
    features.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
    features.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
    features.CircleMarker([45, 60], popup='60').add_to(m)
    features.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
    m._repr_html_()
Example #2
0
def test_marker_popups():
    m = Map()
    features.Marker([45, -180], popup='-180').add_to(m)
    features.Marker([45, -120], popup=Popup('-120')).add_to(m)
    features.RegularPolygonMarker([45, -60], popup='-60').add_to(m)
    features.RegularPolygonMarker([45, 0], popup=Popup('0')).add_to(m)
    features.CircleMarker([45, 60], popup='60').add_to(m)
    features.CircleMarker([45, 120], popup=Popup('120')).add_to(m)
    features.CircleMarker([45, 90], popup=Popup('90'), weight=0).add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[45, -180], [45, 120]], bounds
Example #3
0
def plot_locations_on_map(file_name: str, locations: pd.DataFrame):
    logging.info("Plotting locations on map")
    file_name += '.html'
    start_location = locations.iloc[0, :]
    leaflet_map = folium.Map(
        [start_location['latitude'], start_location['longitude']],
        zoom_start=7)
    for location in locations.itertuples():
        latitude = location[1]
        longitude = location[2]
        location_name = location[3]
        marker = features.Marker([latitude, longitude])
        popup = folium.Popup(location_name)
        icon = features.Icon(color='blue')

        marker.add_child(icon)
        marker.add_child(popup)
        leaflet_map.add_child(marker)

    leaflet_map.save(os.path.join(path_to_maps(), file_name))
    webbrowser.open_new_tab(os.path.join(path_to_maps(), file_name))
Example #4
0
import json
import numpy as np
import vincent

N = 100

multi_iter2 = {
    'x': [4, 5, 6],
    'y': [1, 2, 3],
}

scatter = vincent.Scatter(multi_iter2, iter_idx='x', height=100, width=200)
data = json.loads(scatter.to_json())

m = folium.Map([-34.969672, -71.230373], zoom_start=12)
mk = features.Marker([-34.969672, -71.230373])
p = folium.Popup('Hello')
v = features.Vega(data, width='100%', height='100%')

mk.add_child(p)
p.add_child(v)
m.add_child(mk)

m.save(os.path.join('recursos', 'mapaGrafico.html'))

#################################

mapaDatos = folium.Map(
    location=[-34.969672, -71.230373],
    zoom_start=16,
)
Example #5
0
map = folium.Map(location=[centery, centerx],
                 zoom_start=7,
                 tiles='Stamen Terrain')
raster_layers.ImageOverlay(
    image=dataimage,
    bounds=[[ymin, xmin], [ymax, xmax]],
    colormap=lambda x: (0, 0, 0, x),  #R,G,B,alpha
    #if I want white background then R,G,B is 1,1,1
).add_to(map)

saildrone_path = folium.PolyLine(locations=[[68, -168], [69, 1 - 164],
                                            [71, -162], [72, -156]],
                                 color='red')  #assume the path of Saildrone
saildrone_path.add_to(map)  #put the path into map

startplot = features.Marker([68, -168])
startplotpp = folium.Popup('saildrone_start')
startplotic = features.Icon(color='red')
startplot.add_child(startplotic)
startplot.add_child(startplotpp)
map.add_child(startplot)

endplot = features.Marker([72, -156])
endplotpp = folium.Popup('saildrone_end')
endplotic = features.Icon(color='blue')
endplot.add_child(endplotic)
endplot.add_child(endplotpp)
map.add_child(endplot)

#Save the final plot
map.save(