Geo::GoogleEarth::Pluggable::Plugin::Style - Geo::GoogleEarth::Pluggable Style Plugin Methods


Geo-GoogleEarth-Pluggable documentation Contained in the Geo-GoogleEarth-Pluggable distribution.

Index


Code Index:

NAME

Top

Geo::GoogleEarth::Pluggable::Plugin::Style - Geo::GoogleEarth::Pluggable Style Plugin Methods

SYNOPSIS

Top

  use Geo::GoogleEarth::Pluggable;
  my $document=Geo::GoogleEarth::Pluggable->new;     #ISA L<Geo::GoogleEarth::Pluggable>
  my $style=$document->IconStyle(color=>{red=>255}); #ISA L<Geo::GoogleEarth::Pluggable::Style>
  my $point=$document->Point(style=>$style);         #ISA L<Geo::GoogleEarth::Pluggable::Contrib::Point>
  print $document->render;

METHODS

Top

Methods in this package are AUTOLOADed into the Geo::GoogleEarth::Pluggable::Folder namespace at runtime.

Style

Constructs a new Style object and appends it to the document object. Returns the Style object reference.

  my $style=$folder->Style(
                           id => $id, #default is good
                           IconStyle  => {},
                           LineStyle  => {},
                           PolyStyle  => {},
                           LabelStyle => {},
                           ListStyle  => {},
                          );

  my $style=$folder->Style(
                           IconStyle  => $style1, #extracts IconStyle from $style1
                           LineStyle  => $style2, #extracts LineStyle from $style2
                           PolyStyle  => $style3, #extracts PolyStyle from $style3
                          );

StyleMap

Constructs a new StyleMap object and appends it to the document object. Returns the StyleMap object reference.

  my $stylemap=$document->StyleMap(
                            normal    => $style1,
                            highlight => $style2,
                          );

IconStyle

  my $style=$folder->IconStyle(
                               color => $color,
                               scale => $scale,
                               href  => $url,
                              );

LineStyle

  my $color={red=>255, green=>255, blue=>255, alpha=>255};
  my $style=$folder->LineStyle(color=>$color);

PolyStyle

  my $color={red=>255, green=>255, blue=>255, alpha=>255};
  my $style=$folder->PolyStyle(color=>$color);

LabelStyle

  my $style=$folder->LabelStyle(
                                color => $color,
                                scale => $scale,
                               );

ListStyle

  my $style=$folder->ListStyle(
                               href => $url,
                              );

TODO

Top

Need to determine what methods should be in the Folder package and what should be on the Plugin/Style package and why.

BUGS

Top

Please log on RT and send to the geo-perl email list.

LIMITATIONS

Top

This will construct 100 identical style objects

  foreach (1 .. 100) {
    $document->Point(style=>$document->IconStyle(color=>{red=>255}));
  } 

Do this instead

  my $style=$document->IconStyle(color=>{red=>255});
  foreach (1 .. 100) {
    $document->Point(style=>$style);
  }

SUPPORT

Top

Try geo-perl email list.

AUTHOR

Top

  Michael R. Davis (mrdvt92)
  CPAN ID: MRDVT

COPYRIGHT

Top

SEE ALSO

Top

Geo::GoogleEarth::Pluggable creates a GoogleEarth Document.


Geo-GoogleEarth-Pluggable documentation Contained in the Geo-GoogleEarth-Pluggable distribution.
package Geo::GoogleEarth::Pluggable::Plugin::Style;
use Geo::GoogleEarth::Pluggable::Style;
use Geo::GoogleEarth::Pluggable::StyleMap;
use Scalar::Util qw{blessed};
use warnings;
use strict;

our $VERSION='0.14';

sub Style {
  my $self=shift;
  my %data=@_;
  foreach my $key (keys %data) {
    next unless $key=~m/Style$/;
    #Extracts the particular IconStyle, LineStyle, etc from an existing Style object
    my $ref=$data{$key};
    if (blessed($ref) and $ref->can("type") and $ref->type eq "Style") {
      $data{$key}=$ref->{$key}; #allow Style to be blessed objects
    }
  }
  my $obj=Geo::GoogleEarth::Pluggable::Style->new(
                      document=>$self->document,
                      %data,
                    );
  $self->document->data($obj);
  return $obj;
}

sub StyleMap {
  my $self=shift;
  my %data=@_;
  my $obj=Geo::GoogleEarth::Pluggable::StyleMap->new(
                      document=>$self->document,
                      %data,
                    );
  $self->document->data($obj);
  return $obj;
}

sub IconStyle {
  my $self=shift;
  my %data=@_;
  my $id=delete($data{"id"}); #undef is fine here...
  return $self->Style(id=>$id, IconStyle=>\%data);
}

sub LineStyle {
  my $self=shift;
  my %data=@_;
  $data{"width"}=1 unless defined $data{"width"};
  my $id=delete($data{"id"}); #undef is fine here...
  return $self->Style(id=>$id, LineStyle=>\%data);
}

sub PolyStyle {
  my $self=shift;
  my %data=@_;
  my $id=delete($data{"id"}); #undef is fine here...
  return $self->Style(id=>$id, PolyStyle=>\%data);
}

sub LabelStyle {
  my $self=shift;
  my %data=@_;
  my $id=delete($data{"id"}); #undef is fine here...
  return $self->Style(id=>$id, LabelStyle=>\%data);
}

sub ListStyle {
  my $self=shift;
  my %data=@_;
  my $id=delete($data{"id"}); #undef is fine here...
  return $self->Style(id=>$id, ListStyle=>\%data);
}

1;