Skip to content

Commit 78c57df

Browse files
Merge pull request #3 from meantrix/develop
v0.1.1
2 parents f905a4f + 3990693 commit 78c57df

File tree

10 files changed

+33
-13
lines changed

10 files changed

+33
-13
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: leaflet.multiopacity
22
Type: Package
33
Title: Leaflet Multiple Opacity Controls for R
4-
Version: 0.1.0
4+
Version: 0.1.1
55
Authors@R: c(
66
person(
77
given = "Vinícius",

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# leaflet.multiopacity 0.1.1
2+
3+
* Fix a bug with control icon when collapsed is TRUE.
4+
* Implement a new argument to set control size when collapsed is enabled.
5+
16
# leaflet.multiopacity 0.1.0
27

38
* Initial release of `leaflet.multiopacity`.

R/multiopacity.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#' If FALSE (the default), the opacity control will always appear
2222
#' in its expanded state. Set to TRUE to have the opacity control
2323
#' rendered as an icon that expands when hovered over.
24+
#' @param size
25+
#' Collapsed control size: "m" (medium) or "s" (small).
2426
#' @param position
2527
#' Position of control: "topleft", "topright", "bottomleft", or "bottomright".
2628
#' @param title
@@ -67,6 +69,7 @@ addOpacityControls <- function(map,
6769
category = NULL,
6870
group = NULL,
6971
collapsed = FALSE,
72+
size = c("m", "s"),
7073
position = c(
7174
"topright",
7275
"topleft",
@@ -85,6 +88,7 @@ addOpacityControls <- function(map,
8588
stopifnot(inherits(collapsed, "logical"), length(collapsed) == 1)
8689
if (!is.null(title)) stopifnot(inherits(title, "character"), length(title) == 1)
8790
stopifnot(inherits(renderOnLayerAdd, "logical"), length(renderOnLayerAdd) == 1)
91+
size <- match.arg(size)
8892
position <- match.arg(position)
8993

9094
if (isTRUE(collapsed) && !is.null(title)) {
@@ -101,6 +105,7 @@ addOpacityControls <- function(map,
101105
type = type,
102106
collapsed = collapsed,
103107
position = position,
108+
size = size,
104109
label = title
105110
))
106111

@@ -139,6 +144,7 @@ addOpacityControls <- function(map,
139144
options = {
140145
collapsed: data.options.collapsed,
141146
position: data.options.position,
147+
size: data.options.size,
142148
label: data.options.label
143149
}
144150
).addTo(map);
@@ -175,6 +181,7 @@ addOpacityControls <- function(map,
175181
options = {
176182
collapsed: data.options.collapsed,
177183
position: data.options.position,
184+
size: data.options.size,
178185
label: data.options.label
179186
}
180187
).addTo(map);

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
## leaflet.multiopacity <a href='http://meantrix.com'><img src='man/figures/logo.png' align="right" height="139" /></a>
22

3-
<!--
4-
# leaflet.multiopacity
5-
<a href='http://meantrix.com'><img src='man/figures/header.png'/>
6-
-->
7-
83
<!-- badges: start -->
9-
[![version](https://img.shields.io/badge/version-0.1.0-blue.svg)](https://semver.org)
4+
[![version](https://img.shields.io/badge/version-0.1.1-blue.svg)](https://semver.org)
105
[![CRAN status](https://www.r-pkg.org/badges/version/leaflet.multiopacity)](https://CRAN.R-project.org/package=leaflet.multiopacity)
116
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
127
[![Codecov test coverage](https://codecov.io/gh/meantrix/leaflet.multiopacity/branch/main/graph/badge.svg)](https://codecov.io/gh/meantrix/leaflet.multiopacity?branch=main)

inst/src/Leaflet.Control.Opacity/L.Control.Opacity.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ input[type="range"]::-ms-thumb {
3333

3434
/* 題名レイアウト */
3535
.leaflet-control-layers-label {
36-
margin: 0px 0px 8px 1px
36+
margin: 0px 0px 8px 1px;
3737
}
3838

39-
.multiopacity {
40-
background-image: url(images/alpha.png)!important;
39+
.multiopacity-m {
40+
background-image: url(images/alpha-2x.png)!important;
41+
background-size: 32px!important;
42+
}
43+
44+
.multiopacity-s {
45+
background-image: url(images/alpha-2x.png)!important;
46+
background-size: 20px!important;
47+
width: 30px!important;
48+
height: 30px!important;
4149
}

inst/src/Leaflet.Control.Opacity/L.Control.Opacity.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ L.Control.Opacity = L.Control.extend({
22
options: {
33
collapsed: false,
44
position: 'topright',
5+
size: 'm',
56
label: null
67
},
78
initialize: function (overlays, options) {
@@ -39,6 +40,7 @@ L.Control.Opacity = L.Control.extend({
3940
var className = 'leaflet-control-layers',
4041
container = this._container = L.DomUtil.create('div', className),
4142
collapsed = this.options.collapsed;
43+
size = this.options.size;
4244
container.setAttribute('aria-haspopup', true);
4345
L.DomEvent.disableClickPropagation(container);
4446
L.DomEvent.disableScrollPropagation(container);
@@ -58,7 +60,7 @@ L.Control.Opacity = L.Control.extend({
5860
}
5961
}
6062
//var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
61-
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle multiopacity', container);
63+
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle multiopacity-' + size, container);
6264
link.href = '#';
6365
link.title = 'Layers';
6466
if (L.Browser.touch) {
2.9 KB
Loading
-3.54 KB
Loading

man/addOpacityControls.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/usage-leaflet.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ leaflet() %>%
3939

4040
Note that each function call has its own layerId. If you don't provide a layerId for your layers, the opacity controls will still work, but will use the internal `_leaflet_id` as a label for each control.
4141

42-
You can also customize some interface aspects such as box title, position and whether opacity controls will remain collapsed.
42+
You can also customize some interface aspects such as box title, position, size and whether opacity controls will remain collapsed.
4343

4444
```{r, warning=FALSE}
4545
leaflet() %>%
4646
addProviderTiles("OpenStreetMap", layerId = "base") %>%
4747
addRasterImage(r, layerId = "rast") %>%
4848
addAwesomeMarkers(lng = -2.79545, lat = 54.04321,
4949
label = "Hospital", layerId = "hospital") %>%
50-
addOpacityControls(collapsed = TRUE, position = "topleft")
50+
addOpacityControls(collapsed = TRUE, position = "topleft", size = "s")
5151
```
5252

5353
You can also define the subset of layers you want to show opacity controls to. You can provide the layerId of the layers to be shown.

0 commit comments

Comments
 (0)