app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def generate_google_maps_iframe(location_query, width=600, height=450, zoom=14): base_url = "https://www.google.com/maps/embed/v1/place" # Free method using old-style embeds (no API key required) encoded_location = location_query.replace(' ', '+') iframe_url = f"https://maps.google.com/maps?q={encoded_location}&z={zoom}&output=embed" iframe_code = f"""<iframe width="{width}" height="{height}" style="border:0" loading="lazy" allowfullscreen src="{iframe_url}"></iframe>""" return iframe_code # Example usage location = "Taj Mahal, India" iframe = generate_google_maps_iframe(location) print(iframe) |