Google Map in Coppermine Gallery, version 2 (of mod and api) - Page 2 Google Map in Coppermine Gallery, version 2 (of mod and api) - 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

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 2 Guests are viewing this topic.

Tranz

Quote from: pelhrimak on May 07, 2006, 04:25:43 PM
I cannot upload plugins, dont know why, I have chmod 777 ant  :'(
Could you please create a new thread in the 1.4 plugins support board so that the issue could be resolved?


DocMedicus

Hy Tranz,

really great work. It's working very well. :D
I have only one problem: the overviewmap appears a little beside center browser. I tried to set it to the right bottom of the map but I couldn't figure out yet. How it works on your site?

Btw. I changed again the "$query" in "map.inc.php" so that only a choosenone picture of an album appears in the map.
Tomorrow I will upgrade my side with your Version2 so I could post a link again for example.

Greetings
DocMedicus

Tranz

Quote from: DocMedicus on May 07, 2006, 11:06:41 PM
Hy Tranz,

really great work. It's working very well. :D
I have only one problem: the overviewmap appears a little beside center browser. I tried to set it to the right bottom of the map but I couldn't figure out yet. How it works on your site?
Sorry, I keep forgetting to edit the notes. There is a bug in the current api version. If you go into config and switch to the dev version of the maps api, that should fix it. Of course, it's not perfect because it covers the ToU, but that's Google's problem. :)

Tranz

This is a different version of editOnePic.php. The difference is that instead of double-clicking to get the coordinate value, you drag the marker to the destination. The nice thing about this is that the coordinate values show up immediately, rather than after you submit the form.

FIND:
define('EDITPICS_PHP', true);

ADD:
define('GMAP_PHP', true);
define('REGISTER_PHP', true);



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

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



FIND:
$update .= ", user4 = '".addslashes($user4)."'";

after it, ADD:
    $update .= ", latitude = '".addslashes($latitude)."'";
    $update .= ", longitude = '".addslashes($longitude)."'";




FIND:
if (GALLERY_ADMIN_MODE && $CURRENT_PIC['owner_id'] != USER_ID) {
  get_user_albums($CURRENT_PIC['owner_id']);
} else {
  get_user_albums();
}


AFTER it, ADD:

$map_key = $CONFIG['gmap_api_key'];
$use_dev_version = $CONFIG['gmap_version'];
// if version config is set not to use development version, use 2 (current 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'];

//Google Maps API mysql fun
$query = "SELECT *
FROM {$CONFIG['TABLE_PICTURES']}
WHERE
pid = {$CURRENT_PIC['pid']}
LIMIT 1;
";
$result = cpg_db_query($query);

if($row = mysql_fetch_array($result))
{
    $CURRENT_PIC = $row; //send a copy to get_pic_url it messes with the vars
$latitude = $row['latitude'];
$longitude = $row['longitude'];
// by default, the center coordinate is the picture's latitude and longitude
if (abs($latitude) + abs($longitude) > 0) {
$default_center_coord = $latitude . ',' . $longitude;
$coordinates = $latitude . ',' . $longitude;
} elseif ($CONFIG['gmap_default_center'] != NULL) { //if the picture doesn't have lat/long info, use the default value
//$coordinates = 'no data';
$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';
}
}




FIND:
// If this is the users gallery icon then check it

BEFORE it, ADD:
//lat and long
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$lang_gmap_php['coordinates']}
                </td>
                <td width="100%" class="tableb" valign="top" colspan="2">
                <input type="text" style="width: 100%" name="coordinates" maxlength="255" value="{$coordinates}" class="textinput" id="coordinates"/>
                </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;
}



FIND:
pagefooter();

AFTER it, ADD:
if ($CONFIG['gmap_editOnePic_map'] == 1) {
$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());

// "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();

GEvent.addListener(markerD, "drag", function(){
document.getElementById("coordinates").value=markerD.getPoint().toUrlValue();
});

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

}


IF you FIND:
$THUMB_ROWSPAN=5;

REPLACE with:
$THUMB_ROWSPAN=6;

Tranz

This is a different version of editpics.php. The difference is that instead of double-clicking to get the coordinate value, you drag the marker to the destination. The nice thing about this is that the coordinate values show up immediately, rather than after you submit the form.

FIND:
define('EDITPICS_PHP', true);

ADD:
define('GMAP_PHP', true);
define('REGISTER_PHP', true);



