Exemplo n.º 1
0
# Location coordinates
locations = [[18.6390, -74.1181], [18.598334, -73.960801],
             [18.608997, -74.384686], [18.549278, -74.271252],
             [18.19922, -73.75169]]

# Folium Map instance
mymap = Map(location=[18.6390, -74.1181])

# house the content for the popup
popup_content = ""

for loc in locations:
    # create a geo point instance
    geopoint = Geopoint(latitude=loc[0], longitude=loc[1])

    for weather in geopoint.get_weather():
        hr = '<hr style="margin: 1px;">'
        text = f'{weather[0][11:13]}h: {round(weather[1])}°F <img src="http://openweathermap.org/img/wn/{weather[3]}@2x.png" width="35">'
        popup_content += text + hr

    popup = Popup(popup_content, max_width=300)
    popup.add_to(geopoint)
    geopoint.add_to(mymap)
    popup_content = ""

# add a marker to the map
# jeremie = Marker(location = [latitude, longitude], popup = 'Jeremie')
# jeremie.add_to(mymap)

# save map instance
mymap.save('map.html')
Exemplo n.º 2
0
from folium import Map, Marker, Popup
from geo import Geopoint
# Get latitude and longitude values
locations = [[41, -1], [40, 2], [39, 5], [42, 101]]

# Folium Map instance
mymap = Map(location=[40, 2])

for lat, lon in locations:
    # Create a Geopoint instance
    geopoint = Geopoint(latitude=lat, longitude=lon)
    forecast = geopoint.get_weather()
    popup_content = f"""
    {forecast[0][0][-8:-6]}h: {round(forecast[0][1])}°F <img src="http://openweathermap.org/img/wn/{forecast[0][-1]}@2x.png" width=35>
    <hr style="margin:1px">
    {forecast[1][0][-8:-6]}h: {round(forecast[1][1])}°F <img src="http://openweathermap.org/img/wn/{forecast[1][-1]}@2x.png" width=35>
    <hr style="margin:1px">
    {forecast[2][0][-8:-6]}h: {round(forecast[2][1])}°F <img src="http://openweathermap.org/img/wn/{forecast[2][-1]}@2x.png" width=35>
    <hr style="margin:1px">
    {forecast[3][0][-8:-6]}h: {round(forecast[3][1])}°F <img src="http://openweathermap.org/img/wn/{forecast[3][-1]}@2x.png" width=35>
    """
    # Create Popup object and add it to Geopoint
    popup = Popup(popup_content, max_width=400)
    popup.add_to(geopoint)
    geopoint.add_to(mymap)

# Save the Map instance into a HTML file
mymap.save("map.html")
Exemplo n.º 3
0
from geo import Geopoint

# Get latitude and Longitude values
latitude = 35.67
longitude = 139.65

# Locations List
locations = [[48, 120], [55, 178], [-22, -110]]

#Folium Map instance
mymap = Map(location=[latitude, longitude])

for loc in locations:
    # Create a Geopoint instance
    geopoint = Geopoint(latitude=loc[0], longitude=loc[1])
    weather = geopoint.get_weather()
    html = """<div style="width: 200px; display: flex; flex-direction: column">"""

    for hourly in weather:
        html += f"""
            <div style="border-bottom: 1px solid black; display:flex; align-items:center">
                <h2 style="padding:0;margin:0">{hourly[0][-8:-6]}H {round(hourly[1])}&deg;</h2>
                <img src="http://openweathermap.org/img/wn/{hourly[3]}@2x.png" style="width: 50px">
            </div>
        """

    html += "</div>"

    pop_up = Popup(html=html)
    pop_up.add_to(geopoint)
    geopoint.add_to(mymap)