Created
March 20, 2020 23:51
-
-
Save simboli/370afebd2946411fe08942fd609c22a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = folium.Map([40.417000, -3.703000], zoom_start=13,tiles='http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', attr="<a href=https://www.simboli.eu/>Simboli.EU</a>") | |
for index, row in df_stations.iterrows(): | |
folium.Marker([float(row['latitude']), float(row['longitude'])], | |
popup='<h4>Station '+row['name']+'</h4>\ | |
<b>Number: </b>'+row['number']+'<br/>\ | |
<b>Neighbours: </b>'+row['neighbours']+'<br/>\ | |
<b>Total bases: </b>'+str(row['total_bases'])+'<br/>\ | |
<b>Address: </b>'+row['address']+'<br/>\ | |
<b>Latitude: </b>'+str(row['latitude'])[0:8]+'<br/>\ | |
<b>Longitude: </b>'+str(row['longitude'])[0:8]+'<br/><br/>\ | |
<a href="http://www.google.com/maps/place/'+str(row['latitude'])+','+str(row['longitude'])+'">Open with Google Maps</a>', | |
icon=folium.Icon(color='red' if row.neighbours == 'Centro' else 'orange', | |
prefix='fa', icon='bicycle'),).add_to(m) | |
legendHTML = ''' | |
<style>@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');</style> | |
<p style="font-family: 'Roboto Slab', sans-serif;color:blue;">This map is part of the article <a href="https://www.simboli.eu/blog/lets-analyze-e-bike-sharing-stations-of-madrid/">'let’s analyze e-bike sharing stations of Madrid'</a>.</p> | |
<div style="position: | |
fixed; | |
background-color:white; | |
bottom: 50px; | |
left: 50px; | |
width: 150px; | |
height: 90px; | |
border:2px solid black; | |
padding: 3px; | |
z-index:9999; | |
font-size:14px; | |
font-family:Aleo, Times New Roman">Legend<br/> | |
<i style="color:red">City center</i><br> | |
<i style="color:orange">Other neighborhoods</i> | |
</div> | |
''' | |
m.get_root().html.add_child(folium.Element(legendHTML)) | |
titleHTML = ''' | |
<style>@import url('https://fonts.googleapis.com/css?family=Roboto+Slab');</style> | |
<div style="position: | |
fixed; | |
top: 50px; | |
left: 100px; | |
width: 450px; | |
height: 60px; | |
background-color: white | |
border:2px solid red; | |
padding: 3px; | |
z-index:9999; | |
font-size:13px; | |
font-family:font-family: 'Roboto Slab', sans-serif"> | |
<h3 style="text-shadow: 0 0 2px white; color:#0000b3">Map of BiciMAD stations in Madrid</h3> | |
</div> | |
''' | |
m.get_root().html.add_child(folium.Element(titleHTML)) | |
m.save('map_stations.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment