Comment Geo Maps

This is a plugin for WordPress.  It was developed initially for Streetsblog.org and has been bundled up and released on WordPress.org.

Comment Geo Maps allows you to turn a post or a page into a geo-based issue map.  You create a prompt in the form of a blog post and then people post their comments.  Each comment is geo-coded and becomes a point on the map.    In this way, a geo-based discussion ensues and the map gets populated with data around a certain topic.

Maps can be started as a post, to make it more time sensitive like in mapping participation at a city-wide event, or as a page, to make it more permanent like for mapping dangerous NYC intersections.  The page format fills the whole page and the post format puts a map at the top of the regular list of comments.

You’ll need to be relatively comfortable with php code to get the maps integrated into your theme.

This is the full page view:

screenshot_1

This is the regular post view.

screenshot_2

Installation

To install the plugin:

  1. Unzip the plugin into the /wp-content/plugins directory on your webserver.
  2. Activate the plugin.
  3. Fill in the “Comment Geo Maps” settings page.  Get a Cloudmade map api key here.
  4. Copy cgm-comment.php to your theme directory.
  5. Edit your theme to use cgm-comments.php.  For an example of how to do this see below.
  6. Edit cgm-comments.php as necessary to make it work with your theme.

The diff for my theme directory:

Index: index.php
===================================================================
— index.php   (revision 24134)
+++ index.php   (working copy)
@@ -1,7 +1,12 @@
<?php get_header(); ?>

+<?php if ( function_exists(‘cgm_pageclass’) ):?>
+  <div class=”content <?php cgm_pageclass() ?>”>
+<?php else:?>
<div class=”content”>
+<?php endif;?>
<div id=”page” class=”<?php echo (is_single() || is_page()) ? ‘single’ : ‘list’; ?>”>
+<?php if (is_page() and function_exists(‘cgm_insert_map’)) cgm_insert_map(); ?>

<?php if (is_home()) : ?>
<?php echo wwsgd_message(); ?>
@@ -153,7 +158,12 @@
<?php trackback_rdf(); ?>
–>

-                <?php if (!is_page()) comments_template(); ?>
+ <?php
+if (function_exists(‘cgm_activated’) && cgm_activated())
+ comments_template(‘/cgm-comments.php’);
+elseif (!is_page())
+ comments_template();
+ ?>

</div>

Index: header.php
===================================================================
— header.php  (revision 24134)
+++ header.php  (working copy)
@@ -5,6 +5,7 @@
<head profile=”http://gmpg.org/xfn/11″>

<meta http-equiv=”Content-Type” content=”text/html; charset=<?php bloginfo(‘charset’); ?>”/>
+        <meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ />
<meta name=”verify-v1″ content=”29EsSPL2eQFmv4YbO/CHpiYTEv4523SDZEob2yy6TtE=” />
<meta name=”generator” content=”WordPress <?php bloginfo(‘version’); ?>” /> <!– leave this for stats please –>

Please post any questions and suggestions in the comments section below.

