Google Map in Coppermine Gallery, version 2 (of mod and api) - Page 4 Google Map in Coppermine Gallery, version 2 (of mod and api) - Page 4
 

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

Google Map in Coppermine Gallery, version 2 (of mod and api)

Started by Tranz, May 07, 2006, 10:05:44 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Tranz

The problem is here:
/*
* This function changes the themes template.html as it is read into memory.
* This example adds google analytics code. (Remmed Output if you don't have a valid ID set.
*/

function change_template_html($html)
{   
//$uacct='NN-NNNNNN-N';
    $uacct='NN-NNNNNN-N';


The first line with $uacct is commented out so that is correct. But then the same line follows, uncommented out, negating the commenting out in the first line. Remove the second line.

Brunosh

TranzNDance, your great! So great!
It works !!!!

for codebase.php, I did the mistake because, twice I understood from:

QuoteFind:
$uacct='NN-NNNNNN-N';

Comment it like this:
//$uacct='NN-NNNNNN-N';

that I had to put a comment before
$uacct='NN-NNNNNN-N';
and not replace it or just add // just before it in the line.

My mistake. Sorry.

Thanks a lot again. I am very thankful.


Now as everything works, I would like to know if after that it is possible to have a script to incorporate into my blog's (dotclear) sidebar.
See here, I have in the bottom, a map that displays the connection from the world.
I would like to know if it is possible to have that kind of little map, for the main map (locations_map.php for you)
=> get a little map to display in the sidebar, about 200x135 (I guess for the proportions)... with all the geotags of all the pictures as in locations_map.php (certainly it would display just green tags with "more..." as in yours cpg), but even like this everytag would be displayed...
and after that, clicking on it, we access to the big one directly in coppermine!!!

Do you think it would be possible ?!


Tranz

There are a couple of ways that it could be done. You can check out the instructions for thumbnails.php and displayimage.php for two different ways to add a map to a page. Of course, you would need to add more stuff, like code to call the files that Coppermine needs to run.

As for the "more" marker on my map, the code for it hasn't been posted yet as I am still trying to work out issues with the clustering code. As soon as I have it working and tested, I'll post the code.

Actually, you might want to hold off doing what you want to do until I finish the cluster coding, as the small map would be a good candidate for clustering code.

Brunosh

ok good good good!
Then I'll way for it  ;)
and thank again for your help!  :)

Tranz

#64
All right. I finally figured out how to add coordinate info to a file via upload.php. It's been stumping me since v1 of this mod.

If you as admin are the only one uploading files and you use batch uploading only, you do NOT need to make this modification. This applies to people who allow non-admin users to upload via the upload form, or use the form as admin.

Open include/picmgmt.php
FIND:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)

REPLACE with:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $latitude = '', $longitude = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)


FIND:
    $CURRENT_PIC_DATA['user4'] = $user4;

AFTER it, ADD:
    $CURRENT_PIC_DATA['latitude'] = $latitude;
    $CURRENT_PIC_DATA['longitude'] = $longitude;



FIND:
    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";

REPLACE with:
    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, latitude, longitude, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['latitude']}', '{$CURRENT_PIC_DATA['longitude']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";

-----

Open upload.php

FIND:
define('ADMIN_PHP', true);

AFTER it, ADD:
define('GMAP_PHP', true);


FIND:
// The file input function. Takes the label, field name, and number of iterations as arguments.

BEFORE it, ADD:
function text_box_input_gmap($text, $name, $max_length, $latitude, $longitude) {

    global $CONFIG;
global $coordinates, $latitude, $longitude;


// Create a text box.
echo <<<EOT
<tr>
<td width="40%" class="tableb">
$text
</td>
<td width="60%" class="tableb" valign="top">
<input type="text" style="width: 100%" name="$name" maxlength="$max_length" value="$default" class="textinput" id="$name" />
</td>
</tr>
EOT;

//show map if configured
if ($CONFIG['gmap_editOnePic_map'] == 1) {

echo <<<EOT
        <tr>
<td class="tableb" valign="top" style="white-space: nowrap;">
{$lang_register_php['location']}
</td>
<td width="100%" class="tableb" valign="top" colspan="2">
<noscript>
{$lang_gmap_php['no_javascript']}
</noscript>
<!--{$lang_gmap_php['coord_instructions']}-->
<div id="small_map"></div>
</td>
        </tr>
EOT;
}

} //end text_box_input_gmap()



FIND:
                case 4 :

                    // Call the hidden input funtion.
                    hidden_input($element[0], $element[1]);
                    break;


AFTER it, ADD:
                // If the type is a coordinate text box input
                case 10 :

                    //Call the form input function.
                    text_box_input_gmap($element[0], $element[1], $element[3], $element[4], $element[5]);
                    break;



FIND:
<form method="post" action="$path" enctype="multipart/form-data">

REPLACE with:
<form method="post" action="$path" enctype="multipart/form-data" name="uploadform">


FIND:
        array($lang_upload_php['pic_title'], 'title', 0, 255, 1),

AFTER it, ADD:
        array($lang_gmap_php['coordinates'], 'coordinates', 10, 255, 'latitude', 'longitude'),


FIND:
        $user4 = addslashes($_POST['user4']);

AFTER it, ADD:
        $coordinates = addslashes($_POST['coordinates']);
$coordinates = explode(',',$_POST['coordinates']);
$latitude        = $coordinates[0];
$longitude        = $coordinates[1];


FIND:
            $result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);

