Skip to content

Commit c25e7e2

Browse files
committed
Rebuild docs
1 parent 6900de9 commit c25e7e2

18 files changed

+1004
-360
lines changed

docs/basemaps.html

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,16 @@
245245

246246
<div id="using-basemaps" class="section level2">
247247
<h2>Using Basemaps</h2>
248-
<p>Leaflet supports basemaps using <a href="https://www.mapbox.com/guides/how-web-maps-work/">map tiles</a>, popularized by Google Maps and now used by nearly all interactive web maps.</p>
248+
<p>Leaflet supports basemaps using <a
249+
href="https://www.mapbox.com/guides/how-web-maps-work/">map tiles</a>,
250+
popularized by Google Maps and now used by nearly all interactive web
251+
maps.</p>
249252
<div id="default-openstreetmap-tiles" class="section level3">
250253
<h3>Default (OpenStreetMap) Tiles</h3>
251-
<p>The easiest way to add tiles is by calling <code>addTiles()</code> with no arguments; by default, <a href="https://www.openstreetmap.org/">OpenStreetMap</a> tiles are used.</p>
254+
<p>The easiest way to add tiles is by calling <code>addTiles()</code>
255+
with no arguments; by default, <a
256+
href="https://www.openstreetmap.org/">OpenStreetMap</a> tiles are
257+
used.</p>
252258
<pre class="r"><code>m &lt;- leaflet() %&gt;% setView(lng = -71.0589, lat = 42.3601, zoom = 12)
253259
m %&gt;% addTiles()</code></pre>
254260
<div id="htmlwidget-562da05387aef08f69fb" style="width:100%;height:240px;" class="leaflet html-widget"></div>
@@ -272,7 +278,7 @@ <h3>Default (OpenStreetMap) Tiles</h3>
272278
{
273279
"method": "addTiles",
274280
"args": [
275-
"//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
281+
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
276282
null,
277283
null,
278284
{
@@ -288,7 +294,7 @@ <h3>Default (OpenStreetMap) Tiles</h3>
288294
"opacity": 1,
289295
"zIndex": 1,
290296
"detectRetina": false,
291-
"attribution": "&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"
297+
"attribution": "&copy; <a href=\"https://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"
292298
}
293299
]
294300
}
@@ -300,8 +306,20 @@ <h3>Default (OpenStreetMap) Tiles</h3>
300306
</div>
301307
<div id="third-party-tiles" class="section level3">
302308
<h3>Third-Party Tiles</h3>
303-
<p>Alternatively, many popular free third-party basemaps can be added using the <code>addProviderTiles()</code> function, which is implemented using the <a href="https://github.com/leaflet-extras/leaflet-providers">leaflet-providers plugin</a>. See <a href="http://leaflet-extras.github.io/leaflet-providers/preview/index.html">here</a> for the complete set.</p>
304-
<p>As a convenience, leaflet also provides a named list of all the third-party tile providers that are supported by the plugin. This enables you to use auto-completion feature of your favorite R IDE (like RStudio) and not have to remember or look up supported tile providers; just type <code>providers$</code> and choose from one of the options. You can also use <code>names(providers)</code> to view all of the options.</p>
309+
<p>Alternatively, many popular free third-party basemaps can be added
310+
using the <code>addProviderTiles()</code> function, which is implemented
311+
using the <a
312+
href="https://github.com/leaflet-extras/leaflet-providers">leaflet-providers
313+
plugin</a>. See <a
314+
href="http://leaflet-extras.github.io/leaflet-providers/preview/index.html">here</a>
315+
for the complete set.</p>
316+
<p>As a convenience, leaflet also provides a named list of all the
317+
third-party tile providers that are supported by the plugin. This
318+
enables you to use auto-completion feature of your favorite R IDE (like
319+
RStudio) and not have to remember or look up supported tile providers;
320+
just type <code>providers$</code> and choose from one of the options.
321+
You can also use <code>names(providers)</code> to view all of the
322+
options.</p>
305323
<pre class="r"><code>m %&gt;% addProviderTiles(providers$Stamen.Toner)</code></pre>
306324
<div id="htmlwidget-92aa9ec4a26e6d2eb4c3" style="width:100%;height:120px;" class="leaflet html-widget"></div>
307325
<script type="application/json" data-for="htmlwidget-92aa9ec4a26e6d2eb4c3">{
@@ -413,15 +431,25 @@ <h3>Third-Party Tiles</h3>
413431
"evals": [],
414432
"jsHooks": []
415433
}</script>
416-
<p>Note that some tile set providers require you to register; see the <a href="https://github.com/leaflet-extras/leaflet-providers">project page</a> for more information. You can pass access tokens/keys, and other options, to the tile provider by populating the <code>options</code> argument with the <code>providerTileOptions()</code> function.</p>
434+
<p>Note that some tile set providers require you to register; see the <a
435+
href="https://github.com/leaflet-extras/leaflet-providers">project
436+
page</a> for more information. You can pass access tokens/keys, and
437+
other options, to the tile provider by populating the
438+
<code>options</code> argument with the
439+
<code>providerTileOptions()</code> function.</p>
417440
</div>
418441
<div id="custom-tile-url-template" class="section level3">
419442
<h3>Custom Tile URL Template</h3>
420-
<p>If you happen to have a custom map tile URL template to use, you can provide it as an argument to <code>addTiles()</code>.</p>
443+
<p>If you happen to have a custom map tile URL template to use, you can
444+
provide it as an argument to <code>addTiles()</code>.</p>
421445
</div>
422446
<div id="wms-tiles" class="section level3">
423447
<h3>WMS Tiles</h3>
424-
<p>You can use <code>addWMSTiles()</code> to add WMS (Web Map Service) tiles. The map below shows the Base Reflectivity (a measure of the intensity of precipitation occurring) using the WMS from the <a href="http://mesonet.agron.iastate.edu">Iowa Environmental Mesonet</a>:</p>
448+
<p>You can use <code>addWMSTiles()</code> to add WMS (Web Map Service)
449+
tiles. The map below shows the Base Reflectivity (a measure of the
450+
intensity of precipitation occurring) using the WMS from the <a
451+
href="http://mesonet.agron.iastate.edu">Iowa Environmental
452+
Mesonet</a>:</p>
425453
<pre class="r"><code>leaflet() %&gt;% addTiles() %&gt;% setView(-93.65, 42.0285, zoom = 4) %&gt;%
426454
addWMSTiles(
427455
&quot;http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi&quot;,
@@ -445,7 +473,7 @@ <h3>WMS Tiles</h3>
445473
{
446474
"method": "addTiles",
447475
"args": [
448-
"//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
476+
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
449477
null,
450478
null,
451479
{
@@ -461,7 +489,7 @@ <h3>WMS Tiles</h3>
461489
"opacity": 1,
462490
"zIndex": 1,
463491
"detectRetina": false,
464-
"attribution": "&copy; <a href=\"http://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"
492+
"attribution": "&copy; <a href=\"https://openstreetmap.org\">OpenStreetMap<\/a> contributors, <a href=\"https://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA<\/a>"
465493
}
466494
]
467495
},
@@ -494,7 +522,10 @@ <h3>WMS Tiles</h3>
494522
</div>
495523
<div id="combining-tile-layers" class="section level3">
496524
<h3>Combining Tile Layers</h3>
497-
<p>You aren’t restricted to using a single basemap on a map; you can stack them by adding multiple tile layers. This generally only makes sense if the front tiles consist of semi transparent tiles, or have an adjusted opacity via the <code>options</code> argument.</p>
525+
<p>You aren’t restricted to using a single basemap on a map; you can
526+
stack them by adding multiple tile layers. This generally only makes
527+
sense if the front tiles consist of semi transparent tiles, or have an
528+
adjusted opacity via the <code>options</code> argument.</p>
498529
<pre class="r"><code>m %&gt;% addProviderTiles(providers$MtbMap) %&gt;%
499530
addProviderTiles(providers$Stamen.TonerLines,
500531
options = providerTileOptions(opacity = 0.35)) %&gt;%

docs/choropleths.html

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,12 @@
245245

246246
<div id="choropleths" class="section level2">
247247
<h2>Choropleths</h2>
248-
<p>Making choropleths with leaflet is easy. In this example, we’ll duplicate the <a href="https://leafletjs.com/examples/choropleth/">step-by-step choropleth tutorial</a> from the Leaflet.js website.</p>
249-
<p>The final result will look like this (scroll to the end to see the completed code):</p>
248+
<p>Making choropleths with leaflet is easy. In this example, we’ll
249+
duplicate the <a
250+
href="https://leafletjs.com/examples/choropleth/">step-by-step
251+
choropleth tutorial</a> from the Leaflet.js website.</p>
252+
<p>The final result will look like this (scroll to the end to see the
253+
completed code):</p>
250254
<pre><code>## Registered S3 method overwritten by &#39;geojsonsf&#39;:
251255
## method from
252256
## print.geojson geojson</code></pre>
@@ -1136,27 +1140,40 @@ <h2>Choropleths</h2>
11361140
}</script>
11371141
<div id="data-source" class="section level3">
11381142
<h3>Data source</h3>
1139-
<p>We’ll start by loading the data from JSON. While the Leaflet.js example loads the JSON directly into JavaScript, with the Leaflet R package we instead want to load the data into R.</p>
1140-
<p>In this case, we’ll use the <code>geojsonio</code> package to load the data into <code>sp</code> objects, which will let us easily manipulate the geographic features, and their properties, in R.</p>
1143+
<p>We’ll start by loading the data from JSON. While the Leaflet.js
1144+
example loads the JSON directly into JavaScript, with the Leaflet R
1145+
package we instead want to load the data into R.</p>
1146+
<p>In this case, we’ll use the <code>geojsonio</code> package to load
1147+
the data into <code>sp</code> objects, which will let us easily
1148+
manipulate the geographic features, and their properties, in R.</p>
11411149
<pre class="r"><code>states &lt;- geojsonio::geojson_read(&quot;https://rstudio.github.io/leaflet/json/us-states.geojson&quot;, what = &quot;sp&quot;)
11421150
class(states)</code></pre>
11431151
<pre><code>## [1] &quot;SpatialPolygonsDataFrame&quot;
11441152
## attr(,&quot;package&quot;)
11451153
## [1] &quot;sp&quot;</code></pre>
11461154
<pre class="r"><code>names(states)</code></pre>
11471155
<pre><code>## [1] &quot;id&quot; &quot;name&quot; &quot;density&quot;</code></pre>
1148-
<p>As you can see, we now have a <code>SpatialPolygonsDataFrame</code> with <code>name</code> (state name) and <code>density</code> (population density in people/mi<sup>2</sup>) columns from the GeoJSON.</p>
1156+
<p>As you can see, we now have a <code>SpatialPolygonsDataFrame</code>
1157+
with <code>name</code> (state name) and <code>density</code> (population
1158+
density in people/mi<sup>2</sup>) columns from the GeoJSON.</p>
11491159
</div>
11501160
<div id="basic-states-map" class="section level3">
11511161
<h3>Basic states map</h3>
1152-
<p>Next, let’s make a basic map with just the outline of the states. For our basemap, we’ll use the same <code>"mapbox.light"</code> MapBox style that the example does; if you don’t have a MapBox account, you can just use <code>addTiles()</code> in place of the <code>addProviderTiles</code> call, or choose a free provider.</p>
1162+
<p>Next, let’s make a basic map with just the outline of the states. For
1163+
our basemap, we’ll use the same <code>"mapbox.light"</code> MapBox style
1164+
that the example does; if you don’t have a MapBox account, you can just
1165+
use <code>addTiles()</code> in place of the
1166+
<code>addProviderTiles</code> call, or choose a free provider.</p>
11531167
<pre class="r"><code>m &lt;- leaflet(states) %&gt;%
11541168
setView(-96, 37.8, 4) %&gt;%
11551169
addProviderTiles(&quot;MapBox&quot;, options = providerTileOptions(
11561170
id = &quot;mapbox.light&quot;,
11571171
accessToken = Sys.getenv(&#39;MAPBOX_ACCESS_TOKEN&#39;)))</code></pre>
1158-
<p>We’ve saved the basic basemap as a separate variable <code>m</code> so we can easily iterate on the <code>addPolygons</code> call as we work through the rest of the tutorial.</p>
1159-
<p>To add uniform polygons with default styling, just call <code>addPolygons</code> with no additional arguments.</p>
1172+
<p>We’ve saved the basic basemap as a separate variable <code>m</code>
1173+
so we can easily iterate on the <code>addPolygons</code> call as we work
1174+
through the rest of the tutorial.</p>
1175+
<p>To add uniform polygons with default styling, just call
1176+
<code>addPolygons</code> with no additional arguments.</p>
11601177
<pre class="r"><code>m %&gt;% addPolygons()</code></pre>
11611178
<div id="htmlwidget-92aa9ec4a26e6d2eb4c3" style="width:100%;height:216px;" class="leaflet html-widget"></div>
11621179
<script type="application/json" data-for="htmlwidget-92aa9ec4a26e6d2eb4c3">{
@@ -1962,10 +1979,19 @@ <h3>Basic states map</h3>
19621979
</div>
19631980
<div id="adding-some-color" class="section level3">
19641981
<h3>Adding some color</h3>
1965-
<p>Now, let’s color the states according to their population density. You have <a href="../colors.html">various options</a> for mapping data to colors; for this example we’ll match the Leaflet.js tutorial by mapping a specific set of bins into RColorBrewer colors.</p>
1966-
<p>First, we’ll define the bins. This is a numeric vector that defines the boundaries between intervals (<code>(0,10]</code>, <code>(10,20]</code>, and so on).</p>
1967-
<p>Then, we’ll call <code>colorBin</code> to generate a palette function that maps the RColorBrewer <code>"YlOrRd"</code> colors to our bins.</p>
1968-
<p>Finally, we’ll modify <code>addPolygons</code> to use the palette function and the density values to generate a vector of colors for <code>fillColor</code>, and also add some other static style properties.</p>
1982+
<p>Now, let’s color the states according to their population density.
1983+
You have <a href="../colors.html">various options</a> for mapping data
1984+
to colors; for this example we’ll match the Leaflet.js tutorial by
1985+
mapping a specific set of bins into RColorBrewer colors.</p>
1986+
<p>First, we’ll define the bins. This is a numeric vector that defines
1987+
the boundaries between intervals (<code>(0,10]</code>,
1988+
<code>(10,20]</code>, and so on).</p>
1989+
<p>Then, we’ll call <code>colorBin</code> to generate a palette function
1990+
that maps the RColorBrewer <code>"YlOrRd"</code> colors to our bins.</p>
1991+
<p>Finally, we’ll modify <code>addPolygons</code> to use the palette
1992+
function and the density values to generate a vector of colors for
1993+
<code>fillColor</code>, and also add some other static style
1994+
properties.</p>
19691995
<pre class="r"><code>bins &lt;- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
19701996
pal &lt;- colorBin(&quot;YlOrRd&quot;, domain = states$density, bins = bins)
19711997

@@ -2781,7 +2807,9 @@ <h3>Adding some color</h3>
27812807
</div>
27822808
<div id="adding-interaction" class="section level3">
27832809
<h3>Adding interaction</h3>
2784-
<p>The next thing we’ll want is to make the polygons highlight as the mouse passes over them. The <code>addPolygon</code> function has a <code>highlight</code> argument that makes this simple.</p>
2810+
<p>The next thing we’ll want is to make the polygons highlight as the
2811+
mouse passes over them. The <code>addPolygon</code> function has a
2812+
<code>highlight</code> argument that makes this simple.</p>
27852813
<pre class="r"><code>m %&gt;% addPolygons(
27862814
fillColor = ~pal(density),
27872815
weight = 2,
@@ -3603,13 +3631,22 @@ <h3>Adding interaction</h3>
36033631
"evals": [],
36043632
"jsHooks": []
36053633
}</script>
3606-
<p>(The Leaflet.js tutorial also adds an event handler that zooms into a state when it’s clicked. This isn’t currently possible with the Leaflet R package, except with either custom JavaScript or using Shiny, both of which are outside the scope of this example.)</p>
3634+
<p>(The Leaflet.js tutorial also adds an event handler that zooms into a
3635+
state when it’s clicked. This isn’t currently possible with the Leaflet
3636+
R package, except with either custom JavaScript or using Shiny, both of
3637+
which are outside the scope of this example.)</p>
36073638
</div>
36083639
<div id="custom-info" class="section level3">
36093640
<h3>Custom info</h3>
36103641
<p>Now let’s expose the state names and values to the user.</p>
3611-
<p>The Leaflet.js tutorial shows the hovered-over state’s information in a custom control. Again, that’s possible by adding custom JavaScript or using Shiny, but for this example we’ll use the built-in labels feature instead.</p>
3612-
<p>We’ll generate the labels by handcrafting some HTML, and passing it to <code>lapply(htmltools::HTML)</code> so that Leaflet knows to treat each label as HTML instead of as plain text. We’ll also set some label options to improve the style of the label element itself.</p>
3642+
<p>The Leaflet.js tutorial shows the hovered-over state’s information in
3643+
a custom control. Again, that’s possible by adding custom JavaScript or
3644+
using Shiny, but for this example we’ll use the built-in labels feature
3645+
instead.</p>
3646+
<p>We’ll generate the labels by handcrafting some HTML, and passing it
3647+
to <code>lapply(htmltools::HTML)</code> so that Leaflet knows to treat
3648+
each label as HTML instead of as plain text. We’ll also set some label
3649+
options to improve the style of the label element itself.</p>
36133650
<pre class="r"><code>labels &lt;- sprintf(
36143651
&quot;&lt;strong&gt;%s&lt;/strong&gt;&lt;br/&gt;%g people / mi&lt;sup&gt;2&lt;/sup&gt;&quot;,
36153652
states$name, states$density
@@ -4499,11 +4536,15 @@ <h3>Custom info</h3>
44994536
"evals": [],
45004537
"jsHooks": []
45014538
}</script>
4502-
<p>This is the final version of our polygon layer, so let’s save the result back to the <code>m</code> variable.</p>
4539+
<p>This is the final version of our polygon layer, so let’s save the
4540+
result back to the <code>m</code> variable.</p>
45034541
</div>
45044542
<div id="legend" class="section level3">
45054543
<h3>Legend</h3>
4506-
<p>As our final step, let’s add a legend. Because we chose to color our map using <code>colorBin</code>, the <code>addLegend</code> function makes it particularly easy to add a legend with the correct colors and intervals.</p>
4544+
<p>As our final step, let’s add a legend. Because we chose to color our
4545+
map using <code>colorBin</code>, the <code>addLegend</code> function
4546+
makes it particularly easy to add a legend with the correct colors and
4547+
intervals.</p>
45074548
<pre class="r"><code>m %&gt;% addLegend(pal = pal, values = ~density, opacity = 0.7, title = NULL,
45084549
position = &quot;bottomright&quot;)</code></pre>
45094550
<div id="htmlwidget-2f386608a10ed269577b" style="width:100%;height:216px;" class="leaflet html-widget"></div>

0 commit comments

Comments
 (0)