Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have this code using Geo::GoogleEarth::Pluggable to create KML documents. I would like to add a "ScreenOverlay" to a KML generated with such module that would store a BMP legend for my point but I don't know how I can add it. This is the code generating the two KMLs:

use strict; use Geo::GoogleEarth::Pluggable; my $document=Geo::GoogleEarth::Pluggable->new( name=>'dummy', description=>'bbb', ); $document->LookAt( latitude => 50, longitude => 0, range => 30000, heading => 0, tilt => 0, ); my $folder; $folder = $document->Folder(name=>"FOLDER_1", description=>"FOLDER_1") +; my $icon_style = $folder->IconStyle( color => {red=>255, green=>0, blue=>0}, href => "http://maps.google.com/mapfiles/kml/shapes/square.png" +, scale => 0.4 ); my %point = ( name=>'POINT_1', lat=>50, lon=>0, alt=> 0, description=>'POINT_1', style => $icon_style, ); $folder->Point(%point); my $kstring = $document->archive; my $kfile = 'dummy.kml'; open(KK,">$kfile") or die "$kfile $!"; print KK $kstring; close (KK); my $kml_legend_file = 'dummy_legend.kml'; open (KML,">$kml_legend_file") or die $!; print KML qq(<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.googl +e.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:a +tom="http://www.w3.org/2005/Atom"> <ScreenOverlay id="idLegend"> <name>dummy_legend</name> <description></description> <Icon> <href>dummy_legend.bmp</href> </Icon> <overlayXY x="0" y="1" xunits="fraction" yunits="fraction"/> <screenXY x="0" y="1" xunits="fraction" yunits="fraction"/> <rotationXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/> <size x="0" y="0" xunits="pixels" yunits="pixels"/> </ScreenOverlay> </kml>); close (KML);
Thanks for any suggestion on how to come up with a single KML with the ScreenOverlay included.

Replies are listed 'Best First'.
Re: How to modify KML files
by $h4X4_&#124;=73}{ (Monk) on Jun 01, 2016 at 10:41 UTC

    From what I can tell it's just an XML format. I came across this icons have a default HotSpot orientation specified so the client knows where to place the icon with respect to the coordinates on the map. Google Earth/Maps Icons Is this what your trying to do? that wasn't what you are doing.

    screenoverlay

      Thanks for your time.

      I would like to include the <ScreenOverlay> tag in the XML of the first KML file and then save everything into a single KML file (by the way I used $document->archive, but it should be $document->render, otherwise the document is compressed, as in KMZ files).

      I read back the first KML with XML::Simple, but then I don't know how to insert in such structure the <ScreenOverlay> tag and save everything in KML format.