Comments on a Map Wordpress Plugin

Have you ever wanted to show in a google map from which country your visitors that have been posted a comments come from?

Ok, so I just developed this new plugin so everyone can see this information. This new plugin is based on the ip2nation database.

This plugin checks for all your visitors comments in your posts and obtain the IP address for each comment. Then based on the IP address, the plugin obtains the country and the longitude and latitude of that country. With that information and thanks to the wonderful GoogleMap API; the plugin can generate a map with markers indicating the places from where the comments have been wrote and the number of comments in that country.

Here you can see the map of my comments generated by this plugin:

Next, I will show the basic documentation for the plugin.


Set up the MySQL database (as mentioned on Ozh website)

First of all, go to ip2nation and download the .sql file (I’m not mirroring it because it is updated from times to times, so get the latest one) This .sql file will create two tables, ip2nation and ip2nationCountries.

Tips : first, install PHPMyAdmin on your website. This is a great interface for anything you can do with MySQL databases. Once it’s done, look for the “SQL” link in the menu : you will be prompted for a .sql file, for example the one you just downloaded on your computer. It will set up and populate the required tables.


Download the plugin

Wordpress plugin: Comments on a Map Version 1.0 - April 6, 2007, Downloads: 798 times

Click in the file and save it in your preferred folder. You will need a compression utility like WinZip to uncompress the zip file of the plugin; then drop the directory called “comments_map” in your plugin directory (yourblog/wp-content/plugins). Then activate the plugin (in the admin interface).

Also with this plugin I included the free to use tiny flags pack created by Zarkof and developed originally for this site.


Use the plugin

There exists two ways to include a the map on a post or a page:

The function commentMap() has 5 default parameters. If any parameter is not used, then the plugin will obtain the parameter from the plugin configuration page on the wordpress administration panel. The list of default parameters are:

If you use the <!––commentmap––> tag inside any post, then the configuration parameters will be obtained from the plugin configuration page.

In the configuration page are defined the same parameters mentioned here plus 5 other style-type parameters:


Examples of use

Here is a list of use-examples for this plugin.

The first one is using the tag inside a post or page wrote in wordpress:

... here some text from the post
<!––commentmap––>
here more text in the post …

This is the most simple form of using the plugin. But if you want to modify a wordpress template or simply you are creating your fixed page for wordpress you can always use the commentMap() function as in this example with the default parameters:

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap();?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>

Here is another example changing the size to the map to 300×200 pixels and print a black solid border of 2 pixels around the map:

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap('', 300, 200, 'border:2px solid black');?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>

If you are importing the plugin from a different site, or you are using multiple blogs in one installation of wordpress, then you need to specify the GoogleMap API Key for each blog. In this example I am using as a parameter a GoogleMap API Key (You need to get your own key, if you use this key on your site it will not work!):

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap('ABQIAAAAD6dypj2zClONNwYiohZ0PBTJQVVUoL2EfZ-u
GF_bMN6p27nuhBRD7W2-oEajMAAHu9lUHh4o9bAUQA’);?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>


Notes

If you need support, please be as simple, consistent and accurate as possible. If you need to post lines of code, please upload it somewhere and give me the information to check the code. I can not give support of anything in relation with ip2nation, please refer to the author pages.

Posted by Vadim Zendejas 06.Apr.07

You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

