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

Hi All,
Inspired by this article , I'm trying to experiment with Map Point, OLE, and Perl. I'm trying to create an array of locations to pass to addPolyLine, with no luck so far. The method addPolyLine requires an array of locations, however, it get confused when I try the code below. I may need to use a variant type, but I'm not sure how I would do that... Any ideas? Thanks
use Win32::OLE qw(in with); use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft MapPoint'; $Win32::OLE::Warn = 3; # die on errors... @states= qw (iraq iran); my $MapPoint = Win32::OLE->new('MapPoint.Application', 'Quit'); my $Map = $MapPoint->NewMap(); my $Results = $Map->FindPlaceResults("Virginia"); my $second = $Map->findPlaceResults("Maryland"); my $Location = $Results->Item(1); $Location->GoTo; my $secLocation = $second->Item(1); my @ary = ($location,$secLocation); my $x = $Map->Shapes->addPolyLine(@ary); # Fails # More below here


----
Zak
undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\ +nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\n +utsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print +;

Replies are listed 'Best First'.
Re: OLE & Array (MapPoint addPollyLine)
by jand (Friar) on Oct 09, 2003 at 15:31 UTC
    Try passing @ary by reference in case MapPoint expects an array of locations:
    my $x = $Map->Shapes->addPolyLine(\@ary);
      Sweet! The following code produces the following maps...:
      use Win32::OLE qw(in with); use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft MapPoint'; use Win32::OLE::Variant; $Win32::OLE::Warn = 3; # die on errors... my $MapPoint = Win32::OLE->new('MapPoint.Application', 'Quit'); my $Map = $MapPoint->NewMap(); my $Results = $Map->FindPlaceResults("California"); my $second = $Map->findPlaceResults("Massachusetts"); my $Location = $Results->Item(1); $Location->GoTo; my $secLocation = $second->Item(1); my @ary = ($Location,$secLocation); my $x = $Map->Shapes->addPolyLine(\@ary); $x->{Line}->{EndArrowhead}=True; $Map->{Altitude} = $Map->{Altitude}*4; # adjust zoom $Map->SaveAs("yahoox", 2); # saves in /mydocuments/yahoox.htm /mydocum +ents/yahoox_files/image_map.jpg & /my documents/yahoox_files/image_ov +erview.jpg (image_overview.jpg seems to always be the same image...) $Map->{Altitude} = $Map->{Altitude}*40; $Map->SaveAs("yahoo", 2); $Map->{Saved} = -1;
      map1
      map2


      ----
      Zak
      undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\ +nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\n +utsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print +;
Re: OLE & Array (MapPoint addPollyLine)
by ericwfrost (Initiate) on Oct 10, 2003 at 21:24 UTC
    I'm flattered yee friars and holy men deigned to notice my work. If anyone's interested in syndicating or republishing the article, just include a link back to mp2kmag and let me know where you're going to put it. Thanks, Eric