Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[NEW PLUGIN] GoogleMapByCat v1

(Page 2 of 3)
> > > >
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Andy

many thanks for that.

regards
Colin Thompson
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Andy

I've noticed that some address's that I have for listings do not work, no matter how I try?

eg. http://www.bookbedandbreakfast.com/...r/Ridgeview_619.html

I've different variations of the address:

Ridgeview, Scoresdown, Lynton EX35 6LJ
Scoresdown Farm, Lynton EX35 6LJ

With this situation is there any 'work around' to use 'lat / long' co-ordinates?

Lat: 51.2058
Long: -3.8113

Thanks
Colin Thompson
Quote Reply
Re: [colintho] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi,

You could just try manually adding it into the glinks_GoogleMaps table, with the co-ordinates you gave. I may add in something, so that you can manually add an entry for a link too, as I'd imagine there may be a few people that would like that feature. Gotta pop into town now though, as my cars got some problems, and I need to go get them sorted :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
This 'quick' work around is OK if you want to use 'precise' co-ordinates for the location map on the DETAILED page, as sometimes the ZIP / postcode will only provide a general location marker.

By adding Latitude + Longitude fields to the Links properties table, which can be used for manually adding location co-ordinates. Then editing / adding some extra code to the 'Google Maps' code that goes into the detailed.html page.

This only works for the DETAILED page and will not effect / update the 'category' map, this will still use the location co-ordinates from the address fields.

NOTE: the Plugin "GoogleMap" has a tool to 'refresh' the lat / long' co-ordinates, using the link labelled "Delete a Links long/lat values" - this will then 'grab' the new data during next build.

<%-- START GOOGLE MAP STUFF --%>
<%if LongVal%>
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2.x&key=<%API_Key%>"></script>
<style>.gmap {
margin: 0px;
padding: 0px;
}
.middleColumn {
margin: 0px;
padding: 0px;
}</style>
<div style="padding: 10px 10px 10px 10px;">
<div id="ForumMembers_mapdisplay" style="width: 500px; height: 300px" class="gmap display"></div>
</div>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("ForumMembers_mapdisplay"));
var center = new GLatLng(<%if Latitude%><%Latitude%><%else%><%LatVal%><%endif%>,<%if Longitude%><%Longitude%><%else%><%LongVal%><%endif%>);

map.setCenter(center, 15);
map.enableContinuousZoom();
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());

m0 = new GMarker(new GLatLng(<%if Latitude%><%Latitude%><%else%><%LatVal%><%endif%>,<%if Longitude%><%Longitude%><%else%><%LongVal%><%endif%>));
GEvent.addListener(m0, "click", function() {
m0.openInfoWindowHtml("<h2><%Title%></h2>");
});
map.addOverlay(m0);

}
else {
alert("Your browser is not compatible with the mapping tool.");
}
//]]>
</script>
<%endif%>
<%-- END GOOGLE MAP STUFF --%>


As a quick work around, this appears to work
Colin Thompson

Last edited by:

colintho: Oct 28, 2008, 4:31 AM
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi,

Version 1.2 is now available from the Members Area.

This has a fix in it, to combat the issue where the maps were going funky (markers not showing, zoom level box messed up etc). Please anyone who uses this plugin, upgrade to this version (just upload, install and voila)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Piers1] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hello Piers

did you get the 'hover effect' working within GoogleMapforCat ?

which part did you edit to get that working?
Colin Thompson
Quote Reply
Re: [colintho] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi there Colin,

Here is an example from my live site of the hover effect;
Stagelink.com UK Trucking

However I had to directly edit Andy's code in GoogleMapForCat.pm to get this to work. I am using the original version, which will now not be the current version.
I would recommend looking at the site I referenced first and copying their source code and then working out which bits to swop out with Andy's code.
This not really recommended as the plugin will break if you upgrade the plugin at a later time.

Cheers,

Piers
Quote Reply
Re: [Piers1] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Thanks for the info.

This is such a great plugin, I'd rather not mess with the 'plugin code' (my skills dont go that far)

Would be really good if Andy adds this function (mouseover effect) to the plugin at some point in the future when workload permits?

Perhaps there could be an option: 'clickable marker' or 'mouseover marker'?

option to add 'text' to the InfoWindowHtml

option for the category map to show 'links' or 'sub-categories' or both?

Andy, keep up the great work.

regards
Colin Thompson
Quote Reply
Re: [colintho] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi,

I'll try and get it added in as an option. Still pretty busy =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi Andy,

Is it possible to have different icons for the markers? I'll like to have red and blue balloons for my icons so probably we can add a new field for each site where we can upload their icon, do you think that's possible?

Thanks for this nice plugin :)

Jesus
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi,

Mmm.. not sure. The code I use for this plugin was just something I found on another site (showing you how to use it), so wouldn't know really how to assign a different marker image for each one - I'll post something on their support group, and see if anyone can point me in the direction.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi,

I found some code so that the red icon can be changed to a different color, for each link - however, its not a simple case of just editing the script, so would need some custom work. regarding uploading a custom icon, I'm not sure how we could do that though :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Hi Andy,

