Google Maps and Earth (1 Viewer)

pekajo

Registered User.
Local time
Tomorrow, 10:13
Joined
Jul 25, 2011
Messages
132
Hi
Can anyone give me the vba code for getting google maps and earth (different buttons) in a browser from Street,suburb,state and post code fields.

Thanks
Peter
 

zeroaccess

Active member
Local time
Today, 18:13
Joined
Jan 30, 2020
Messages
671
Are you trying to open a browser to Google Maps based on text box fields?

The URL needs to be built using the GPS coordinates. If you can find that, that would be a good start.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:13
Joined
Oct 29, 2018
Messages
21,358
Hi Peter. Have you tried using?

Application.FollowHyperlink
 

Saphirah

Active member
Local time
Tomorrow, 00:13
Joined
Apr 5, 2020
Messages
163
Hey. So. Google Maps Links can either be created using the coordinates or your can search for specific places.
Here is an example of a google maps link:

Code:
https://www.google.com/maps/place/64807+Dieburg+Lessingstrasse+DE/

This will show the Place Dieburg in Germany
(64807 is the post code, Dieburg is the name of the city and Lessingstrasse is the street name. DE is the country code for germany.)

So what you want to do is something like this. Lets say you have a web view called "browser".

Code:
Dim postCode As String 'Of cause you need to assign something to these variables
Dim countryCode As String
Dim street As String

browser.ControlSource = "=""https://www.google.com/maps/place/" & postCode & "+" & street & "+" & countryCode & "/"""
 
Last edited:

strive4peace

AWF VIP
Local time
Today, 18:13
Joined
Apr 3, 2020
Messages
1,003
hi pekajo,

if you want the map to open in its own window, you can use Application.FollowHyperlink sURL where sURL is the string for the URL. Note that it must be a valid address! If anything is wrong or not found, you won't even get a map that is close.

I also use a different form for the URL:

Code:
   Dim vURL As Variant _
      , sURL As String
 
   vURL = Null
 
   With Me.Street
      If Not IsNull(.Value) Then
         vURL = (vURL + " ") & .Value
      End If
   End With
 
   With Me.suburb
      If Not IsNull(.Value) Then
         vURL = (vURL + " ") & .Value
      End If
   End With
 
   With Me.St 'State
      If Not IsNull(.Value) Then
         vURL = (vURL + " ") & .Value
      End If
   End With
 
   With Me.PostCode
      If Not IsNull(.Value) Then
         vURL = (vURL + " ") & .Value
      End If
   End With
 
   sURL = "https://maps.google.com/maps?q=" & vURL
   Application.FollowHyperlink sURL
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 23:13
Joined
Jul 9, 2003
Messages
16,245

Attachments

  • VesselVogueLifeboatBrandNorsafe_SMALL.zip
    39.5 KB · Views: 174

Users who are viewing this thread

Top Bottom