Google Maps and Earth (1 Viewer)

pekajo

Registered User.
Local time
, 08:49
Joined
Jul 25, 2011
Messages
76
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, 15:49
Joined
Jan 30, 2020
Messages
658
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, 13:49
Joined
Oct 29, 2018
Messages
14,095
Hi Peter. Have you tried using?

Application.FollowHyperlink
 

Saphirah

Member
Local time
Today, 22:49
Joined
Apr 5, 2020
Messages
57
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, 15:49
Joined
Apr 3, 2020
Messages
571
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, 21:49
Joined
Jul 9, 2003
Messages
12,455

Attachments

  • VesselVogueLifeboatBrandNorsafe_SMALL.zip
    39.5 KB · Views: 27

Users who are viewing this thread

Top Bottom