Zapier: Map Entire Table of Addresses with Latitude/Longitude via Google Maps API


#1

Does anyone have a Zapier workflow that ingests an Airtable table and then creates a Google Map that includes all records?

In a magical world, there’d be a way to layer multiple views, updated dynamically, on one map.

Thanks in advance!!!


#2

Did you find a way to integrate maps? Would love to figure this out too. Thanks


#3

Anyone have a solution?


#4

If you have Blocks you can just use the Maps block to do this.

If you need something more specific, though, you can use Zapier and the Google Maps API to do this pretty easily. You can either do it on new records, or if you have a bunch of records (or don’t want to risk Zapier running before you finish typing one in) you can create a view that filters out anything that doesn’t have a specific state (e.g. a checkbox called “Zapier” so that records in your normal view only get added to the filtered view if that checkbox is checked, thereby preventing Zapier from seeing any new records until you’re ready for it to see them).

Actually, if you’re just trying to make a map with a bunch of locations using geocoded addresses (lat/lon coordinates) then you don’t even need the Google Maps API. You can just build a URL directly in Airtable like this:

  1. Start with: https://www.google.com/maps/dir/
  2. Append the latitude and longitude coordinates to the URL in this format: lat,long//lat,long//lat,long//lat,long

Basically, latitude and longitude are separated by a comma (as per the usual) and each set of coordinates is separated by two forward slashes. A single forward slash will tell Google Maps you want directions between all of these places. Two, however, will just make them points on the map (and the first one the “origin” with the familiar red marker). If you already store your geocoded addresses in the lat,lon format in a text field (or use a formula field to combine them that way if not: latitude&’,’&longitude is the basic formula, btw, presuming those are your field names for each), you can just make a new table in your base that links to the table with addresses and uses a rollup field to combine them with the ARRAYJOIN() function using // (the two forward slashes) as your separator. I think you can just prepend the Google Maps URL to that by putting it in quotes and sticking an & between it and the ARRAYJOIN() function but I’m not sure if rollups are that flexible. This is slightly easier to do with the same approach while using the Airtable API, and you can do a lot more with that URL afterwards, but if you want to keep it in Airtable you have to take those extra steps—at least, I think that’s the case. It’d be nice if you could keep it all in one table but I haven’t figured out a way to roll up all the records in the same table and I’m pretty sure Airtable told me that can’t be done about three months ago. But, if they implement field summary functions for formula fields one of these days that’ll change. :slight_smile:

But, if you’re intent on using the Google Maps API and Zapier to do something else with those geocoded addresses you can just make an action that triggers on a new record (or a new record in a view) and use the Zapier Webhooks action to process the API request. You’d want to use a GET action because the Google Maps API uses GET. You generally need geocoded location data to query the API, but the API can generate that for you if you don’t have it (like the original poster). If you need to geocode your address(es) first, you can just use two webhook actions to do this. The zap would look like this:

  1. Airtable -> New Record (or New Record in View)
  2. Zapier Webhooks -> GET: Google Maps API call to Geocode an Address
  3. Zapier Webhooks -> GET: Google Maps API call [X] using geocoded location data from the previous call
  4. Profit???

If you don’t need to geocode, just leave out #2. For the final step, you just add an action that does something with the processed data. I came across this post when looking to see if Zapier could handle geocoding without an extra call, just to keep things simple, but it can’t (which is why I am posting this—I figure someone else might search for this information someday). I wanted a way to find the hospital closest to any given address so my step #3 call uses the geocoded address to look that up, then add it into Airtable. But we’re dealing with Zapier here, so if you want to send the result elsewhere you can. So, #3 and (especially) #4 depend on what you’re trying to accomplish.

Anyway, I hope this helps (someone)! It may sound kind of complicated, but it’s quite simple. The whole process is just hard to explain (or, at least, sounds a little convoluted when explaining) because I don’t really know the exact reason for wanting to do this. In some cases the solution is very elegant and simple, and in other cases it’s a bit more encumbered—but only due to the number of steps! All steps are straightforward! Just make sure you have a Google Maps API key set up properly if you’re going to use it. (It’s kind of hard to skip over that step without knowing, but you never know!)


#5

For occasional use, you can use BatchGeo - just add an extra column at the top of your data with column headers and copy and paste your address columns. It doesn’t address your need for automation, but I found it handy for a one-time map of our membership to see what local neighborhoods we weren’t reaching.

You don’t even need lat/long data, it works perfectly well with addresses.