Apr 29, 2011

Control Google Earth from Manipulate

One reader asks: could one drive Google Earth from a set of controls within a Manipulate? The answer is yes, however, I only know how to do it with Windows platform through Google Earth COM API. In the past, this issue is covered in this post: Control Google Earth from Mathematica.

The example here is very simple, rotate the camera from Manipulate.

Needs["NETLink`"]
InstallNET[];
(* start up goolge earth *)
ge = CreateCOMObject["GoogleEarth.ApplicationGE"];
(* get the camera object *)
cam = ge@GetCamera[0]
(* define a function to rotate the camera *)
runcam[{lat_, lon_}] := Module[{},
   cam@FocusPointLongitude = lon;
   cam@FocusPointLatitude = lat;
   ge@SetCamera[cam, 2]];

Manipulate[
runcam[{lat, lon}]; {lat, lon}, {lat, -50, 50}, {lon, -180, 180}]

googleearthcontrol

3 comments:

Anonymous said...

Hello;

When I run your code, using 8.0.01 Mathematica, on windows 7, I get this error

CreateCOMObject::netexcptn: A .NET exception occurred: {At Line = 122, the input was:,ge=CreateCOMObject[GoogleEarth.ApplicationGE];,System.Runtime.InteropServices.COMExcep\[Ellipsis] cketHandler.createCOM(KernelLinkImpl ml)}. >>


do you know how to fix it?

thanks
steve

Anonymous said...

Sorry, no idea on this issue.

Anonymous said...

same error here...