Untitled

 avatar
unknown
plain_text
2 years ago
864 B
3
Indexable
import folium
import requests

# Function to retrieve car location data
def get_car_locations():
    # Replace 'API_ENDPOINT' with the actual API endpoint that provides car location data
    API_ENDPOINT = 'API_ENDPOINT'
    response = requests.get(API_ENDPOINT)
    data = response.json()
    return data

# Get car location data
car_data = get_car_locations()

# Create a map centered around a specific location
# Replace 'LATITUDE, LONGITUDE' with the desired center coordinates
map_center = [LATITUDE, LONGITUDE]
map_osm = folium.Map(location=map_center, zoom_start=12)

# Add car markers to the map
for car in car_data:
    car_lat = car['latitude']
    car_lon = car['longitude']
    car_marker = folium.Marker([car_lat, car_lon])
    car_marker.add_to(map_osm)

# Save the map as an HTML file
map_osm.save('car_tracking_map.html')
Editor is loading...