Hi,
I use gallery2 (skidoo) embedded into joomla.
I got a problem to show the map into joomla with gallery2bridge.
So I found a solution because I don't need dynamic marker generation: export data to a kml file and create a map into joomla with google api to show this file, it work fine.
It works but I need to customize kml file generator.
I have albums with GPS coordinates. Into each albums I have photos without GPS coordinate.
I made a googleearth.inc modification to obtain a placemark for each album and it works. When I clic on a placemark, infowindow appear containing album thumbnail. Great.
Now my goal is to remove album thumbnail and display child items thumbnails in the infowindow when I clic on the placemark.
Here is my code:
original
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2007 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Written by Nic Roets. Placed in the public domain. */
/* Changelog:
Changed from map module 0.5.1d (Karl Newman, 2006-12-22):
* Fixed reversed longitude/latitude bug
* Fixed several bugs where conditional test variables were not initialized every pass
* Removed lots of dead code related to importing GPS track
* Validates field values to ensure they are in legal range
* Changed to use mapHelper function to retrieve field values
* Changed to recursive function to export a single item or create a hierarchy of
all subitems of current item
* Only include subitems (in particular ChildDataItems) that have GPS coordinates set
* Added support for optional 'GELookAt' field to customize how GE portrays the location
* Got rid of the View and associated form, which wasn't doing anything but confusing people.
Note that this requires a change to the "Export to GE" link in map/module.inc
to call this as 'controller' instead of 'view'.
It makes the "Export to GE" a direct link to download to Google Earth.
Further updates (Karl Newman, 2006-12-26)
* Added "Document" enclosing structure; fixed styles to avoid using deprecated icons.
Still more updates (Karl Newman, 2006-12-27)
* Use "LookAt" block for albums if they have coordinates set (still won't show a point, though)
* Include albums if they have coordinates set, even if no children do.
* Show the album thumbnail and link to the album in the folder description.
More refinements (Karl Newman, 2006-12-28)
* Changed the prefix to GoogleEarth instead of GoogleEarthAlbum, since it can be used to view a
single item as well as an album. Also, this really should be a View, not a Controller, since
it doesn't modify any data. So, I changed it to an Immediate view, patterned after
DownloadItem in the Core module. These changes will affect module.inc as well.
* Added function documentation, prefix private functions with _
*/
/**
* Module to export items to a KML file for display in Google Earth
*
* @package map
* @author Nic Roets
* @author Karl Newman
* @version $Revision: 1253 $
*/
class GoogleEarthView extends GalleryView {
/**
* @see GalleryView::isImmediate
*/
function isImmediate() {
return true;
}
/**
* @see GalleryView::isAllowedInEmbedOnly
*/
function isAllowedInEmbedOnly() {
return true;
}
/**
* @see GalleryView::shouldSaveSession
*/
function shouldSaveSession() {
return false;
}
/**
* @see GalleryView::renderImmediate
*/
function renderImmediate($status, $error) {
global $gallery;
$phpVm = $gallery->getPhpVm();
$itemId = GalleryUtilities::getRequestVariables('itemId');
list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
list ($ret, $placemarks) = GoogleEarthView::_createGETree($item, array(), array());
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
if (!empty($placemarks)) {
$outstring = '<?xml version="1.0" encoding="UTF-8"?>'
. '<kml xmlns="http://earth.google.com/kml/2.0">'
. "\n<Document><name>Gallery2</name><open>1</open>\n"
. '<Style id="PhotoIconNormal"><IconStyle>' . "\n"
. '<Icon><href>http://maps.google.com/mapfiles/kml/pal4/icon46.png</href></Icon>' . "\n"
. '</IconStyle></Style>' . "\n"
. '<Style id="PhotoIconHighlight"><IconStyle><scale>1.1</scale>' . "\n"
. '<Icon><href>http://maps.google.com/mapfiles/kml/pal4/icon38.png</href></Icon>' . "\n"
. '</IconStyle><LabelStyle><scale>1.1</scale></LabelStyle></Style>' . "\n"
. '<StyleMap id="PhotoIconPair">' . "\n"
. '<Pair><key>normal</key><styleUrl>#PhotoIconNormal</styleUrl></Pair>' . "\n"
. '<Pair><key>highlight</key><styleUrl>#PhotoIconHighlight</styleUrl></Pair></StyleMap>'
. "\n" . $placemarks . "</Document>\n</kml>\n";
$phpVm->header('Content-Type: application/vnd.google-earth.kml+xml');
$phpVm->header('Content-Description: View Gallery items in Google Earth');
$phpVm->header("Content-Disposition: inline; filename=GalleryGE-{$itemId}.kml");
$phpVm->header('Content-Length: ' . strlen($outstring));
echo $outstring;
} else {
/* Should probably return some error that no child elements had valid GPS coordinates */
}
return null;
}
/*
* Recursive function to generate the Folder and Placemark elements to represent the albums
* and items that have GPS coordinates set.
*
* param GalleryItem $item the current item/album to process
* param array $data array of arrays (keyed by itemID) of field data (keyed by field name)
* associated with the $item (e.g., GPS coordinates)
* param array $ancestors list of parent item IDs already processed (to prevent infinite loops)
*
* returns string KML subelements: folder(s) and/or placemark(s)
*/
function _createGETree($item, $data, $ancestors) {
GalleryCoreApi::requireOnce('modules/map/classes/mapHelper.class');
$returnstring = ''; /* start with a blank string */
if (empty($data)) { /* workaround for first call if no field data passed */
list ($ret, $data) = mapHelper::fetchFieldValues(array($item));
}
/* If it's an album or similar */
if ($item->getCanContainChildren()) {
/* Get all the direct children of this item, in album sort order */
list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($item);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
/* If the list of direct children wasn't empty */
if (!empty($childIds)) {
/* If we haven't already included this item in a parent folder */
if (!array_search($item->getId(), $ancestors)) {
/* Add ourselves to the ancestors array */
$ancestors[] = $item->getId();
/* Load the children */
list ($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
/* Grab the field data for the child items */
list ($ret, $fielddata) = mapHelper::fetchFieldValues($childItems);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
foreach ($childItems as $childItem) {
/* Recurse into this function with the next level down */
list ($ret, $childstring) =
GoogleEarthView::_createGETree($childItem, $fielddata, $ancestors);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$returnstring .= $childstring;
}
/*
* Only add containing folder info if there are child elements or if the folder
* has coordinates of its own.
*/
if (!empty($returnstring) or !empty($data[$item->getId()]['GPS'])) {
$coordstring = (!empty($data[$item->getId()]['GPS']))
? $data[$item->getId()]['GPS']
: '';
$LookAtstring = (!empty($data[$item->getId()]['GELookAt']))
? $data[$item->getId()]['GELookAt']
: '';
/* modif seb */
list ($ret, $childitemstring) =
GoogleEarthView::_createGEChildItem($item, $data[$item->getId()]);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$returnstring .= $childitemstring;
}
}
}
}
else { /* It's not a container item */
if (GalleryUtilities::isA($item, 'GalleryDataItem')) {
list ($ret, $childitemstring) =
GoogleEarthView::_createGEChildItem($item, $data[$item->getId()]);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null);
}
$returnstring .= $childitemstring;
}
}
return array(null, $returnstring);
}
/*
* Create name, Snippet and description elements single Placemark element
*
* param GalleryItem $item the current GalleryDataItem for which to generate text elements
*
* return string name, Snippet and description elements for the item, properly CDATA-escaped
*
*/
function _createTextElements($item) {
$returnstring = '';
GalleryCoreApi::requireOnce('lib/smarty_plugins/modifier.entitytruncate.php');
/* Get the item title if not blank, else use the file/directory name (path component) */
$title = $item->getTitle() ? $item->getTitle() : $item->getPathComponent();
/* Use the item summary for the Snippet, otherwise use the item description */
$summstring = $item->getSummary()
? GalleryUtilities::markup($item->getSummary(), 'strip')
: smarty_modifier_entitytruncate(
GalleryUtilities::markup($item->getDescription(), 'strip'),
80);
/** @todo If/when KML officially supports HTML in Snippet blocks, remove the 'strip' */
$returnstring = '<name><![CDATA[' . GalleryUtilities::markup($title)
. "]]></name>\n<description><![CDATA["
. ($item->getSummary()
? GalleryUtilities::markup($item->getSummary()) . "<br>\n"
: '')
. GoogleEarthView::_createThumbnailLink($item)
. GalleryUtilities::markup($item->getDescription())
. ']]></description><Snippet>' . $summstring . "</Snippet>\n";
return $returnstring;
}
/*
* Create a single Placemark element
*
* param GalleryItem $item the current GalleryDataItem to represent in a Placemark
* param array $fielddata field data associated with the $item
*
* return string KML placemark element
*
*/
function _createGEChildItem($item, $fielddata) {
$goodcoords = false;
$returnstring = '';
/* Select items that have GPS coordinates filled out */
if (!empty($fielddata['GPS'])) {
$posxy = explode(',', $fielddata['GPS']);
if (count($posxy) >= 2) { /* changed to >= 2 to accommodate possible elevation field */
$lat = (float)$posxy[0];
$lon = (float)$posxy[1];
$goodcoords = ((abs($lat) < 90) and (abs($lat) < 180));
}
}
if ($goodcoords) {
$coord = sprintf('%s,%s', $posxy[1], $posxy[0]);
/* This spot is one of the weird ones that wants longitude listed first */
$point = "<Point><altitudeMode>clampToGround</altitudeMode>\n<coordinates>"
. $coord . ",0</coordinates>\n</Point>\n";
/* Output Placemark to Google Earth */
$coordstring = (!empty($fielddata['GPS'])) ? $fielddata['GPS'] : '';
$LookAtstring = (!empty($fielddata['GELookAt'])) ? $fielddata['GELookAt'] : '';
$returnstring .= '<Placemark id="g2id_' . $item->getId() . '">'
. GoogleEarthView::_createTextElements($item)
. "<styleUrl>#PhotoIconPair</styleUrl>\n" . $point
. GoogleEarthView::_createLookAtBlock($coordstring, $LookAtstring)
. "</Placemark>\n";
}
return array(null, $returnstring);
}
/*
* Create a LookAt block to apply to a folder or placemark
*
* param string $GPSstring the GPS coordinates in latitude,longitude format
* param string $LookAtstring the Google Earth LookAt parameters in heading,tilt,range format
*
* returns string KML LookAt block
*
*/
function _createLookAtBlock($GPSstring, $LookAtstring) {
$headingstr = "0";
$tiltstr = "45";
$rangestr = "3000";
$returnstring = '';
$goodcoords = false;
$posxy = array();
if (!empty($GPSstring)) {
$posxy = explode(',', $GPSstring);
if (count($posxy) >= 2) { /* changed to >= 2 to accommodate possible elevation field */
$lat = (float)$posxy[0];
$lon = (float)$posxy[1];
$goodcoords = ((abs($lat) < 90) and (abs($lon) < 180));
}
}
/*
* Use sprintf and %F to force non-locale-aware float printing to avoid inadvertant
* commas in the float values. Limit decimal places for range, tilt, heading. If %F is
* not supported (PHP 4.3.9 or 5.0.2 or earlier), fall back to the raw string.
*/
if ($goodcoords) {
/* Parse the 'GELookAt' field */
if (!empty($LookAtstring)) {
$lookat = explode(',', $LookAtstring);
/*
* If at least one parameter, then #1 is the heading in degrees.
* Must be between 0 and 360 degrees
*/
if (count($lookat) >= 1 and !empty($lookat[0])
and $lookat[0] >= -360 and $lookat[0] <= 360) {
$heading = (float)$lookat[0];
$headingstr = sprintf('%.2F', $heading) == '' ? $lookat[0]
: sprintf('%.2F', $heading);
}
/*
* If at least two parameters, then #2 is the tilt in degrees.
* Must be between 0 and 90 degrees
*/
if (count($lookat) >= 2 and !empty($lookat[1])
and $lookat[1] >= 0 and $lookat[1] <= 90) {
$tilt = (float)$lookat[1];
$tiltstr = sprintf('%.2F', $tilt) == '' ? $lookat[1]
: sprintf('%.2F', $tilt);
}
/* If at least three parameters, then #3 is the range in meters. Must be > 0 */
if (count($lookat) >= 3 and !empty($lookat[2]) and $lookat[2] > 0) {
$range = (float)$lookat[2];
$rangestr = sprintf('%.2F', $range) == '' ? $lookat[2]
: sprintf('%.2F', $range);
}
}
$lonstr = $posxy[1];
$latstr = $posxy[0];
$returnstring = sprintf('<LookAt><longitude>%s</longitude><latitude>%s</latitude>'
. '<range>%s</range><tilt>%s</tilt><heading>%s</heading>',
$lonstr, $latstr, $rangestr, $tiltstr, $headingstr)
. "</LookAt>\n";
}
return $returnstring;
}
/*
* Create an HTML snippet to display the thumbnail for an item and create a link to the gallery
* item
*
* param GalleryItem $item the current GalleryDataItem to represent in a Placemark
*
* returns string HTML snippet suitable for inclusion in a CDATA-escaped description element
*
*/
function _createThumbnailLink($item) {
$hsitemLink = '';
$dthumbLink = '';
global $gallery;
$urlGenerator =& $gallery->getUrlGenerator();
$returnstring = '';
$theid = $item->getId();
/* Get the thumbnail item ID for the item */
list ($ret, $thumbs) = GalleryCoreApi::fetchThumbnailsByItemIds(array($theid));
$thumbId = $thumbs[$theid]->getId();
$dthumbLink = $urlGenerator->generateUrl(
array('view' => 'core.DownloadItem', 'itemId' => $thumbId),
array('forceFullUrl' => true, 'htmlEntities' => false));
$hsitemLink = $urlGenerator->generateUrl(
array('view' => 'core.ShowItem', 'itemId' => $theid),
array('forceFullUrl' => true, 'htmlEntities' => false));
if ($hsitemLink != '' and $dthumbLink != '') {
$returnstring = '<a TARGET="_blank" href="' . $hsitemLink . "\">\n<img src=\"" . $dthumbLink
. '" width=300 height=189><a TARGET="_blank" href="' . $hsitemLink . "\">\n</a><br>';
}
return $returnstring;
}
}
?>
Hope you'll understand what I say...
Does anyone could help me?
Thanks,
ledom
Posts: 77
Noboby could help me?
Posts: 508
Sorry, I forgot to check this forum. You might be interested in some changes I recently checked into SVN. It changes the Google Earth KML generator into a Smarty template (like the rest of Gallery2) that you can customize yourself without having to change the PHP. You can get it from the gmap-module project on sourceforge. I'm working on wrapping it into a release but I have to make some other changes first. It should be usable in its current state, but I can't guarantee that everything is working perfectly. If you do decide to use it, please post here with any problems you encounter and I'll try to make it a priority to help you.
Posts: 77
Excellent! i will have a look at that. Thanks
Because the problem I have with gmap module (map don't load into joomla) I decided to use kml file to show markers on the map. it works fine and it's faster than sending lot of request. You can have a look at the map here if you want: http://picturevolution.com/photos-anciennes-geolocalisees.html
My goal is to show one marker by album (only album have coord) and to show album content multiple thumbnails into infowindow. The I can use slimbox to open directly pictures from infowindow. (here is my test page: http://picturevolution.com/slimbox.html)
regards
Posts: 508
Hmmm... Well, I'm not sure my changes will support that scenario. I think it might only include items which have GPS coordinates. I'll have to look at what I've done and make sure you can do that.
Posts: 508
Okay, I've checked in the changes to support what you want to do so you can svn up to get those. Now all items in the tree are presented to the template, not just items with GPS data. You'll still have to do the work to include the photos in the infowindow, though. But now all you have to do is copy the modules/map/templates/GoogleEarth.tpl into a new "local" directory (i.e., modules/map/templates/local/GoogleEarth.tpl) and then modify that file and it should use your modifications in preference to the default file I supply.
A couple hints: The $treeList nodes have an attribute $node.hasChildren which will be true if the node is an album. If it's an album and at least one of it's descendants has GPS data, the node will have an attribute $node.childHasGeoData set to true (this is how I know I need to create a folder in order to display a sub-item later). You can check !empty($item.geoData) to see if the current node/item has GPS data.
Good luck! I can probably give you some more help with your template if you get stuck.
Posts: 39
Hi there,
I follow very closely your discussion because I am still hoping to find a solution to make G2+map module+Joomla 1.5+php5 work together. It seems that the bug has been clearly identified in other posts (http://gallery.menalto.com/node/81796), it would be nice to correct that bug instead of finding a working around with kml file that does not support original functionalities. I can help on that issue if necessary (i have some little xp on php).
Looking forward reading you
David
Posts: 77
Thanks, i'll have a look to that when i'll have more time.
Be sure I'll post the result.
If it work it will be excellent, it's excatly what i need to have the simplest navigation on my website.
Posts: 77
Not enough time to work on it. For me the kml solution is the better way. I spend lot of time to find where the error come from but cannot understand what is the problem. May be time limit.
Posts: 77
Hi, here i'am!
First, I think it is a good idea to make a kml template.
I customized the tpl file to allow opening thumbnail into slimbox and it works (it's just a test, not what I want to do.). Here is the code:
Now, to add all child's thumbnails into the infowindow, I don't know how to do. I think I must use foreach but don't know how to use it... I tried {foreach( $item.childItems as $item.childItem )} but got an error...
Could you help me please? Tanks!
Posts: 508
Yep, you have the right idea. The way I have it set up, there are two parallel arrays, $treeList and $GEItems. $treeList defines the album structure, while $GEItems has the data for the individual items (title, description, coordinates, thumbnail, etc.) So, when you encounter {if $node.childHasGeoData}, you'll have to create a new iteration of $treeList (with a new loop variable, such as $node2) inside that if block and loop until you reach the node you're currently at, which is the parent album. Then iterate through the child items (which you can monitor by using a $depth2 variable) and when your depth drops back to the level of your current album, then you're done.
Sorry, that's probably pretty confusing. It's just a brain dump, and I'm in a rush right now. If you still need some help, let me know and I'll try to give you some code to test.
Posts: 77
Wow! thank you. I understand your explanation (2 arrays) but the problem is that I don't you how to code it... i'm not programmer
Posts: 508
Okay, I'll play around with it and see if I can come up with something for you. Give me a few days, though. By the way, I was mistaken--the trigger you're looking for in your case is {if $node.hasChildren && !empty($item.geoData) && !$node.childHasGeoData} That will give you the albums which have coordinates where none of the album children have coordinates.
Posts: 508
Okay, here ya go. Create a new directory named "local" in the modules/map/templates directory, then copy the GoogleEarth.tpl into the local directory. Edit it to replace the description section with this code:
You'll probably have to tweak it for formatting, or if you want to add the item titles, etc., but hopefully it will do what you want.
Posts: 77
YES! thank you very much! it works fine. I add slimbox functionality. Have a look: http://picturevolution.com/test.html
Just one thing, even if I remove <br> I cannot show pictures side by side... if you have a tip...
Thanks Siliconfiend
Posts: 508
Yeah, I saw that when I was testing it. I could show 2 pictures side-by-side (with 150 pixel thumbnails), but if I put a third in there, it was cut off. (I was testing in Google Earth). You might try limiting the thumbnail sizes with the maxSize argument to g->image, or try wrapping the thumbnails in a <div> (and then messing with the style) or maybe put them in a table if you have to.
Posts: 77
Ok, it works for me! I removed all <br>, add a <table> and change the width into egeoxml (use it because I need it to use clusterer). Now the problem is that resized pics are not transmetted to tpl and I need it to show into slimbox (original pics are huge).
I understand thaht I need to add this to googlearth.inc:
then
foreach ($items as $item) { $id = $item->getId(); $GEItems[$id] = (array)$item; /* This assumes that every item has a valid thumbnail. May not be true. */ $GEItems[$id]['thumbnail'] = (array)[$id]; $GEItems[$id]['resizes'] = (array)[$id]; if (array_key_exists($id, $geoData)) {
and use $subitem.resizes to show them, but it don't works (blank page).
Could you say me whats wrong?
Posts: 508
You nuked the array name. Try this:
$resizes is an array, so note the extra [1] subscript on the end there. You might need to use [0] or [1] or [2], etc., to get the size you want.
Posts: 77
Ok, then by adding [1] I access to the id of a resized picture.
In tpl file I use: $subitem.resizes
and it doesn't work... Don't understant why. My links are now: ...?g2_view=core.DownloadItem&g2_itemId=Array" ??? why array?? I tried to use $subitem.resizes[1] but it's not better. resizes is a column no?
It seems taht i'm learning php... I think I understant and... No...
Posts: 508
Well, without digging into it more, I'm not entirely sure what fetchResizesByItemId actually returns. Can you post the part of the tpl file where you're using $subitem.resizes?
Oh, one thing you could try--it's possible the casting to an array is happening too soon, so try wrapping the argument in parentheses. In other words:
Posts: 77
Same result with or without ()
I join the files (tpl, inc and kml result)
I found that about fetchResizesByItemId: http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methodfetchResizesByItemIds. It seems to return an array of id but I don't find and understand the structure of the array.
I made a test by replacing $subitem.thumbnails by $subitem.resizes, just to test, in this case I obtain a render problem of the <img>
Not a piece of cake this stuff...
Posts: 508
Ah. I think I see the problem now. You're trying to pass the $subitem.resizes as the itemId to the g->url function. Try $subitem.resizes.id instead.
Posts: 77
Your right! thanks! I though resizes contains the ids. With 0, it works, not with 1: $GEItems[$id]['resizes'] = (array)$resized[$id][0];
Excellent, now I'll can simplify the navigation on my website for a better experience.
Next step, I'll try to add multiple elements into slimbox to navigate easily into subitems (Slimbox.open([["left.jpg"], ["middle.jpg"], ["right.jpg"]], 1, {loop: true});)
Thanks you so much for this friendly help. Work on an open source software like gallery2 with people like you is a pleasure. I learn a lot of things.
Posts: 508
You're quite welcome. I'm glad I could help. Good luck with the rest of your customization. I've never used Slimbox or Lightbox, but if there's anything else I can help you with, feel free to ask.
Posts: 77
Ok, it works fine! and I'm so glad to
I limited the number of subitem at two, integrated correctly slimbox, now I can see directly photographs "before" (last century) and "after" (now) onto the map into infowindow. I like that, really simpler to use. You can have a look here: http://picturevolution.com
The link "Agrandir" show pictures into slimbox.
Now, another question: actually using the view in googlearth button download the kml file. Is it possible to change that to make it overwrite a kml file onto the server?
Thanks
Posts: 508
I'm not entirely sure I understand what you want to do. I think you mean you want to get the KML file from the gallery site every time instead of loading a static file from your web site. If that's what you want to do, it should be pretty easy. Probably just change the url to the KML file to be http://www.yourgallerysite.com/gallery/main.php?g2_view=map.GoogleEarth&g2_itemId=7 (I'm assuming an itemId of 7 is the root of your gallery--it seems to be for most installations).
Posts: 77
Yes, sorry if it's not really clear...
What I want is to save the kml file on the server instead of download it on my computer and the upload it on the server. But your solution works fine even if it's slower because of générating the kml file each time the page is loaded.
I got another question: do you think it is possible to add into infowindows a link to the next marker in the kml file? I look to the map API documentation but I don't find a solution.
Posts: 508
I think that's going to be very difficult if not impossible, because you're using a KML file instead of the map API directly, so you don't have access to the marker references to create those links.
Posts: 77
May be I'll try to add a sidebar, like this: http://tech.reumer.net/google-maps/demo-google-maps/kml-sidebar.html
I come back to my previous question. Actually I use http://www.yourgallerysite.com/gallery/main.php?g2_view=map.GoogleEarth&g2_itemId=7 into the map, the problem is that generating the kml is very long, and it slow down (too much) the page loading. I think the best way is to manually generate kml file, 1 time per week for exemple. Now, to do that I clic on the link to generate the file, download it on my computer, then upload it to the website with my ftp client. Is it possible, when i clic on the link to generate the kml, it is saved directly on the server, not download on my computer?
thanks
Posts: 508
I don't think there's any way to do that. If you have shell access to your server, the best way to do what you want is to set up a cron job with wget to periodically get the generated KML file. Or, hopefully I'll be able to use caching soon and then retrieving the file should be much faster.
Posts: 77
It's impossible to save the kml file on the host by clicking on "view in googleearth" button ???
Something I don't understand: when I click on the "view in googleearth" button, a kml file is created on the host, before it is send to my computer, or not?
Another question, when I use "view in googleearth" from joomla (gallery2 embeded), it works fine for this album: http://picturevolution.com/photos-avant-apres/?g2_itemId=2033 (not a lot of subalmbums) but it don't works for this one: http://picturevolution.com/photos-avant-apres/?g2_itemId=2033 (with a lot of subalbums and photos).
All is working when I use gallery2 standalone...
I think it is a time limit problem no? do you have an idea?
I need to generate the kml file from joomla, because of the urls of the photos into the kml file.
I thought: "if it don't work into joomla, I'll use it into gallery, but I need to change urls into kml by adding myself the good "prefix" before the relative url".
So, I try to change forceFullUrl into tpl file to false to get the relative url, but I got the same urls in the kml file, I don't konw why.
Posts: 508
As far as I know, it's generated in memory and streamed to your browser. You could probably work out a way to save it to a file, but you'd have to write PHP.
Those two links are the same...
There have been some other problems reported with Joomla and the map module (but for the Map functionality, not for the KML export). It could be time limit or maybe memory related. I don't really know.
The parameter you want is forceDirect not forceFullUrl. forceDirect=true makes the urls refer to the gallery codebase path, not to your embedded (Joomla) path. In theory, it shouldn't make any difference for this application. I'm pretty sure you need to have forceFullUrl, though. Otherwise I don't think it will work in Google Earth/Maps.
Posts: 77
Ok, I understand. I thought a kml file was created on the host.
Sorry for the same urls...
Finally I found a solution: I remove g->url and change these line
<a TARGET="_blank" href="http://picturevolution.com/photos-avant-apres/?g2_itemId={$item.id}">Voir d'autres photos de ce lieu ou laisser un commentaire</a>
with the good url, now it's OK! It link to gallery2 embeded and not standalone.
For the downloading problem, may be a time limit. I ask about it into g2bridge forum. I'll post here if I got a reply.
Ok, for forceDirect. I didn't see a change because I modified googlearth.tpl and not /local/googleearth.tpl... :/
Thanks for all Siliconfiend!
Posts: 77
Hello
I got a new problem due to the size of my gallery (and memory limit -32Mo- on my share host, or may be time limit).
When I use the kml generator, I got an error 500 and no kml file upload
If I reload the page (F5), I got a kml file, but it is incomplete...
http://picturevolution.com/photos2/main.php?g2_view=map.GoogleEarth&g2_itemId=7
If I use kml generator on a smaller album, it works fine.
.
I think it is a time limit (set to 30s into phpinfo.php) or memory limit, but nothing into logs.
Do you think it is possible to make improvement (progress bar for exemple: http://codex.gallery2.org/Gallery2:Progressbar)?
I use map module from SVN.
Thanks
ledom
Posts: 508
It's hard to know what's happening. It could be failing in the template processing. I would first suspect that it's a memory problem, because I think I'm properly extending the time limit as I'm retrieving and processing items. I don't think the progress bar can help here.
Posts: 77
Ok, thanks. I think it's a memory limit problem too. Do you know how I can improve this? I think it will be better to save data into a file (or print out them on screen using echo) than into arrays in memory, to avoid memory limit. Do you think it is possible by modifying GoogleEarth.inc file?
Posts: 508
I don't know. I suspect it's not possible due to how the template system works. You could maybe revert to the old style where I directly rendered the kml file from GoogleEarth.inc and modify it from there, but the short answer is that there are probably no easy solutions.
Posts: 77
I made a test on my localhost:
Error 500 with 32Mo of memory into php.ini
Works (complete kml file) with 64Mo of memory
I don't know how to improve php and templates script to limit memory usage. So, I will try...
Posts: 77
May be I found a solution to write kml file (not download it), but I need help.
Say me if I'm wrong but the fetch smarty function sould be used to fetch template output (kml file).
Then it is simple to write it into a file with fwrite (php)
What I do:
Into googleearth.inc I add:
$phpVm->header('Content-Description: View Gallery items in Google Earth'); $phpVm->header("Content-Disposition: inline; filename=GalleryGE-{$itemId}.kml"); $ret = $template->display('gallery:modules/map/templates/GoogleEarth.tpl'); $fichier = fopen("fichier.txt", "w+"); fwrite($fichier, $template->fetch('gallery:modules/map/templates/GoogleEarth.tpl')); //ecriture de "Modification du Fichier fichier.txt" fclose($fichier); if ($ret) { return $ret; }
After executing I got a fichier.txt file.
Problem: it only contain the "Array" txt...
Any idea?
Posts: 508
I don't know if that will change anything. I suspect the memory limit is being hit within the Smarty parser.
Posts: 77
oh sorry, I don't explain correctly
It is not to avoid memory limit problem (my solution consist to divide big album into subalbums and then generate kml for subalbums)
This is only to save kml directly on the server, not downloading it because as I use kml files to show a map, it is easiest to save it than download then reupload by ftp...
Normally fetch (into smarty) return the content of the page generated by tpl (display show the content) but with this code it seems it is an array. Do you think my code is correct? I don't understand why I get an array with fetch.
Posts: 508
Okay, sorry for the slow response. Overburdened with work... Anyway, that's a simple answer. The fetch method of the GalleryTemplate class returns an array, as you've seen. The first element is a status/error code. If it's nonzero, then there was a problem. That's why you see all over the code structures like this:
So, to solve your problem, you could add a list element like this to capture the return values. You could maybe get away with just using array subscript 1. Or more explicitly (see bold part):
fwrite($fichier, $template->fetch('gallery:modules/map/templates/GoogleEarth.tpl')[1]); //ecriture de "Modification du Fichier fichier.txt"
I don't know without testing if this is valid PHP, though.
Posts: 77
Great! It works, you show me the way, thanks
fwrite($fichier, $template->fetch('gallery:modules/map/templates/GoogleEarth.tpl')[1]); //ecriture de "Modification du Fichie
doesn't work
but:
do the job!!! I get my kml into a file.