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

Last updated on May 2, 2012 By

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 ph

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.

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

Download 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

[tubepress video=”IVXel6Wc2sM”]


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º.

[sourcecode lang="vb" highlight="12,13" title="Sub 1: StreetViewPanarama"]
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
[/sourcecode]

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.

[sourcecode lang="vb" highlight="20,21,22,23,24,25" title="Sub 2: GoogleStaticStreetView"]
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
[/sourcecode]

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

[sourcecode lang="vb" highlight="22,23,24,25,26,27,28,29,30" title="Sub 2: GoogleStaticStreetView"]
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
[/sourcecode]

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.

Related Posts:


Connect on YouTube, LinkedIn, Twitter.

Hey, I'm Victor Chan

Are you struggling with complex Excel tasks? Feeling overwhelmed by spreadsheets that are hard to use?

Many people believe mastering Excel is about learning shortcuts, functions, and formulas. But this overlooks the importance of building practical, real-world applications. It's not just about knowing the tools. It's about using them effectively.

That's where I come in. You'll get a unique perspective to Excel training from me. I have over 20 years of experience at Deloitte and two global tech companies. And I know what can make a difference in your career.

Let me help you integrate Excel into your professional life. Starting today. Read one of my articles, watch one of my videos. Then apply the new technique to your work. You'll see the difference immediately!


Recommended Posts

Discover the PROVEN Blueprint for transforming your Excel skills, supercharging your productivity, and standing out in your career! My course helps you to learn Excel VBA and save hours of time even if you have zero prior experience with programming.

Solve tricky Excel problems and take your work to the next level! Get customized solutions for your unique needs. Save time and gain insights with truly expert Excel solutions from only $97 per task.

Get a clear overview of your project progress using the Excel project timeline. Use it to communicate the big picture, track task progress, and stay on top of your project goals. Stay organized with our project timeline!

Our cheat sheets provide quick and easy reference to commonly used Excel VBA concepts and code snippets.

Unlock new levels of productivity and efficiency with our cheat sheets, and write VBA code like a pro in no time.

RECOMMENDED READING

Are you looking to upskill and stay ahead of the curve? Excel is a powerful tool that keeps growing in demand. We round up the best online courses for learning Excel.

Are you looking to up your spreadsheet game? Excel is an invaluable tool that can help you stay organized and save time. From data analysis to budgets, Excel can do it all!

Today, having Excel skills is more critical than ever. Those who know how to use Excel are more likely to find higher-paying jobs. And get promoted faster.

JOIN FREE EMAIL NEWSLETTER

Step up your Excel game! Join our free email newsletter and get updates on how to become more awesome at Excel.