FIND:
$THUMB_ROWSPAN=5;

REPLACE with:
$THUMB_ROWSPAN=6;


FIND:
array($CONFIG['user_field4_name'], 'user4', 0, 255),

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


FIND:
$user4       = get_post_var('user4', $pid);

after it, ADD:
                $coordinates = get_post_var('coordinates', $pid);


FIND:
$update .= ", user4 = '".addslashes($user4)."'";

after it, ADD:
$coordinates = explode(',',$coordinates);
$latitude        = $coordinates[0];
$longitude        = $coordinates[1];
$update .= ", latitude = '".addslashes($latitude)."'";
$update .= ", longitude = '".addslashes($longitude)."'";



FIND:
                $isgalleryicon_disabled = ($CURRENT_PIC['category'] < FIRST_USER_CAT) ? 'disabled="disabled" ':'';

AFTER it, ADD:
    global $CONFIG, $pid, $map_key, $default_center_coord, $default_zoom_level, $map_code, $coordinates, $lang_register_php, $lang_gmap_php, $version;
    $pid = $CURRENT_PIC['pid'];
$coordinates = $latitude . ',' . $longitude;
$map_key = $CONFIG['gmap_api_key'];
$use_dev_version = $CONFIG['gmap_version'];
// if version config is set not to use development version, use 2 (current 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'];

//Google Maps API mysql fun
$query = "SELECT *
FROM {$CONFIG['TABLE_PICTURES']}
WHERE
{$CONFIG['TABLE_PICTURES']}.pid = {$pid}
LIMIT 1;
";
$result = cpg_db_query($query);

if($row = mysql_fetch_array($result))
{
    $CURRENT_PIC = $row; //send a copy to get_pic_url it messes with the vars
$latitude = $row['latitude'];
$longitude = $row['longitude'];
// by default, the center coordinate is the picture's latitude and longitude
if (abs($latitude) + abs($longitude) > 0) {
$default_center_coord = $latitude . ',' . $longitude;
$coordinates = $latitude . ',' . $longitude;
} elseif ($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';
}
$map_code .= <<<EOT
var map$pid = new GMap2(document.getElementById("small_map$pid"));
map$pid.setCenter(new GLatLng({$default_center_coord}), {$default_zoom_level});
map$pid.addControl(new GSmallMapControl());

/////Draggable markers

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

markerD$pid.enableDragging();

GEvent.addListener(markerD$pid, "drag", function(){
document.getElementById("coordinates$pid").value=markerD$pid.getPoint().toUrlValue();
});

EOT;
}

//show map if configured
if ($CONFIG['gmap_editpics_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$pid" style="width: 300px; height: 300px; color: black; margin: 5px auto;"></div>
                </td>
        </tr>
EOT;
}



FIND:
<input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput" />

REPLACE with:
                <input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput" id="$name" />
                </td>
        </tr>

EOT;
}       

//array($lang_gmap_php['coordinates'], 10, 255, 'latitude', 'longitude'),
//function form_input($text, $name, $max_length)

