[wp-hackers] Comments and Google Maps

Roy Schestowitz r at schestowitz.com
Mon Nov 14 04:07:25 GMT 2005


_____/ On Mon 14 Nov 2005 02:00:40 GMT, [Brian Lalor] wrote : \_____

> Good evening, all.  I'm trying to find a way to plot the location of  
> commenters on a Google Map within a Page in WP.  I don't yet see a  
> plugin for this, so I'm going to attempt to whack something  
> together.  If this has already been done by someone, please let me  
> know so I can stop wasting my time and everyone elses'. :-)


First of all, I suggest you have a look at the following:

http://www.mapservices.org/myguestmap/

I  assume you are familiar with MyGuestmap already, but I should  probably
not assume anything. The service plots readership, not comments, but these
are technically similar.

I  once subscribed to the service, but did not take this further since, if
I  remember  correctly, JavaScript needed to be inserted to all pages.  In
turn, it 'calls home' and gathers statistics on somebody else's server and
exploits  somebody  else's traffic. Much like Flickr, they are willing  to
give away traffic with future expansion in mind. This can, in turn, trans-
form  the third-party service into one you are uncomfortable with (if  not
loathe).  This makes you plug-in a very desirable one in comparison and  I
think it will attract enormous interest among WordPress users, particular-
ly if it is made trivial to install. Having said that, MyGuestmap recently
moved from a .br domain to a .org domain, which is a good sign, for them.


> The basic concept is this: have a Page (in WP parlance) titled  
> something along the lines of "Reader Locations", and collect on that  
> page, via comments, the location of the commenter.  I intend to  
> create a plugin that will add several fields (post code, lat/lon) to  
> the comment form, and then, from within the page, present a Google  
> Map with the locations plotted onto it.  This started off seeming  
> fairly simple, but now I'm starting to see some additional complexity.


Will it perhaps be worth anonymising? People might not want to be publicly
bound to an IP address or, even worse, their postcode and location. I sup-
pose you speak of a temporary (intermediate) solution here.


> It looks like, in order to store the additional geographical  
> information about the comment, I will have to create my own table in  
> the DB.  Is this correct?  Is there any existing mechanism for  
> storing arbitrary data about a comment?


How about a schema for 'user'? If commenters return time after time, there
might  be plenty of duplication. If you change the database, however, this
would make the plug-in difficult to install and retract.


> I'd say that's the first thing I'm struggling with.  Once I'm able to 
>  store the content, enabling a Page or post with this capability will 
>  be simply adding a custom field or checking a box when editing the  
> post.  I'll probably provide another PHP template that will provide  
> the comments as an XML file to be consumed by the mapping code.


How  about  changing wp-post-comment.php (not sure about the filename)  to
include  a call to a completely separate and new function which does noth-
ing but accumulate IP addresses or locational information? This will leave
everything  else unchanged. This isolation would be a healthy one for rea-
sons I described in the previous paragraph.


> Is there a good example to follow that does something similar?


I can think of other services (including ones which use Yahoo's API) where
the  intention is assign items to locations in the map. As there are  many
of them, there is probably place for re-use of source code.

Hope it helps,

Roy

-- 
Roy S. Schestowitz      |    "In hell, treason is the work of angels"
http://Schestowitz.com  |    SuSE Linux     |     PGP-Key: 0x74572E8E
  3:55am  up 10 days 23:53,  2 users,  load average: 0.28, 0.29, 0.42



More information about the wp-hackers mailing list