Title: [Plugin: Basic Google Maps Placemarks] Icon Categories
Last modified: August 20, 2016

---

# [Plugin: Basic Google Maps Placemarks] Icon Categories

 *  Resolved [erinhamalainen](https://wordpress.org/support/users/erinhamalainen/)
 * (@erinhamalainen)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/)
 * Hi Ian
 * Firstly, great plugin!
 * Secondly, I like to make a different icon for each placemark on the map. I saw
   you have a coding on the FAQs for this, but Im not sure where to put it in the
   edit part of your plugin, and what bits of code to change (Im doing my website
   for a uni assignment and still learning code).
 * Ive bolded what i think i need to change depending on the category – do I need
   to do the below code for each category or can i just build within this? (I assume
   the png image below is the icon wanted to be displayed on the map?)
 * Help is much appreciated!
    [http://erinh.phpfogapp.com/plan/map/](http://erinh.phpfogapp.com/plan/map/)
 *     ```
       function setBGMPDefaultIconByCategory( $iconURL, $placemarkID )
       {
           $placemarkCategories = wp_get_object_terms( $placemarkID, 'bgmp-category' );
   
           foreach( $placemarkCategories as $pc )
               if( $pc->slug == '<strong>restaurants</strong>' )
                   $iconURL = get_bloginfo( 'stylesheet_directory' ) . '/<strong>images/bgmp-default-icon.png'</strong>;
   
           return $iconURL;
       }
       add_filter( 'bgmp_default-icon', 'setBGMPDefaultIcon', 10, 2 );
       ```
   
 * [http://wordpress.org/extend/plugins/basic-google-maps-placemarks/](http://wordpress.org/extend/plugins/basic-google-maps-placemarks/)
 * _[Moderator Note: Please post code or markup snippets between backticks or use
   the code button. As it stands, your code may now have been permanently damaged/
   corrupted by the forum’s parser.]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Ian Dunn](https://wordpress.org/support/users/iandunn/)
 * (@iandunn)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024011)
 * Hi Erin, it’s not a good idea to modify the plugin directly, because then your
   changes will be overwritten any time you upgrade. Instead, you can put your changes
   inside [a functionality plugin](http://www.doitwithwp.com/create-functions-plugin/).
 * If you want to assign icons to multiple categories, you can do within a single
   function using a series of if/else statements [or a switch()](http://pastebin.com/hp0FNma1).
 *  Thread Starter [erinhamalainen](https://wordpress.org/support/users/erinhamalainen/)
 * (@erinhamalainen)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024088)
 * Hi Ian, thanks so much for your reply they were great instructions – however 
   the category icons still seem not to be working?
 * I have added the [bgmp-map categories=”restaurant,winery,accommodation,golf,hot-
   air-balloon”] as your installation instructions said.
 * When i zipped my php file I also included folders to map the icons
    i.e. ‘/images/
   marker-icons/food-icon.png’; = (plugin)/images/market-icons/(icon.png file) –
   is this correct?
 * Do the icons need to be a particular size? I’ve tried both with the size i have
   and the size of the existing icon but to no change
 * [http://erinh.phpfogapp.com/plan/map/](http://erinh.phpfogapp.com/plan/map/)
 *  Thread Starter [erinhamalainen](https://wordpress.org/support/users/erinhamalainen/)
 * (@erinhamalainen)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024089)
 * I found the workaround by using the featured image, but if you have time would
   like to know where I was going wrong above? thanks!
 *  Plugin Author [Ian Dunn](https://wordpress.org/support/users/iandunn/)
 * (@iandunn)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024095)
 * Hi Erin, the size doesn’t matter at all. I can’t tell what’s going wrong since
   you changed back to using the featured image, but my first guess would be that
   the URLs were wrong. You can install [Firebug](http://getfirebug.com/) and check
   the Console tab for 404 errors.
 * Instead of using relative paths, it’s better to use one of the API functions 
   to generate an absolute one. If the images are stored in the content directory,
   you’d use `wp_uploads_dir()`; if they’re in a theme you’d use `get_stylesheet_directory_uri()`;
   and if they’re in a plugin you’d use `plugin_dir()`. You can check [the Codex](http://codex.wordpress.org)
   for details on how to use those functions.
 *  Thread Starter [erinhamalainen](https://wordpress.org/support/users/erinhamalainen/)
 * (@erinhamalainen)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024107)
 * Thanks so much for your help Ian, I think I’m just not understanding the PHP 
   coding… I will try and look into it if I have time, for what I need it for the
   featured image will work ok for now 🙂
 *  [dhobeika](https://wordpress.org/support/users/dhobeika/)
 * (@dhobeika)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024152)
 * I am also having some problems with this. [I added this following code](http://pastebin.com/hmcde18C)
   to my functions.php file — we have 5 different categories of events, for most
   I just set the featured image, but I did a test one for Chicago without setting
   the featured image and just checking off the category name and it didn’t work.
 * Any suggestions?
 * [http://www.americanhistorybowl.com/regionals/](http://www.americanhistorybowl.com/regionals/)
 *  Plugin Author [Ian Dunn](https://wordpress.org/support/users/iandunn/)
 * (@iandunn)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024158)
 * dhobeika, if you use Firebug or Chrome Dev Tools you’ll see these errors in the
   console log:
 *     ```
       bgmp_createMarker(): OK - Tulsa  icon wasn't passed in. functions.js:141
       bgmp_createMarker(): IL - Chicago  icon wasn't passed in.
       ```
   
 * If you view the page source and look at the bgmpData.markers array, you’ll see
   that the icon values for both are “null”

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Plugin: Basic Google Maps Placemarks] Icon Categories’ is closed to 
new replies.

 * ![](https://ps.w.org/basic-google-maps-placemarks/assets/icon-128x128.png?rev
   =1152531)
 * [Basic Google Maps Placemarks](https://wordpress.org/plugins/basic-google-maps-placemarks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/basic-google-maps-placemarks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/basic-google-maps-placemarks/)
 * [Active Topics](https://wordpress.org/support/plugin/basic-google-maps-placemarks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/basic-google-maps-placemarks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/basic-google-maps-placemarks/reviews/)

## Tags

 * [icons](https://wordpress.org/support/topic-tag/icons/)

 * 7 replies
 * 3 participants
 * Last reply from: [Ian Dunn](https://wordpress.org/support/users/iandunn/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-basic-google-maps-placemarks-icon-categories/#post-3024158)
 * Status: resolved