

{"id":265,"date":"2021-01-07T13:05:55","date_gmt":"2021-01-07T15:05:55","guid":{"rendered":"http:\/\/meantrix.com\/blog\/?p=265"},"modified":"2021-01-07T13:07:33","modified_gmt":"2021-01-07T15:07:33","slug":"leaflet-multiopacity-package-for-r","status":"publish","type":"post","link":"https:\/\/meantrix.com\/blog\/2021\/01\/07\/leaflet-multiopacity-package-for-r\/","title":{"rendered":"leaflet.multiopacity package for R"},"content":{"rendered":"\n<p><code>leaflet.multiopacity<\/code> is the new package developed by Meantrix team. It provides an extension to the already known <code>leaflet<\/code> package for R, and allows the creation of an opacity control for multiple layers in one single widget.<\/p>\n\n\n\n<p>This package was developed to supply the need for an opacity control which, first: works with the <code>leafletProxy()<\/code> function of <code>leaflet<\/code> package when rendering maps in a Shiny application, and second: works with more than one layer.  However, it can be used in any <code>leaflet<\/code> map where an opacity control is needed, being a Shiny application, a R Markdown file or a single isolated map.<\/p>\n\n\n\n<p>Take a look at some examples:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: r; title: ; notranslate\" title=\"\">\nleaflet()\n  addProviderTiles(&quot;OpenStreetMap&quot;, layerId = &quot;base&quot;)\n  addRasterImage(r, layerId = &quot;rast&quot;)\n  addAwesomeMarkers(lng = -2.79545, lat = 54.04321,\n                    label = &quot;Hospital&quot;, layerId = &quot;hospital&quot;)\n  addOpacityControls()\n#&gt; No filter used, showing all layers.\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/meantrix.github.io\/leaflet.multiopacity\/articles\/usage-leaflet.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"434\" src=\"http:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.29.34.png\" alt=\"\" class=\"wp-image-270\" srcset=\"https:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.29.34.png 703w, https:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.29.34-300x185.png 300w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><\/a><figcaption><a href=\"https:\/\/meantrix.github.io\/leaflet.multiopacity\/articles\/usage-leaflet.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (abre numa nova aba)\">Click here for the interactive version.<\/a><\/figcaption><\/figure>\n\n\n\n<p>The following case shows how to create controls for specific groups only. It is also possible to specify layerIds or categories (types of layers). Furthermore, it is possible to customize the control position and whether the control will be collapsible or not (and the icon size, in this case).<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: r; title: ; notranslate\" title=\"\">\nleaflet()\n  addProviderTiles(&quot;OpenStreetMap&quot;, layerId = &quot;osm&quot;, group = &quot;base&quot;)\n  addRasterImage(r, layerId = &quot;rast&quot;, group = &quot;rasters&quot;)\n  addAwesomeMarkers(lng = -2.79545, lat = 54.04321,\n                    layerId = &quot;hospital&quot;, label = &quot;hospital&quot;,\n                    group = &quot;markers&quot;)\n  addOpacityControls(group = c(&quot;base&quot;, &quot;rasters&quot;, &quot;markers&quot;))\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/meantrix.github.io\/leaflet.multiopacity\/articles\/usage-leaflet.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"434\" src=\"http:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.34.11.png\" alt=\"\" class=\"wp-image-271\" srcset=\"https:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.34.11.png 703w, https:\/\/meantrix.com\/blog\/wp-content\/uploads\/2021\/01\/Captura-de-Tela-2021-01-07-\u00e0s-11.34.11-300x185.png 300w\" sizes=\"(max-width: 703px) 100vw, 703px\" \/><\/a><figcaption><a href=\"https:\/\/meantrix.github.io\/leaflet.multiopacity\/articles\/usage-leaflet.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (abre numa nova aba)\">Click here for the interactive version.<\/a><\/figcaption><\/figure>\n\n\n\n<p>The <code>leaflet.multiopacity<\/code> is already available on CRAN, and more info on usage and instructions can be found on its reference page: <a rel=\"noreferrer noopener\" aria-label=\" (abre numa nova aba)\" href=\"https:\/\/meantrix.github.io\/leaflet.multiopacity\/\" target=\"_blank\">https:\/\/meantrix.github.io\/leaflet.multiopacity\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>leaflet.multiopacity is the new package developed by Meantrix team. It provides an extension to the already known leaflet package for R, and allows the creation of an opacity control for multiple layers in one single widget.<\/p>\n","protected":false},"author":4,"featured_media":276,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[24,23,8],"class_list":["post-265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sem-categoria","tag-leaflet","tag-packages","tag-r"],"_links":{"self":[{"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/posts\/265"}],"collection":[{"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":8,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/posts\/265\/revisions"}],"predecessor-version":[{"id":278,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/posts\/265\/revisions\/278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/media\/276"}],"wp:attachment":[{"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/media?parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/categories?post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meantrix.com\/blog\/wp-json\/wp\/v2\/tags?post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}