REPLACE with:
            $result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $user1, $user2, $user3, $user4, $latitude, $longitude, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);


FIND:
    array('unique_ID', $_POST['unique_ID'], 4),

AFTER it, ADD:
    array($lang_gmap_php['coordinates'], 'coordinates', 10, 255, $latitude, $longitude),


FIND:
    // Close the table, create footers, and flush the output buffer.
    endtable();
    pagefooter();

(be careful because there are 5 pagefooter() in the file)

AFTER it, ADD:

//if config set, show map
if ($CONFIG['gmap_editOnePic_map'] == 1) {
$map_key = $CONFIG['gmap_api_key'];
$use_dev_version = $CONFIG['gmap_version'];
// if version config is set not to use development version, use 2 (geocodedPoint stable), otherwise, use 2.x (latest development)
if ($use_dev_version == 1) {
$version = '2.x';
} else {
$version = '2';
}

$default_zoom_level = $CONFIG['gmap_default_zoom'];
if ($CONFIG['gmap_default_center'] != NULL) { //if the picture doesn't have lat/long info, use the default value
$def_coordinates = explode(',',$CONFIG['gmap_default_center']);
$default_center_coord = $def_coordinates[0] . ',' . $def_coordinates[1];
} else { //if there is no default center, use Google, Inc address
$default_center_coord = '37.42225327545478,-122.0855712890625';
}

//This variable gets fed into master template
$gmap_code = <<<EOT
<script src="http://maps.google.com/maps?file=api&amp;v=$version&amp;key=$map_key" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("small_map"));
map.setCenter(new GLatLng({$default_center_coord}), {$default_zoom_level});
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

// "tiny" marker icon
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

/////Draggable markers
var point = new GLatLng({$default_center_coord});
var markerD = new GMarker(point, {icon:icon, draggable: true});
map.addOverlay(markerD);
markerD.enableDragging();

//gets coordinate values by dragging marker around
GEvent.addListener(markerD, "drag", function(){
document.getElementById("coordinates").value=markerD.getPoint().toUrlValue();
});

//gets coordinate values by double-clicking or moving the map
GEvent.addListener(map, 'moveend', function() {
var center = map.getCenter();
var latLngStr = center.y + ', ' + center.x ;
document.uploadform.coordinates.value = latLngStr;
});

}   else {
  alert("Sorry, the Google Maps API is not compatible with this browser");
}
//]]>
</script>
EOT;
} //end if show map


Repeat the above step except:
FIND:
    // Close the table, create footers, and flush the output buffer.
    endtable();
    echo "</form>";
    pagefooter();


Please let me know if you have trouble with your particular setup. There are 5 pagefooters under 5 conditions and I saw 2 places where the map code needed to be placed. If the map doesn't show up, please let me know what the Group setting is with regards to the Upload Method.

bongadam

Thank you very much for this great mod ! It is amazing.
I used it for few month without any problem. But now, if I have 3 or more pictures with the same lat/long, tab doesn't work (nothing is displayed when I clic to mark) and if I clic to image, a JS error occurs :


Erreur : [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.appendChild]"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: http://maps.google.com/mapfiles/maps2.59.api.js :: Lb :: line 45"  data: no]
Fichier source : http://maps.google.com/mapfiles/maps2.59.api.js
Ligne : 45


I have noticed than Brunosh'map has the same error (http://yourbde.free.fr/coppermine/map.php)

This problem is quit new, all was ok before.

I have tried to upgrade the mod with your recent modification, without success  :'(

Bongadam

ps : sorry for my poor english

Tranz

Hmmm... I have the same problem with my map and I haven't changed my map code for a while. There might have been a change to the api, though I don't see any other reports of this problem. I'll explore this further when I get home. Thanks for reporting it.

Tranz

Yeah, something happen to the api code so for now, I'd recommend rolling back the version. In include/map.inc.php

Look for this:
<script src="http://maps.google.com/maps?file=api&amp;v=$version&amp;key=$map_key" type="text/javascript">


Replace with:
<script src="http://maps.google.com/maps?file=api&amp;v=2.58&amp;key=$map_key" type="text/javascript">


