Jump to content

PHP File delivery of KML file not accepted by google maps


WiredHome

Recommended Posts

I have some KML files with client information in them, and want to make them accessible only by logged on users - then delivering them to google maps. So, the KML files are in a secure folder and as you'll see below I use readfile to send them out. Through various web browsers, I can open the link (google earth is configured, starts, and works great), giving that same link to google maps fails with a file not found error.

 

The minimalist [unsecured] version for debugging this "f.php" script -

<?php

$t = "test.kml";

header("Content-Type: application/vnd.google-earth.kml+xml");

header("Content-Length: " . filesize($t));

readfile($t);

?>

 

this allows a: http://www.mysite.com/f.php and b: http://www.mysite.com/test.kml

dropping a into http://maps.google.com/ fails and

dropping b into http://maps.google.com/ works fine.

 

I've read and worked it from a "header" perspective and am very sure I'm not introducing characters ahead of the header. I can in fact download the file just fine (saving or launching into Google Earth), but google maps is not accepting it.

 

The PHP script

Header from the PHP delivered version:

==============

HTTP/1.1 200 OK

Server: Microsoft-IIS/5.0

Date: Sat, 23 Jan 2010 15:55:18 GMT

X-Powered-By: ASP.NET

X-Powered-By: PHP/5.2.11

Content-Type: application/vnd.google-earth.kml+xml

Content-Length: 390080

 

<?xml version="1.0" encoding="UTF-8"?>

... the rest of the file streams from here ...

==============

 

and direct from the IIS delivered version it looks like this:

==============

HTTP/1.1 200 OK

Server: Microsoft-IIS/5.0

X-Powered-By: ASP.NET

Date: Sat, 23 Jan 2010 15:56:53 GMT

Content-Type: application/vnd.google-earth.kml+xml

Accept-Ranges: bytes

Last-Modified: Mon, 18 Jan 2010 20:57:57 GMT

ETag: "104b82e98098ca1:dd1"

Content-Length: 390080

 

<?xml version="1.0" encoding="UTF-8"?>

==============

 

I've tried various modifications to the headers, within the constraints of PHP control, but have been unsuccessful. For example, adding -

header("Accept-Ranges: bytes");

header("Last-Modified: Mon, 18 Jan 2010 20:57:57 GMT");

 

results in

==============

HTTP/1.1 200 OK

Server: Microsoft-IIS/5.0

Date: Sat, 23 Jan 2010 16:03:47 GMT

X-Powered-By: ASP.NET

X-Powered-By: PHP/5.2.11

Accept-Ranges: bytes

Last-Modified: Mon, 18 Jan 2010 20:57:57 GMT

Content-Type: application/vnd.google-earth.kml+xml

Content-Length: 390080

 

<?xml version="1.0" encoding="UTF-8"?>

==============

 

I've looked at timing aspects, and the server response to either query is within a fraction of a second - the php being about 1/4 second slower.

 

An easy recommendation might be to post this into a google maps forum too, and I'm seeking out the right one to do so.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.