Hi Florian (original creator) and every people,
Thanks to a good idea of a gf I searched a plugin to display a map with location (lat/long) for pictures of my website.
I tested several but your plugin is the better.
But a problem with your plugin was all pictures were already saved with data location.
It was not my case.
I wanted a solution like your plugin but with a module to save data location for every picture on a empty map (from google maps).
Then after some hours to work, i writed this module.
Here are the explanations :
Fields in the TABLE_CONFIGI added 2 new fields in the TABLE_CONFIG in the script 'histotag_install.php' :
//Last geodata used By Pierre BASMOREAU (28/09/2010)
if (!$CONFIG['plugin_flf_histotag_lastlatitude']) {
$sql = "insert IGNORE into {$CONFIG['TABLE_CONFIG']} values ('plugin_flf_histotag_lastlatitude','0.000000')";
cpg_db_query($sql); }
if (!$CONFIG['plugin_flf_histotag_lastlongitude']) {
$sql = "insert IGNORE into {$CONFIG['TABLE_CONFIG']} values ('plugin_flf_histotag_lastlongitude','0.000000')";
cpg_db_query($sql); }
//End of last geodata
These fields save the last location used after creating geodata of an image.
Script "creategeodata.php"This new script is placed at the root of your plugin and works only in the admin mode.
This script is based on code of this website :
http://itouchmap.com/latlong.htmlI cleaned this code to keep the essentiel.
a)
For a picture WITHOUT geodata:
It displays an empty map (from Google Maps) just to locate the place of picture (the thumb is displayed under the map).
A submit button saves the current location of the marker into the table "plugin_flf_histotag" (fields : 'exif_GPS_GPSLatitudeRef', 'exif_GPS_GPSLatitude_1', 'exif_GPS_GPS_Latitude_2', 'exif_GPS_GPSLatitude_3', 'exif_GPS_GPSLongitudeRef', 'exif_GPS_GPSLongitude_1', 'exif_GPS_GPS_Longitude_2', 'exif_GPS_GPSLongitude_3').
b)
For picture WITH geodata :
The same map is displayed but with the marker located in the lat/long from the picture. So if the location is bad, administrator can change it.
After saving the new location of picture, latitude and longitude are saved in these 2 new fields defined above.
This location is used to start a new location for a next picture near the previous.
Script "include/histotag_support.php":
I done some changes in the functions 'renderGeoButton' and 'GenerateLinkToMap'.
a) First, on function 'GenerateLinkToMap', I wanted that this function returns always a result with difference between 'user mode' and 'admin mode'. The link returned in admin mode is not used.
function GenerateLinkToMap($CoppermineID) {
// Generate a Link to the Google Map for the picture with the given $ID
// 1st read GPS EXIF-Data from Datbase
// IF exists, convert to decimal output for google Maps
// Then generate link to open new map
// New map is being generated with code from map.php
/******************************************************************************
DATE: 28/09/2010 By Pierre BASMOREAU
function returns always a link
******************************************************************************/
global $CONFIG, $flf_lang_var;
$query="select * from {$CONFIG['TABLE_PREFIX']}plugin_flf_histotag where pid='{$CoppermineID}'";
$vResult = cpg_db_query($query);
$array = mysql_fetch_assoc($vResult);
if ($vResult) {
// found data in table 'plugin_flf_histotag'
$lat_hour=flf_calc($array['exif_GPS_GPSLatitude_1']);
$lat_min=flf_calc($array['exif_GPS_GPSLatitude_2']);
$lat_sec=flf_calc($array['exif_GPS_GPSLatitude_3']);
$long_hour=flf_calc($array['exif_GPS_GPSLongitude_1']);
$long_min=flf_calc($array['exif_GPS_GPSLongitude_2']);
$long_sec=flf_calc($array['exif_GPS_GPSLongitude_3']);
// if data are ok calc latitude and longitude
if ($lat_hour && $lat_min && $lat_sec && $long_hour && $long_min && $long_sec) {
$flf_longitude =degree2decimal($long_hour."h".$long_min."m".$long_sec."s".$array['exif_GPS_GPSLongitudeRef']);
$flf_latitude=degree2decimal($lat_hour."h".$lat_min."m".$lat_sec."s".$array['exif_GPS_GPSLatitudeRef']);
$maplink = <<<EOT
plugins/flf_histotag/include/histotag_map.php?width={$CONFIG['plugin_flf_histotag_mapwidth']}&height={$CONFIG['plugin_flf_histotag_mapheight'] }&apiKey={$CONFIG['plugin_flf_histotag_apikey'] }&latitude={$flf_latitude}&longitude={$flf_longitude}&type={$CONFIG['plugin_flf_histotag_mapmode']}&showcontrol={$CONFIG['plugin_flf_histotag_changemaptype']}
EOT;
$returnvalues[0]=$maplink;
$returnvalues[1]=$flf_longitude;
$returnvalues[2]=$flf_latitude;
}
else {
// If admin mode = link on creategeodata.php (29/09/2010)
if (GALLERY_ADMIN_MODE) {
//maplink not used in this state. It is here just to return a value
$maplink = <<<EOT
plugins/flf_histotag/creategeodata.php?width={$CONFIG['plugin_flf_histotag_mapwidth']}&height={$CONFIG['plugin_flf_histotag_mapheight'] }&apiKey={$CONFIG['plugin_flf_histotag_apikey'] }&type={$CONFIG['plugin_flf_histotag_mapmode']}&showcontrol={$CONFIG['plugin_flf_histotag_changemaptype']}
EOT;
$returnvalues[0]=$maplink;
}
}
}
return $returnvalues;
}
b) Second, on function 'renderGeoButton' I wanted display a message on various cases :
- "No geodata for this picture" in user mode;
- "Create geodata for this picture" in admin mode if picture have no geodata;
- "View/Modify geodata" in admin mode when picture have location.
function renderGeoButton($template_img_navbar) {
global $CONFIG, $CURRENT_PIC_DATA, $FAVPICS, $REFERER, $lang_picinfo, $flf_lang_var;
$ref = $REFERER ? "&referer=$REFERER" : '';
switch ($CONFIG['plugin_flf_histotag_mapmode']) {
case '6':
$geo_tgt_return=generateLinkToBingMap($CURRENT_PIC_DATA['pid']);
break;
default:
$geo_tgt_return=generateLinkToGoogleMap($CURRENT_PIC_DATA['pid']);
$geo_tgt=$geo_tgt_return[0].$ref."#top_display_media";
break;
}
// $fav_tgt = "addfav.php?pid={$CURRENT_PIC_DATA['pid']}".$ref."#top_display_media";
/******************************************************************************
DATE: 28/09/2010 By Pierre BASMOREAU
$geo_tgt_return[0] returns always a link (see Function GenerateLinkToMap)
If geodata :
$geo_tgt_return[0] returns a link to show the place on map
$geo_tgt_return[1] et $geo_tgt_return[2] returns long/lat
If no geodata :
$geo_tgt_return[0] returns a link on 'creategeodata.php' only in ADMIN MODE
$geo_tgt_return[1] not exists
******************************************************************************/
// To test if geodata, add a clause $geo_tgt_return[1]
if ($geo_tgt_return[0] && $geo_tgt_return[1]) {
// GeoData found
//User mode ? ===> just show the map
if (!GALLERY_ADMIN_MODE) {
$geo_tgt=$geo_tgt_return[0];
$geo_title = $flf_lang_var['click_link'];
$geo_icon = "geo.png";
$geo_icon_hover = "geo.png";
$geo_button="
<script type=\"text/javascript\" src=\"plugins/flf_histotag/js/greybox_rightsize.js\"></script>
<td align=\"center\" valign=\"middle\" class=\"navmenu\" width=\"42\">
<a href=\"$geo_tgt\" flfwidth=\"{$CONFIG['plugin_flf_histotag_mapboxwidth']}\" flfheight=\"{$CONFIG['plugin_flf_histotag_mapboxheight']}\" class=\"flfbox\" title=\"{$flf_lang_var['notice']}\" id=\"geo_lnk\"><img src=\"plugins/flf_histotag/images/$geo_icon\" border=\"0\" align=\"middle\" alt=\"$geo_title\" id=\"geo_ico\" /></a>
</td>
<script type=\"text/javascript\">
$('#fav_lnk').mouseover(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon_hover'); } );
$('#fav_lnk').mouseout(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon'); } );
</script>
";
}
//Admin mode ? ===>view or modify geodata
else {
$geo_title = $flf_lang_var['view_modify_geodata'];
$geo_icon = "geo.png";
$geo_icon_hover = "geo.png";
$geo_button = "
<script type=\"text/javascript\" src=\"plugins/flf_histotag/js/greybox_rightsize.js\"></script>
<td align=\"center\" valign=\"middle\" class=\"navmenu\" width=\"42\">
<a href=\"javascript:;\" title=\"$geo_title\" onclick=\"return MM_openBrWindow('index.php?file=flf_histotag/creategeodata&id={$CURRENT_PIC_DATA['pid']}&latitude={$geo_tgt_return[2]}&longitude={$geo_tgt_return[1]}','Create GeoData','scrollbar=no,toolbar=no,status=no,resizable=no,width=700,height=500')\"><img src=\"plugins/flf_histotag/images/$geo_icon\" border=\"0\" align=\"middle\" alt=\"$geo_title\" id=\"geo_ico\" /></a>
</td>
<script type=\"text/javascript\">
$('#fav_lnk').mouseover(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon_hover'); } );
$('#fav_lnk').mouseout(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon'); } );
</script>
";
}
}
// Else no geodata
else {
if ($CONFIG['plugin_flf_histotag_geosupport']=='1') {
// if user mode = no link
if (!GALLERY_ADMIN_MODE) {
// show button only if parameter is set, otherwise: no button!
$geo_tgt="#top_display_media";
$geo_title = $flf_lang_var['no_data'];
$geo_icon = "nogeo.png";
$geo_icon_hover = "nogeo.png";
$geo_button = "
<td align=\"center\" valign=\"middle\" class=\"navmenu\" width=\"42\">
<a href=\"$geo_tgt\" class=\"navmenu_pic\" title=\"$geo_title\" id=\"geo_lnk\"><img src=\"plugins/flf_histotag/images/$geo_icon\" border=\"0\" align=\"middle\" alt=\"$geo_title\" id=\"geo_ico\" /></a>
</td>
<script type=\"text/javascript\">
$('#fav_lnk').mouseover(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon_hover'); } );
$('#fav_lnk').mouseout(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon'); } );
</script>
";
}
// if admin mode = show button with link to 'creategeodata.php'
else {
$geo_tgt=$geo_tgt_return[0];
$geo_title = $flf_lang_var['no_data_admin'];
$geo_icon = "nogeo.png";
$geo_icon_hover = "nogeo.png";
$geo_button = "
<script type=\"text/javascript\" src=\"plugins/flf_histotag/js/greybox_rightsize.js\"></script>
<td align=\"center\" valign=\"middle\" class=\"navmenu\" width=\"42\">
<a href=\"javascript:;\" title=\"$geo_title\" onclick=\"return MM_openBrWindow('index.php?file=flf_histotag/creategeodata&id={$CURRENT_PIC_DATA['pid']}','Create GeoData','scrollbar=no,toolbar=no,status=no,resizable=no,width=700,height=500')\"><img src=\"plugins/flf_histotag/images/$geo_icon\" border=\"0\" align=\"middle\" alt=\"$geo_title\" id=\"geo_ico\" /></a>
</td>
<script type=\"text/javascript\">
$('#fav_lnk').mouseover(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon_hover'); } );
$('#fav_lnk').mouseout(function() { $('#fav_ico').attr('src', 'plugins/flf_histotag/images/$geo_icon'); } );
</script>
";
}
}
}
$search = substr_count($template_img_navbar, "<!-- BEGIN pic_info_button -->") > 0 ? "<!-- BEGIN pic_info_button -->" : "<!-- BEGIN slideshow_button -->";
$template_img_navbar = str_replace($search, $geo_button.$search, $template_img_navbar);
return $template_img_navbar;
}
On every case,
a particular link is called to view only location or to create/view/modify location by the script "creategeodata.php".
Files "lang/english.php" and "lang/french.php"I added some messages in english/french to display messages in the correct langue :
// New messages (28/09/2010) By Pierre BASMOREAU
$flf_lang_var['no_data_admin'] = 'Create geodata for this image';
$flf_lang_var['save_geodata'] = 'GeoData saved successfull';
$flf_lang_var['center_marker'] = 'Center marker';
$flf_lang_var['view_modify_geodata'] = 'View/Modify geodata';
$flf_lang_var['submit_geodata'] = 'Tag picture';
// End of new messages
U can test this module on your website.
U can find these files attached here.
I hope my work will be accepted on a futur version of your plugin (I used version 1.6)
Regards
Pierre