Does anyone know of a command-line method to fetch the location currently centered in the display of a running Google Earth? I have spent untold hours trying to figure this out, and have always come up with a blank. If I can find a small command-line program that spits out a latitude/longitue/altitude of the current center of the Google-Earth viewpoint, I can greatly enhance my geoencoding support plugin for Adobe Lightroom. I'm looking for solutions for both Windows and Mac, although they don't need to be the same.
I do know about the Win COM library, but I'm not a Windows developer and have no idea what to do with it.
I'd love to hear ideas (or receive source code... hint hint! 🙂 ) if anyone has them...
Hi there; I use a mac and I use applescript for that. The Google Earth applescript dictionary is not very extensive, but you can get latitude and longitude just fine. The script reads the coordinates and writes them to a temporary text file, which I later read in the lua script. To execute the applescript from the lua script I use something like this:
exitOption = LrTasks.execute(“osascript ” .. _PLUGIN.path .. “/GoogleEarthKit.scpt ” .. _PLUGIN.path .. “/coords.tmp”)
The applescript itself:
I’m not sure how the code will show up in the comment; should you need it as a file just let me know!
Greetings from Spain!
Thanks for the head start! I ended up using GetPointOnTerrain {0, 0} instead of GetViewInfo because I want to know what the user is looking at, not where they’re looking from, but this solves my needs on OSX(!). Thanks! —Jeffrey
The Google Earth API has provisions for registering Event Listeners. An example provided just updates local variables every time the user clicks anywhere in the window. You could use that to grab the last clicked event. Granted, the API documentation I was looking at seems to be specific to embedding Google Earth in your browser. Hmm, maybe embed Google Earth right into your geoencode plugin? 😉
I do not know if what you describe is possible and I also I do not know how you intend to use it in connection with yout Lightroom plugin so I can only offer this suggestion.
In Google Earth the user selects
‘View’ -> ‘Make this my start location’ and then
‘File’ -> ‘Save’ -> ‘Save My Places’
so that the
\Application Data\Google\GoogleEarth\myplaces.kml
is updated (unfortunately the .kml file is not updated instantly)
and within your plugin (perhaps in a separate task) chcek the .kml file for any change of
and within .
Hi Jeffrey,
I did a quick Google search, and looks like it is possible to get the lat/long coordinates from Google Earth.
A guy named David Tryse has a program called Google Earth Position that displays a pop-up window with the lat/long coordinates of the center of the current Google Earth view: http://david.tryse.net/googleearth/#programs, with a link to a place to download his program http://code.google.com/p/googleearth-autohotkey/
I’m not sure if he reveals his code in the above links, but you might wanna try asking him for any hints.
Hello,
I don’t know much about programming, but if you just want to copy the lat/lng of the current viewpoint, I think you can try Autohotkey.
With autohotkey
– find the windows of GoogleEarch
– send the shortcut for “New Placemark”: Ctr+Shift+P, it should open a dialog
– send 2 times the Tab key
– send Ctr+C
– send Tab key
– send Home key
– send Ctr+V
– send Ctr+A
– send Ctr+C
and you have the lat/lng in clipboard
I don’t know if it can help but a user create a Google Map (not Google Earth) to recover the coordinates of the point clicked (which can be better than the center of viewpoint)
http://www.google.com/ig/directory?url=Webb.Howard%2Bfoobar%40gmail.com&type=authors
I hadn’t notice the GetPointOnTerrain function, I guess they extended the dictionary in the last version. I’ll be able to include the altitude now, so thanks to you as well!
I was able to get it working for Windows, too… thanks for the pointers to AutoHotKey. Using the library from Google, I ended up using
as my script. Thanks for the help!
Depending on how the application works: Adding a network-link that refreshes every second will send the current coordinates (and the ll and tr-corner) to a webserver. That could well be localhost. You can send back a list of the images in the viewport, so the geo-tagged images also show up in earth.
Chris
That would be wonderful, but Lightroom doesn’t allow any network access other than “open this url”, “send this HTTP POST”, etc, so I can’t do anything as direct as talk to Earth directly. I do have plans for greater integration, but it’ll require some magic under the hood. (There’s already some amazing magic under the hood for many features of these plugins, but users generally don’t care about the mountains you had to move… either it works for them or it doesn’t (and they normally complain in either case 🙂 ) —Jeffrey