How to open two KML documents in GE

45 views
Skip to first unread message

mikemcc

unread,
Jun 5, 2010, 6:35:55 AM6/5/10
to KML Developer Support - KML Server Side Scripting
Is it possible to get PHP to:
- create a KML document and open it in GE
- continue immediately to create and open another KML document.

I am coding:
$kml = array('<?xml version="1.0" encoding="ISO-8859-1"?>');
$kml[] = '<kml xmlns="http://www.opengis.net/kml/2.2">';
$kml[] = '<Document>';

// all the KML for the first document

$kml[] = '</Document>';
$kml[] = '</kml>';
$kmloutput = join("\n", $kml);

header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmloutput;

$kml = array('<?xml version="1.0" encoding="ISO-8859-1"?>');
$kml[] = '<kml xmlns="http://www.opengis.net/kml/2.2">';
$kml[] = '<Document>';

// all the KML for the second document

$kml[] = '</Document>';
$kml[] = '</kml>';
$kmloutput = join("\n", $kml);

header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmloutput;

Instead of 'pausing' to open the first document, PHP adds the lines
for the second document to the end of the first document, so when it
eventually tries to open a document, GE complains that there's junk
after the first document element.

It all works fine if I opt to write each document file to disk, but
not when I ask PHP to open the two files in GE instead.

Rossko

unread,
Jun 6, 2010, 3:51:03 PM6/6/10
to KML Developer Support - KML Server Side Scripting
> Is it possible to get PHP to:
> - create a KML document and open it in GE
> - continue immediately to create and open another KML document.

Pass GE a KML document containing network links to your two 'real' KML
docs.

Set up php scripts to supply the 'real' KML docs when requested, AJAX
style.
In practice, you could have just one script that accepts GET
parameters to determine which KML to return;
www.mysite.com/myKMLfeed.php?dataset=Bananas

mikemcc

unread,
Jul 3, 2010, 8:22:15 AM7/3/10
to KML Developer Support - KML Server Side Scripting
Sorry not to thank you before, Rossko - I have only just spotted this.
Will try it soon. Thanks. Mike
Reply all
Reply to author
Forward
0 new messages