import os # First, import folium package import folium from geopy.geocoders import Nominatim as NT # Initialize Nominatim API geo_locator = NT(user_agent = "geoapiExercises") # write the place place_1 = "Yemen"
location_1 = geo_locator.geocode(place_1) # now, it will search for the location by using the latitude and longitude, with zoom_start = 15 user_map1 = folium.Map(location = [location_1.longitude, location_1.latitude], zoom_start = 15 ) # At last, open the base map user_map1
user_map1 = folium.Map(location = [location_1.longitude, location_1.latitude], zoom_start = 15) #Now, we will pass the string in popup parameter folium.Marker([location_1.longitude, location_1.latitude], popup = ['YEMEN']).add_to(user_map1) # now, open the map user_map1
输出:
第四步:在地图上添加线条
用户可以使用以下代码在地图上添加直线来连接两个坐标。
示例-
# First, import folium package import folium import os from geopy.geocoders import Nominatim as NT