geolocation-ai / map_overlay.py
Wendgan's picture
Upload map_overlay.py
076108a verified
raw
history blame contribute delete
450 Bytes
from PIL import Image, ImageDraw
def generate_map(lat, lon):
# Create a blank world map canvas
img = Image.new("RGB", (400, 200), "white")
draw = ImageDraw.Draw(img)
# Project lat/lon onto the canvas (simple equirectangular projection)
x = int((lon + 180) / 360 * 400)
y = int((90 - lat) / 180 * 200)
# Draw a red dot at the predicted location
draw.ellipse((x - 4, y - 4, x + 4, y + 4), fill="red")
return img