Geo::GoogleEarth::Document - Generates GoogleEarth KML Documents


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

Index


Code Index:

NAME

Top

Geo::GoogleEarth::Document - Generates GoogleEarth KML Documents

SYNOPSIS

Top

  use Geo::GoogleEarth::Document;
  my $document    = Geo::GoogleEarth::Document->new();  #is a special Folder...
  my $folder      = $document->Folder();                #Geo::GoogleEarth::Document::Folder object
  my $placemark   = $document->Placemark();             #Geo::GoogleEarth::Document::Placemark object
  my $networklink = $document->NetworkLink();           #Geo::GoogleEarth::Document::NetworkLink object
  my $style = $document->Style();                       #Geo::GoogleEarth::Document::Style object
  print $document->render();

DESCRIPTION

Top

Geo::GoogleEarth::Document is a Perl object oriented interface that allows for the creation of XML documents that can be used with Google Earth.

Geo::GoogleEarth::Document is a Geo::GoogleEarth::Document::Folder with a render method.

USAGE

Top

This is all of the code you need to generate a complete Google Earth document.

  use Geo::GoogleEarth::Document;
  my $document=Geo::GoogleEarth::Document->new();
  $document->Placemark(address=>"1600 Pennsylvania Ave NW, Washington, DC");
  print $document->render;

render

Returns an XML document with an XML declaration and a root name of "Document"

  print $document->render;

archive

Returns a KMZ formatted Zipped archive of the XML document

  print $document->archive;

Style

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

  my $style=$document->Style(id=>"myicon1",
                 iconHref=>"http://maps.google.com/mapfiles/kml/paddle/L.png");

BUGS

Top

SUPPORT

Top

Try geo-perl email list.

AUTHOR

Top

    Michael R. Davis (mrdvt92)
    CPAN ID: MRDVT

COPYRIGHT

Top

SEE ALSO

Top

Geo::GoogleEarth::Document creates a GoogleEarth KML Document.

Geo::GoogleEarth::Document::Base is the base for Geo::GoogleEarth::Document::* packages.

Geo::GoogleEarth::Document::Folder is a Geo::GoogleEarth::Document folder object.

Geo::GoogleEarth::Document::NetworkLink is a Geo::GoogleEarth::Document NetworkLink object.

Geo::GoogleEarth::Document::Placemark is a Geo::GoogleEarth::Document Placemark object.

Geo::GoogleEarth::Document::Style is a Geo::GoogleEarth::Document Style object.

XML::Simple is used by this package to generate XML from a data structure.


Geo-GoogleEarth-Document documentation Contained in the Geo-GoogleEarth-Document distribution.
package Geo::GoogleEarth::Document;
use strict;
use base qw{Geo::GoogleEarth::Document::Folder}; 
use Geo::GoogleEarth::Document::Style;
use XML::Simple qw{};
use Archive::Zip qw{COMPRESSION_DEFLATED};
use IO::Scalar qw{};

BEGIN {
    use vars qw($VERSION);
    $VERSION     = '0.11';
}

sub render {
  my $self=shift();
  my $xs=XML::Simple->new(XMLDecl=>1, RootName=>q{kml}, ForceArray=>1);
  return $xs->XMLout({xmlns=>"http://earth.google.com/kml/2.2", Document=>[$self->structure]});
}

sub archive {
  my $self=shift;
  my $azip=Archive::Zip->new;
  my $member=$azip->addString($self->render, "doc.kml");
  $member->desiredCompressionMethod(COMPRESSION_DEFLATED);
  $member->desiredCompressionLevel(9);

  my $archive=q{};
  my $iosh=IO::Scalar->new( \$archive );
  $azip->writeToFileHandle($iosh);
  $iosh->close;

  return $archive;
}

sub Style {
  my $self=shift();
  my $obj=Geo::GoogleEarth::Document::Style->new(@_);
  $self->data($obj);
  return $obj;
}

1;