Hi,
On my site, I have a link on each page that takes some url parameters
declared in the page ($lat & $long etc) to create a link to a php
script which then writes a kml file on the fly. The browser then
downloads and opens the file with GE.
Apparently this is not what happens for all visitors to my site. Users
of Opera see nothing but the CDATA sectons of the resultant kml file
displayed in the browser window. Some users of Firefox have the kml
file open with dreamweaver or see GE attempt to open the php file and
thus do nothing much Yet, other users see it work perfectly as
intended.
Here is an example link from one particular page:
http://oceandots.com/flyto.php?lat=16.360&long=145.655&place=Anatahan&group=Mariana+Islands
The php script shown below takes the necessary parameters from the url
and creates a kml file
PHP script:
<?php
header("Content-type: application/vnd.google-earth.kml+xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<kml xmlns=\"
http://earth.google.com/kml/2.1\">\n";
echo "<Document>\n";
$lat = $_GET['lat'];
$long = $_GET['long'];
$place = $_GET['place'];
$group = $_GET['group'];
$link = $_SERVER['HTTP_REFERER'];
echo "<Placemark>\n";
echo "<description><![CDATA[$place, $group<br /> lat: $lat, long:
$long<br /><a href='$link'>$place</a> ]]></description>\n";
echo "<name>$place</name>\n";
echo "<LookAt>\n";
echo "<longitude>$long</longitude>\n";
echo "<latitude>$lat</latitude>\n";
echo "<range>5000.00</range>\n";
echo "<tilt>20.0</tilt>\n";
echo "<heading>0</heading>\n";
echo "</LookAt>\n";
echo "<visibility>0</visibility>\n";
echo "<Point>\n";
echo "<extrude>1</extrude>\n";
echo "<altitudeMode>relativeToGround</altitudeMode>\n";
echo "<coordinates>$long,$lat</coordinates>\n";
echo "</Point>\n";
echo "</Placemark>\n";
echo "</Document>\n";
echo "</kml>\n";
?>
which makes a kml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="
http://earth.google.com/kml/2.1">
<Document>
<Placemark>
<description><![CDATA[Anatahan, Mariana Islands<br /> lat: 16.360,
long: 145.655<br /><a href='
http://oceandots.com/pacific/mariana/
anatahan.htm'>Anatahan</a> ]]></description>
<name>Anatahan</name>
<LookAt>
<longitude>145.655</longitude>
<latitude>16.360</latitude>
<range>5000.00</range>
<tilt>20.0</tilt>
<heading>0</heading>
</LookAt>
<visibility>0</visibility>
<Point>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>145.655,16.360</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I had thought that maybe the server should be sending the correct MIME
types for GE-opening files, but since it works for many visitors as
is, I'm not too sure that this is the issue. I have a shared hosting
account so have little or no control over server configuration.
Any ideas why this works for some users, not for others and not for
Opera users at all?
Regards
Douglas Kerr
ps this is my first usenet posting, so I've no idea whether I've
formatted this post correctly. Apologies in advance.