|
|
|||||||
|
Warning: somewhat cryptic techobabble follows. Many of you have noticed that Google Earth exposes a COM Type Library (win32 only, of course). We've been tweaking it through the various public beta releases and we think it's now ready for a little more attention. There are several important points to keep in mind: 1. This is BETA quality. Which means it's NOT RELEASE QUALITY, is subject to change, etc. 2. We're calling it an API. A better name might be "interface that gives you several useful methods for programmatically controlling some aspects of the application behaviour", but API sounds catchier. 3. This is BETA quality. YMMV. 4. Support for this is somewhat informal. There is no email address, there are no telephone numbers, etc. There is, however, this fine forum and this fine body of fellow GE enthusiasts. (The people responsible for developing this stuff are avid readers...) 5. The documentation is here: http://earth.google.com/comapi/ 6. Have I mentioned that this is BETA quality? Praise, criticisms, flames, bug reports etc. all welcomed as replies in this thread. |
||||||||
|
|
|||||||
|
Great News! To start the ball rolling the earth.idl - original IDL for COM interface and documentation. link is broken [this is on the main page linked to above]
|
||||||||
|
|
|||||||
|
And it turns out that the documentation is also BETA... http://earth.google.com/comapi/earth_8idl.html (The "files" tab gives the correct link. Nice catch, thanks.) |
||||||||
|
|
|||||||
|
Hurray! I've been looking for this official documentation for weeks. Thanks to the helpful folks here for getting me through the API pre-documentation. |
||||||||
|
|
|||||||
|
nice to see the COM API getting some official (albeit beta) backing. Are there any plans for an ActiveX like control that allows for embedding of the main globe view? I think I saw a Google Maps interview some time ago where embedding GE into a web browser was discussed. This can be accomplished now with the help of some hwnd reparenting and subclassing but it would be nice if this were a supported feature. cheers brian |
||||||||
|
|
|||||||
|
I'm working with the COM API with Java through a Java-COM bridge. the GetMainHwnd function returns an int with the current bridge I'm using. Is there anyway to manipualte this in Java? Possibly to embed it in a JFrame? I fear this might begin to take this thread off topic but you mentioned it I'd figure I'd ask. |
||||||||
|
|
|||||||
|
I don't know about Java or how to reparent to a JFrame but you can traverse the windows hwnd hierarchy using standard WIN32 functions(FindWindowEx, SendMessage, SetParent etc). When you find the hwnd housing the main display, reparent it to your hwnd and move the main GE hwnd offscreen (or invisible), toggle its window style to remove it from taskbar. get a copy of Spy++ to see the current GE windows layout. this is a really ghetto way to build a task specific applicaiton around GE so it would be great if a fully supported ActiveX (or similar) control was supported. cheers brian |
||||||||
|
|
|||||||
|
Everything looks great. Been messing around with it and haven't found any problems. One question and one comment: I was poking around at the Apple Script Dictionary for the Mac version of GE (also in beta). And there is a function called MoveCamera(x,y) that starts the camera moving at the velocity vector passed. Are there plans to have a similar function for the win32 COM API, or will this eventually be dropped form the Apple Script library? Also: A nice addition to the OpenKmlFile function would be the ability to open the KML and not have GE fly-to the placemark. Or is that option configured in the KML file itself? |
||||||||
|
|
|||||||
|
This was a quiet pre-release of the COM API documentation, but... it's been a bit too quiet. For those who've been using it, we've tried to address the deficiencies with the new version and are looking for as much feedback as possible before it goes gold. Thanks for all the comments so far and tell your dev friends to give it a try. |
||||||||
|
|
|||||||
|
I think I've mentioned this in other places, but I figured I'd remention it here since the API is officially in beta now. When i call the LoadKmlData and pass it a string containing a <Update> tag it throws an error. But if I take that same KML string, write it to a file and then use OpenKmlFile it works. I was wondering if anyone else was experiencing similar problems. |
||||||||
|
|
|||||||
|
You have tried the same thing that me did. I want to update Placemark position by using <Update> tag because the COM API still lack this support. I know that <Update> tag is for use with <NetworkLinkControl> but I donīt want use php+apache in this solution. I need a refresh interval less than 1 second, so this now only can be accomplished using the COM API. If you find a solution for use <Update> tag in LoadKmlData please, let me know. thks. capitao |
||||||||
|
|
|||||||
|
my solution right now is to take the KML string, write it to a file programatically and then read the file with OpenKmlFile(String fileName). |
||||||||
|
|
|||||||
|
Hi I could not see any references to the Time UI in the API. I was hoping it would be exposed and raise events as the timer was playing. This would be very useful to control an external application, eg the synchronised playback of an AVI file regards pk |
||||||||
|
|
|||||||
|
Anyone write any .NET wrappers for this yet, or shall I be the first to take a crack at it? Paul |
||||||||
|
|
|||||||
|
[EDIT] - BTW, I've included a Visual Studio Solution/Project etc., so you should be able to build this immediately and use it from your favorite .NET language. C#.NET wrapper is now here : http://tropicalwatch.googlecode.com/svn/trunk/GoogleEarthCOMWrapper/ Paul |
||||||||
|
|
|||||||
|
It would also be nice to be able to catch events from the COM API. For instance, feature selections, mouse clicks. As far as I can tell, we get 1-way interaction right now from the COM API to the GE App...would be nice to have both ways via events. Another thing I'm looking at is adding features as children to other features. Right now you can GET features by name or href, but it would be nice to do something like this (pseudocode): Code:
Paul |
||||||||
|
|
|||||||
|
To use the COM API in Visual Basic for Applications (VBA), you need the Programmatic ID (ProgID). The "old" ProgID was Keyhole.KHInterface, and the new one appears to be GoogleEarth.ApplicationGE. Example: Dim GEI As ApplicationGE Dim TerrainPoint As Variant Set GEI = CreateObject("GoogleEarth.ApplicationGE") Call GEI.SetCameraParams(0, 0, 0, AbsoluteAltitudeGE, 1000#, 0#, 0#, 5#) TerrainPoint = GEI.getPointOnTerrainFromScreenCoords(0, 0) SetCameraParams appears to return a value, but I haven't figured out how to obtain it. Using the Call statement tells VBA to throw away the return value, otherwise you get a compile (??) error. getPointOnTerrainFromScreenCoords returns a "SAFEARRAY", which can be obtained in VBA by using a Variant. To get the altitude (meters) returned by that method, use TerrainPoint(2). Note that the new documentation shows the SAFEARRAY as the third parameter to getPoint... , not a return value. In the old KHInterface, the function with the same name returned the value as shown above. The example shown above works with the new API, but it is possible that I have somehow tripped up VBA into invoking the old function. Or maybe there is a documentation error (less likely). - JK |
||||||||
|
|
|||||||
Quote: Hello Brian, have a look at http://www.googleearthairlines.com , it has a working browserplugin :-) Yours Jan |
||||||||
|
|
|||||||
|
Very cool. One thing I noticed that is still missing from the automation interfaces is the ability to close a KML that was opened programatically. There is an OpenKml but no corresponding CloseKml. Is there any future plans for this? Thanks, -- George |
||||||||
|
|
|||||||
|
Is there any Java code available to compile and play with? |
||||||||
|
|
|||||||
|
Hi JK - I'm having trouble calling SetCamera and SetCameraParams in VBA. Were you ever able to do this? The camera I'm passing in is one I retrieved using GetCamera, so presumably its valid. Tried with various speeds between 0.1 and 4.5. I'm getting error 5, invalid procedure call or argument. Tried calling with and without the "Call" statement. Thanks, Kirk |
||||||||
|
|
|||||||
|
I am trying to find the easiest way to retrieve a placemark's coordinates from Google Earth. This does not seem possible through the API, all I can retrieve is the name. Does this mean I have to find the .kml file and look the coordinates up in there? Thank you, Trevor |
||||||||
|
|
|||||||
|
I haven't tried setcamera, but: Call GEI.SetCameraParams(latitude,longitude, altitude, AbsoluteAltitudeGE, range, tilt, azimuth, 5) works in Excel. I believe the altitude is the point you are looking at (I specify 0) and range is "from how far away" you are looking. Since I also use tilt of zero, range is equivalent to altitude. Speed of 5 is "instant," which is what I want. Once you do this, if you ask for GetPointOnTerrainFromScreenCoords, you should get the same lat long back, right? Not quite. Usually, it is very close, but I include a loop that keeps hitting SetCameraParams until they are within 0.0005 degrees. About 1 time out of 20, it will take 2-8 tries to get close enough. Go figure. Be sure to check your arguments, given the error message you received. Did you "Set GEI = CreateObject( ....)? Good Luck. - Jeff |
||||||||
|
|
|||||||
|
Ah, if you have the name, you can eventually find that for which you search. (Or something like that.) In VBA, this works: Private Sub GetFeature_Click() Dim GEI As ApplicationGE Dim TerrainPoint As Variant Dim Feature As FeatureGE Set GEI = CreateObject("GoogleEarth.ApplicationGE") While (GEI.IsInitialized = 0) Wend Set Feature = GEI.GetHighlightedFeature() MsgBox (Feature.Name) Call GEI.SetFeatureView(Feature, 5) TerrainPoint = GEI.GetPointOnTerrainFromScreenCoords(0, 0) MsgBox ("Latitude: " & TerrainPoint(0) & " Longitude: " & TerrainPoint(1)) End Sub In other words, once you get the name, fly there and read the coordinates of where you are. You fly at speed 5 so you arrive "instantly". If you save the "current" lat, long, alt you can then instantly fly back. I'm guessing you will see noticeable "jitter" on the screen by flying there and back, but whether that matters ....? (This retrieves the information for a highlighted feature, but I'm guessing you know how to retrieve the names of all the features.) - jeff |
||||||||
|
|
|||||||
|
That trick works, but the coordinates that are returned are the lat/lon of the placemark's view, which can be different from the placemark's true location. Also, it does not return the altitude of the placemark, which I need as well. It seems odd to me that one can not directly access the placemark's properties through the API. I can load the myplaces.kml file to get the coordinates of the placemarks I have previously saved, but they may not be current if the user has chosen to move them during the current session. If there was a way to force Google Earth to write out a .kml file for the current placemark settings, then I could go that route. It seems that reading out the coordinates of placemarks from Google Earth is a rather basic operation that would benefit people other than me. If it can not be done, I hope it is a feature added in later releases of the API. Trevor P.S ~ Thanks Jeff for taking the time to make a suggestion. |
||||||||
|
|
|||||||
|
A cheap work-around is to read the myplaces.kml file, as this has the coordinates to all of the placemarks. However if a user moves one of the placemarks or creates a new one, that change will not be shown in the kml file. To force the current changes to be updated to the kml file one can logout and then login to the server using the API. This will trigger GoogleEarth to dump the current placemarks to the kml file which can now be read in. It may be wise to save the screen position before logging out so that you can reset it to the current view when you log back in, otherwise it will go to the default set in the kml file. This is definitely a band-aid solution, but it works. If anyone has a better way, please post it here. Thanks, Trevor |
||||||||
|
|
|||||||
|
Very clever! Of course, you would miss placemarks not created by the user (which are still in Temporary Places). But then you would probably know if that was in issue in your applcation. When you close GE it asks if you want to move those items from Temporary places to MyPlaces; do you know what it does when you do a programmatic logout? All in all, we can almost see from what part of Google Earth the API is exposed. By left clicking on an item in Saved Places pane, you go to the view of the item, which is not necessarily its location. In the Saved Places pane you can see "names" of items, but no other information can be displayed. What you need is access the API connected to the right click ... |
||||||||
|
|
|||||||
|
Hello, I'm trying to get the altitude on one location ... for that I'm using the following subroutine : 'Example to get the altitude of the highest European Moutain Private Sub Command3_Click() Dim GEI As ApplicationGE Dim PointOnTerrain() As Double Dim ret Set GEI = CreateObject("GoogleEarth.ApplicationGE") 'wait for GE initialisation While (GEI.IsInitialized = 0) DoEvents Wend ' Terrain elevation exaggeration. GEI.ElevationExaggeration = 1 ' a value of 1 (default) displays the terrain at true altitude 'Flies to the specified camera Call GEI.SetCameraParams(45.8325541, 6.86437217, 0, RelativeToGroundAltitudeGE, 1000, 0, 0, 5) '5.0, the camera will immediately be set without any transition 'wait for the end of the streaming Process While (GEI.StreamingProgressPercentage < 100) DoEvents Wend 'Get the coordinates PointOnTerrain = GEI.GetPointOnTerrainFromScreenCoords(0, 0) MsgBox "Altitude Mont Blanc in GoogleEarth " & PointOnTerrain(2) End Sub My problem is : even if I wait for the end of the streaming process I'm not sure to get the right value for the altitude. Can give me the "current" altitude . How can I be sure to get the altitude of the right Position ? Regards, Cuq |
||||||||
|
|
|||||||
|
I have been using the API for a short time and already have a few features I would like to see added. I have also seen feature requests scattered throughout various threads. My concern is that if these requests are not consolidated into a common thread, they may not be read by the right people and consequently, never implemented. I would suggest posting any changes/additions that you would like to see in later releases of the API to this thread. Add API access to placemark coordinates |
||||||||
|
|
|||||||
|
I have a solution by using GetCamera : Private Sub Command1_Click() Dim GEI As ApplicationGE Dim Feat As FeatureGE Dim Child As FeatureCollectionGE Dim CameraInfo As CameraInfoGE Set GEI = CreateObject("GoogleEarth.ApplicationGE") 'wait GE initialisation While (GEI.IsInitialized = 0) DoEvents Wend ' load a Feature by his name Set Feat = GEI.GetFeatureByName("default") 'Set Child = Feat.GetChildren 'Debug.Print Child.Count 'Check if we have a "view" if it's valid goto to this placemark If Feat.HasView Then Call GEI.SetFeatureView(Feat, 5) 'Speed 5 for teleportation End If 'Return the current camera information Set CameraInfo = GEI.GetCamera(1) MsgBox "Latitude=" & CameraInfo.FocusPointLatitude & " Longitude=" & CameraInfo.FocusPointLongitude End Sub |
||||||||
|
|
|||||||
|
This solution was already posted (along with my own). Neither are elegant and have their problems. I would still like to see the ability to retrieve a placemark's coordinates (including altitude) added to the API. It might be wise to send a private message for solutions to posted requests so that change requests don't get lost in the discussion. Thanks. |
||||||||
|
|
|||||||
|
My first posting here, so: Hi everyone! Just have been using the GE-API for some time now, and there are some things I wish to see:
If there is any workaround for the first at present, please tell me via PM, as it's important for my current project. I am fooling around with SendMessage and stuff, but it won't work. The Qt widgets are not good to be remote controlled. |
||||||||
|
|
|||||||
|
Cuq - Why do you think you are getting the wrong altitude? The latitude and longitude you give appears to be that of the label "Mont Blanc." If you run your code (so that you are only 1000 meters above the surface), the label will be (almost) centered in the screen. Then, if you tilt the view (with manual controls) you can see that the center of your screen is not the top of Mont Blanc. (Or at least what GE thinks is the top.) Using your code with Lat: 45.837508 and Long: 6.865066 I get 4477 meters. Does this sound closer? - Jeff |
||||||||
|
|
|||||||
|
Hello, You're right the best solution is to have directly via an API function acces to the global information of a placemark (longitude, latitude, comment ....) Concerning my sample code , the solution are a little bit different. In the solution already posted the function used was GetPointOnTerrainFromScreenCoords in my example I'm using GetCamera(1) with the properties .FocusPointLatitude and .FocusPointLongitude which is on my point of vue a better solution compare to the previous one. Even if at the end you're right .. the best solution will be an enhancement of the API. Best regards, Cuq |
||||||||
|
|
|||||||
|
Hello, Thanks a lot for your answer. The problem was not the accuracy of the data. GE is not made to represent exactly the topology of the earth in such case. My problem is to get the same result every time. In my case if you run several times the same routine starting from different initial position you don't get the same result. Between the call of SetCameraParams and the result return by GetPointOnTerrainFromScreenCoords you are not sure to be at the exact position and in my case GetPointOnTerrainFromScreenCoords can return the altitude of the previous position. Note : the right altitude for the Mont Blanc are 4808 m but that's not the goal of this topic. Best regards, Cuq |
||||||||
|
|
|||||||
|
I think I now understand your problem. Note that GetPointOnTerrainFromScreenCoords also returns the latitude and longitude in addition to altitude. Like you, I've noticed that the returned values of lat/long don't always/immediately match the ones I put in. So I include: Do TerrainPoint = GEI.GetPointOnTerrainFromScreenCoords(0, 0) LongDiff = Abs(INputLongitude - TerrainPoint(1)) LatDiff = Abs(INputLatitude- TerrainPoint(0)) Repeat = Repeat + 1 Loop While (LongDiff > 0.0005 Or LatDiff > 0.0005 Or TerrainPoint(2) < 2) And Repeat < 100 (For my application, being within 0.0005 degrees (about 55 meters) is close enough.) About 19 times out of 20, it falls straight through the loop (the returned point is close to the requested point). 1 out of 20 it takes 2-8 loops until it is close enough. On the other hand, I don't check StreamingProgressPercentage as you have, as I think that has more to do with the visual picture than the altitude model. We could do a test (using a spreadsheet with a list of points) to see how many loops there are with and without, but it would be tough to control all the variables. Let me know if a loop like one shown here helps you. - Jeff |
||||||||
|
|
|||||||
|
thanks a lot !! I have made some minor modifications ( I must include the SetCameraParams in the loop to be sure to be at the right place and it's OK ) MY final code : Epsilon =0.0005 Do Call GEI.SetCameraParams(LookingPosition(0), LookingPosition(1), 0, RelativeToGroundAltitudeGE, 100, 0, 0, 5) PointOnTerrain = GEI.GetPointOnTerrainFromScreenCoords(0, 0) While (GEI.StreamingProgressPercentage < 100) DoEvents Wend LongDiff = Abs(LookingPosition(1) - PointOnTerrain(1)) LatDiff = Abs(LookingPosition(0) - PointOnTerrain(0)) Repeat = Repeat + 1 Loop While (LongDiff > Epsilon Or LatDiff > Epsilon Or PointOnTerrain(2) < 0) And Repeat < 100 Best regards, |
||||||||
|
|
|||||||
|
Hello, We have the possibility to load a KML file via the API function. But it's not possible to save / export a KML file. a function SaveKMLFile([in] BSTR fileName,[in] IFeatureGE **pFeature) will be welcome. best regards, Cuq |
||||||||
|
|
|||||||
|
Ponte Rasa |
||||||||
|
|
|||||||
|
Thanks for the info. This is how to control Google Earth from Python: Code:
|
||||||||
|
|
|||||||
|
May I suggest we have another forum called "COM API Discussion" instead of putting it in "KML Discussion"? |
||||||||
|
|
|||||||
|
I was wondering if anyone could help me get started with using the COM API. I downloaded Visual Studio Express for C++ (free download) and am trying to include the API. Is there an example/tutorial somewhere that I can check out? Thanks in advanced. |
||||||||
|
|
|||||||
|
Jim - You've got to be a brave soul to access the API from C++, because you need to know the subtlties of COM programming. It is very powerful in C++, and so requires someone smarter than me to capably handle it. First, to answer your question, No. There is no set of sample code yet. Second, once you get working smoothly in C++, this snippet may answer some of your basic questions (note that there is a lot of non-GE code omitted, necessary just to get the application to start): #import "C:\Program Files\Google\Google Earth\googleearth.exe" named_guids // ... CoInitialize(NULL); HRESULT hr; EARTHLib::IApplicationGE* pGEI; hr = CoCreateInstance(EARTHLib::CLSID_ApplicationGE, NULL, CLSCTX_LOCAL_SERVER, EARTHLib::IID_IApplicationGE, (void**) &pGEI ); if (hr != S_OK) { MessageBox((LPCTSTR)"Couldnt load GoogleEarth interface"); return 0; } SAFEARRAY TPoint; double TPValues[3]; double Lat, Long, Alt; LONG index; TPoint = *pGEI->GetPointOnTerrainFromScreenCoords(0,0); index = 0; for (index = 0;index <=2;index++) { SafeArrayGetElement(&TPoint,&index,&TPValues[index]); } CString outstring; outstring.Format(L"Lat %f, Long %f, Alt %f",TPValues[0],TPValues[1],TPValues[2]); MessageBox(outstring); pGEI->SetCameraParams(38,-122,1000,EARTHLib::AbsoluteAltitudeGE,0,0,0,2); while (pGEI->GetStreamingProgressPercentage()<100) {}; pGEI->Release(); CoUninitialize(); |
||||||||
|
|
|||||||
|
Thx for the reply. I may take ur suggestion and utilize some other language other than C++. |
||||||||
|
|
|||||||
|
I posted a .NET (C#) wrapper for the COM API awhile back. All you have to do is add a reference to the assembly in your visual studio project. Paul |
||||||||
|
|
|||||||
|
I downloaded your C# wrapper...seems to work fine. Thx.
|
||||||||
|
|
|||||||
|
Kirk: Don't presume that the values returned from GetCamera are correct. It will sometimes return a negative ICameraInfoGE.Tilt, which is invalid (Tilt must be between 0 and 90) and causes SetCamera to fail. Regards, Wade |
||||||||
|
|
|||||||
|
Much appreciation to this API. Request: Since properties in ICameraInfoGE does not update when the camera moves, it'd be nice to have a callback to know when the camera has been moved, to know when to refresh ICameraInfoGE. Thoughts? Thanks again, great work. Wyatt |
||||||||
|
|
|||||||
|
Any pointers people may have to get up and running with Java and the COM API, is the Java-COM bridge mentioned available to share around? |
||||||||
|
|
|||||||
|
The difference in coordinates is related with the screen offset argument. The argument must adapted to render window placement (and not to real screen coordinates). To get correct measures you must pass render window realive offset.
|
||||||||
|
|
|||||||
|
Hi I'm successfully using python to turn the world, but the SetCameraParams API calculates it's own intermediate path that involves zooming in and out at each call of SetCameraParams. Does anyone have suggestions on how to achieve a completely smooth turning of the world using the API ? Pete =========================================================== Code:
|
||||||||
|
|
|||||||
|
Hi, I have a tool that uses the API, it was working ok with the version 4 of GE (Released on September 13, 2006). It is no longer working with the new version 4.0.2416 (November 1st). Do you have the same problem? I would like to know if the API has changed, or my program is wrong? Thanks www.zonums.com |
||||||||
|
|
|||||||
|
If you use smaller steps, you can reduce the "hopping" as much as you want. I think it happens because setting the cameraparams is like "clicking" on a new location, and GE naturally zooms out before it flies to the new location. If I'm correct, you can't eliminate the hopping, but you can reduce it to an imperceptible amount. The downside is that you will end up with a maximum effective speed, given that you have to move to more points. But since you can set the slew speed as high as 5 ("instant") that probably won't be a problem for you. - Jeff |
||||||||
|
|
|||||||
|
Yes, I've seen some minor changes in the API langage but my previous program must be modified to run under the new release. For example with : GetPointOnTerrainFromScreenCoords Previous version : Dim PointOnTerrain() As Double PointOnTerrain = GEI.GetPointOnTerrainFromScreenCoords(0, 0) Since 4.0.2416 Dim PointOnTerrain As PointOnTerrainGE Set PointOnTerrain = GEI.GetPointOnTerrainFromScreenCoords(0, 0) And there are certainly other changes in the API. Best regards, Cuq |
||||||||
|
|
|||||||
|
Nice suggestion, thanks - so I've tried it and still have issues. For the record here are the issues ... Option 1: Small incremental changes in Longitude with speed set less than 5: The problem is that calling SetCameraParams stops the camera movement (started by the previous call SetCameraParams call). So you may "reduce the hopping [zoom out, zoom in], but will always have a "stop / start" jumpy effect - which kills realism. You just cant do that to the world ! Option 2: Use Teleport - and just make the movements at more than 15 frames / second - so the user will see a smooth turning world Well, my script will do around 6 setCameraParams / second on my PC we still have a jumpy effect. This is incredibly ineffecient, and not using the capabilities of the core engine in GE. A Solution What I think we need is a MovementMode for the SetCameraParams API. If you set "ContinueToFly" then the camera interpolates from it's current vector (speed and direction) to the vector that is required. If you set "CameraStops" - (which would be the default), then you get what we have now. Usage Case : Anyone using the API to create auto-running demonstrations of GoogleEarth's capabilities and self running displays of realtime data on the earth. |
||||||||
|
|
|||||||
|
I concur with your MovementMode suggestion. I was trying to add GE to my flight simulation application, but the constant zoom-out / zoom-in made it unusable. I also couldn't get it to go below approx 2* ground elevation, which made takeoffs and landings unrealistic. Anxiously awaiting v2.0 |
||||||||
|
|
|||||||
Quote: JACOB, (JAva to COm Bridge) is open source, I believe. Just do a google search for it. There are other Java to COM Bridges that are a bit nicer but you have to pay for them. I'm using the EZJCom which has a free trial you can play around with, but the DLL expires after using it for awhile. |
||||||||
|
|
|||||||
|
The problem with altitudes appears to be that SetCameraParams ignores the AltMode parameter and interprets all altitudes as being above ground level. I have to calculate my own AGL altitude, which means that I could end up underground if my ground level doesn't concur with GE's, causing even more weirdness. |
||||||||
|
|
|||||||
|
I have some VB5 code that uses the GE COM API. It may be accessed via: http://www.fortotalrecall.com/GE%20interface.htm Included are several suggestions and comments directed at any GE developer that may stray past. The code shows how to: o Make appropriate declarations. o Check if any version of GE is installed. o Find the fully qualified name of the GE executable. o Access the GE COM API properties and methods from VB5. o Check the version of GE installed is 4.0.2091 or later. o Launch GE and wait for it to initialize. o Get the handle of the main GE window and position the GE window as per last use. o Monitor any changes the user makes to the GE Navigator control. o Overlay a chart on GE: ....o Flush any current chart overlay. ....o Build a kml file describing the chart overlay and send it to GE. ....o Sympathetically move the GE view. o Overlay vessel tracks on GE: ....o Build a new vessel data kml file describing the vessel tracks. ....o Replace any old vessel data kml file with the new vessel data kml file. ....o Set up the vessel link kml file and send it to GE. ....o Sympathetically move the GE view. o Send a kml file to GE. o Kill the GE fetch error window. o Extract GE window settings for next use. o Flush any current active kml files. o Close GE. o "Park" GE so that it can be quickly resurrected. o Convert VB5 color long to GE <color> ... </color> hex string. o Use GE features to inspect the GE Temporary Places folder. |
||||||||
|
|
|||||||
|
Hi TP, I am trying to do the same with FsX using FSUIPC in c#. I am calling SetCameraParam and GE seems to zoom in and out for every call. I set the range to a constant '1' and speed to constant 5 (tried .1 and it was even wiered). Other params are coming from FS. Where you able to get a flicker free movement by manipulating AGL yourself?? |
||||||||
|
|
|||||||
|
I have not been able to get it to be flicker-free at all. The least annoying way to go is to update the GE view only every 10-15 sec, which is unacceptable for a realistic windshield view, but at keeps the flicker from being too distracting. However, the zoom-out / zoom-in doesn't always complete its movement. It seems to be a three-part movement: (1) zoom out; (2) zoom in to the specified lat and long at ground level; (3) climb up to the specified altitude. It often gets stuck at arbitrary points along this undesired path, so not only will the view sometimes be several miles back of where I want it, but sometimes it will be several thousand feet below where I want it. It also frequently gets stuck in a mode where the view is flickering rapidly (5-6 times per second) between two different views at different altitudes. Do you know if it is possible to specify a bank angle? Obviously the viewer can do it manually in airplane mode, but have you found a way to specify a bank angle with the API? If any GE developer is reading this, I would like the following: - ability to go directly from point A to point B without all the zooming crap - fix the flicker bug - add a bank angle to the SetCameraParams API call |
||||||||
|
|
|||||||
|
Seems like the problems of jitter and/or flickering is due to using camera position control to simulate camera velocity control. I sure would love to see velocity control in a future release! Also - is it me, or is it impossible to access the data associated with a feature? What I mean here is to programatically access the KML data associated with a placemark, path, etc. in "My Places" |
||||||||
|
|
|||||||
|
Hi there i'm also working on get a smooth flying using Teleport my experiment result here (unlinked yet) http://www.googleearthairlines.com/_index3.html only way to avoid flickering is set Terrain layer off ...not good i know... also i agree at all on SetCameraParams altMode bug |
||||||||
|
|
|||||||
|
i have added just SaveKmlFile on my GE web plugin at http://www.googleearthairlines.com/_index3.html (working in progres) |
||||||||
|
|
|||||||
|
I was wondering anybody can help me to save an GE's image use GE COM API , the function IApplicationGE::SaveScreenShot can just save a low quality black and white screen shot, thanx
|
||||||||
|
|
|||||||
|
After loading a kml file, how one do the equivalent of pressing Play to fly over the path? |
||||||||
|
|
|||||||
|
I get fairly decent movies by SetCameraParams where I want to go periodically check if StreamingProgressPercentage = 100 if it does, wait a moment and double check (maybe another streaming has started) if progress percentage really is 100 then periodically grab screen image and see if it's changed when things seem to have settled down, SetCameraParams to the same place (in case GE got stuck) and repeat the above once. This seems to take easily a second even if the speed is 5.0 Is there a better way? |
||||||||
|
|
|||||||
|
I think a nice feature, for future versions of the COM API, would be to be able to change the navigation mode. A function like SetNavigationMode - GetNavigation Mode. demo9 |
||||||||
|
|
|||||||
|
Hi, I have an application where i would like to interrogate google earth for a location on earth and have it fly to the location and insert a placemark. Basically, i have a large list of site names in a spreadsheet, that i wish to automatically turn into placemarks in google earth and get the latitude and longitude for each site. Could the developers please include a method to search google earth using the COM API as well as being able to insert a placemark at the location. This would be a great help, and much better than manually typing the sites into google earth and manually inserting placemarks. regards John |
||||||||
|
|
|||||||
|
Hi, here a little PHP script for someone interested in using GoogleEarth API with this scripting language. This script is used to search position of Costa Crociere ships and use coordinates to create a Placemark. It is only intended as a basic learning sample for using Google Earth API in PHP. http://spazioinwind.libero.it/davidechiodi/testGE.php If you get a Method Not Allowed response please copy url to your browser's address bar and go |
||||||||
|
|
|||||||
|
Hi all, As far as I know, to interface a 3rd party application with GE, we can either use the type library compiled from the original <earth.idl> or the type library generated by importing <googleearth.exe> in C++ programming environment. My question is: has anybody else found out the difference between the two generated type libraries? Why are there more classes exposed by the type lib file generated by importing googleearth.exe than compiling earth.idl, detailed as below: interfaces that are contained in <googleearth.tlh> generated from importing googleearth.exe but not contained in the type lib from compiling earth.idl: 1. ITimeGE 2. ITimeIntervalGE 3. IPointOnTerrainGE 4. ITourControllerGE 5. IAnimationControllerGE 6. ISearchControllerGE Why didn't GE crew put these interfaces in the official COM API?
|
||||||||
|
|
|||||||
|
Hi Forza_Juve, I saw this difference too. Generated type libraries (with tlbimp (.Net)) are abstracted from a resource (exe, dll) which results in a complete coverage of the visible interface of that resource. IDL's are often maintained manually which may result in inconsistencies between the IDL-code and the resource it is supposed to represent. Trying to explain these inconsistencies is a matter of guessing: 1. Documentation lag between exe and IDL. 2. The listed interfaces aren't supposed to be visible at all but, due to a careless build of the exe-file, they are. 3. The listed interfaces are supposed to be visible but their implementation is yet unstable. Not documenting them in IDL may avoid some problems. 4. Any mixture of the forementioned. Anyway, these interfaces are visible and therefor usable. Has anyone already experimented with them? Next to those promising looking interface names the generated type library contains a few odd names as well (I will not list them here). My guess is that there will be a smoothing release soon, either an extended IDL or an exe-file with an interface with a limited visibility (or both). Does anyone know if tlbimp has an option to generate IDL i.s.o. a type library, or a tool with such a function? If so, I might publish the IDL-file matching the most recent Google Earth API here to satisfy C++ developers.... Regards, Pollens |
||||||||
|
|
|||||||
|
It's great that you are releasing this COM api! I discovered it about a year ago, and played around at adding buttons to our app (which is web based GIS) to copy the view between our app and Google Earth. It worked great! Recently we thought we might dust it off and see if we really want to deliver it, since (like everyone else) our customers love and use Google Earth a lot. However we have run in to a problem - always with SetView (ie copying a view to Google Earth). GetView always works. Initially we were (obviously) using the KH interfaces. This works fine with V3, but I found that with the version I had (~15 Dec beta build), it appeared flaky - more often than not it would just do nothing. I discovered at that point this post, and the new API. So I converted the code to use IApplicationGE->SetView. The sequence is that I do a GetView to get a camera, then alter latitude, longitude and range, leaving the other parameters alone, and set it back. This seemed to work fine (with an hour or two of testing).... until I upgraded to the released version of V4 (4.0.2722). Once again it became flaky - SetView would work a few times, then would fail Debugging showed that the call returned E_INVALIDARG, and once that happened it seems to happen from then on. This includes just calling GetCamera, and then SetCamera with the same camera. I tried using IApplicationGE->SetViewParams. That seems to work better, but eventually it seems to go out as well. Note I'm using VC++ 6, and I'm an experienced COM programmer, so I'm sure I'm calling the interfaces correctly. I'm using 1.0 as the speed so that should be a valid parameter. Any idea of what could be going on? I would be glad to send or post the specific code I'm using if that would help! Any and all help appreciated! Thanks, Jeff |
||||||||
|
|
|||||||
|
I trying to use COM API to manage GE from ERP Application. I suggest to extend API (IFeatureGE, i think) functions to receive KML data from GE. Current API give me possibility to upload KML to GE, but what about feedback? Now external application can only issue KML "orders" to GE, but how it can issue questions and get answers? Good extension can be also event handlers to monitor user actions. Regards |
||||||||
|
|
|||||||
|
Found the solution to the problem I was seeing - I consider it a bug in the API. The problem was that I was preserving "Tilt". Code has been added to SetCamera and SetCameraParams to check that parameters are in range - specifically if tilt < 0, it returns E_INVALIDARG. Unfortunately internally tilt (and perhaps other values) can fall outside the correct range. It turns out when I got the error, I was seeing tilt of approx -1e-14 - ie a very small negative number. I'd suggest that GetCamera should clamp all values to within the correct range, so that it returns a "valid" camera as far as SetCamera is concerned. Anyway once I did the clamping myself, it works great! Jeff |
||||||||
|
|
|||||||
|
I have a couple questions... Is there a way to specify drawing a polygon outline without specifying an "innerBoundaryIs"? When I remove the innerBoundary, the polygon gets filled in (even with <fill> set to 0). When I do specify the innerBoundary with the same points and specify 1 for <outline>, I get a real thin line that is hardly noticable (I tried specifying <width> in <LineStyle>). Since I am creating a mapping interface from our software to GoogleEarth, I don't see how I can automatically generate the innerBoundary. In my application, I generate a kml file and load it using LoadKmlData and the networklink feature. Sometimes the polygon looks different depending on how it was loaded (via the application or just double-clicking the generated kml file). Does anyone know why that might be? |
||||||||
|
|
|||||||
|
The COM API is wonderful! What fun! I wondered if there was anyway to set a new placemark using the API. That would be a good feature! Thanks Si |
||||||||
|
|
|||||||
|
Hi,Eeveryone The last GE verstion Updated the COM API,The ISearchControll is one of the new API,Have enybody know how to use this future to search custorm data. for example , i have load a big kml file,i want search a placemak in my kml file,how to do ? Please help me,thx |
||||||||
|
|
|||||||
|
Greetings. I am a newbie to this COM stuff and have only been looking at this for a couple days. Obviously I have a lot of questions so I was hoping you guys could help me get started or point me in the correct direction. To get to the point, I'm trying to make a MFC C++ ( i have to use c++ ) project that has two controls on it : zoom in and zoom out. I basically want to zoom-in and zoom-out on Google Maps using my controls on my MFC App. Now that you know the simple scope of my project, here are my questions and since everyone here seems to know what they are doing besides me, I figured this is the best place to ask. What do I do with the earth.idl file and how do I use it? After looking at pseabury's C#.Net wrapper earlier in this thread at: http://tropicalwatch.googlecode.com/svn/trunk/GoogleEarthCOMWrapper/ I wanted to write my own. I also don't know what he meant by add a reference to the assembly ( im guessing he meant add a reference to the executable? ). I don't know how to interface with the .idl. I've tried two ways. First I tried to follow pseabury's way but for some reason my compiler ( VS 2005 ) doesn't like when I say "using EARTHLib;" or "using namespace EARTHLib;". These generate these two errors respectively: "Error 1 error C2873: 'EARTHLib' : symbol cannot be used in a using-declaration" and "Error 1 error C2871: 'EARTHLib' : a namespace with this name does not exist" Why? I thought the namespace was defined in the .idl so why isn't it working? Since that didn't work, I tried to make a .h file GoogleEarthAPI.h and start defining all the functions and classes which I derive publically from COleDispatchDriver. I didn't think that was the right way though because I still don't know how I'm going to interface with the .idl and I noticed the UUID's in the .idl file. The way I planned to interface with the .idl was to do something like this: Code: void IApplicationGE::SetRenderWindowSize(long width, long height) to interface with this in the earth.idl file Code: [id(7), helpstring("method SetRenderWindowSize")] HRESULT SetRenderWindowSize(long width, long height);I didn't want to go too far down this path without asking first what to do first. That is code that i've seen from people interfacing with an .idl for an .ocx . InvokeHelper is a public function in COleDispatchDriver. That could be completely the wrong way -- i have no clue ![]() So what do I need to get this to work? I have the .idl file added to the project. And I know I need a .cpp file to define how all the functions work. But how and where do I use the namespace EARTHLib and do I still need a .h file or does the .idl file count for all the declarations? The C#.Net version confused me and I can't find a C++ wrapper. For those that can't answer this directly, if you know of any good reads on COM on the web, please feel free to PM me with a link or respond so that I might be able to solve my own problem. Thanks in advance guys and hopefully someone can point me in the right direction. |
||||||||
|
|
|||||||
|
In VS2005 add a reference to your project...choose the COM Tab, look for Google Earth Type Library 1.0 and add it. That gives you the EARTHLib namespace. Apparently the container that gets generated is called Interop.EARTHLib and the namespace is EARTHLib. See images below. ![]()
|
||||||||
|
|
|||||||
|
I sent you a PM with a screenshot. I don't have a References Node in my project because I'm not developing with C#.Net. From the IDE Manual: " ... a Visual C# project has a references node within its project, but a Setup Project does not." I see no way to add a reference. Anyone have any ideas of how you interface with the .idl through C++? I still can't figure it out but am still playing with it. |
||||||||
|
|
|||||||
|
Hi, I was wondering if someone would help me with the proper syntax and code for polling then accessing the SAFEARRAY of 'doubles' returned by the COM API upon calling the GetPointOnTerrainFromScreenCoords method. Here is what I have being playing with for many hours: SAFEARRAY *iGazeGPS; iGazeGPSBound[0].cElements = 3; iGazeGPSBound[0].lLbound = 0; iGazeGPS = SafeArrayCreate(VT_R8,1,iGazeGPSBound); hr = IApplicationGE_GetPointOnTerrainFromScreenCoords(AppGE, 0.0, 0.0, &iGazeGPS); It doesn't work - iGazeGPS always gets mangled. I have no more ideas (tried everything I can think of). Thanks Nick |
||||||||
|
|
|||||||
|
I forgot to mention - it's C, not C++. Please help, this is time sensitive! Thanks |
||||||||
|
|
|||||||
|
Hi the interface you are using is obsolete ... the latest GetPointOnTerrainFromScreenCoords now return an interface not a safearray check the idl generated from exe file to be sure about Quote: |
||||||||
|
|
|||||||
|
Iam having the same problem and my earth.idl file shows passing in a SafeArray to get the results, does this mean Iam using an old earth.idl file or something, I only downloaded it 2 days ago? Chris |
||||||||
|
|
|||||||
|
The IDL on googles website clearly shows a safearry. Perhaps if you use a high level language like VB it returns an ?interface? or a return value, but in C it requires the use of a SafeArray. I can't get it to work whatever I do. I am not amazingly experienced with C so perhaps I am doing something wrong with pointers? Has anyone has got this interface to work with C or C++? Nick |
||||||||
|
|
|||||||
|
I have the same problem with ICameraInfoGE. I get the camera properties and then set them back, but SetCameraParams comes back with an INVALID_ARG return code. Upon inspection, I saw that GetCamera sometimes returns "Tilt" as negative, which according to documentation can only be between 0 and 90. I corrected the Tilt values programmatically, but still I get the INVALID_ARG return code from SetCameraParams sporadically. Any feedback on a fix is greatly appreciated! thanks, M. |
||||||||
|
|