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
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:
- <!––commentmap––> : This tag you can add it when you are writing a post or a page with wordpress and want that the map appears in that post or page.
- commentMap() : This is a PHP function, if you want to add the map in a template or different place than a post (like a fixed 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:
- $google_key : The GoogleMap API Key needed for your site in order to rander the map (GoogleMaps API registration - Enter your blog URL as the GoogleMaps URL)
- $width : The width of the map displayed in pixels.
- $height: The height of the map displayed in pixels.
- $style: The css style that will be applied to the div containing the map (example: margin:5px;).
- $return: The default value is 0, this means that the function will print the map directly; if this value is set to 1 then the function will return the code of the map instead of printing it.
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:
- Label text color : This will define the color of the text displayed on the information window above marker. You can input in text (ex. red, blue, black) or in the standard css format (ex. #333333)
- Country name font size : This will define the font size of the title, in this case the country name in the information window above marker.
- Country name style : The style of the country name in the information window above marker.
- Information font size : The size of the font in the information window above marker with exception of the country name.
- Use flag in label : If is activated it will print a flag of the country (to the left of the country name) based on the tiny flags pack images created by Zarkof.
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 leave a response, or trackback from your own site.
11 Responses to “Comments on a Map Wordpress Plugin”
6 pingbacks and 0 trackbacks to this post.
- 在Google Map上标记留言者 at catch the digital flow »» June 15th, 2007 at 1:52 pm from United States
- WP Plugins DB » Blog Archive » Comments on a Map »» May 20th, 2007 at 6:01 pm from United States
- 在Google Map上标记留言者 : catch the digital flow »» May 19th, 2007 at 11:09 pm from United States
- Mark all the commenters on a Google map at Unbid Weblog »» April 26th, 2007 at 11:26 pm from United States
- 在Google Map上标记留言者 « catch the digital flow »» April 26th, 2007 at 8:03 pm from United States
- 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
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:
- <!––commentmap––> : This tag you can add it when you are writing a post or a page with wordpress and want that the map appears in that post or page.
- commentMap() : This is a PHP function, if you want to add the map in a template or different place than a post (like a fixed 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:
- $google_key : The GoogleMap API Key needed for your site in order to rander the map (GoogleMaps API registration - Enter your blog URL as the GoogleMaps URL)
- $width : The width of the map displayed in pixels.
- $height: The height of the map displayed in pixels.
- $style: The css style that will be applied to the div containing the map (example: margin:5px;).
- $return: The default value is 0, this means that the function will print the map directly; if this value is set to 1 then the function will return the code of the map instead of printing it.
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:
- Label text color : This will define the color of the text displayed on the information window above marker. You can input in text (ex. red, blue, black) or in the standard css format (ex. #333333)
- Country name font size : This will define the font size of the title, in this case the country name in the information window above marker.
- Country name style : The style of the country name in the information window above marker.
- Information font size : The size of the font in the information window above marker with exception of the country name.
- Use flag in label : If is activated it will print a flag of the country (to the left of the country name) based on the tiny flags pack images created by Zarkof.
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 leave a response, or trackback from your own site.
11 Responses to “Comments on a Map Wordpress Plugin”
-
Tim Says:
October 9th, 2007 at 8:12 am from United StatesNice implementation of a great idea! Thx.
-
Honey Says:
September 18th, 2007 at 5:25 am from IndiaThis is KOOOOOOLLLL
Great work Vadim!!
Keep up the good work.
Cheers!
;) -
tznqrtdasu Says:
June 22nd, 2007 at 2:31 am from Korea (South)Hello! Good Site! Thanks you! jlnxonzunp
-
Lorenzo Says:
May 31st, 2007 at 7:52 am from Mexicoche 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! -
北极冰仔 Says:
May 13th, 2007 at 6:09 pm from Germany不错,很好用.
-
Lorenzo Says:
May 3rd, 2007 at 1:30 am from MexicoCarnaaal! 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!
-
Gerhard Says:
April 21st, 2007 at 12:38 am from Germanyvery 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
-
billie Says:
April 19th, 2007 at 2:10 am from Mexicoque 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!!
-
Vadim Zendejas Says:
April 7th, 2007 at 4:36 pm from JapanThank you Ozh…
-
Ozh Says:
April 7th, 2007 at 4:28 pm from France(just a note: the alt text on commenter’s flag should be “written”, not “writed” :)
-
Ozh Says:
April 7th, 2007 at 4:25 pm from FranceNice idea !
6 pingbacks and 0 trackbacks to this post.
- 在Google Map上标记留言者 at catch the digital flow »» June 15th, 2007 at 1:52 pm from United States
- WP Plugins DB » Blog Archive » Comments on a Map »» May 20th, 2007 at 6:01 pm from United States
- 在Google Map上标记留言者 : catch the digital flow »» May 19th, 2007 at 11:09 pm from United States
- Mark all the commenters on a Google map at Unbid Weblog »» April 26th, 2007 at 11:26 pm from United States
- 在Google Map上标记留言者 « catch the digital flow »» April 26th, 2007 at 8:03 pm from United States
- www.gbrauckmann.de » SPAM-MAP Wordpress Plugin »» April 20th, 2007 at 11:27 pm from Germany







October 9th, 2007 at 8:12 am from United States
Nice implementation of a great idea! Thx.
September 18th, 2007 at 5:25 am from India
This is KOOOOOOLLLL
Great work Vadim!!
Keep up the good work.
Cheers!
;)
June 22nd, 2007 at 2:31 am from Korea (South)
Hello! Good Site! Thanks you! jlnxonzunp
May 31st, 2007 at 7:52 am from Mexico
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!
May 13th, 2007 at 6:09 pm from Germany
不错,很好用.
May 3rd, 2007 at 1:30 am from Mexico
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!
April 21st, 2007 at 12:38 am from Germany
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
April 19th, 2007 at 2:10 am from Mexico
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!!
April 7th, 2007 at 4:36 pm from Japan
Thank you Ozh…
April 7th, 2007 at 4:28 pm from France
(just a note: the alt text on commenter’s flag should be “written”, not “writed” :)
April 7th, 2007 at 4:25 pm from France
Nice idea !