function form_input_gmap($text, $name, $max_length, $latitude, $longitude,$field_width=100)
{
    global $CURRENT_PIC, $coordinates;

    $latitude = $CURRENT_PIC[$latitude];
    $longitude = $CURRENT_PIC[$longitude];
if (abs($latitude) + abs($longitude) > 0) {
$coordinates = $latitude . ',' . $longitude;
} else {
$coordinates = '';
}
    $value = $coordinates;
    $name .= $CURRENT_PIC['pid'];
    if ($text == '') {
        echo "        <input type=\"hidden\" name=\"$name\" value=\"\" />\n";
        return;
    }

    echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                        $text
        </td>
        <td width="100%" class="tableb" valign="top">
                <input type="text" style="width: {$field_width}%" name="$name" maxlength="$max_length" value="$value" class="textinput" id="$name" />



FIND:
                            case 4 :
                                    form_options();
                                    break;


AFTER it, ADD:
case 10 :
                                    form_input_gmap($element[0], $element[1], $element[3], $element[4], $element[5]);
                                    break;



FIND:
pagefooter();

AFTER it, ADD:
if ($CONFIG['gmap_editpics_map'] == 1) {
$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()) {
// "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);

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


DocMedicus

Hy Tranz,

thanks for your fast support yesterday. Now its working.

Here is a demolink for V2:http://www.hamburg-kompakt.de/cpg143/map.php

Thanks again  :-* and have a nice day.
DocMedicus

tibu

Is there a way to install this mod without using the master template plugin?
The reason is I have installed a DigiBug photo/gift ordering plugin and the master template plugin conflicts with it. :(

Would It be better to use V1 of this mod?

EDIT TO ADD:
It seems that the sample section of the master template is what was conflciting with digibug (the Google Analytics section). So I no longer need to install without using the master template, I am going to remove the google analytics section from the master template plugin and reinstall it. I don't know how may of you are using the DigiBug plugin, but if you are hopefully this information helps you out.

Tranz

Just so you know, you don't need to reinstall the plugin every time you edit codebase.php

So is the issue resolved? :)

tibu

Oh yes, thanks for mentioning that I don't need to reinstall, I was only doing that because I don't have access to ftp where I am at right now. (I was using the plugin upload in pluginmgr.php to upload changes).

YES the issue is resolved.  ;D

Thanks again for a great mod with clear instructions.

lgpfort

Hi Thu,
Ver 1 is working on http://www.mobipics.net/vspace/mobimaps3.php
So I installed cpg145 on another site http://www.mobilogs.net/cpg/vistamap.php
and added the Ver 2 using the master template, but no success.
Not sure what to check next.

Tranz


tibu

The map shows up on the My Favorites/Lightbox page. Since it is on your site, I assume this is by design. Is there a way to remove it from appearing on that page?

Tranz

That's because My Favorites is just another type of album that is displayed in thumbnails.php. If you want to filter it out, change the modified code in thumbnails.php to this:
if ($album != 'favpics') {
$center_avg_coords = TRUE;
include('include/map.inc.php');
}

rafynet

I know my problem most likely has to do with the CSS for gmap (codebase.php) but i followed the instructions to the tee and the map displays all funny ... outside of the 'designated' area.

Please help

www.rafy.net/gallery/map.php
login: test
pw: test

Tranz

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

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

You can also remove the stuff between <script> in codebase.php that has to do with Google Analytics if you are not using it.

teamsand

Hi Im really interested in the coppermine capabilities of the map mod, and so far yourslooks great, I love the multi-tab feature. I was wondering If you had any plans to allow for registered users to tag thier albums or photos onto the map? This would be pretty awsome as no other app does this yet ( trust me ive spend weeks/months testing the only thing that comes close is the gallery2 map mod which Ive helped work on, but the gallery2 user control is awful). I would be more than willing to pay/donate a nice amount for this kind of user permission functionality.

Tranz

#37
Quote from: teamsand on May 23, 2006, 06:16:22 PM
Hi Im really interested in the coppermine capabilities of the map mod, and so far yourslooks great, I love the multi-tab feature. I was wondering If you had any plans to allow for registered users to tag thier albums or photos onto the map? This would be pretty awsome as no other app does this yet ( trust me ive spend weeks/months testing the only thing that comes close is the gallery2 map mod which Ive helped work on, but the gallery2 user control is awful). I would be more than willing to pay/donate a nice amount for this kind of user permission functionality.
Yes, I would like an easy way for people to click a point on the map and get a popup to upload a file. If I don't have anything else to do this three day weekend, I'll look into.

However, your registered users can still add images to the map, in a roundabout way. They upload the file(s), then if you permit them, when they go to edit the files, a map will display just as it does for admin. Unfortunately, I haven't been able to get it to work on the upload.php file, which is the form they see as they upload. They have to edit the file after the fact. This has been fixed, so the user can enter coordinate info when the upload the file.

teamsand

Ah ok that would be nice, I actually havn't installed coppermine yet since Ive been with gallery2 for so long but its persistent lack of user control and permission has me leaving. I will throw this up and test it out.

You can see my oldish gallery2 map here ( http://gallery.dotnature.com/main.php?g2_view=map.ShowMap) that I made a custom infowindow and style for, the directions and meta data come in handy.

looking forward to helping out, thanks.

Tranz

Quote from: teamsand on May 24, 2006, 05:24:27 AM
You can see my oldish gallery2 map here ( http://gallery.dotnature.com/main.php?g2_view=map.ShowMap) that I made a custom infowindow and style for, the directions and meta data come in handy.

looking forward to helping out, thanks.
The map you are using has some nice features.

I'm looking forward to your help. :) Frankly, I don't always know what I'm doing. I just know to search, and copy/paste/edit. It would be great to collaborate with someone more versed than I am in the maps api.