from folium import Map from geo import Geopoint # get values latitude = 18.6390 longitude = 74.1181 antipode_latitude = latitude * -1 antipode_longitude = 0 jmap = Map(location) jmap.save(str('antipode.html')) long = 90.9 lat = 13.9 mypoint = Geopoint(long, lat) print(mypoint.closest_parallel())
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")
from geo import Geopoint # 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)
from folium import Map, Marker, Popup from geo import Geopoint # Get latitude and longitude values # without using CLI # locations = [[31, 121], [30, 120], [12, 119]] # using CLI latitude = float( input('Hey user, please enter the latitude of the place, e.g. 31.44 : ')) longitude = float( input('Hey user, please enter the longitude of the place, e.g. 121.36 ; ')) locations = [[latitude, longitude]] tz = Geopoint(latitude=locations[0][0], longitude=locations[0][1]) city = tz.get_time_zone().split('/') print(f'You are nearby {city[-1]} in {city[0]}') antipode_latitude = latitude * -1 # Add 180 for negative longtitudes # Subtract 180 for positive longitudes if longitude < 0: antipode_longitude = longitude + 180 else: antipode_longitude = longitude - 180 locations.append([antipode_latitude, antipode_longitude]) anti_tz = Geopoint(latitude=locations[1][0], longitude=locations[1][1]) anti_city = anti_tz.get_time_zone().split('/')
from folium import Map from geo import Geopoint latitude = 40.09 longitude = -3.47 antipode_latitude = latitude * -1 if longitude < 0: antipode_longitude = longitude + 180 elif longitude == 0: antipode_longitude = 180 elif longitude > 180: antipode_longitude = "Invalid value" else: antipode_longitude = longitude - 180 location = [antipode_latitude, antipode_longitude] mymap = Map(location) mymap.save("antipode.html") mypoint = Geopoint(41.2, 4.1) print(mypoint.closest_parallel()) print(antipode_latitude) print(antipode_longitude) print(mymap)
from folium import Map, Marker, Icon, Popup 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])}°</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)