11 Responses to “Comments on a Map Wordpress Plugin”

  1. Written from United States
    Tim Says:

    Nice implementation of a great idea! Thx.

  2. Written from India
    Honey Says:

    This is KOOOOOOLLLL :)

    Great work Vadim!!

    Keep up the good work.

    Cheers!
    ;)

  3. Written from Korea (South)
    tznqrtdasu Says:

    Hello! Good Site! Thanks you! jlnxonzunp

  4. Written from Mexico
    Lorenzo Says:

    che che cheeee ya postea algo manolo!!! oye, estan chidas las galerias http://www.mincel.com/gallery/main.php
    me voy a fusilar alguna jaja.
    Saludos!

  5. Written from Germany
    北极冰仔 Says:

    不错,很好用.

  6. Written from Mexico
    Lorenzo Says:

    Carnaaal! Que pedo che manole, ya no sé nada de ti! De seguro has de estar de embarrado con algun che gadget nuevo verdad cabron? Jaja. Oye que pedo, ches japs ya te los echaste? ya estuvo la maestria? Echale ganas manole, que yo por aca estoy chingandole duro porque me quiero ir en Septiembre a revivir viejos y muy buenos tiempos. Saludos!

  7. Written from Germany
    Gerhard Says:

    very nice idea Vadim.
    In order to get zoom an pan into the map, just add these controls:
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    into the function onLoad.

    I also changed the type of comments from approved (eq 1) to ’spam’ just to see where all the SPAM guys come from. :-)

    habe fun and thx for this plugin

  8. Written from Mexico
    billie Says:

    que onda!! ei pues que padre.. ya sabes de quien son los comments de china eh! haha

    che vadim internacional!

    por cierto, de seguro sabras que banorte se junto con un banco de japon, no? creo el segundo mas importante depor alla…

    saludos!!

  9. Written from Japan
    Vadim Zendejas Says:

    Thank you Ozh…

  10. Written from France
    Ozh Says:

    (just a note: the alt text on commenter’s flag should be “written”, not “writed” :)

  11. Written from France
    Ozh Says:

    Nice idea !

6 pingbacks and 0 trackbacks to this post.

  1. 在Google Map上标记留言者 at catch the digital flow »» June 15th, 2007 at 1:52 pm from United States
  2. WP Plugins DB » Blog Archive » Comments on a Map »» May 20th, 2007 at 6:01 pm from United States
  3. 在Google Map上标记留言者 : catch the digital flow »» May 19th, 2007 at 11:09 pm from United States
  4. Mark all the commenters on a Google map at Unbid Weblog »» April 26th, 2007 at 11:26 pm from United States
  5. 在Google Map上标记留言者 « catch the digital flow »» April 26th, 2007 at 8:03 pm from United States
  6. www.gbrauckmann.de » SPAM-MAP Wordpress Plugin »» April 20th, 2007 at 11:27 pm from Germany

Leave a Reply

Comments on a Map Wordpress Plugin

Have you ever wanted to show in a google map from which country your visitors that have been posted a comments come from?

Ok, so I just developed this new plugin so everyone can see this information. This new plugin is based on the ip2nation database.

This plugin checks for all your visitors comments in your posts and obtain the IP address for each comment. Then based on the IP address, the plugin obtains the country and the longitude and latitude of that country. With that information and thanks to the wonderful GoogleMap API; the plugin can generate a map with markers indicating the places from where the comments have been wrote and the number of comments in that country.

Here you can see the map of my comments generated by this plugin:

Next, I will show the basic documentation for the plugin.


Set up the MySQL database (as mentioned on Ozh website)

First of all, go to ip2nation and download the .sql file (I’m not mirroring it because it is updated from times to times, so get the latest one) This .sql file will create two tables, ip2nation and ip2nationCountries.

Tips : first, install PHPMyAdmin on your website. This is a great interface for anything you can do with MySQL databases. Once it’s done, look for the “SQL” link in the menu : you will be prompted for a .sql file, for example the one you just downloaded on your computer. It will set up and populate the required tables.


Download the plugin

Wordpress plugin: Comments on a Map Version 1.0 - April 6, 2007, Downloads: 798 times

Click in the file and save it in your preferred folder. You will need a compression utility like WinZip to uncompress the zip file of the plugin; then drop the directory called “comments_map” in your plugin directory (yourblog/wp-content/plugins). Then activate the plugin (in the admin interface).

Also with this plugin I included the free to use tiny flags pack created by Zarkof and developed originally for this site.


Use the plugin

There exists two ways to include a the map on a post or a page:

The function commentMap() has 5 default parameters. If any parameter is not used, then the plugin will obtain the parameter from the plugin configuration page on the wordpress administration panel. The list of default parameters are:

If you use the <!––commentmap––> tag inside any post, then the configuration parameters will be obtained from the plugin configuration page.

In the configuration page are defined the same parameters mentioned here plus 5 other style-type parameters:


Examples of use

Here is a list of use-examples for this plugin.

The first one is using the tag inside a post or page wrote in wordpress:

... here some text from the post
<!––commentmap––>
here more text in the post …

