Bhaskar Karambelkar's Blog

Leaflet Diary: Chapter 5, Leaflet 1.1 and Beyond


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

This is the sixth blog entry in my series Leaflet-Diary. In my last post: Chapter 4, Towards Leaflet 1.1, I talked about changes that were made to the Leaflet package to make it extensible. This one is about the release of version 1.1 and what’s coming in the months ahead.


  • Leaflet 1.1.0 has finally been released and available via CRAN. It contains a ton of new features, enhancements, and bug fixes.
  • Next iteration of changes will start soon.
  • Leaflet.extras is coming along nicely and should also be available on CRAN in the near future.

Long Read

Version 1.1

After almost a full year of development and with contributions from many people, Leaflet 1.1.0 was released on CRAN. Although RStudio folks were really nice to mention my humble contribution, I can personally tell you that this was a combination of contributions from a lot of folks. A truly team effort of many people involved in improving the GIS visualization capabilities in R. Here I will elaborate on the RStudio blog post highlighting some of the major features available in leaflet 1.1.0. If you have followed the past posts of Leaflet Diary you might be familiar with most of the following items.

  • Leaflet JS lib upgraded from 0.7.3 to 0.7.7, and respective plugins upgraded too. Leaflet 0.7.7 will be the last release in 0.7.x series of the Javascript library.
  • Support for custom projections via the leafletCRS class. To see this in action check out some of the examples I have uploaded to Rpubs.
  • Support for labels on mouse over.
  • Mutually compatible marker clustering and grouping. See fourth example in this Rpubs page.
  • Auto-completable 3rd party tiles provider list.
  • Support for adding custom Javascript buttons and toolbars.
  • Ability to highlight shapes on mouse over.
  • Support for more customized markers.
  • Support for sf objects in addition to sp objects. sf is the successor and in many ways a better alternative to sp for storing/processing spatial data in R.
  • Support for crosstalk from cross-widget communication. This allows your leaflet widget to interact with other widgets on the page.
  • With version 1.1.0 leaflet will handle missing data more gracefully. It will either warn or error out when data is missing depending on whether it can or cannot proceed.

As you can see a lot of effort and time was put in to making Leaflet 1.1.0 as bug free and as feature rich as possible by everyone involved.

What’s Next?

Although it is still too early to determine what’s next for leaflet, one thing we are all excited about is the release of version 1.x of the Leaflet Javascript library. At this point I am evaluating how much of an effort it will be to upgrade the R package to use the 1.x version of the JS lib. But rest assured that the new JS version not only comes with a lot of bug fixes, but also some major performance improvements and some interesting features. So stay tuned for future development.

Leaflet Extras

My own add-on package to leaflet, leaflet-extras is coming along nicely. If you haven’t checked it out yet, I highly encourage you to do so. One of the advantage of the Leaflet JavaScript library is that it is very extensible and provides a ton of plugins that enhance the capabilities of the base library. We have already integrated some of these plugins in to the leaflet R package. But we cannot incorporate all the plugins and we need to keep the leaflet R package relatively stable. With that in mind we made the R package extensible, and leaflet.extras is an add-on R package that provides enhanced functionality using a lot of 3rd plugins. For those unfamiliar with leaflet.extras here is a small list of feature set it supports.

  • Enhanced and extended support for GeoJSON, TopoJSON, GPX, KML file formats.
  • Automatic choropleths with bi-directional legend highlighting.
  • Heatmaps
  • More customized icons.
  • Support for drawing shaped and markers on the map and interacting with them in Shiny.
  • Search GeoJSON and markers on the map. Geolocate using OSM Nominatim API.
  • Support for time dimension. (Coming soon).
  • Miscellaneous features like tile caching, suspend map during scrolling, GPS locator.

If you work with ESRI products like ArcGIS/ArcMap etc. Also check out my other add-on package leaflet.esri. More on this in a separate blog post.

Final Word

2017 promises to bring a lot of exciting features to geospatial data analysis and visualization using R. A lot of interested parties and experts in this domain are involved in the process. If you want to follow I suggest you check out r-spatial and its related products/blogs. Also the folks over at ROpenSci are doing some fantastic work in providing a lot of packages for geospatial analysis.