I have a leaflet map for various attraction types which works fine with using the standard blue icon.

What I'd like is to be able to specify a different icon based on the attraction type field.

I thought this feature existed based on https://drupal.org/node/1882806 but I can't seem to get anything to work.

I've been trying to set it up through the Leaflet settings in views using the POINT ICON Field (html DivIcon) setup. However, whatever I try seems to end up with a page full of errors and no icons.

I can't find any documentation on using this feature so would really appreciated some help.

Thanks, Chris

3 Answers 3


Here is what I did. You should be able to tweak it to fit your needs:

  1. I created terms and uploaded images for them.
  2. I created nodes and associated terms with them.
  3. I went ahead and created my leaflet view, using the appropriate token in Point Icon in leaflet settings.

    I hope that helps.


I created a patch a few months back that added the ability to set all map options via a textfield and also token support in the icon path. I used this on one of my own sites allowing nodes of different taxonomies to have different icons. Though you could use any token to differentiate between icons.

The patch was made a few months ago, and for some reason the maintainer did not like using a textfield to set all map options so would not commit the patch. you will be able to look at the patch and see how I did it though.

The thread is at https://drupal.org/node/2089209

  • Thanks for this ,looks useful. I guess I'd just have to put a token in the icon path within the provided textfield. Will probably give it a go, ...but, I thought there was a way of doing this using the existing Leaflet module (as per the link in my post) Feb 23, 2014 at 20:37
  • There is a patch in that thread to allow for divicons but I don't think it has been committed yet. When I was using the leaflet module I customized it for my needs and found that adding token support was the easiest way do get different icons
    – 2pha
    Feb 23, 2014 at 23:45

I applied the patch in comment #14 of https://www.drupal.org/node/1918170 (to Drupal 7.37) - after that tokens worked in the Point icon - Icon URL field.

  1. I set up a Taxonomy to describe the categories for which I wanted different icons.
  2. I next added a simple text field to the terms in this vocabulary to contain the relative path to the .png file to use as a marker. This needs to be relative to the site name. I put my image files in the /leaflet/images folder, so these paths are like:


  3. I then added a term reference field to the content type I wanted to map and populated it using terms from the new Taxonomy.

  4. When setting up the view to display this content, I clicked on the "settings" for Leaflet map, made sure the checkbox (added by the patch) was ticked to allow tokens to be used in the Point icon settings and then scrolled down to the Tokens list and found the necessary token to go in the Icon URL field. It is like:


  5. Save, and then go to the map page. The map marker files specified in the Taxonomy terms should now be used.

I put a series of .png files in the /leaflet/images folder that were all the same shape, but differed in colour and pattern. They could therefore share the same shadow. So I specified a single, fixed path to my shadow image file in the Icon Shadow URL field and fixed values for x and y under Icon Anchor, Shadow Anchor and Popup Anchor.

[N.B. The relevant patch was posted more than a year ago, RTBCed 8 months ago and there are comments from about 10 users in the thread confirming that the patch works. I checked whether it had been applied to the 7.x-dev version of the Leaflet module - it has not!]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.