Bhaskar Karambelkar's Blog

Leaflet Diary: Chapter 3, Making Leaflet Extensible


Tags: r r-stats rstats GIS leaflet Leaflet-Diary

This is the fourth blog entry in my series ‘Leaflet-Diary’. In my last post Chapter 2: Projections and then some, I talked projections, easy button support and upgrading leaflet to 0.7.7. This one is about phase III, making the Leaflet package extensible and allowing for users to integrate many more Leaflet plugins.


  • Some bugs were squashed.
  • Leaflet package is now extensible. You can write your own R package that augment core leaflet functionality by incorporating various plugins.
  • A new R package leaflet.extras has been created to extend the leaflet package.

Long Read

Making Leaflet extensible

One of the strengths of the leaflet javascript library is the plugins eco-system it supports, and it is not fair to the R community to not be able to take advantage of this. The leaflet R package already integrates some plugins, but there are literally hundreds of plugins. It is not feasible to incorporate all of them in the R package. However with the work that went into this phase it is now possible to extend the leaflet package and incorporate as many plugins as you want. Most of the work went into opening up some of internal functions of the leaflet package as well as tidying them up a bit.


I created a new R package leaflet.extras where I have integrated more plugins and continue to do so. This will be the future direction for the leaflet package, the core package will only see bug fixes, performance improvements etc. and any new plugins will be developed in external packages.

End of Phase 3

This marks the end of Phase 3 in my leaflet development. If you like what you see or have comments/questions/critiques don’t hesitate to contact me via Twitter or open an issue over at Github. In the mean time happy mapping.