Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: 1 [2]   Go Down

Author Topic: Coppermine photos/files in Google Earth  (Read 45251 times)

0 Members and 1 Guest are viewing this topic.

kryspin

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 21
Re: Coppermine photos/files in Google Earth
« Reply #20 on: May 15, 2009, 03:33:18 pm »

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?
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Coppermine photos/files in Google Earth
« Reply #21 on: May 15, 2009, 05:40:00 pm »

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.
Logged

bitcloud

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Coppermine photos/files in Google Earth
« Reply #22 on: July 29, 2009, 06:59:08 am »

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):
Code: [Select]
<?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:
Code: [Select]
<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
Logged
Pages: 1 [2]   Go Up
 

Page created in 0.814 seconds with 28 queries.