Opening KML files from a browser straight to GE

6 views
Skip to first unread message

Tallywag

unread,
May 23, 2008, 4:43:37 AM5/23/08
to KML Developer Support - KML Server Side Scripting
I have a php script called writeKML.php which queries a database and
outputs dynamic KML which I would like to go straight to GE.
Is this possibly or does the user have to save the output as a KML
file and then run the KML.

I ask as I have read various posting which implies this is possible
but when I try it I always get the usual pop up box with OPEN SAVE
CANCEL button options.

I have the line ...
header('Content-Type: application/vnd.google-earth.kml+xml');
as the first line of output generated by the php page but I just get
the above pop up.
If I click on OPEN then I get my KML output sent to my text editor
If I click SAVE then it pops up the Save As file browser and offers
writeKML.php as the save filename.

The behaviour I am after is the KML being sent to GE.... is this
possible?

thanks

barryhunter [KML Guru]

unread,
May 24, 2008, 7:44:58 AM5/24/08
to KML Developer Support - KML Server Side Scripting
In an effort to answer this I created this:
http://www.nearby.org.uk/kml-headers.php

which allows testing of the various options. It contains all the ones
I can think of that might effect it. Let me know if want to see
others, or if want the source...

I cant find a method of doing what you want. The issue seems to be
that many browsers by default show the dialog and have 'always ask for
this type of file' ticked - leaving the option in the users control.
It seems you can force the display of the dialog with Content-
Disposition but not force it to be skipped.

(BTW LiveHTTPHeaders or Fiddler type applications are useful for
testing this... )

KoflAIR

unread,
May 25, 2008, 6:46:36 AM5/25/08
to KML Developer Support - KML Server Side Scripting
This sounds familiar to me, I had the same problems a few days ago.

It happend after I installed GE 4.3. From that moment on, GE refused
to open network links from localhost addresses. Instead, my XML Editor
or a text editor opened. There was no way back.

I solved the problem with the following sequence:
- Uninstall GE 4.3
- Install GE 4.2
* at this moment, it worked!
- Download the standalone installer for GE 4.3
- Install GE 4.3
* it still worked, but badly failed again after some hours.

That's why I fell back to GE 4.2 on my local development machine.
Later when the application goes online on a web server, I'll upgrade
again to 4.3.

Maybe this path could solve you problem?

Tallywag

unread,
May 25, 2008, 4:26:20 PM5/25/08
to KML Developer Support - KML Server Side Scripting
Hi Barry
nice page, your default option actually worked (albeit with the pop up
box still appearing but at least clicking on Open actually opens up
directly google earth rather than just displaying the KML in the
browser page) which I can live with.

I had to do two things...
1) add a local .htaccess file with the necessary content to the
directory on my server
2) add the header('Content-Disposition: attachment;
filename="tempout.kml"'); to my writeKML.php file

Pressing the "Open" in the dialogue offered under IE & FF now opens
the dynamic KML written by my php script straight into GE....

happy days ;o)

many thanks
Keith

Reply all
Reply to author
Forward
0 new messages