Opening Google Maps In Street View Instead of Layers View

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
I have the following code which opens Google Maps and navigates to the latitude & longitude specified:

VBA Code:
Sub CommandButton1_Click()
Dim chromePath As String

chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
      
Shell (chromePath & " -url http://www.google.com/maps/place/" & UserForm1.txtLatitude & "," & UserForm1.txtLongitude), vbMaximizedFocus
  
End Sub

This code is working fine, except that it's opening in the generic "layers" view instead of "Satellite" view where you can see trees, buildings, etc. Actual textures.

Does anyone know of a way to open Google Maps in Satellite view?

Bonus Points: I would actually rather grab a screen shot of the map (in satellite view) and paste it into a frame in a userform if possible rather than opening a Chrome Window and finding the location, but I'll take what I can get....

Thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi there

Try the below change and let us know...

VBA Code:
Shell (chromePath & " -url https://www.google.com/maps?t=k&q=" & UserForm1.txtLatitude & "," & UserForm1.txtLongitude), vbMaximizedFocus
 
Upvote 0
This worked perfectly Jimmypop - thank you!

Can I ask one more question - are you aware of how to (or any specific resources how to) capture a screen shot of that map and paste it into a frame on a userform? That would be my ultimate goal but the code above is a solution I can live with until I figure the other way out...
 
Upvote 0
This worked perfectly Jimmypop - thank you!

Can I ask one more question - are you aware of how to (or any specific resources how to) capture a screen shot of that map and paste it into a frame on a userform? That would be my ultimate goal but the code above is a solution I can live with until I figure the other way out...

Hi... I did try but also struggling with that one... maybe someone else spots this and has a solution...
 
Upvote 0
Below is some code I use to put an image inside an image object on a worksheet, you may be able to re-purpose it for a UF?

VBA Code:
Sub GoogleStaticMap()
    Dim oShape As Shape
    Dim sURL As String
    
    Set oShape = Sheet1.Shapes("gPic")
    sURL = "https://maps.googleapis.com/maps/api/staticmap?center=51.4196774,-0.975"
    sURL = sURL & "&maptype=hybrid" & "&zoom=10" & "&size=" & 700 & "x" & 700 & "&sensor=false" & "&scale=1" & "&key=API_KEY_HERE"
    oShape.Fill.UserPicture sURL
End Sub
 
Upvote 0
Hi @Georgiboy

I tried the above code as is but getting error

Screenshot 2022-11-25 091558.png

on line

Screenshot 2022-11-25 091616.png
 
Upvote 0
Hi @Jimmypop

I probably should have mentioned a few things:

You need to have an active API key from Google
You need to activate the Static Maps part of the API on the Google cloud platform
The active API Key needs to replace "API_KEY_HERE" in the code
The rectangle shape on the sheet needs to be named: gPic
 
Upvote 0
So, I am SO close to having this code working (I think...)....

I have the code written, and everything passes correctly except the last line....

VBA Code:
Sub CommandButton2_Click()
Dim oShape As Image
Dim sURL As String
    
    Set oShape = UserForm1.Controls("gPic")
    sURL = "https://maps.googleapis.com/maps/api/staticmap?center=" & UserForm1.txtLatitude & "," & UserForm1.txtLongitude
    sURL = sURL & "&maptype=hybrid" & "&zoom=10" & "&size=" & 386 & "x" & 386 & "&sensor=false" & "&scale=1" & "&key=ABCDEFG"
    oShape.Picture = LoadPicture(sURL)
End Sub

(I replaced the API key with generic letters but the key is there in the real code).

The error I am getting is on the last line...oShape.Picture = LoadPicture(sURL).

I get a "Run Time Error 75: Path/File Access Error".

Any ideas?
 
Upvote 0
I got something very close to work....

Instead of using the image control, I am using the web browser control with the following code:

VBA Code:
.WebBrowserMap.Navigate2 "https://www.google.com/maps/@" & .txtLatitude & "," & .txtLongitude & ",17z"

It's not quite a screen shot but it's close enough...
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,842
Members
449,193
Latest member
MikeVol

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top