A free Google Apps Script that reads your Google Calendar and adds a travel block before every event: when to leave, and whether to walk, bike, take public transport (including NS trains) or drive.
Put a location on your events and the script handles the rest. It runs automatically whenever your calendar changes.
Every travel block is titled like ๐ฒ Leave 08:42 ยท Biking, so a glance at your calendar or a notification is enough.
Compares walking, biking, public transport, NS and driving. Short trips are walked, medium ones biked, and otherwise the fastest option wins.
In the Netherlands, it plans trains with the official NS API: tracks, transfers, fares and crowd forecasts, with the way to and from the station planned too.
Every travel option is a link that opens that exact mode in Google Maps with arrive by set to your event, so traffic and timetables are right.
Back-to-back events? It routes from your previous event. Long gap? It assumes you went home. After the last event it plans your trip home. Sleeping somewhere else? Add a multi-day all-day event with that address.
From home you bike to the bus stop or station instead of walking. Your bike stays where you parked it, and at the end of the day you're sent back to it to ride home.
Not enough time between two events? You get one block marked โ that leaves when the first one ends, with how late you'll be and when you'd have to leave to be on time.
Planned the trip yourself, like a lift or a train you booked? Add it to your travel calendar and no second travel block is added.
Keyword rules like "arrive 2 hours early for anything titled flight, and don't plan a return trip".
Open a travel block to see all options side by side. Each one is a link to that specific travel mode, and the chosen route comes with step-by-step directions.
Route: Home โ Main Building, Delft
Duration: 28 mins, 0 transfer(s)
No servers, no subscriptions. It runs in your own Google account.
In Google Calendar, add a new calendar called "Travel" and copy its Calendar ID (Settings โ Integrate calendar).
Create a project on script.google.com and paste in TravelBlocks.gs: all the code in one file.
Add a file Config.local with your TARGET_CALENDAR_ID, HOME_LOCATION and optionally NS_API_KEY (free at apiportal.ns.nl), or set them as Script Properties.
Run syncTravel once and grant permissions. It sets up its own triggers and runs automatically from then on.
All options are documented in the CONFIG block of the script. Override the ones you want in your own Config.local file.
// When to walk or bike
MODE_SELECTION: {
walkIfUnderMinutes: 15,
bikeIfUnderMinutes: 40,
allowDriving: false
},
// Arrive 5 minutes early by default
ARRIVAL_BUFFER_MINUTES: 5,
// Special rules by keyword
SPECIAL_RULES: [
{
keywords: ['flight', 'vlucht'],
arrivalBufferMinutes: 120,
disableReturnHome: true
}
]