<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/leaflet-2-0-0/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://blog.rstudio.com/2018/05/10/leaflet-2-0-0/"> RStudio Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="http://rstudio.github.io/leaflet/" target="_blank">leaflet</a> 2.0.0 is now on CRAN!</p>
<p>The leaflet R package wraps the <a rel="nofollow" href="https://leafletjs.com/" target="_blank">Leaflet.js</a> JavaScript library, and this release of the R package marks a major upgrade from the outdated Leaflet.js 0.7.x to the current Leaflet.js 1.x (specifically, 1.3.1).</p>
<p>Leaflet.js 1.x includes some non-backward-compatible API changes versus 0.7.x. If you’re using only R code to create your Leaflet maps, these changes should not affect you. If you are using custom JavaScript, some changes may be required to your code. Please see the Leaflet.js <a rel="nofollow" href="http://leafletjs.com/reference-1.3.0.html" target="_blank">reference documentation</a> and <a rel="nofollow" href="https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md" target="_blank">changelog</a>.</p>
<div>
<h2>leaflet.extras and leaflet.esri</h2>
<p>Two additional packages by <a rel="nofollow" href="https://www.karambelkar.info/about/" target="_blank">Bhaskar Karambelkar</a>, leaflet.extras and leaflet.esri, have been updated on CRAN to utilize the latest Leaflet.js library bindings. leaflet.extras extends the Leaflet R package using various Leaflet.js plugins, offering features like heatmaps, additional marker icons, and drawing tools. leaflet.esri provides access to ArcGIS services, based on the <a rel="nofollow" href="https://esri.github.io/esri-leaflet/" target="_blank">ESRI leaflet plugin</a>.</p>
<pre><code>library(leaflet)
library(leaflet.extras)

leaflet(quakes) %>%
  addTiles() %>%
  addHeatmap(lng = ~long, lat = ~lat, radius = 8)</code></pre>
<p><br>
<iframe width="100%" src="https://rstudio-pubs-static.s3.amazonaws.com/388042_d0a5b2ee3b2d44858e9cfc55edb109bf.html" height="400px"><br>
</iframe>
</div>
<div>
<h2>Full changelog</h2>
<div>
<h3>Breaking Changes</h3>
<ul>
<li>Update to latest Leaflet.js 1.x (v1.3.1). Please see the Leaflet.js <a rel="nofollow" href="http://leafletjs.com/reference-1.3.0.html" target="_blank">reference documentation</a> and <a rel="nofollow" href="https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md" target="_blank">change log</a>.</li>
<li>Previously, labels were implemented using the 3rd party extension <a rel="nofollow" href="https://github.com/Leaflet/Leaflet.labelExtension" target="_blank">Leaflet.label</a>. Leaflet.js 1.x now provides this functionality naively. There are some minor differences to note:
<ul>
<li>If you are using custom JavaScript to create labels, you’ll need to change references to <code>L.Label</code> to <code>L.Tooltip</code>.</li>
<li>Tooltips are now displayed with default Leaflet.js styling.</li>
<li>In custom javascript extensions, change all <code>*.bindLabel()</code> to <code>*.bindTooltip()</code>.</li>
</ul>
</li>
<li>All Leaflet.js plugins updated to versions compatible with Leaflet.js 1.x.</li>
</ul>
</div>
<div>
<h3>Known Issues</h3>
<ul>
<li>The default CSS z-index of the Leaflet map has changed; for some Shiny applications, the map now covers elements that are intended to be displayed on top of the map. This issue has been fixed on GitHub (<code>devtools::install_github(&quot;rstudio/leaflet&quot;)</code>). For now, you can work around this in the CRAN version by including this line in your application UI:</li>
</ul>
<pre><code>tags$style(&quot;.leaflet-map-pane { z-index: auto; }&quot;)</code></pre>
</div>
<div>
<h3>Features</h3>
<ul>
<li>Added more providers for <code>addProviderTiles()</code>: OpenStreetMap.CH, OpenInfraMap, OpenInfraMap.Power, OpenInfraMap.Telecom, OpenInfraMap.Petroleum, OpenInfraMap.Water, OpenPtMap, OpenRailwayMap, OpenFireMap, SafeCast.</li>
<li>Add <code>groupOptions</code> function. Currently the only option is letting you specify zoom levels at which a group should be visible.</li>
<li>Added support for drag events.</li>
<li>Added <code>method</code> argument to <code>addRasterImage()</code> to enable nearest neighbor interpolation when projecting categorical rasters.</li>
<li>Added an <code>'auto'</code> method for <code>addRasterImage()</code>. Projected factor results are coerced into factors.</li>
<li>Added <code>data</code> parameter to remaining <code>addXXX()</code> methods, including addLegend.</li>
<li>Added <code>preferCanvas</code> argument to <code>leafletOptions()</code>.<br>
### Bug Fixes and Improvements</li>
<li>Relative protocols are used where possible when adding tiles. In RStudio 1.1.x on linux and windows, a known issue of ‘<a rel="nofollow" href="https:/leaflet-2-0-0/" target="_blank">https://</a>’ routes fail to load, but works within browsers (rstudio/rstudio#2661).</li>
<li><code>L.multiPolyline</code> was absorbed into <code>L.polyline</code>, which also accepts an <a rel="nofollow" href="http://leafletjs.com/reference-1.3.0.html#polyline" target="_blank">array of polyline information</a>.</li>
<li>Fixed bug where icons were anchored to the top-center by default, not center-center.</li>
<li>Fixed bug where markers would not appear in self contained knitr files.</li>
<li><code>L.Label</code> is now <code>L.tooltip</code> in Leaflet.js. <code>labelOptions()</code> now translates old options <code>clickable</code> to <code>interactive</code> and <code>noHide</code> to <code>permanent</code>.</li>
<li>Fix a bug where the default <code>addTiles()</code> would not work with .html files served directly from the filesystem.</li>
<li>Fix bug with accessing columns in formulas when the data source is a Crosstalk SharedData object wrapping a spatial data frame or sf object.</li>
<li>Fix strange wrapping behavior for legend, especially common for Chrome when browser zoom level is not 100%.</li>
<li>Fix incorrect opacity on NA entry in legend.</li>
<li>Ensure type safety of <code>.indexOf(stamp)</code>.</li>
<li><code>validateCoords()</code> warns on invalid polygon data.</li>
</ul>
</div>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://blog.rstudio.com/2018/05/10/leaflet-2-0-0/"> RStudio Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/7sC6Bm35dwk" height="1"></a></div>