This is just temporary until Google fixes the latest version.

bongadam

Thank you, it's ok with your modification  :)

In your gallery, you have "more markers" which group marker. How have you add this feature? It is very interesting.

Tranz

#69
I asked for help in the Google Group for the Map api and someone confirmed that there was a change to the api that affected our maps, though not all maps. He provided a solution that was also very simple, fortunately.

You can undo the above code change to ensure you get the latest api version.

FIND:
  this.tabs[0].contentElem = '<div style="width:'+this.tabs.length*88+'px">' + this.tabs[0].contentElem + '</div>';

Replace with:
  this.tabs[0].contentElem.innerHTML = '<div style="width:'+this.tabs.length*88+'px">' + this.tabs[0].contentElem.innerHTML + '</div>';


As for the More markers, it's still in beta and is buggy so I haven't provided the code for it. But once it works, I'll definitely share it. :)

snark

Hi all,

TranzNDance, congratulations for this mod. This is really great stuff! Most of it works fine on my gallery (at http://photos.reichertonline.be) but I have a few issues.

The Gallery Map ( at http://photos.reichertonline.be/gmaps.php , check the Venise album ) doesn't show anything.
Nor does it on the Thumbnail page for the same album.

Any clue? I'm pretty sure I made all required changes.

Thanks for your help, and for this great integration.  :)

Tranz

Do you have a link to a photo that has been assigned coordinate values?

snark

Yes, this picture for instance: http://photos.reichertonline.be/displayimage.php?album=19&pos=1
But it works fine for 1 picture and to assign them too. It's only in the thumbnail view and gallery map that it fails.

Furthermore, if I change the size of the map, it doesn't look like it's modified.

Tranz

Go to Config and enable debug mode for admin. Then go to the gallery map page. Under debug info, scroll down the list of queries until you see one or two that contain latitude in the query. It is likely that the map related queries are the last of the queries in the query part of the debug info.

Copy and paste those queries here, please.

rafynet

has anyone figured out a way to enter album coordinates in /modifyalb.php?album=x ??

btw ... this must be the coolest mod ever !!!

snark

Quote from: TranzNDance on August 24, 2006, 04:57:46 PMCopy and paste those queries here, please.
Here you are!  :)

    [16] => SELECT albums.*, pictures.*, albums.title AS title, COUNT(*) AS n
FROM cpg_albums AS albums, cpg_pictures AS pictures
WHERE
pictures.aid = albums.aid
AND ABS(pictures.latitude) + ABS(pictures.longitude) > 0

GROUP BY albums.aid
ORDER BY albums.title
; (0.105s)

Tranz

OMG! How embarrassing. A block of code was deleted from include/map.inc.php... probably from the last time I modified the post. I've updated the post accordingly. http://forum.coppermine-gallery.net/index.php?topic=31206.msg144440#msg144440

Hope that helps! Thanks for reporting this instead of giving up on the mod.

snark

Quote from: TranzNDance on August 25, 2006, 07:06:50 AMHope that helps! Thanks for reporting this instead of giving up on the mod.
It surely helped, as it's working fine now :D ! Thank you so much!

"giving up"? I know the words but not their meaning! ;D

gt4mike

Hello !

Your mod work fine on my galery, thanks !  ;D

I want resize the height from the windows in google_map.php

I join a photo and you can see wich windows i would like to resize

I have try to change the height in the CSS style from google_map.php :

<style type="text/css">

#gmap {
width: 100%;
height: 500px;
border: outset thick gray;
}

#small_map { /* for maps in editOnePic.php, displayimage.php, and editpics.php */
width: 300px;
height: 300px;
color: black;
margin: 5px auto;
}

.infowindow { /* styling for map popup  */
width: 300px;
height: 200px;
overflow: auto;
text-align: left;
}

#gmap_sidebar { /* contains thumbnails that link to points on the map. scrollbar appears if the content is too long */
background-color: black;
height: 500px;
overflow:auto;
text-align: center;
/*
padding: 0 10px 0 15px;
background-image:url(../../images/tile.gif) ;
background-repeat: repeat-y;
background-position: left;
*/
}

#gmap_sidebar img { /* adds spacing around thumbnails in the sidebar */
margin: 10px 0 0 0;
border: 2px solid black;
}

#gmap_sidebar a:hover img { /* highlights hovered thumbnails in the sidebar */
border: 2px solid silver;
}

#gmap_sidebar a:hover { /* hand cursor shows when hovered over thumbnails in the sidebar */
cursor: pointer;
}

#gmap_sidebar hr { /* style for the horizontal rule that separates groups of images in the sidebar */
width: 60%;
}

</style>


But it doesn't work. ???

Could you help me please ?

PS : sorry for my english :-\

Tranz

Could you please post the link to the file? It would make it easier to troubleshoot.