Translate posts to Experimental | Feedback
Google
Official Google Earth Download Site
Topic Options
Rate This Topic
Previous Topic
View All Topics Index
Next Topic
#291380 - 01/19/06 08:50 AM PHP KML generator
Kaaosa Offline
Traveler

Registered: 01/19/06
Posts: 4
So, I downloaded GE last night, and I'm in love with it. So, I stayed up an extra two hours to build a PHP KML generator. It's a simple bit of PHP code that parses like a KML file and contains a function for generating placemarks. I have a little demo on my site at http://kaaosa.com/google. With the form, you can add a location to a MySQL database, which the KML generator (which you load into GE) reads. If you guys like it, I'll post a link to the PHP code.

Hope this sort of thing hasn't been posted a million times before.

Top
#291381 - 01/19/06 09:50 AM Re: PHP KML generator [Re: Kaaosa]
kaprchal Offline
Traveler

Registered: 12/13/05
Posts: 19
Loc: Chicago/Austin TX
Thanks.

I would like to see the code, but where is this KML generator? Are you just referring to a network link?


Ken

Top
#291382 - 01/19/06 10:43 AM Re: PHP KML generator [Re: kaprchal]
Kaaosa Offline
Traveler

Registered: 01/19/06
Posts: 4
The generator is located at http://kaaosa.com/google/gearth.php

The network link (http://kaaosa.com/google/gearth.kml) is used because that's the only way I know of to get the thing to refresh over time.

Source attached to post.

Top
#291383 - 01/19/06 10:44 AM Re: PHP KML generator [Re: Kaaosa]
Kaaosa Offline
Traveler

Registered: 01/19/06
Posts: 4
Err, here's the source: http://kaaosa.com/google/gearth.txt

Top
#291384 - 01/19/06 11:30 AM Re: PHP KML generator [Re: Kaaosa]
vlex Offline
New Poster

Registered: 01/19/06
Posts: 1
Loc: eldritch, new england
hi there,

i saw that your submit form accepts input, but is there some way to jump to the results?

in other words, where is the resulting KML file?

Also, can you supply the PHP code? the link to the .txt file:
<http://kaaosa.com/google/gearth.txt> is NOT FOUND on your server.

I think it would be great if we could query MySQL and bundle the output into KML format...

I'd love to see your code, meanwhile, I might have to work on that idea!

regards, vlex

Top
#291385 - 01/19/06 12:59 PM Re: PHP KML generator [Re: vlex]
Kaaosa Offline
Traveler

Registered: 01/19/06
Posts: 4
Yeah, I messed up the filename on the source code. It's fixed now and that link should work. The generated KML file is located at http://kaaosa.com/google/gearth.php

Top
#291386 - 01/19/06 07:11 PM Re: PHP KML generator [Re: Kaaosa]
BrianT Offline
Traveler

Registered: 05/14/05
Posts: 104
Before pressing on with your project, check out the considerable work TJ's done in this realm--

http://kml.tjworld.net/


BT

Top
#291387 - 02/01/06 01:31 AM Re: PHP KML generator [Re: BrianT]
a666 Offline
Traveler

Registered: 02/01/06
Posts: 2
Loc: Tyrol
hi,

i am experiencing with PHP generated KML as well. for texting purposes i digitize points in Google Maps, send the result as a query string to a php file that translates this in KML. in Firefox anything works fine, but in MSIE 6 the file doesn't open in GE. note that i do not dump a file to the server in order to call it from there but i wriite it straight to the client.

i am doint this like that:

Code:
 <?php
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf8");
echo <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<name>some title</name>
<StyleMap id="MYGT_R

# ETC...



Firefox opens this directly in GE, MSIE recognizes this as XXXX.php and opens it in ... GoLive :-(

when i add another header line like

Code:
 header("Content-disposition: attachment; filename=geotraceSample.kml"); 



all i get in MSIE is the XML code displayed. adding a trailing URL string like &MSIE=.kml doesn't help either. (mime-types on the server ar set.)

i saw that the http://bbs.keyhole.com/ubb/download.php?Number=345 works fine, can someone point me to what's in there to make it work in MSIE?

thx, andr

Top
#291388 - 02/01/06 02:11 AM Re: PHP KML generator [Re: a666]
a666 Offline
Traveler

Registered: 02/01/06
Posts: 2
Loc: Tyrol
okay, i found a way (see below). but the "download/open/cancel" question from MSIE remains. the dowwnload.php from bbs.keyhole.com doesn't have this, what's the trick here?

Code:
# set $myKMLCode together as a string
$downloadfile="myKml.kml"; # give a name to appear at the client
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf8");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($myKMLCode));
header("Pragma: no-cache");
header("Expires: 0");
echo $myKMLCode;
?>


Top