| Geo-GoogleEarth-Document documentation | Contained in the Geo-GoogleEarth-Document distribution. |
Geo::GoogleEarth::Document::Folder - Geo::GoogleEarth::Document::Folder object
use Geo::GoogleEarth::Document; my $document=Geo::GoogleEarth::Document->new(); my $folder=$document->Folder(name=>"My Folder");
Geo::GoogleEarth::Document::Folder is a Geo::GoogleEarth::Document::Base with a few other methods.
my $folder=$document->Folder(); #add folder to $document my $folder=$folder->Folder(); #add folder to $folder
Constructs a new Folder object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
my $folder=$folder->Folder(name=>"My Folder"); $folder->Folder(name=>"My Folder");
Constructs a new Placemark object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
my $placemark=$folder->Placemark(name=>"My Placemark",
address=>"1600 Pennsylvania Ave NW, Washington, DC");
$folder->Placemark(name=>"My Placemark", lat=>38.897607, lon=>-77.036554);
Constructs a new NetworkLink object and appends it to the parent folder object. Returns the object reference if you need to make any setting changes after construction.
my $networklink=$folder->NetworkLink(name=>"My NetworkLink",
url=>"./anotherdoc.kml");
$folder->NetworkLink(name=>"My NetworkLink", url=>"./anotherdoc.kml");
Returns the object type.
my $type=$folder->type;
Returns a hash reference for feeding directly into XML::Simple.
Unfortunately, this package cannot guarantee how Folders, Placemarks, or NetworkLinks are ordered when in the same folder. Because, it's a hash reference! But, order is preserved within a group of Folders, NetworkLink, and Placemarks.
my $structure=$folder->structure;
Pushes arguments onto data array and returns an array or reference that holds folder object content. This is a list of objects that supports a type and structure method.
my $data=$folder->data; my @data=$folder->data; $folder->data($placemark);
Due to a limitation in XML::Simple and the fact that we feed it a hash, it is not possible to specify the order of Folders, Placemarks and NetworkLinks. However, this package does preserve the order of creation within groups of Folders, Placemarks, and NetworkLinks. A good work around is to put unique types of objects in folders.
Try geo-perl email list.
Michael R. Davis (mrdvt92)
CPAN ID: MRDVT
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
Geo::GoogleEarth::Document creates a GoogleEarth KML Document.
| Geo-GoogleEarth-Document documentation | Contained in the Geo-GoogleEarth-Document distribution. |
package Geo::GoogleEarth::Document::Folder; use strict; use base qw{Geo::GoogleEarth::Document::Base}; use Geo::GoogleEarth::Document::Folder; use Geo::GoogleEarth::Document::Placemark; use Geo::GoogleEarth::Document::NetworkLink; BEGIN { use vars qw($VERSION); $VERSION = '0.07'; }
sub Folder { my $self=shift(); my $obj=Geo::GoogleEarth::Document::Folder->new(@_); $self->data($obj); return $obj; }
sub Placemark{ my $self=shift(); my $obj=Geo::GoogleEarth::Document::Placemark->new(@_); $self->data($obj); return $obj; }
sub NetworkLink { my $self=shift(); my $obj=Geo::GoogleEarth::Document::NetworkLink->new(@_); $self->data($obj); return $obj; }
sub type { my $self=shift(); return "Folder"; }
sub structure { my $self=shift(); my $structure={name=>[$self->name]}; #{Placemark=>[], Folder=>[], ...} foreach my $obj ($self->data) { #$obj->type should be one of Placemark, Folder, NetworkLink $structure->{$obj->type}=[] unless ref($structure->{$obj->type}) eq 'ARRAY'; #$obj->structure should be a HASH structure to feed into XML::Simple push @{$structure->{$obj->type}}, $obj->structure; } return $structure; }
sub data { my $self=shift(); $self->{'data'} = [] unless ref($self->{'data'}) eq ref([]); my $data=$self->{'data'}; if (@_) { push @$data, @_; } return wantarray ? @$data : $data; }
1;