Announcement

Collapse
No announcement yet.

Google Earth COM

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Google Earth COM

    I am trying to get Coordinates from Google Earth, but the result always is empty, i.e Google Earth loads, but that it's. Can somebody point me in the right direction?

    Code:
    $PROGID_EARTHLib_PointOnTerrainGE = "GoogleEarth.PointOnTerrainGE"
    
    ' Interface Name  : IPointOnTerrainGE
    ' Description     : IPointOnTerrainGE Interface
    ' Class Name      : PointOnTerrainGE
    ' ClassID         : $CLSID_EARTHLib_PointOnTerrainGE
    ' ProgID          : $PROGID_EARTHLib_PointOnTerrainGE
    ' Version ProgID  : $PROGID_EARTHLib_PointOnTerrainGE1
    Interface IPointOnTerrainGE $IID_EARTHLib_IPointOnTerrainGE 
        Inherit IDispatch
    
        Property Get Latitude <1> () As Double
        Property Get Longitude <2> () As Double
        Property Get Altitude <3> () As Double
        Property Get ProjectedOntoGlobe <4> () As Long
        Property Get ZeroElevationExaggeration <5> () As Long
    End Interface
    
    
    local oGoogle AS Idispatch
    local latitude, longitude as double
    oGoogle = newCOM $PROGID_EARTHLib_PointOnTerrainGE
    sleep 2000 'to make sure google earth has finished initialisation
    object get oGoogle.latitude to latitude
    object get oGoogle.longitude to longitude
    		
    ? using$("Latitude: #.##### Longitude: #.#### ",latitude,longitude)
    rgds Werner

  • #2
    Longitude and latitude of WHAT? (WHERE?)

    Just in plain English, it looks like you are creating an instance of an object and asking it to find the latitude and longitude of "nothing"

    There must be a missing piece to this puzzle.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I've not used Google maps but it appears $PROGID_EARTHLib_PointOnTerrainGE represents a pin point object representing an existing point on the map so the GET is returning the existing info LAT/LONG info.
      <b>George W. Bleck</b>
      <img src='http://www.blecktech.com/myemail.gif'>

      Comment


      • #4
        Google Earth displays the current longitude and latitude in status window at the bottom of a map, so my assumption was the values of these two variables are always current. The point on terrain has it's own ProgID and it's interface has just 5 properties. Unfortunately Google publishes the interface description only, but no example how to access the data (or I was too blind to find it).

        rgds
        Werner

        Comment


        • #5
          I don't have Google Earth on this machine, but IIRC there was a "setup" screen to tell it where you are. (I did this once, when I was on vacation Spring 2008 so the memory may be a tad off here).

          Maybe you have to go thru something like that... you are at "0,0" until you tell Google Earth where you are?
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Google Earth COM API Documentation is here
            http://earth.google.com/comapi/index.html

            Think of the IPointOnTerrainGE interface as mapping a point on your computer screen to a
            point on the earth. In the following code snippet, the constants and coclasses have different
            names, because I am using the Type Library Viewer for Phoenix 3.0.

            Code:
            '-------------------------------------------------------------------------------
            
            FUNCTION Form1_InitWindow _
              ( _
              BYVAL hWnd    AS DWORD, _ ' handle of main window
              BYVAL lParam  AS LONG _   ' address of command line
              ) AS LONG
            
              LOCAL oGoogle       AS GoogleEarthApplicationGE 
              LOCAL oTerrain      AS GoogleEarthPointOnTerrainGE   
              LOCAL x             AS DOUBLE
              LOCAL y             AS DOUBLE 
              LOCAL Latitude      AS DOUBLE
              LOCAL Longitude     AS DOUBLE
              LOCAL fInitialized  AS LONG
            
              oGoogle = newCOM $PROGID_GOOGLEEARTHAPPLICATIONGE1
              IF ISOBJECT(oGoogle) THEN
            
                DO
                  OBJECT CALL oGoogle.IsInitialized TO fInitialized
                  IF fInitialized THEN EXIT DO
                LOOP 
                
                MSGBOX "Google Earth initialized"
            
                x = 0
                y = 0
                OBJECT CALL oGoogle.GetPointOnTerrainFromScreenCoords(x, y) TO oTerrain
                IF ISOBJECT(oTerrain) THEN
                  OBJECT GET oTerrain.Latitude TO Latitude
                  OBJECT GET oTerrain.Longitude TO Longitude
                  ? USING$("Latitude: #.##### Longitude: #.#### ",latitude,longitude)      
                END IF
              END IF
            
            END FUNCTION
            Dominic Mitchell
            Phoenix Visual Designer
            http://www.phnxthunder.com

            Comment


            • #7
              Thanks Dominic, I will try it again.

              Rgds
              Werner

              Comment


              • #8
                Progress?

                Werner (or anyone).... is there any progress with this thread? I was hoping to see a code example. I'd like to use Google Earth COM API with PowerBasic. I have to admit I don't know where to start, but could really use a 'Hello-World' type example from which to learn and grow.

                Has anyone successfully used the Google Earth COM API with PB ?
                Christopher P. Becker
                signal engineer in the defense industry
                Abu Dhabi, United Arab Emirates

                Comment


                • #9
                  How to Control Google Earth with VB 6

                  http://www.xtremevbtalk.com/showthread.php?t=287038

                  I realize this is not a PB example, but it should give you some ideas.

                  Joe

                  Comment


                  • #10
                    compile-ready code example?

                    Werner (or anyone else),
                    Can you post some complete, compile-ready source code that invokes the example function already given? I'm clearly missing an #INCLUDE statement or something. I've re-registered the Google Earth COM API, but PBCC5 is not seeing it. Just a simple example would be great.
                    Thank you so much!
                    Christopher P. Becker
                    signal engineer in the defense industry
                    Abu Dhabi, United Arab Emirates

                    Comment


                    • #11
                      Okay, I have made some progress on my own, but I still need some help. Here is a stripped-down example that uses OBJECT CALL into Google Earth. All this program does is get the latitude and longitude of Google Earth's center and print it in a PB console. It works. What I need now is the ability to issue command/control statements from PB into Google Earth. I've studied the interface, and tried all combinations of OBJECT CALL and OBJECT LET, but nothing works. Can someone write a line of PBCC code that drives Google Earth (for example, a line that moves the Google Earth latitude/longitude window)?

                      I've attached the #INCLUDE file in case someone wants to test.

                      Michael Mattias, I need you now. You can insult my intelligence, that's okay, I just need the code to work.

                      Code:
                      #COMPILER PBCC 5
                      ' also requires Google Earth 5.x to be installed
                      #INCLUDE "googleearth.inc"
                      FUNCTION PBMAIN() AS LONG
                          DIM oGoogle AS IDISPATCH
                          DIM oTerrain AS IDISPATCH
                          DIM fInitialized  AS LONG
                          DIM x AS DOUBLE
                          DIM Latitude AS DOUBLE
                          DIM Longitude AS DOUBLE
                          oGoogle = NEWCOM $PROGID_EARTHLib_ApplicationGE1
                          IF ISOBJECT(oGoogle) THEN
                              WHILE fInitialized <> 1
                                  OBJECT CALL oGoogle.IsInitialized TO fInitialized
                              WEND
                              WHILE fInitialized = 1
                                  OBJECT CALL oGoogle.IsInitialized TO fInitialized
                                  OBJECT CALL oGoogle.GetPointOnTerrainFromScreenCoords(x, x) TO oTerrain
                                  OBJECT GET oTerrain.Latitude TO Latitude
                                  OBJECT GET oTerrain.Longitude TO Longitude
                                  PRINT Latitude, Longitude
                                  SLEEP 300
                              WEND
                          END IF
                      END FUNCTION
                      Attached Files
                      Christopher P. Becker
                      signal engineer in the defense industry
                      Abu Dhabi, United Arab Emirates

                      Comment


                      • #12
                        On startup two identical splash screens are shown in different locations.

                        I can get Altitude out of the Terrain object.

                        SaveScreenShot needs a full path using Unicode. "Quality 0" is amusingly bad!

                        Still messing about.

                        ******** added this link may be useful http://nuigroup.com/forums/viewthread/5646/
                        Last edited by Chris Holbrook; 19 Jan 2010, 12:38 PM.

                        Comment

                        Working...
                        X