Excel Demo showing how to create a Panorama with Google Maps Street View Images

[Image] Royal Albert Hall
Google Maps has become a very popular tool for finding addresses and directions. I use it pretty much every time I want to find driving directions to a new address. But did you know that it’s possible to export Google Maps and Street View images from the Google Maps service and show them in an Excel workbook?

Getting Google Maps Images into Excel opens up the possibility of creating simple applications that combine the different types of maps onto one screen. In our 5 minute video you’ll see a short demonstration of a spreadsheet that can generate a 360º Street View panorama by combining 4 images of the chosen location.

You can download the workbook to play around with the demo then see how it’s been coded in VBA. And if you tweak the code enough you be able to create a 360º panorama featuring the Royal Albert Hall that looks ‘almost’ as good as the photo above.

Image Credit: Royal Albert Hall by Amanda Slater (licensed under Creative Commons CC BY-SA 2.0)

Google Maps in Excel – Using Google Street View API & Google Static Maps API

The demo spreadsheet works by putting together 4 Google Street View images with 2 Google Static Maps images onto an Excel workbook with the effect of a panoramic dashboard.

[Image] Google Maps in Excel Workbook Layout

Grid layout showing how 6 Google Maps Images are
combined into a panoramic dashboard

It works to dynamically download Google Maps images on the fly by making simple requests to the relevant Google Maps API service using HTTP requests, much like your web browser would do.

The spreadsheet was created by Petros Chatzipantazis at Spreadsheet1.com and is being shown here as an interesting example of what Excel is capable of doing, over and above its traditional role as a spreadsheet program.

There are 2 areas I should bring to your attention before you download and use / modify the free workbook.

1. Google Usage Limits

As of 1 May 2012 the usage limits were 1,000 unique image requests per viewer per 24 hour period but this is subject to change at any time. See the Google Street View API documentation and Google Static Maps API documentation for the latest usage limits.

2. Google Maps Image Permissions

You should read the Google Usage Permissions if you plan to use Google Maps images anywhere (Print, Digital, Media, Online Video etc.) as there are certain restrictions on the use of Images that Google requires you to follow.



Download the Spreadsheet and Try it out

[Image] Download Sample WorkbookDownload the Google Maps Static API demo workbook for free from SpreadSheet1.com – the site is run by Petros who created the Google Maps Static API demo workbook.

The workbook has been tested on Excel 2010, and will also work on Excel 2007. There are no guarantees that it will function correctly in other versions of Excel.

You must have a working connection to the web in order to access the Google APIs otherwise the workbook will not display any images.

When you open the workbook you’ll need to Enable Macros to get it working – or you can start by choosing not to Enable Macros and check out the VBA code using the VBA Editor (use ALT + F11 to open the VBA Editor, then ALT + F11 again to switch back to the main Excel workbook view).

You are welcome to freely distribute the workbook unmodified but please do not distribute the workbook if you have made any modifications to it. If you do make modifications you should only use the resulting workbook for your own personal purposes.

And do make yourself familiar with the Google Terms of Service if you wish to adapt the workbook for other purposes. You can follow these links to the Permission Guidelines for Google Maps and Google Earth and the Google Maps Developers FAQs



Watch this 5 minute video: Google Maps and Google Street View Panorama in Excel

Google Maps in Excel ➜ Demo Workbook
Runtime
4:59
View count
4,962


Image Credits in Video:

King’s College Cambridge by Sarah under the Creative Commons License Attribution 2.0 Generic (CC BY 2.0)
Buckingham Palace by Peter Robers under the Creative Commons Attribution 2.0 Generic (CC BY 2.0)

Video Highlights:

0:28 Launch application from Custom Ribbon Tab “Map Panorama”
1:20 Point of Interest: Buckingham Palace
2:12 Visual representation of what the application does
2:40 Taking a look at the VBA Sub StreetViewPanarama(…)
3:52 Taking a look at the VBA Sub GoogleStaticMap(…)



How the Excel workbook interacts with Google Static Maps and Street View APIs

There are two sets of subroutines that drive the workbook’s interaction with Google APIs. The first set deals with Street View Images and the second set deals with Static Maps Images.

Set 1: Google Street View Images

Code snippets: Generating the Street View Panorama

