import folium import requests import json import subprocess #create map object m = folium.Map(location=[52.516190, 13.377693], tiles='Stamen Toner',zoom_start=13) #make api request (writes api responses to json) subprocess.call(['sh','./scooter_locations.sh']) #import scooter1 data with open('scooter1.json', 'r') as scooter_location: location_data=scooter_location.read() #print(location_data) location_data_json = json.loads(location_data) #print(location_data_json) lat = location_data_json['data']['attributes']['lat'] #print(lat) lng = location_data_json['data']['attributes']['lng'] #print(lng) #create markers for scooter1 folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) #import scooter2 data with open('scooter2.json', 'r') as scooter_location: location_data=scooter_location.read() location_data_json = json.loads(location_data) lat = location_data_json['data']['attributes']['lat'] lng = location_data_json['data']['attributes']['lng'] #create markers for scooter2 folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) #import scooter3 data with open('scooter3.json', 'r') as scooter_location: location_data=scooter_location.read() location_data_json = json.loads(location_data) lat = location_data_json['data']['attributes']['lat'] lng = location_data_json['data']['attributes']['lng'] #create markers for scooter3 folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) #import scooter4 data with open('scooter4.json', 'r') as scooter_location: location_data=scooter_location.read() location_data_json = json.loads(location_data) lat = location_data_json['data']['attributes']['lat'] lng = location_data_json['data']['attributes']['lng'] #create markers for scooter4 folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) #import scooter5 data with open('scooter5.json', 'r') as scooter_location: location_data=scooter_location.read() location_data_json = json.loads(location_data) lat = location_data_json['data']['attributes']['lat'] lng = location_data_json['data']['attributes']['lng'] #create markers for scooter2 folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) #generate map.html m.save('map.html')