Meetup Finder

Hey ho, fellow humans. I have a short one-day project I want to showcase. The issue it tackles is a pretty common one. Suppose you have some friends and you want to meet up with them. So where would be the optimal location? The meetup-finder tool can help you with that!

The Google Maps API is used to determine travel times within a specified area. As input, you will need to specify the addresses of your friends and it will then create a heat map based on the average travel times within that area. The location with the lowest average travel time is then marked in the created map.

Here is a short guide on how to get it working:

Step 1: Get Your Google Maps API Key

To get started, you will need a Google Maps API key to access the necessary services (like geocoding and travel time calculations). Follow these steps:

  1. Go to the [Google Cloud Console](https://console.cloud.google.com/).
  2. If you don’t have an account, sign up for one.
  3. Create a new project in the console (or select an existing one).
  4. In the left-hand menu, navigate to APIs & Services > Credentials.
  5. Click Create Credentials and choose API Key.
  6. Your new API key will appear. Copy this key, as you’ll need to add it to the script.

Step 2: Add the API Key to the Script

Once you have the API key, you need to set it up in the script so it can make requests to the Google Maps API.

  • 1: Open the script (`good_meeting_location_finder.py`) in your preferred code editor.
  • 2: Find the following line, where the Google Maps client is initialized:
gmaps = googlemaps.Client(key=os.environ.get("GOOGLE_MAPS_API_KEY"))
  • 3: You have two options for providing the API key:
    • Option 1: Set up the API key as an environment variable. This method is more secure since it keeps your key out of the codebase. Add this line to your terminal configuration file (e.g., `.bashrc`, `.zshrc`) or directly into your terminal:
export GOOGLE_MAPS_API_KEY='your_api_key_here'
    • Option 2: Edit the script directly by replacing the `os.environ.get(“GOOGLE_MAPS_API_KEY”)` with your API key string:
gmaps = googlemaps.Client(key="your_api_key_here")
  • 3: Save the script.

Step 3: Input Your Friends’ Addresses

Next, you need to specify the addresses of your friends in the `input_addresses.json` file.

  • 1: Open or create a file named `input_addresses.json` in the same directory as the script.
  • 2: Add your friends’ names and addresses in the following format:
[
    {
    "name": "Alice",
    "address": "123 Main St, Anytown, USA"
    },
    {
    "name": "Bob",
    "address": "456 Oak Ave, Anytown, USA"
    }
]
    • The `”name”` field is optional but recommended to identify whose address is whose.
    • The `”address”` field should contain each person’s full address.
  • 3: Save the `input_addresses.json` file.

Step 4: Run the Script

Once you’ve added the API key and input addresses, it’s time to run the script:

  • 1: In the terminal, navigate to the project directory where your script and `input_addresses.json` file are located.
  • 2: Run the script with:
python meeting_location_finder.py
  • 3: The script will generate a file named `map.html` in the same directory. This file contains an interactive map with the following features:
    • A heatmap that visualizes the average travel times for various locations, with green areas representing the shortest times and red areas representing the longest times.
    • Markers for each friend’s address (house icons).
      • A star marker showing the best meeting location based on the lowest average travel time.

Step 5: Explore the Output

To explore the results:

  1. Open the `map.html` file in any web browser.
  2. You can interact with the map by:
    • Clicking on the house markers to display the name and address of your friends.
    • Clicking on the star marker to see the best meetup location and its average travel time.
    • Clicking over on areas of the heatmap to view the average travel time for each grid point.

If you have any questions, please HESITATE TO ASK!

That’s it, goodbye and thank’s for the fish!

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Scroll to Top