-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafrimap.py
58 lines (41 loc) · 1.73 KB
/
afrimap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
"""afrimap.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1krFU_rioZ7OTNMMTNz3VsR1DJTPPvsYo
"""
import folium
f = folium.Figure(width=1000, height=900)
initial_location = [0, 24]
zoom_start_defined = 1
min_zoom_defined = 3
m = folium.Map(location= initial_location, tiles="OpenStreetMap",
zoom_start=zoom_start_defined, min_zoom = min_zoom_defined).add_to(f)
#m.fit_bounds([[35.642876, -16.403380], [-36.237454, 54.569064]])
folium.Marker(location=[-13.133897, 27.849333], tooltip="Zambia: The real Africa", popup="<strong>Zambia: The Real Africa</strong>", icon = folium.features.CustomIcon("zambia.png", icon_size = (30, 30))).add_to(m)
m
"""# New section"""
import pandas as pd
df = pd.read_csv("data.csv")
def popup_html(row):
i = row
country_name=df['name'].iloc[i]
tourism_url=df['external_link'].iloc[i]
fun_fact =df['fun_fact'].iloc[i]
html = """
<!DOCTYPE html>
<html>
<center><h4 style="margin-bottom:5"; width="200px">{}</h4>""".format(country_name) + """</center>
<center><h6 style="margin-bottom:5"; width="200px"><b>Fun Fact:</b> <br>{}</h6>""".format(fun_fact) + """</center>
<center><a href=\"""" + tourism_url + """\" target=”_blank”>Official Visiting Site</a></center>
<center> </center>
</html>
"""
return html
import pandas as pd
df = pd.read_csv("data.csv")
for i in range(0,len(df)):
html = popup_html(i)
popup = folium.Popup(folium.Html(html, script=True), max_width=500)
folium.Marker(location = [df['latitude'][i], df['longitude'][i]], tooltip = df['name'][i],popup = popup, icon = folium.features.CustomIcon(df['icon_name'][i], icon_size = (40, 40))).add_to(m)
m.save("afrimap.html")