This is the most simple form of using the plugin. But if you want to modify a wordpress template or simply you are creating your fixed page for wordpress you can always use the commentMap() function as in this example with the default parameters:

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap();?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>

Here is another example changing the size to the map to 300×200 pixels and print a black solid border of 2 pixels around the map:

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap('', 300, 200, 'border:2px solid black');?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>

If you are importing the plugin from a different site, or you are using multiple blogs in one installation of wordpress, then you need to specify the GoogleMap API Key for each blog. In this example I am using as a parameter a GoogleMap API Key (You need to get your own key, if you use this key on your site it will not work!):

< ?php get_header(); ?>
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Look! you can see from where everyone has posted a comment:
< ?php commentMap('ABQIAAAAD6dypj2zClONNwYiohZ0PBTJQVVUoL2EfZ-u
GF_bMN6p27nuhBRD7W2-oEajMAAHu9lUHh4o9bAUQA’);?>
< ?php endwhile; endif; ?>
< ?php get_footer(); ?>


Notes

If you need support, please be as simple, consistent and accurate as possible. If you need to post lines of code, please upload it somewhere and give me the information to check the code. I can not give support of anything in relation with ip2nation, please refer to the author pages.

Posted by Vadim Zendejas 06.Apr.07

You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

11 Responses to “Comments on a Map Wordpress Plugin”

  1. Written from United States
    Tim Says:

    Nice implementation of a great idea! Thx.

  2. Written from India
    Honey Says:

    This is KOOOOOOLLLL :)

    Great work Vadim!!

    Keep up the good work.

    Cheers!
    ;)

  3. Written from Korea (South)
    tznqrtdasu Says:

    Hello! Good Site! Thanks you! jlnxonzunp

  4. Written from Mexico
    Lorenzo Says:

    che che cheeee ya postea algo manolo!!! oye, estan chidas las galerias http://www.mincel.com/gallery/main.php
    me voy a fusilar alguna jaja.
    Saludos!

  5. Written from Germany
    北极冰仔 Says:

    不错,很好用.

  6. Written from Mexico
    Lorenzo Says:

    Carnaaal! Que pedo che manole, ya no sé nada de ti! De seguro has de estar de embarrado con algun che gadget nuevo verdad cabron? Jaja. Oye que pedo, ches japs ya te los echaste? ya estuvo la maestria? Echale ganas manole, que yo por aca estoy chingandole duro porque me quiero ir en Septiembre a revivir viejos y muy buenos tiempos. Saludos!

  7. Written from Germany
    Gerhard Says:

    very nice idea Vadim.
    In order to get zoom an pan into the map, just add these controls:
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    into the function onLoad.

    I also changed the type of comments from approved (eq 1) to ’spam’ just to see where all the SPAM guys come from. :-)

    habe fun and thx for this plugin

  8. Written from Mexico
    billie Says:

    que onda!! ei pues que padre.. ya sabes de quien son los comments de china eh! haha

    che vadim internacional!

    por cierto, de seguro sabras que banorte se junto con un banco de japon, no? creo el segundo mas importante depor alla…

    saludos!!

  9. Written from Japan
    Vadim Zendejas Says:

    Thank you Ozh…

  10. Written from France
    Ozh Says:

    (just a note: the alt text on commenter’s flag should be “written”, not “writed” :)

  11. Written from France
    Ozh Says:

    Nice idea !

6 pingbacks and 0 trackbacks to this post.

  1. 在Google Map上标记留言者 at catch the digital flow »» June 15th, 2007 at 1:52 pm from United States
  2. WP Plugins DB » Blog Archive » Comments on a Map »» May 20th, 2007 at 6:01 pm from United States
  3. 在Google Map上标记留言者 : catch the digital flow »» May 19th, 2007 at 11:09 pm from United States
  4. Mark all the commenters on a Google map at Unbid Weblog »» April 26th, 2007 at 11:26 pm from United States
  5. 在Google Map上标记留言者 « catch the digital flow »» April 26th, 2007 at 8:03 pm from United States
  6. www.gbrauckmann.de » SPAM-MAP Wordpress Plugin »» April 20th, 2007 at 11:27 pm from Germany

Leave a Reply