Want to link addresses in Excel to Google Maps? If you have addresses or GPS coordinates in your cells, I'll show you how to visualize them in Google Maps.
The HYPERLINK Function
Before we dive in, let's explore the Excel HYPERLINK function. As the name implies, it creates a hyperlink to a URL. The function is easy to use, with only two arguments.
- The URL: It can be an external link or a reference within the workbook.
- [Optional] Friendly Name: Assign a custom label for the link in the cell.
This article will show how to generate URLs based on your cell data. Let's check out some examples.
How to Build a Google Maps URL
Let's use these addresses and add URLs in column B for each one.
Google provides an API (Application Program Interface) to plot a location on Google Maps easily. An API is essentially a URL with added arguments. The Google Maps API is: https://www.google.com/maps/search/?api=1&query=
Combine this API with the cell content using an ampersand (&) to create a URL for each address.
=HYPERLINK("https://www.google.com/maps/search/?api=1&query="&[@ Address])
- Click on a link
- Google Maps opens in your browser at the specified location.
URL with Latitude and Longitude
You can also generate URLs using Latitude and Longitude, but you must meet these two requirements:
- The decimal separator for latitude and longitude must be a dot (.)
- The separator between latitude and longitude must be a comma.
The API format is https://www.google.com/maps/search/?api=1&query=lat,long
If your local settings use commas as delimiters, force the dot by adding SUBSTITUTE(TEXT(B2, "@"), ",", ".")
for each coordinate.
Note: Only a decimal point works as a separator for latitude and longitude.
Add More arguments to the URL
As you know, there are many ways to use Google Maps (satellite, road, traffic, set the zoom, ....). If you use one of these arguments, you must put your coordiantes in the center field
Here is the list of all the arguments you can set.
map_action=map
(required): Specifies the map view type. Usemap_action=map
to display a map.center
(optional): Sets the map center using comma-separated latitude/longitude coordinates (e.g.,-33.8569,151.2152
).zoom
(optional): Adjusts the zoom level from 0 (world view) to 21 (close-up). Default is 15.basemap
(optional): Sets the map type. Options areroadmap
(default),satellite
, orterrain
.layer
(optional): Adds a layer to the map, likenone
(default),transit
,traffic
, orbicycling
.
Here are some examples and the result
- Grand Canyon (terrain) https://www.google.com/maps/@?api=1&map_action=map&zoom=12&basemap=terrain¢er=36.1069,-112.1129
- Big Ben - London (roadmap + traffic) https://www.google.com/maps/@?api=1&map_action=map&zoom=16&basemap=roadmap&layer=traffic¢er=51.5007,-0.1246