I just got an idea... lets see if this can be done ;)

I have this code:

Code:
var iconMark = new GIcon(G_DEFAULT_ICON);
iconMark.image = <%IconUpload%>;
var iconMarksize = new GSize(38,42);
iconMark.iconSize = iconMarksize;

Which help us have custom icons per Marker. Now as you can see I think we need to create a new field on the database (IconUpload) and then just add the code to the plugin, I think this could be done.

When you use your own icon for the marker you have something like this:

Code:
function addtag(point, address) {
var marker = new GMarker(point, iconMark);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(address); } );
return marker;
}
var point = new GLatLng($article.m_lat$,$article.m_lon$);
var address = '<%PointAddress%>';
var marker = addtag(point, address, iconMark);
map.addOverlay(marker);

I think I'm also covering here another point to add the address to the same point as someone else asked before using the PointAddress variable (that can be also add it to the GLinks db, as we're doing it with the IconUpload).

Now as per your pluign code, I'm seeing this (around line 197):

Code:
$back .= qq|
var iconMark = new GIcon(G_DEFAULT_ICON);
iconMark.image = $link->{IconMark};
var iconMarksize = new GSize(38,42);
iconMark.iconSize = iconMarksize;

function addtag(point, address) {
m$i = new GMarker(new GLatLng($lat,$long));
GEvent.addListener(m$i, "click", function() {
m$i.openInfoWindowHtml('<h2>$link->{Title}<h2><br/>Address:$link->{PointAddress}<p><a href=\"$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}\">Ir al sitio</a></p>');
});
return m$i;
}
var point = new GLatLng($lat,$long);
var address = '$link->{PointAddress}';
var marker = addtag(point, address, iconMark);
map.addOverlay(m$i);
}
|;

I dont know if something like this might work, but I think I'm close enough, I think we need to add a couple of fields to the db (marker icon upload and marker address) and then add the code modifications, what do you think?

Jesus

PS
I write the code as I was thinking and typing so it might have some errors :p but i think that could be the idea.
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1 In reply to
I'll try and have a look - but I'm actually on vacation this week - so not doing much work ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1 In reply to
Ok, preliminary I've got it working - http://gossamerlinks.com/...UK%2Findex.html;d=1l

Here are the changes you need to make into /Plugins/GoogleMapForCat.pm:

find:

Code:
} else {
alert("Your browser is not compatible with the mapping tool.");
}

..and add this below it:

Code:
function addtag(point, address, iconimage, thelink) {


var iconMark = new GIcon(G_DEFAULT_ICON);
iconMark.image = iconimage;
var iconMarksize = new GSize(38,42);
iconMark.iconSize = iconMarksize;


var marker = new GMarker(point, iconMark);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(address + "<br><br><a href='" + thelink + "'>View More</a>"); } );
return marker;
}

Then find:

Code:
if ($CFG->{build_detailed}) {

my $detailed_url = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $hit->{LinkID} );

$back .= qq| m$i = new GMarker(new GLatLng($lat,$long));
GEvent.addListener(m$i, "click", function() {
m$i.openInfoWindowHtml('<h2>$link->{Title}<h2><p><a href=\"$detailed_url\">Click to view details</a></p>');
});
map.addOverlay(m$i);
|;

} else {


$back .= qq| m$i = new GMarker(new GLatLng($lat,$long));
GEvent.addListener(m$i, "click", function() {
m$i.openInfoWindowHtml('<h2>$link->{Title}<h2><p><a href=\"$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}\">Click to goto their site</a></p>');
});
map.addOverlay(m$i);
|;


}

..and change to:

Code:
my $address = qq|$link->{Address1}, $link->{City}, $link->{State}, $link->{ZIP}, $link->{Country}|;

$link->{MapMarkerImage} || = "http://maps.google.com/mapfiles/ms/micons/blue-dot.png";

if ($CFG->{build_detailed}) {

my $detailed_url = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $hit->{LinkID} );

# $back .= qq| m$i = new GMarker(new GLatLng($lat,$long));
# GEvent.addListener(m$i, "click", function() {
# m$i.openInfoWindowHtml('<h2>$link->{Title}<h2><p><a href=\"$detailed_url\">Click to view details</a></p>');
# });
# map.addOverlay(m$i);
# |;
$back .= qq|

var point = new GLatLng("$lat","$long");
var marker = addtag(point, "$address","$link->{MapMarkerImage}","$detailed_url");
map.addOverlay(marker);
|;


} else {


# $back .= qq| m$i = new GMarker(new GLatLng($lat,$long));
# GEvent.addListener(m$i, "click", function() {
# m$i.openInfoWindowHtml('<h2>$link->{Title}<h2><p><a href=\"$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}\">Click to goto their site</a></p>');
# });
# map.addOverlay(m$i);
# |;

$back .= qq|

var point = new GLatLng("$lat","$long");
var marker = addtag(point, "$address","$link->{MapMarkerImage}","$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}");
map.addOverlay(marker);
|;


}