Two subroutines are used to generate the Street View Panorama.

The first sub loops through each of the four Workbook Street View images and calls the second sub “GoogleStaticStreetView” to update each Workbook image with the respective Google Street View image for 0º, 90º, 180º and 270º.

Sub StreetViewPanarama(strAddress As String)
    Dim oWS As Worksheet
    Dim i As Long
    If bRunMode Then On Error Resume Next
    Set oWS = ThisWorkbook.Sheets("Map View")
    For i = 1 To 4
        Call GoogleStaticStreetView(oWS.Shapes("StreetView" & i), _
            strAddress, (i - 1) * 90, 256, 256)
    Next i
    Set oWS = Nothing
End Sub


In the code snippet below you can see strURL is defined by joining together several parameters, which are defined by the Google Street View API.

Sub GoogleStaticStreetView(oShape As Shape, _
                        strAddress As String, _
                        nHeading As Long, _
                        Optional nHeight As Long = 512, _
                        Optional nWidth As Long = 512)
    'https://developers.google.com/maps/documentation/streetview/
    Dim strURL As String
    If bRunMode Then On Error Resume Next 'Error if quota exceeded
    If Len(strAddress) > 0 Then
        'URL-Escaped addresses
        strAddress = Replace(strAddress, " ", "+")
    Else
        Exit Sub
    End If
    strURL = _
    "http://maps.googleapis.com/maps/api/streetview?" & _
    "&location=" & strAddress & _
    "&size=" & nWidth & "x" & nHeight & _
    "&heading=" & nHeading & _
    "&sensor=false"
    oShape.Fill.UserPicture strURL
End Sub


Try out the Google Street View URL for the Royal Albert Hall (London)

To see how the strURL call works in practice try copying the following URL and putting it in a new tab/window on your browser (or follow the link directly by clicking here)

http://maps.googleapis.com/maps/api/streetview?_&location=51.501554,-0.178082&size=512x512&heading=135&fov=100&pitch=0&sensor=false

This should bring up the latest StreetView Image of the Royal Albert Hall in London like this:

[Image] Royal Albert Hall Street View

Royal Albert Hall Street View

For the latest documentation from Google head over to the Google Street View Developers Documentation. Here’s a quick breakdown of the parameters used in the URL.

URL for Street View Image of Royal Albert Hall
http://maps.googleapis.com/maps/api/streetview?_&location=51.501554,-0.178082&size=512x512&heading=135&fov=100&pitch=0&sensor=false

location (required)
Text string or lat/lng value (in this case 51.501554,-0.178082). Street View Image API snaps to the images photographed closest to specified location.

size (required)
Specifies output size of image in pixels. Size is specified as {width}x{height}.

heading (optional)
Indicates compass heading of camera from 0 to 360 (both 0º and 360º are for North, 90º is East, 180º is South and 270º is West). If not specified, a value is calculated to direct the camera towards the specified location, from the point at which the closest photograph was taken.

fov (optional; default is 90)
Determines horizontal field of view in degrees, with a maximum allowed value of 120.

pitch (optional; default is 0)
Specifies up or down angle of camera relative to the Street View vehicle.

sensor (required)
indicates whether or not the request came from a device using a location sensor (e.g. a GPS) to determine the location sent in this request. This value must be either true or false.

Set 2: Google Static Maps Images

In the code snippet below you can see strURL is defined by joining together several parameters, which are defined by the Google Static Maps API.

Code snippet

Sub GoogleStaticMap(oShape As Shape, _
                    strAddress As String, _
                    Optional strMapType As String = "roadmap", _
                    Optional nZoom As Long = 12, _
                    Optional nHeight As Long = 512, _
                    Optional nWidth As Long = 512)
    'https://developers.google.com/maps/documentation/staticmaps/
    Dim strURL As String
    If bRunMode Then On Error Resume Next 'Error if quota exceeded
    If Len(strAddress) > 0 Then
        'URL-Escaped addresses
        strAddress = Replace(strAddress, " ", "+")
    Else
        Exit Sub
    End If
    strURL = _
    "http://maps.googleapis.com/maps/api/staticmap?center=" & _
    strAddress & "," & _
    "&maptype=" & strMapType & _
    "&markers=color:green%7Clabel:%7C" & strAddress & _
    "&zoom=" & nZoom & _
    "&size=" & nWidth & "x" & nHeight & _
    "&sensor=false" & _
    "&scale=1"
    oShape.Fill.UserPicture strURL
