Coppermine photos/files in Google Earth - Page 2 Coppermine photos/files in Google Earth - Page 2
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Coppermine photos/files in Google Earth

Started by Tranz, January 25, 2006, 03:53:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kryspin

Hi TranzNDance, thanks for the mod, I got it working and it is really beutifull, saves a lot of time.

I have tons of geocoded pictures, so showing them all at one time in GE has no point. However I was thinking of sending to GE only the pictures from currently viewed album (on request, clicking on link etc...). I realize it is probably a piece of cake, but unfortunately, I'm not much of a coder, so I have great troubles modifying the code. Do you think you could be so generous and help me with it?

Tranz

I think that's a good idea. The map mod is able to specify albums, so it's not impossible to do it for this.

I'll be on vacation next week so hopefully I'll have time to work on this then. However, I can't promise that I'll finish work on this because I really should be upgrading the map mod for Coppermine's next version.

bitcloud

This works great for me TranznDance... cheers again!
There is one minor issue (which is unrelated to your code) which was causing me a little trouble.

It appears that google earth's embedded IE window (which i think renders both the info balloons, and the embedded browser window) is caching either the mapping.php file, or the kml file (or both)
In order to get it to load updated information into earth, I was having to load IE and manually shift-refresh both files (or clear the cache I guess)

I tried add "no cache" headers in the kml, but it would still cache the php. The only way I could manage to get it to reload both was to use the nocache header in the kml, and force a random additional variable when the kml calls the mapping.php file (ie mapping.php?loadid=987623)

This might be a hacky way about it (If anyone has a more elegant solution, I'm all ears)
but here's how I did it.
mapping.php remains the same.
You no longer need your kml file.

create a new php file called something like mappingkml.php (this is your new kml file)

Put the following code in it (edit your site name and URL, and the name of mapping.php if your file is named differently):
<?php
$loadID gmdate("D, d M Y H:i:s") . rand(1515);

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

<kml xmlns="http://www.google.com/earth/kml/2.0">
<NetworkLink>
<name>Your Site Name</name>
<Url>
<href>http://yourURL/mapping.php?input='.$loadID.'</href>
</Url>
<visibility>1</visibility>
</NetworkLink>
</kml>';

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header('Content-type: application/vnd.google-earth.kml+xml');
echo $content;
?>

The loadid bit is because when a variable is parsed into the php, it forces the reload of the file...

This should generate a legit kml file, though it will still have the php extension. So I then edited my .htaccess file and added:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^mappingkml.kml mappingkml.php [L]
</IfModule>

(maybe you don't need all those lines if you can fit the rule in somewhere else)

Now when someone links to mappingkml.kml, it will pull up the contents of mappingkml.php - google earth should load it without any grief, and you shouldn't have any caching issues...
('course you can name mappingkml.kml in your htaccess to anything - mapping.kml for example to make it less redundant and redundant :) )

It should also be fairly easy to mod this to parse variables to to mappingkml.php - so that you can generate custom kml files from albums/search terms/users etc...

I'm not much of a coder sorry, so if it's messy I apologise :D