You need to then also add a new field to the "Links" table, called "MapMarkerImage" .. this setup should work:

Name: MapMarkerImage
Type: CHAR
Size: 255
Form type: TEXT

That should do the trick.

If you want to make sure people don't upload too big images - then you may wanna also pass that field through the Thumb_Images (or Thumb_Images_GD) plugin, so it shrinks it down to a size that will look good on the map)

I hope you appreciate this - as I've just spent a good part of 1 1/2 hours of my last day of vacation doing this for you Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Thank you Andy, I really appreciate your work specially when you're on vacation. I hope this can help many others as I truly beleive that maps its a must on all directories.

Jesus
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Hi,

Ok, I've now made this an official release (thought I may as well, seeing as I spent so long making the changes =))

It works a little different to the above modification. Basically, a new field is added, and a set of 29 different icons. People can then select one of those icons to show - thus giving the map a bit more of a unique feel (instead of just simple red "markers")

Version 1.5 is now available from the Download Area on our site.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Hi Andy,

I donwload the new plugin version from your site and now i'm not seeing the markers, also I'm not seeing those default markers you mention. I downloaded the new version as I'll like to have the latest version of the plugin. Will you help me?

Thanks
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
What version do you now have?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Hi Andy,

Version: 3.0.4 and Plugin Version 1.5

Jesus


Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Hi,

Can you email me GLinks admin details, so I can have a look at how you have it setup?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Sure Andy, email on its way.

Thanks for looking.

Jesus
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Hi,

The problem was due to you not having the right fields in your Links table (you were missing Address1, Address2, City, State, ZIP and Country). I've added these, and also fixed up an issue with the marker image field already being used (from the last modification I suggested to you before). All looks good now :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
Thanks for checking Andy,

A few questions... On the previous version you used long/lat in order to put those values per link on the Plugins page, are those values still need it? I'll like to use it in order to display properly the icon on the map.

Also, I noticed that you adjust the field for the markers so now I can select from those default icon markers, is it possible to have an extra field so I can upload custom icon markers if I need it and then have an if statment on the page so, if its custom marker use mine or if not then use the default marker icon selected?

Thanks again for helping me with this issue, I'll enjoy a lot using it once I get it right.

Jesus
Quote Reply
Re: [Jesus] [NEW PLUGIN] GoogleMapByCat v1nk In reply to
You really don't like making my job easy, huh? LOL Whistle

Ok, all done.

I changed:

Code:
if ($link->{MapMarkerImage}) {
$link->{MapMarkerImage} = qq|$CFG->{build_static_url}/icons/$link->{MapMarkerImage}.png|;
}

..to:

Code:
if ($link->{MapMarkerImageUpload}) {
$link->{MapMarkerImage} = Get_Image_URL($link->{ID},"MapMarkerImageUpload");
} elsif ($link->{MapMarkerImage}) {
$link->{MapMarkerImage} = qq|$CFG->{build_static_url}/icons/$link->{MapMarkerImage}.png|;
}

Then added this new function to the bottom of the plugin file:

Code:
# Get_Image_URL(ID,Field)
sub Get_Image_URL {
# -------------------------------------------------------------------
# Call with <%global_name($ID,'FieldName')%>
# NOTE: This is for the CATEGORY images...

my ($ID,$field,$table) = @_;

$table ||= 'Links';

# make sure a fieldname and ID are provided...
if (!$ID || !$field) { return "You need to define the ID and fieldname."; }

# get the actual path to where the file is/will be saved...
my $schema = $DB->table($table)->cols;
my $path = $schema->{$field}->{'file_save_url'};
$path =~ s,/$,,; # get rid of trailing / at end of $path

my $image_details = $DB->table($table."_Files")->select( { ForeignColName => $field, ForeignColKey => $ID } )->fetchrow_hashref;

my $id = $image_details->{ID};
my $filename = $image_details->{File_Name};
my $file_url = $image_details->{File_URL}; # this is only the URL/folder

my @cut = split //, $id;
my $folderid = $cut[$#cut];

my $url = "$file_url/$folderid/$id-$filename";


$url =~ s|([^\/]+)$|GT::CGI->escape( $1 )|e;

return $url;

}

..and finally added a new field to your Links table, called "MapMarkerImageUpload", type: CHAR(255), form_type => FILE , and then set the file_save_url and file_save_path to a folder on your server.


Quote:
A few questions... On the previous version you used long/lat in order to put those values per link on the Plugins page, are those values still need it? I'll like to use it in order to display properly the icon on the map.

Yup, these are still used:

Code:
var point = new GLatLng("25.7208","-100.2379");
var marker = addtag(point, "7-minilogo.gif<br/>,<h2>Con-Air</h2>,Reales No. 201, San Nicolas de los Garza, Nuevo Leon, 66476, Mexico","http://maps.google.com/mapfiles/ms/micons/blue-dot.png","http://www.domain.com/cgi-bin/directorio/jump.cgi?ID=2323");
map.addOverlay(marker);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
> > > >