End Sub

Try out the Google Static Maps URL for the Royal Albert Hall (London)

To see how the strURL call works in practice try copying the following URLs and putting them in a new tab/window on your browser (or follow these direct links for the Roadmap and the Satellite)

Static Maps Roadmap:
http://maps.googleapis.com/maps/api/staticmap?center=51.501554,-0.178082,&maptype=roadmap&markers=color:green%7Clabel:%7C51.501554,-0.178082&zoom=16&size=320x320&sensor=false&scale=1

Static Maps Satellite:
http://maps.googleapis.com/maps/api/staticmap?center=51.501554,-0.178082,&maptype=satellite&markers=color:green%7Clabel:%7C51.501554,-0.178082&zoom=16&size=320x320&sensor=false&scale=1

These bring up the latest Road & Satellite Images of the Royal Albert Hall in London:

[Image] Royal Albert Hall Road Map

Royal Albert Hall Road Map

[Image] Royal Albert Hall Satellite image

Royal Albert Hall Satellite image

Google Static Maps Documentation

If you would like to read Google’s documentation on how to use the Static Maps API click here.

Remember to Check out the Spreadsheet

Head back to the download section to find out how to download a free copy of the Google Maps in Excel demo workbook by Petros of Spreadsheet1.com

Share this page and let us know what you think

Please share the article and video using the sharing buttons on this page. And we would love to know what you think of the demo in the comment section

Do you have any suggestions about how you can see it being used in a real life application? Does it make you think of something you would like to do in Excel with VBA and images? Use the comment section to share your thoughts and ideas.

Do you have any questions about how the spreadsheet or VBA code works? Again just use the comment section to ask about the spreadsheet. We are happy to help answer your questions where possible.

Contact us to discuss Excel development projects

Finally if you are interested in contacting us for development work please use the contact form below. We provide a free initial consultation that’s focused on understanding your requirements and how we can meet them. We treat all inquiries confidentially and you can trust us to deliver professional results using Microsoft Excel.

Your Name (required)

Your Email (required)

Subject (required)

Operating System version:

Microsoft Excel version:

Project Deadline:

Budget:

Briefly describe your Excel Project Requirements:


Attach Sample Spreadsheet (optional)



About-Launch-ExcelWelcome to Launch Excel
If this is your first time to LaunchExcel.com - Welcome to Launch Excel. My name is Victor and I'm the Chief Teaching Officer of Launch Excel, a website I started to help you learn how to use Microsoft Excel more effectively. Check out my welcome page created specially for you: Click here to view Welcome Page


7 Responses to Excel Demo showing how to create a Panorama with Google Maps Street View Images
  1. Comcube Technologies
    May 10, 2012 | 8:10 pm

    Thanks for this beautiful information. It’s worth reading. Love to see your blog!

    • Victor
      May 10, 2012 | 8:50 pm

      Thanks for your comment. Hope you enjoy the rest of our blog.

      Cheers
      Victor

  2. Chris
    September 4, 2012 | 12:42 pm

    Cant download your example workbook, not free anymore ? It prompts for login

  3. GeoFF
    January 28, 2013 | 5:17 pm

    Hi there! It’s one of the best maps-excel integration available on the net. Unfortunately, I am having some troubles I do not know how to fix; if I open the xlsm file downloaded as zip and run it under Excel Prof. 2010, it appears a popup saying “runtime exception -2147352571 (80020005): cannot set ColumWidths. Types do not match”. Solutions?
    Regards

  4. Petros
    February 11, 2013 | 2:58 pm

    @GeoFF
    Thanks for your vote of confidence in our work.

    Please try unzipping & saving the .xlsm file to local disk before running (e.g. don’t run it from inside ZIP archive)

  5. buy garcinia cambogia
    June 22, 2013 | 10:12 am

    That is very fascinating, You’re an overly skilled blogger. I have joined your feed and look forward to in search of extra of your fantastic post. Additionally, I have shared your website in my social networks