Skip to content

Commit 3e65a74

Browse files
committed
Merge branch 'master' into v1.0
2 parents bb4e33d + 59040f9 commit 3e65a74

23 files changed

+3898
-74
lines changed

.Rbuildignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
^javascript$
1313
^package\.json$
1414
^node_modules$
15-
1615
^data-raw$

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
S3method("[",leaflet_awesome_icon_set)
44
S3method("[",leaflet_icon_set)
5+
S3method(metaData,SharedData)
56
S3method(metaData,SpatialLinesDataFrame)
67
S3method(metaData,SpatialPointsDataFrame)
78
S3method(metaData,SpatialPolygonsDataFrame)
89
S3method(metaData,data.frame)
910
S3method(metaData,list)
1011
S3method(metaData,map)
1112
S3method(metaData,sf)
12-
S3method(metaData,sharedData)
1313
S3method(pointData,POINT)
1414
S3method(pointData,SharedData)
1515
S3method(pointData,SpatialPoints)

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ leaflet 1.1.1
1313
* Add `groupOptions` parameter, currently the only option is letting you specify
1414
zoom levels at which a group should be visible.
1515

16+
* Fix bug with accessing columns in formulas when the data source is a Crosstalk
17+
SharedData object wrapping a spatial data frame or sf object.
18+
19+
* Fix incorrect opacity on NA entry in legend. (PR #425)
20+
1621
leaflet 1.1.0
1722
--------------------------------------------------------------------------------
1823

R/layers.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ clearPopups <- function(map) {
478478
#'
479479
#' @param label A vector or list of plain characters or HTML (marked by
480480
#' \code{\link[htmltools]{HTML}}), or a formula that resolves to such a value.
481-
#' @param data A data frame over which the formua is evaluated.
481+
#' @param data A data frame over which the formula is evaluated.
482482
#'
483483
#' @keywords internal
484484
#' @export
@@ -734,7 +734,7 @@ makeIcon <- function(iconUrl = NULL, iconRetinaUrl = NULL, iconWidth = NULL, ico
734734
#' @param iconWidth,iconHeight size of the icon image in pixels
735735
#' @param iconAnchorX,iconAnchorY the coordinates of the "tip" of the icon
736736
#' (relative to its top left corner, i.e. the top left corner means
737-
#' \code{iconAnchorX = 0} and \code{iconAnchorY = 0)}, and the icon will be
737+
#' \code{iconAnchorX = 0} and \code{iconAnchorY = 0}), and the icon will be
738738
#' aligned so that this point is at the marker's geographical location
739739
#' @param shadowUrl the URL or file path to the icon shadow image
740740
#' @param shadowRetinaUrl the URL or file path to the retina sized version of

R/legend.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@
4949
#' @param layerId the ID of the legend; subsequent calls to \code{addLegend}
5050
#' or \code{addControl} with the same \code{layerId} will replace this
5151
#' legend. The ID can also be used with \code{removeControl}.
52+
#' @param group \code{group} name of a leaflet layer group.
53+
#' Supplying this value will tie the legend to the leaflet layer group
54+
#' with this name and will auto add/remove the legend as the
55+
#' group is added/removed, for example via layerControl.
56+
#' You will need to set the \code{group} when you add a layer
57+
#' (e.g. \code{\link{addPolygons}}) and supply the same name here.
5258
#' @example inst/examples/legend.R
5359
#' @export
5460
addLegend <- function(
5561
map, position = c('topright', 'bottomright', 'bottomleft', 'topleft'),
56-
pal, values, na.label = 'NA', bins = 7, colors, opacity = 0.5, labels,
62+
pal, values, na.label = 'NA', bins = 7, colors, opacity = 0.5, labels = NULL,
5763
labFormat = labelFormat(), title = NULL, className = "info legend",
58-
layerId = NULL
64+
layerId = NULL, group = NULL
5965
) {
6066
position = match.arg(position)
6167
type = 'unknown'; na.color = NULL
@@ -147,7 +153,7 @@ addLegend <- function(
147153
colors = I(unname(colors)), labels = I(unname(labels)),
148154
na_color = na.color, na_label = na.label, opacity = opacity,
149155
position = position, type = type, title = title, extra = extra,
150-
layerId = layerId, className = className
156+
layerId = layerId, className = className, group = group
151157
)
152158
invokeMethod(map, getMapData(map), "addLegend", legend)
153159
}

R/normalize-SharedData.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' @export
2-
metaData.sharedData <- function(obj) {
3-
obj$data(withSelection = TRUE, withFilter = FALSE, withKey = TRUE)
2+
metaData.SharedData <- function(obj) {
3+
metaData(obj$data(withSelection = TRUE, withFilter = FALSE, withKey = TRUE))
44
}
55

66
#' @export

R/plugin-awesomeMarkers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ makeAwesomeIcon <- function(
175175
#' = 'fa'})
176176
#' @param extraClasses Additional css classes to include on the icon.
177177
#' @return A list of awesome-icon data that can be passed to the \code{icon}
178-
#' @param squareMarker Whether to use a sqare marker.
178+
#' @param squareMarker Whether to use a square marker.
179179
#' @param iconRotate Rotate the icon by a given angle.
180180
#' @param fontFamily Used when \code{text} option is specified.
181181
#' @param text Use this text string instead of an icon.

R/plugin-measure.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ leafletMeasureDependencies <- function() {
2626
#' @param completedColor base color to use for features generated
2727
#' from a completed measurement.
2828
#' Value should be a color represented as a hexadecimal string.
29-
#' @param popupOptions \code{list} of ptions applied to the popup
29+
#' @param popupOptions \code{list} of options applied to the popup
3030
#' of the resulting measure feature.
3131
#' Properties may be any \href{http://leafletjs.com/reference.html#popup-options}{standard Leaflet popup options}.
3232
#' @param captureZIndex Z-index of the marker used to capture measure clicks.

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ leafletProxy <- function(mapId, session = shiny::getDefaultReactiveDomain(),
152152
# This won't be necessary in future versions of Shiny, as session$ns (and
153153
# other forms of ns()) will be smart enough to only namespace un-namespaced
154154
# IDs.
155-
if (!is.null(session$ns) && nzchar(session$ns(NULL)) && !startsWith(mapId, session$ns(""))) {
155+
if (!is.null(session$ns) && nzchar(session$ns(NULL)) && substring(mapId, 1, nchar(session$ns(""))) != session$ns("")) {
156156
mapId <- session$ns(mapId)
157157
}
158158

inst/examples/groupOptions.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
library(leaflet)
2+
pal <- colorQuantile("YlOrRd", quakes$mag)
3+
4+
leaflet(quakes) %>%
5+
addProviderTiles(providers$Esri.OceanBasemap, group = "basic") %>%
6+
addCircleMarkers(group = "detail", fillOpacity = 0.5,
7+
radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>%
8+
addLegend(pal = pal, values = ~mag, group='detail', position='bottomleft')
9+
10+
l <- leaflet(quakes) %>%
11+
addProviderTiles(providers$Esri.OceanBasemap, group = "basic") %>%
12+
addMarkers(data = quakes, group = "basic") %>%
13+
addCircleMarkers(group = "detail", fillOpacity = 0.5,
14+
radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>%
15+
addLegend(pal = pal, values = ~mag, group='detail', position='bottomleft') %>%
16+
groupOptions("detail", zoomLevels = 7:18) %>%
17+
addControl(htmltools::HTML("Zoom Level"), position = "topright",
18+
layerId = "zoom_display")
19+
20+
# Just to show the zoom level
21+
htmlwidgets::onRender(l, jsCode = htmlwidgets::JS(
22+
"function(el, x) {
23+
debugger;
24+
var map = this;
25+
detailsControl = document.getElementById('zoom_display');
26+
detailsControl.innerHTML = '<div>Zoom Level:'+map.getZoom()+'</div>';
27+
map.on('zoomend', function(e) {
28+
detailsControl = document.getElementById('zoom_display');
29+
detailsControl.innerHTML = '<div>Zoom Level:'+map.getZoom()+'</div>';
30+
});
31+
}"))

0 commit comments

Comments
 (0)