35 Responses to “Comment Geo Maps”

  1. baron Says:

    Works great, thank you

  2. Rollins Says:

    Hey. I installed the plugin automatically from within word press. Where do I find the “cgm-comment.php” file?

    Thanks

  3. Chris Abraham Says:

    @Rollins: the cgm-comments.php file will be in the wp-content/plugins/comment-geo-maps directory of your wordpress installation.

  4. Rollins Says:

    Yeah Thanks. Don’t really know what I was thinking. Guess was just hungry. lol

  5. Ming Says:

    None of the functions are being found (ie. cgm_pageclass(), cgm_insert_map()) . How do include the functions?

  6. Chris Abraham Says:

    @Ming: Did you activate the plugin?

  7. Ming Says:

    @chris: yep… maybe i have a conflict with another plugin

  8. Utnnyan Says:

    Hello,

    Total noob here but I would like to create a wordpress page that hosts the map and whenever a specific type of post is created (which has an address) that address is mapped to the page with the map. any idea if I can do this? I really don’t get the instructions on how to get the map to show up or integrate.

    Thank you

  9. Chris Abraham Says:

    Uttnyan: this plugin maps comments on posts and pages on a map. It really would require some solid html/css/php skills to fit it to your blog so you may want to get some help doing this.

  10. Juan Carlos Says:

    I installed the plugin but I only get javascript errors and a blank box for the map. Do you have more documentation or examples of integration?

    Thanks a lot!

    J. Carlos

  11. Chris Abraham Says:

    @Juan: This is the only live example of its use right now: http://gothamschools.org/comment-maps/whats-on-the-chopping-block-at-your-school/ and I must admit that if your theme is complicated it might be tricky to get it to work well on all browsers.

  12. Mike Says:

    This plugin is exactly what I need. Thank you. I am not a complete newb and understand PHP a little, but I am not able to follow the editing instructions for the header.php and the index.php correctly. I believe if a line does not have a + or – symbol it should exist within the template. If it has a + sign then you need to add it and a – sign means to remove a particular line of code.

    I am not able to find in the index.php files of a number of templates some of the lines in your instructions that should exist like in the index.php

    <div id=”page” class=””>

    or

    -

    Any help would be appreciated, I could be missing something obvious.

    Thanks.

  13. Chris Abraham Says:

    @Mike: The instructions here are only an example of how to fit the plugin to a theme. Each theme will be a little different. So if you can’t find a particular line, don’t worry so much.

  14. Mike Says:

    OK – so the lines below are required in the two .php files?

    Index: index.php
    ===================================================================
    +
    + <div class=”content ”>
    +
    +if (function_exists(’cgm_activated’) && cgm_activated())
    + comments_template(’/cgm-comments.php’);
    +elseif (!is_page())
    + comments_template();
    + ?>

    Index: header.php
    ===================================================================
    +

  15. Mike Says:

    Apologies ignore earlier post, lines were stripped out. I will figure it myself our try another angle.

    Thanks.

  16. matthew Patulski Says:

    Hi,
    I like the premise.

    I am trying to integrate into the journalist theme and I get this error:

    Fatal error: Call to undefined function the_last_commenter() in /…/wp-content/themes/journalist/cgm-comments.php on line 255

    theme:
    http://wordpress.org/extend/themes/journalist

    Any thoughts?

  17. Chris Abraham Says:

    @Matthew: You can just take out that line that calls the_last_commenter(). That should fix things.

  18. Jesse Says:

    How to add map? I have installed the plugin, activated, followed the customization for index.php and header.php but I don’t see the map. Your plugin concept is great! Bright idea!

  19. Chris Abraham Says:

    @Jesse: Did you follow all the instructions here?
    https://projects.openplans.org/commentgeomaps/wiki/WikiStart#Installation

    It’s turning out that getting this plugin working for themes is pretty tricky, especially if you’re not a html/css adept.

  20. Paul Says:

    Hi Chris, I really am struggling to get this working…

    Using the latest release of WP, default theme, index.php:

    Would be grateful of you showing me where I place your code, thanks, Paul:

    <div id=”post-”>
    <a href=”" rel=”bookmark” title=”Permanent Link to “>
    <!– by –>

    <?php the_tags(‘Tags: ‘, ‘, ‘, ”); ?> Posted in |

    Not Found
    Sorry, but you are looking for something that isn’t here.

  21. Paul Says:

    Sorry about the above posts – how do I share my code!?

  22. Chris Abraham Says:

    @Paul. From what you’ve posted, I really don’t know what is wrong. Sorry. And you might find pastebin.com useful in sharing code and such.

  23. Paul Says:

    Sorry about that Chris, Thanks for Pastebin link:

    http://pastebin.com/m2eec5947

    I’m basically using the default theme, before I transfer to my own theme…

    But the latest seems very different to the example you gave.

    Hope you can help, but understand if you’re busy.

    Thanks, Paul

  24. Chris Abraham Says:

    @Paul. Integrating this plugin into your theme is not an easy task and will vary from theme to theme. I could give you a few instructions but I’m pretty sure it won’t work properly immediately but only after some HTML/CSS tweaks. You should probably find someone with those skills to help you out.

  25. Paul Says:

    Really? but the code I pasted is the unaltered index.php for the WordPress default theme. It would be great if you could provide the code for this release.

  26. ForestWander Says:

    Hi Chris,

    Thanks for developing this plugin.

    I am looking for something that will let my website visitors post markers on the Google map with their comments.

    Is that what this plugin will allow?

    Can the comments be moderated?

    Thank you again for your help.

  27. Chris Abraham Says:

    @ForestWander: Yes, this is what this plugin allows. See http://bit.ly/ngkKK as an example. I think if you turn on comment moderation you’d be able to moderate them.

  28. jonathan soroko Says:

    Chris,
    I’d like to offer a thought – perhaps there are themes that will integrate easily with the plugin. It would be worth a theme change – or building a site around the theme – given some of the issues which could be addressed. For instance, in my neighborhood in Brooklyn, we have very high numbers of chiild/vehicle and bicyclist/vehicle morbidity and mortality. We also have – to give a couple of other examples – suspicions of cancer clusters over petroleum pipelines, and widespread storm drain failures.
    If it means using a different theme – no problem. Or – we find someone who knows the WordPress end – and persuade or hire them to write it. This isn’t a small obstacle – but it’s not insurmountable.J.

  29. Hector Acosta Says:

    I really cant make it work, i´ve copied CGM CGM Comments Diff on index .php and ive tried editing other php files.. when i dont get an error, i simply just dont get nothing at all, not even the map. Could u help me please Chris! I love your plugin, but its really hard for a novice.

  30. Bill Says:

    This plugin appears to do exactly what I want. Links to further documentation and other forum seem to be no longer active. Could someone provide me with some direction? A link or description of missing documentation would be helpful (Edit your theme to use cgm-comments.php. For an example of how to do this, see http://oss.openplans.org/commentgeomaps/wiki/CGMCommentsDiff)
    and
    (Edit cgm-comments.php as necessary to make it work with your theme).

    Thank you.

  31. Chris Abraham Says:

    @Bill: Yes, that oss.openplans site got shut down. I’m hoping to have an opportunity to update this plugin and the support docs in the near future. I’ll post comments here with updates on this.

  32. Nick Says:

    Hi Chris,

    This plugin would be absolutely brilliant for a number of things I am working on but sadly without any documentation I cannot figure out how to make it work. Do you have any plans for opening the documentation back up anytime? Much apreciated.

    Thank you.

  33. Chris Abraham Says:

    @Nick, I’ve restored the instructions above in this post, see the code diff. This plugin really needs a rewrite to make use of the new Google API, WordPress hooks etc. I’m going to try and get to this.

  34. Nick Says:

    Hi Chris,

    Thank you for your quick reply. I will attempt in a moment to see if I can get it working. Fingers crossed. If so this will be superb.

  35. Nick Says:

    @Chris I’m not having much luck. I think mostly to do with where I should put the code in the header.php. At the moment where I have it placed it isnt working but gives me a plus symbol in the top of the page which is part of the code being echoed.