# Another way it so create a base class of Marker and to keep this timeline and
# the behaviours associated with the marker. This approach is implemented here.
#
-use Glib::Object::Subclass 'Champlain::Marker' =>
+use Glib::Object::Subclass 'Champlain::BaseMarker' =>
properties => [
# The timeline controlling the animation
$layer->remove($last);
# And then recreate it with another color
- my $marker = Champlain::Marker->new_with_label($last->{name}, $font, undef, undef);
+ my $marker = Champlain::Marker->new_with_text($last->{name}, $font, undef, undef);
$marker->set_position($last->get('latitude', 'longitude'));
push @markers, $marker;
$layer->add($marker);
my $white = Clutter::Color->new(0xff, 0xff, 0xff, 0xff);
my $orange = Clutter::Color->new(0xf3, 0x94, 0x07, 0xbb);
- my $marker = Champlain::Marker->new_with_label($name, $font, $white, $orange);
+ my $marker = Champlain::Marker->new_with_text($name, $font, $white, $orange);
$marker->{name} = $name;
$marker->set_position($latitude, $longitude);
push @markers, $marker;
my $marker;
- $marker = Champlain::Marker->new_with_label("Montr\x{e9}al", "Airmole 14", undef, undef);
+ $marker = Champlain::Marker->new_with_text(
+ "Montr\x{e9}al", "Airmole 14", undef, undef
+ );
$marker->set_position(45.528178, -73.563788);
$marker->set_reactive(TRUE);
$marker->signal_connect_after("button-release-event", \&marker_button_release_cb, $map);
$layer->add($marker);
- $marker = Champlain::Marker->new_with_label("New York", "Sans 15", $white, undef);
+ $marker = Champlain::Marker->new_with_text(
+ "New York", "Sans 15", $white, undef
+ );
$marker->set_position(40.77, -73.98);
$layer->add($marker);
- $marker = Champlain::Marker->new_with_label("Bratislava", "Sans 15", $orange, undef);
+ $marker = Champlain::Marker->new_with_text(
+ "Bratislava", "Sans 15", $orange, undef
+ );
$marker->set_position(47.130885, -70.764141);
$layer->add($marker);
sub marker_button_release_cb {
my ($marker, $event, $map) = @_;
+ return FALSE unless $event->button == 1 && $event->click_count == 1;
- return FALSE if $event->button != 1 || $event->click_count > 1;
-
print "Montreal was clicked\n";
-
return TRUE;
}
sub map_view_button_release_cb {
my ($actor, $event, $map) = @_;
- return FALSE if $event->button != 2 || $event->click_count > 1;
+ return FALSE unless $event->button == 2 && $event->click_count == 1;
my ($lat, $lon) = $map->get_coords_from_event($event);
printf "Map was clicked at %f, %f\n", $lat, $lon;
my $marker;
- $marker = Champlain::Marker->new_with_label("Montr\x{e9}al", "Airmole 14", undef, undef);
+ $marker = Champlain::Marker->new_with_text(
+ "Montr\x{e9}al", "Airmole 14", undef, undef
+ );
$marker->set_position(45.528178, -73.563788);
$marker->set_reactive(TRUE);
$marker->signal_connect_after("button-release-event", \&marker_button_release_cb, $map);
$layer->add($marker);
- $marker = Champlain::Marker->new_with_label("New York", "Sans 15", $white, undef);
+ $marker = Champlain::Marker->new_with_text(
+ "New York", "Sans 15", $white, undef
+ );
$marker->set_position(40.77, -73.98);
$layer->add($marker);
my $file = File::Spec->catfile($FindBin::Bin, 'images', 'who.png');
eval {
- $marker = Champlain::Marker->new_with_image_full($file, 40, 40, 20, 20);
+ $marker = Champlain::Marker->new_with_image($file);
$marker->set_position(47.130885, -70.764141);
$layer->add($marker);
};
sub marker_button_release_cb {
my ($marker, $event, $map) = @_;
+ return FALSE unless $event->button == 1 && $event->click_count == 1;
- return FALSE if $event->button != 1 || $event->click_count > 1;
-
print "Montreal was clicked\n";
-
return TRUE;
}
sub map_view_button_release_cb {
my ($actor, $event, $map) = @_;
- return FALSE if $event->button != 2 || $event->click_count > 1;
+ return FALSE unless $event->button == 2 && $event->click_count == 1;
my ($lat, $lon) = $map->get_coords_from_event($event);
printf "Map was clicked at %f, %f\n", $lat, $lon;