Class: GoogleEarthTour in Category Geospatial Mapping : Google Earth from Total Visual SourceBook

Create a Google Earth KML file to generate an animated tour by adding locations and wait times, then launch Google Earth with it using VBA or VB6.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the CGoogleEarthTour class.
Class_Initialize Initialize Set initial parameters for the class.
AddFlyTo Method Add a FlyTo location to the KML file.
AddWait Method Add a wait point to the KML tour file.
Save Method Complete the KML file and save the final changes. This method must be called before launching the KML file in Google Earth.
GetFileName Private Get the file name with extension without the leading drive and folder names. This private member supports the class.
CreateKMLFile Private Create and saves a Google Earth KML file from a string.
KillFile Private Delete the named file, handling errors if the file does not exist.
LaunchKML Method When the file is created, launch Google Earth with the KML file that was created. The user must have KML files associated with Google Earth for this feature to work.
Launch Private Open Google Earth by specifying the path to the KML document we created.
' Example of CGoogleEarthPoints
'
' To use this example, create a new module and paste this code into it.
' Run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)
' See the animation in Google Earth. Google Earth must already be installed on your PC to run this.

Private Sub Examples_CGoogleEarthTour()
  ' Comments: Example of using the CGoogleEarthTour class to create a KML file to show an animated tour between locations on Google Earth with VBA and VB6.
  '           Requires Google Earth to be installed and the default program when a KML file is opened.

  Const cstrKMLFile As String = "C:\Total Visual SourceBook 2013\Samples\GoogleEarthTour.kml"
  Dim clsGoogleEarthTour As CGoogleEarthTour
  Dim intCount As Integer
  Dim strError As String

  Set clsGoogleEarthTour = New CGoogleEarthTour

  With clsGoogleEarthTour
    ' Add three points to the tour and pause 5 seconds between locations
    For intCount = 1 To 3
      Select Case intCount
        Case 1
          ' FMS Office
          Call .AddFlyTo(38.916376, -77.226722, 1000, 6.333, 33.5, 15)
        Case 2
          ' White House
          Call .AddFlyTo(38.897683, -77.036497, 500, 6.333, 0, 5)
        Case 3
          ' Lincoln Memorial
          Call .AddFlyTo(38.889321, -77.050166, 500, 6.333, 0, 5)
      End Select

      ' Add a 5 second wait between points
      Call .AddWait(5)
    Next intCount

    ' Save the KML file
    strError = .Save(cstrKMLFile)
    If strError = "" Then
      ' Launch Google Earth with the KML file
      strError = .LaunchKML
    End If
    If strError <> "" Then
      MsgBox strError
    End If
  End With
End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS