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!
 
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...
Please share with us the entire code up to now... thanks
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
@BrianExcel

I have been looking into this and it has given me reason to investigate further:

It works fine on my 2016 version of Excel however' it is not working in my 365 version and throwing the same error as you have described.

Are you on a MAC by any chance?
 
Upvote 0
I have created a work around if you would like to try, part of the issue was down to the fact that Google produces PNG files and they are not supported.

The idea is, load the png result into a chart, export the chart as jpg, load the exported file to the UF image box, delete the temp file we created.

The workaround is:
Create a sheet named "tmp"
Add a blank chart to that sheet named "Chart 1"
Hide the sheet we just created (optional)

See the below code that I have cobbled together to make the above happen:
VBA Code:
Private Sub CommandButton1_Click()
    GoogleStaticMap Me.gPic, Me.TextBox1.Value & "," & Me.TextBox2.Value
End Sub


Sub GoogleStaticMap(oShape, sAddress As String)
    Dim sURL As String
    Dim wsTmp As Worksheet
    Dim oCht As ChartObject
    Dim tmpImage As String
    
    Set wsTmp = Sheets("tmp")
    Set oCht = wsTmp.ChartObjects("Chart 1")
    tmpImage = Environ("temp") & "\tmp.jpg"
    
    sURL = _
    "http://maps.googleapis.com/maps/api/staticmap?center=" & _
    sAddress & _
    "&maptype=hybrid" & _
    "&zoom=" & 10 & _
    "&size=" & 500 & "x" & 500 & _
    "&scale=1" & _
    "&key=API-KEY-HERE"

    With wsTmp
        With oCht.Chart
            .ChartArea.Format.Fill.UserPicture (sURL)
            .Export Filename:=tmpImage, FilterName:="JPG"
        End With
    End With
            
    oShape.Picture = LoadPicture(tmpImage)
    Kill (tmpImage)
End Sub

Couple of notes about the code above:
Me.gPic is the image box on the UF named: gPic
Me.TextBox1.Value is the lat
Me.TextBox2.Value is the long

Hope this helps
 
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...

That may also work with the static maps url?

I am not able to use active x where i am set up at the moment as it has been blocked by IT
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

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