import folium import requests import json import subprocess from datetime import datetime from glob import glob #create map object m = folium.Map(location=[52.516190, 13.377693], tiles='Stamen Toner',zoom_start=13, zoom_control=False) #make api request (writes api responses to json) subprocess.call(['sh','./scooter_locations.sh']) #import scooter data scooter_counter = 1 for file in glob('Scooters/*.json'): print ('importing data of scooter nr.' + str(scooter_counter) + '/10') with open(file, '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) print('imported. moving on...') #create markers for scooter print('creating marker for scooter nr.' + str(scooter_counter) + '/10') folium.Marker([lat,lng], popup='ARTIST_NAME + ARTWORK_TITLE', tooltip='ARTIST_NAME_HERE', icon=folium.Icon(icon='cloud')).add_to(m) print('created. moving on...') scooter_counter = scooter_counter+1 #generate map.html m.save('map.html') #adding mobile support m.get_root().header.add_child(folium.Element( '' )) #saving timestamp print('generating timestamp') with open('datetime.txt', 'w') as timestamp: timestamp.write(str(datetime.now())) print('finished!')