Man, you seem to do everything so as to make it as hard as possible to figure out. :-)

Look at this code, with comments to show fixes.

#!/usr/bin/perl -w use strict; use Glib qw/TRUE FALSE/; use Gtk2 -init; use Goo::Canvas; #variables my $ellipsoid = 23; #static WSG83 my $zone; my @mtp; my @ps; my @cs; my $count = 1; # changed to bring more into field of view my $way_ref = [40, 70,140, 130]; #Create Window my $window = new Gtk2::Window ( "toplevel" ); $window->signal_connect ("delete_event", sub { Gtk2->main_quit; }); $window->set_border_width (10); $window->set_size_request(640,480); $window->set_position('center'); #Create Scrolled Window my $scwin = Gtk2::ScrolledWindow->new(); $scwin->set_policy('always','always'); $window->add($scwin); #add canvas my $canvas = Goo::Canvas->new(); $scwin->add($canvas); my $root = $canvas->get_root_item(); # this group isn't doing anything, so when you add # your PolyLines to it, it isn't there. You need to place # the group somewhere on the canvas #waypoint lines group my $way_group = Goo::Canvas::Group->new($root); #add Background image my $filename = shift or die "no image $!\n"; my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename); my $image = Goo::Canvas::Image->new($root, $pixbuf, 0, 0, 'width' => $pixbuf->get_width, 'height' => $pixbuf->get_height); #handle the events $canvas->signal_connect (event => \&event_handler); # your TRUE option below creates closed lines, you may want FALSE #Start the waypoint connector, notice group is $root, NOT $way_group my $way_lines = Goo::Canvas::Polyline->new($root,TRUE,undef, stroke_color => 'pink', #make more visible line_width => 5, ); # PolyLine wants an Points object my $points = Goo::Canvas::Points->new($way_ref); # setting after line creation, sets the 'points' property by name $way_lines->set(points => $points); $window->show_all; Gtk2->main; #------------------------------------------------ #handle the mosue events sub event_handler { my ( $widget, $event ) = @_; #on 2 mouse presses, a doubleclick if ( $event->type eq "2button-press" ) { my ($x,$y) = ($event->x,$event->y); print 'x->',$x,' ','y->',$y; #Drop waypoint icon my $tgroup = Goo::Canvas::Group->new ($root); Goo::Canvas::Ellipse->new($tgroup,$x,$y,7.5,7.5, fill_color => 'purple', stroke_color => 'black'); Goo::Canvas::Text->new ($tgroup,$count,$x,$y,-1,'GTK_ANCHOR_CE +NTER', font => 'Sans Bold 15', fill_color => 'pink', ); print " $count\n"; push @$way_ref,$x,$y; my $points = Goo::Canvas::Points->new($way_ref); $way_lines->set(points => $points); $count++; print "$way_lines\n"; return; } } #------------------------------------------------

I'm not really a human, but I play one on earth CandyGram for Mongo

In reply to Re^5: Drawing Shapefiles in Goo::Canvas by zentara
in thread Drawing Shapefiles in Goo::Canvas by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.