jjorsett has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to cause the Google Earth camera to fly to a particular position using a Perl script, but my attempts to alter the camera settings are running into a problem. The following code fails
use warnings; use strict; use Win32::OLE; my $GE = Win32::OLE->new('GoogleEarth.ApplicationGE'); my $cameraInfo = $GE->GetCamera(0); $cameraInfo->Range = 500;
with the error "Can't modify non-lvalue subroutine call at GE.pl line 6." Ok, so maybe I need to treat it as a function call, so I tried
use warnings; use strict; use Win32::OLE; my $GE = Win32::OLE->new('GoogleEarth.ApplicationGE'); my $cameraInfo = $GE->GetCamera(0); $cameraInfo->Range(500);
and got the error "Win32::OLE(0.1707) error 0x80020011: "Does not support a collection" in METHOD/PROPERTYGET "Range" at GE.pl line 6" As I understand it, this means there's something wrong with the argument type, so I tried variations on the argument like '500'. No luck. I can read the parameters fine, such as
print $cameraInfo->Range;
which yields the expected result. Can anyone tell me what I'm doing wrong here? If it helps, when I run the following:
use warnings; use strict; use Win32::OLE; use Data::Dumper; my $GE = Win32::OLE->new('GoogleEarth.ApplicationGE'); my $cameraInfo = $GE->GetCamera(0); print Dumper($cameraInfo);
I get this:
$VAR1 = bless( { 'FocusPointLatitude' => '38.9594283106337', 'FocusPointLongitude' => '-95.2654992558942', 'FocusPointAltitude' => '0', 'FocusPointAltitudeMode' => 2, 'Range' => '11110155.9149248', 'Tilt' => '0', 'Azimuth' => '-1.00991539999065e-005' }, 'Win32::OLE' );

Replies are listed 'Best First'.
Re: Controlling Google Earth via COM interface
by Anonymous Monk on Jun 13, 2009 at 00:55 UTC
    Can anyone tell me what I'm doing wrong here?

    You seem to be guessing at the API.

      You seem to be guessing at the API.

      The API description of ICameraInfoGE is right here. I've used the Google Earth API extensively in C++, including ICameraInfoGE. I've used the iTunes API to examine and set Track info using Perl in the same manner as my first example and it works just dandy. So something specific to Perl and Google Earth seems to be going on.

        How would you use that in VB?
        $cameraInfo->{Range}= 500; $cameraInfo->->LetProperty( Range => 500);