Skip to content

Commit fc22f96

Browse files
authored
Merge pull request #301 from bhaskarvk/milestone/v1.1
Batch 1 Milestone/v1.1
2 parents 1bc41ee + a6b1177 commit fc22f96

21 files changed

+340
-70
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: leaflet
22
Type: Package
33
Title: Create Interactive Web Maps with the JavaScript 'Leaflet' Library
4-
Version: 1.0.2.9002
4+
Version: 1.0.2.9003
55
Date: 2016-09-17
66
Authors@R: c(
77
person("Joe", "Cheng", email = "[email protected]", role = c("aut", "cre")),

NAMESPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ export(colorFactor)
5454
export(colorNumeric)
5555
export(colorQuantile)
5656
export(createLeafletMap)
57+
export(derivePoints)
58+
export(derivePolygons)
5759
export(dispatch)
5860
export(easyButton)
5961
export(easyButtonState)
62+
export(evalFormula)
63+
export(expandLimits)
64+
export(expandLimitsBbox)
65+
export(filterNULL)
6066
export(fitBounds)
6167
export(getMapData)
6268
export(hideGroup)
@@ -75,6 +81,7 @@ export(leafletProxy)
7581
export(makeAwesomeIcon)
7682
export(makeIcon)
7783
export(mapOptions)
84+
export(markerClusterDependencies)
7885
export(markerClusterOptions)
7986
export(markerOptions)
8087
export(pathOptions)
@@ -96,6 +103,7 @@ export(removeShape)
96103
export(removeTiles)
97104
export(removeTopoJSON)
98105
export(renderLeaflet)
106+
export(safeLabel)
99107
export(scaleBarOptions)
100108
export(setMaxBounds)
101109
export(setView)

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
leaflet 1.1
22
--------------------------------------------------------------------------------
33

4+
* Fixed Issues #288, #261, #283
5+
46
* Added 2 new plugins Proj4Leaflet (PR #294) and EasyButton (PR #295).
57

68
* Upgraded existing plugins to their respective latest versions and added missing/new functionality from those plugins. (PR #293)

R/layers.R

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# Evaluate list members that are formulae, using the map data as the environment
2-
# (if provided, otherwise the formula environment)
1+
#' Evaluate list members that are formulae, using the map data as the environment
2+
#' (if provided, otherwise the formula environment)
3+
#' @param list with members as formulae
4+
#' @param data map data
5+
#' @export
36
evalFormula = function(list, data) {
47
evalAll = function(x) {
58
if (is.list(x)) {
@@ -15,9 +18,13 @@ evalFormula = function(list, data) {
1518
# polygon lists (returned from polygonData()) use `attr(x, "bbox")` (though at
1619
# least they are the same shape as the Spatial bounding boxes).
1720

18-
# Notifies the map of new latitude/longitude of items of interest on the map, so
19-
# that we can expand the limits (i.e. bounding box). We will use this as the
21+
#' Notifies the map of new latitude/longitude of items of interest on the map
22+
# So that we can expand the limits (i.e. bounding box). We will use this as the
2023
# initial view if the user doesn't explicitly specify bounds using fitBounds.
24+
#' @param map map object
25+
#' @param lat vector of latitudes
26+
#' @param lng vector of longitudes
27+
#' @export
2128
expandLimits = function(map, lat, lng) {
2229
if (is.null(map$x$limits)) map$x$limits = list()
2330

@@ -33,8 +40,11 @@ expandLimits = function(map, lat, lng) {
3340
map
3441
}
3542

36-
# Same as expandLimits, but takes a polygon (that presumably has a bbox attr)
37-
# rather than lat/lng.
43+
#' Same as expandLimits, but takes a polygon (that presumably has a bbox attr)
44+
#' rather than lat/lng.
45+
#' @param map map object
46+
#' @param poly A spatial object representing a polygon.
47+
#' @export
3848
expandLimitsBbox = function(map, poly) {
3949
bbox = attr(poly, "bbox", exact = TRUE)
4050
if (is.null(bbox)) stop("Polygon data had no bbox")
@@ -358,6 +368,7 @@ WMSTileOptions = function(
358368
#' the latitude column from \code{data})
359369
#' @param popup a character vector of the HTML content for the popups (you are
360370
#' recommended to escape the text using \code{\link[htmltools]{htmlEscape}()}
371+
#' @param popupOptions A Vector of \code{\link{popupOptions}} to provide popups
361372
#' for security reasons)
362373
#' @param layerId the layer id
363374
#' @param group the name of the group the newly created layers should belong to
@@ -380,6 +391,7 @@ addPopups = function(
380391
expandLimits(pts$lat, pts$lng)
381392
}
382393

394+
#' options for specify popup realted options
383395
#' @param className a CSS class name set on an element
384396
#' @param
385397
#' maxWidth,minWidth,maxHeight,autoPan,keepInView,closeButton,zoomAnimation,closeOnClick
@@ -421,7 +433,9 @@ clearPopups = function(map) {
421433
invokeMethod(map, NULL, 'clearPopups')
422434
}
423435

424-
# Helper Function to create a safe label
436+
#' Helper Function to create a safe label
437+
#' @describeIn map-layers Create a label with sanitized text/html
438+
#' @export
425439
safeLabel <- function(label, data) {
426440
if (is.null(label)) {
427441
return(label)
@@ -484,6 +498,7 @@ addMarkers = function(
484498
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
485499
icon = NULL,
486500
popup = NULL,
501+
popupOptions = NULL,
487502
label = NULL,
488503
labelOptions = NULL,
489504
options = markerOptions(),
@@ -518,8 +533,9 @@ addMarkers = function(
518533

519534
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addMarkers")
520535
invokeMethod(
521-
map, data, 'addMarkers', pts$lat, pts$lng, icon, layerId, group, options, popup,
522-
clusterOptions, clusterId, safeLabel(label, data), labelOptions
536+
map, data, 'addMarkers', pts$lat, pts$lng, icon, layerId, group, options,
537+
popup, popupOptions, clusterOptions, clusterId,
538+
safeLabel(label, data), labelOptions
523539
) %>% expandLimits(pts$lat, pts$lng)
524540
}
525541

@@ -549,6 +565,9 @@ addLabelOnlyMarkers = function(
549565
data = data)
550566
}
551567

568+
#' Adds marker-cluster-plugin HTML dependency
569+
#' @export
570+
#' @describeIn map-layers add maker cluster plugin
552571
markerClusterDependencies = function() {
553572
list(
554573
htmltools::htmlDependency(
@@ -802,6 +821,7 @@ addCircleMarkers = function(
802821
fillOpacity = 0.2,
803822
dashArray = NULL,
804823
popup = NULL,
824+
popupOptions = NULL,
805825
label = NULL,
806826
labelOptions = NULL,
807827
options = pathOptions(),
@@ -818,7 +838,8 @@ addCircleMarkers = function(
818838
map$dependencies = c(map$dependencies, markerClusterDependencies())
819839
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addCircleMarkers")
820840
invokeMethod(map, data, 'addCircleMarkers', pts$lat, pts$lng, radius,
821-
layerId, group, options, clusterOptions, clusterId, popup, safeLabel(label, data), labelOptions) %>%
841+
layerId, group, options, clusterOptions, clusterId,
842+
popup, popupOptions, safeLabel(label, data), labelOptions) %>%
822843
expandLimits(pts$lat, pts$lng)
823844
}
824845

@@ -891,6 +912,7 @@ addCircles = function(
891912
fillOpacity = 0.2,
892913
dashArray = NULL,
893914
popup = NULL,
915+
popupOptions = NULL,
894916
label = NULL,
895917
labelOptions = NULL,
896918
options = pathOptions(),
@@ -902,7 +924,8 @@ addCircles = function(
902924
dashArray = dashArray
903925
))
904926
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addCircles")
905-
invokeMethod(map, data, 'addCircles', pts$lat, pts$lng, radius, layerId, group, options, popup, safeLabel(label, data), labelOptions) %>%
927+
invokeMethod(map, data, 'addCircles', pts$lat, pts$lng, radius, layerId, group, options,
928+
popup, popupOptions, safeLabel(label, data), labelOptions) %>%
906929
expandLimits(pts$lat, pts$lng)
907930
}
908931

@@ -924,6 +947,7 @@ addPolylines = function(
924947
smoothFactor = 1.0,
925948
noClip = FALSE,
926949
popup = NULL,
950+
popupOptions = NULL,
927951
label = NULL,
928952
labelOptions = NULL,
929953
options = pathOptions(),
@@ -935,7 +959,8 @@ addPolylines = function(
935959
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
936960
))
937961
pgons = derivePolygons(data, lng, lat, missing(lng), missing(lat), "addPolylines")
938-
invokeMethod(map, data, 'addPolylines', pgons, layerId, group, options, popup, safeLabel(label, data), labelOptions) %>%
962+
invokeMethod(map, data, 'addPolylines', pgons, layerId, group, options,
963+
popup, popupOptions, safeLabel(label, data), labelOptions) %>%
939964
expandLimitsBbox(pgons)
940965
}
941966

@@ -956,6 +981,7 @@ addRectangles = function(
956981
smoothFactor = 1.0,
957982
noClip = FALSE,
958983
popup = NULL,
984+
popupOptions = NULL,
959985
label = NULL,
960986
labelOptions = NULL,
961987
options = pathOptions(),
@@ -970,7 +996,7 @@ addRectangles = function(
970996
lat1 = resolveFormula(lat1, data)
971997
lng2 = resolveFormula(lng2, data)
972998
lat2 = resolveFormula(lat2, data)
973-
invokeMethod(map, data, 'addRectangles',lat1, lng1, lat2, lng2, layerId, group, options, popup, safeLabel(label, data), labelOptions) %>%
999+
invokeMethod(map, data, 'addRectangles',lat1, lng1, lat2, lng2, layerId, group, options, popup, popupOptions, safeLabel(label, data), labelOptions) %>%
9741000
expandLimits(c(lat1, lat2), c(lng1, lng2))
9751001
}
9761002

@@ -989,6 +1015,7 @@ addPolygons = function(
9891015
smoothFactor = 1.0,
9901016
noClip = FALSE,
9911017
popup = NULL,
1018+
popupOptions = NULL,
9921019
label = NULL,
9931020
labelOptions = NULL,
9941021
options = pathOptions(),
@@ -1000,7 +1027,7 @@ addPolygons = function(
10001027
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
10011028
))
10021029
pgons = derivePolygons(data, lng, lat, missing(lng), missing(lat), "addPolygons")
1003-
invokeMethod(map, data, 'addPolygons', pgons, layerId, group, options, popup, safeLabel(label, data), labelOptions) %>%
1030+
invokeMethod(map, data, 'addPolygons', pgons, layerId, group, options, popup, popupOptions, safeLabel(label, data), labelOptions) %>%
10041031
expandLimitsBbox(pgons)
10051032
}
10061033

R/normalize.R

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ doResolveFormula.SpatialPointsDataFrame = function(data, f) {
5050
doResolveFormula(data@data, f)
5151
}
5252

53-
# Given a data object and lng/lat arguments (which may be NULL [meaning infer
54-
# from data], formula [which should be evaluated with respect to the data], or
55-
# vector data [which should be used as-is]) return a lng/lat data frame.
53+
#' Given a data object and lng/lat arguments (which may be NULL [meaning infer
54+
#' from data], formula [which should be evaluated with respect to the data], or
55+
#' vector data [which should be used as-is]) return a lng/lat data frame.
56+
#' @param data map data
57+
#' @param lng longitude
58+
#' @param lat latitude
59+
#' @param missingLng whether lng is missing
60+
#' @param missingLat whether lat is missing
61+
#' @param funcName Name of calling function (for logging)
62+
#' @export
5663
derivePoints = function(data, lng, lat, missingLng, missingLat, funcName) {
5764
if (missingLng || missingLat) {
5865
if (is.null(data)) {
@@ -78,6 +85,16 @@ derivePoints = function(data, lng, lat, missingLng, missingLat, funcName) {
7885
data.frame(lng = lng, lat = lat)
7986
}
8087

88+
#' Given a data object and lng/lat arguments (which may be NULL [meaning infer
89+
#' from data], formula [which should be evaluated with respect to the data], or
90+
#' vector data [which should be used as-is]) return a spatial object
91+
#' @param data map data
92+
#' @param lng longitude
93+
#' @param lat latitude
94+
#' @param missingLng whether lng is missing
95+
#' @param missingLat whether lat is missing
96+
#' @param funcName Name of calling function (for logging)
97+
#' @export
8198
derivePolygons = function(data, lng, lat, missingLng, missingLat, funcName) {
8299
if (missingLng != missingLat) {
83100
stop(funcName, " must be called with both lng and lat, or with neither.")

R/plugin-awesomeMarkers.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ verifyIconLibrary <- function(library) {
207207
#' the latitude column from \code{data})
208208
#' @param popup a character vector of the HTML content for the popups (you are
209209
#' recommended to escape the text using \code{\link[htmltools]{htmlEscape}()}
210+
#' @param popupOptions A Vector of \code{\link{popupOptions}} to provide popups
210211
#' for security reasons)
211212
#' @param layerId the layer id
212213
#' @param group the name of the group the newly created layers should belong to
@@ -233,6 +234,7 @@ addAwesomeMarkers = function(
233234
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
234235
icon = NULL,
235236
popup = NULL,
237+
popupOptions = NULL,
236238
label = NULL,
237239
labelOptions = NULL,
238240
options = markerOptions(),
@@ -270,7 +272,8 @@ addAwesomeMarkers = function(
270272

271273
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addAwesomeMarkers")
272274
invokeMethod(
273-
map, data, 'addAwesomeMarkers', pts$lat, pts$lng, icon, layerId, group, options, popup,
275+
map, data, 'addAwesomeMarkers', pts$lat, pts$lng, icon, layerId,
276+
group, options, popup, popupOptions,
274277
clusterOptions, clusterId, safeLabel(label, data), labelOptions
275278
) %>% expandLimits(pts$lat, pts$lng)
276279
}

R/utils.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ dispatch = function(map,
3131
stop("Invalid map parameter")
3232
}
3333

34-
# remove NULL elements from a list
34+
#' remove NULL elements from a list
35+
#' @param x A list whose NULL elements will be filtered
36+
#' @export
3537
filterNULL = function(x) {
3638
if (length(x) == 0 || !is.list(x)) return(x)
3739
x[!unlist(lapply(x, is.null))]

0 commit comments

Comments
 (0)