Skip to content

Commit 4370ace

Browse files
authored
Merge pull request #293 from bhaskarvk/issue/9-upgradePlugins-PR
Upgrade existing Leaflet Plugins
2 parents 381a663 + aed6cf4 commit 4370ace

File tree

75 files changed

+14631
-897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+14631
-897
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
^package\.json$
1313
^node_modules$
1414

15+
^data-raw$

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: leaflet
22
Type: Package
33
Title: Create Interactive Web Maps with the JavaScript 'Leaflet' Library
4-
Version: 1.0.1.9004
5-
Date: 2016-05-25
4+
Version: 1.0.2.9000
5+
Date: 2016-09-17
66
Authors@R: c(
77
person("Joe", "Cheng", email = "[email protected]", role = c("aut", "cre")),
88
person("Yihui", "Xie", role = c("aut")),
@@ -31,6 +31,7 @@ Description: Create and customize interactive maps using the 'Leaflet'
3131
License: GPL-3 | file LICENSE
3232
URL: http://rstudio.github.io/leaflet/
3333
BugReports: https://github.com/rstudio/leaflet/issues
34+
Depends: R (>= 3.1.0)
3435
Imports:
3536
base64enc,
3637
htmlwidgets,
@@ -50,5 +51,7 @@ Suggests:
5051
testit (>= 0.4),
5152
rgdal,
5253
R6,
53-
RJSONIO
54+
RJSONIO,
55+
purrr
5456
RoxygenNote: 5.0.1
57+
LazyData: true

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export(addCircleMarkers)
1515
export(addCircles)
1616
export(addControl)
1717
export(addGeoJSON)
18+
export(addGraticule)
19+
export(addLabelOnlyMarkers)
1820
export(addLayersControl)
1921
export(addLegend)
2022
export(addMarkers)

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
leaflet 1.1
2+
--------------------------------------------------------------------------------
3+
4+
* Upgraded existing plugins to their respective latest versions and added missing/new functionality from those plugins. (PR #293)
5+
6+
* Added Graticule plugin (PR #293)
7+
18
leaflet 1.0.2
29
--------------------------------------------------------------------------------
310

R/layers.R

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ safeLabel <- function(label, data) {
436436
#' Extra options for marker and polygon labels
437437
#'
438438
#' @param
439-
#' noHide,direction,offset
439+
#' noHide,direction,offset,textsize,textOnly,style
440440
#' label options; see \url{https://github.com/Leaflet/Leaflet.label#options}
441441
#' @describeIn map-options Options for labels
442442
#' @export
@@ -448,11 +448,15 @@ labelOptions = function(
448448
#pane = NULL,
449449
offset = c(12,-15),
450450
opacity = 1,
451+
textsize = "10px",
452+
textOnly = FALSE,
453+
style = NULL,
451454
zoomAnimation = TRUE
452455
) {
453456
list(
454457
clickable = clickable, noHide = noHide, direction = direction,
455458
opacity = opacity, offset = offset,
459+
textsize = textsize, textOnly = textOnly, style = style,
456460
zoomAnimation = zoomAnimation, className = className
457461
)
458462
}
@@ -516,13 +520,39 @@ addMarkers = function(
516520
) %>% expandLimits(pts$lat, pts$lng)
517521
}
518522

523+
#' @describeIn map-layers Add Label only markers to the map
524+
#' @export
525+
addLabelOnlyMarkers = function(
526+
map, lng = NULL, lat = NULL, layerId = NULL, group = NULL,
527+
icon = NULL,
528+
label = NULL,
529+
labelOptions = NULL,
530+
options = markerOptions(),
531+
clusterOptions = NULL,
532+
clusterId = NULL,
533+
data = getMapData(map)
534+
) {
535+
addMarkers(map = map, lng = lng, lat = lat, layerId = layerId,
536+
group = group,
537+
icon = makeIcon(iconUrl =
538+
system.file('htmlwidgets/lib/leaflet/images/1px.png',
539+
package='leaflet'),
540+
iconWidth = 1, iconHeight = 1),
541+
label = label,
542+
labelOptions = labelOptions,
543+
options = options,
544+
clusterOptions = clusterOptions,
545+
clusterId = clusterId,
546+
data = data)
547+
}
548+
519549
markerClusterDependencies = function() {
520550
list(
521551
htmltools::htmlDependency(
522552
'leaflet-markercluster',
523-
'0.4.0',
553+
'0.5.0',
524554
system.file('htmlwidgets/plugins/Leaflet.markercluster', package = 'leaflet'),
525-
script = 'leaflet.markercluster.js',
555+
script = c('leaflet.markercluster.js', 'leaflet.markercluster.layersupport-src.js', 'leaflet.markercluster.freezable-src.js'),
526556
stylesheet = c('MarkerCluster.css', 'MarkerCluster.Default.css')
527557
)
528558
)
@@ -717,17 +747,26 @@ markerOptions = function(
717747
#' spiderfy it so you can see all of its markers
718748
#' @param removeOutsideVisibleBounds clusters and markers too far from the
719749
#' viewport are removed from the map for performance
750+
#' @param spiderLegPolylineOptions Allows you to specify PolylineOptions (\url{http://leafletjs.com/reference.html#polyline-options}) to style spider legs. By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }
751+
#' @param freezeAtZoom Allows you to freeze cluster expansion to a zoom level.
752+
#' Can be a zoom level e.g. 10, 12 or 'max' or 'maxKeepSpiderify'
753+
#' See \url{https://github.com/ghybs/Leaflet.MarkerCluster.Freezable#api-reference}
720754
#' @describeIn map-options Options for marker clusters
721755
#' @export
722756
markerClusterOptions = function(
723757
showCoverageOnHover = TRUE, zoomToBoundsOnClick = TRUE,
724-
spiderfyOnMaxZoom = TRUE, removeOutsideVisibleBounds = TRUE, ...
758+
spiderfyOnMaxZoom = TRUE, removeOutsideVisibleBounds = TRUE,
759+
spiderLegPolylineOptions = list(weight= 1.5, color= '#222', opacity= 0.5),
760+
freezeAtZoom = FALSE,
761+
...
725762
) {
726763
list(
727764
showCoverageOnHover = showCoverageOnHover,
728765
zoomToBoundsOnClick = zoomToBoundsOnClick,
729766
spiderfyOnMaxZoom = spiderfyOnMaxZoom,
730-
removeOutsideVisibleBounds = removeOutsideVisibleBounds, ...
767+
removeOutsideVisibleBounds = removeOutsideVisibleBounds,
768+
spiderLegPolylineOptions = spiderLegPolylineOptions,
769+
freezeAtZoom = freezeAtZoom, ...
731770
)
732771
}
733772

R/plugin-graticule.R

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
leafletGraticuleDependencies <- function() {
2+
list(
3+
htmltools::htmlDependency(
4+
"leaflet-graticule",
5+
"0.1.0",
6+
system.file("htmlwidgets/plugins/Leaflet.Graticule", package = "leaflet"),
7+
script = c("L.Graticule.js", "Graticule-binding.js")
8+
)
9+
)
10+
}
11+
12+
#' Add a Graticule on the map
13+
#' see \url{https://github.com/turban/Leaflet.Graticule}
14+
#'
15+
#' @param map a map widget object
16+
#' @param interval The spacing in map units between horizontal and vertical lines.
17+
#' @param style path options for the generated lines. See \url{http://leafletjs.com/reference.html#path-options}
18+
#' @param layerId the layer id
19+
#' @param group the name of the group this layer belongs to.
20+
#' @examples
21+
#' library(leaflet)
22+
#'
23+
#' leaf <- leaflet() %>%
24+
#' addTiles() %>%
25+
#' addGraticule()
26+
#'
27+
#' @export
28+
addGraticule <- function(
29+
map,
30+
interval = 20,
31+
style = list(color= '#333', weight= 1),
32+
layerId = NULL,
33+
group=NULL
34+
) {
35+
map$dependencies <- c(map$dependencies, leafletGraticuleDependencies())
36+
invokeMethod(
37+
map,
38+
getMapData(map),
39+
'addGraticule',
40+
interval,
41+
style,
42+
layerId,
43+
group
44+
)
45+
}

R/plugin-measure.R

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ leafletMeasureDependencies <- function() {
22
list(
33
htmltools::htmlDependency(
44
"leaflet-measure",
5-
"1.2.0",
5+
"2.0.2",
66
system.file("htmlwidgets/lib/leaflet-measure", package = "leaflet"),
77
script = "leaflet-measure.min.js",
88
stylesheet = "leaflet-measure.css"
@@ -29,6 +29,16 @@ leafletMeasureDependencies <- function() {
2929
#' @param popupOptions \code{list} of ptions 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}.
32+
#' @param captureZIndex Z-index of the marker used to capture measure clicks.
33+
#' Set this value higher than the z-index of all other map layers to
34+
#' disable click events on other layers while a measurement is active.
35+
#' @param localization Locale to translate displayed text.
36+
#' Available locales include en (default), cn, de, es, fr, it, nl, pt,
37+
#' pt_BR, pt_PT, ru, and tr
38+
#' @param decPoint Decimal point used when displaying measurements.
39+
#' If not specified, values are defined by the localization.
40+
#' @param thousandsSep Thousands separator used when displaying measurements.
41+
#' If not specified, values are defined by the localization.
3242
#'
3343
#' @return modified map
3444
#' @examples
@@ -49,6 +59,7 @@ leafletMeasureDependencies <- function() {
4959
#' , primaryAreaUnit = "sqmeters"
5060
#' , activeColor = "#3D535D"
5161
#' , completedColor = "#7D4479"
62+
#' , localization = 'de'
5263
#' )
5364
#'
5465
#' @export
@@ -62,6 +73,10 @@ addMeasure <- function(
6273
, activeColor = "#ABE67E"
6374
, completedColor ="#C8F2BE"
6475
, popupOptions = list( className = 'leaflet-measure-resultpopup', autoPanPadding = c(10,10) )
76+
, captureZIndex = 10000
77+
, localization = 'en'
78+
, decPoint = '.'
79+
, thousandsSep = ','
6580
) {
6681
map$dependencies <- c(map$dependencies, leafletMeasureDependencies())
6782
invokeMethod(
@@ -79,6 +94,10 @@ addMeasure <- function(
7994
, activeColor = activeColor
8095
, completedColor = completedColor
8196
, popupOptions = popupOptions
97+
, captureZIndex = captureZIndex
98+
, localization = localization
99+
, decPoint = decPoint
100+
, thousandsSep = thousandsSep
82101
)
83102
)
84103
)

R/plugin-minimap.R

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
globalVariables(c('providers')) # To make R CMD Check happy
2+
13
leafletMiniMapDependencies <- function() {
24
list(
35
htmltools::htmlDependency(
46
"leaflet-minimap",
5-
"0.1.0",
7+
"3.3.1",
68
system.file("htmlwidgets/plugins/Leaflet-MiniMap", package = "leaflet"),
79
script = c('Control.MiniMap.min.js', 'Minimap-binding.js'),
810
stylesheet = c('Control.MiniMap.min.css')
@@ -14,32 +16,52 @@ leafletMiniMapDependencies <- function() {
1416
#' \url{https://github.com/Norkart/Leaflet-MiniMap}
1517
#'
1618
#' @param map a map widget object
17-
#' @param position The standard Leaflet.Control position parameter, used like all the other controls.
19+
#' @param position The standard Leaflet.Control position parameter,
20+
#' used like all the other controls.
1821
#' Defaults to 'bottomright'.
1922
#' @param width The width of the minimap in pixels. Defaults to 150.
2023
#' @param height The height of the minimap in pixels. Defaults to 150.
21-
#' @param collapsedWidth The width of the toggle marker and the minimap when collapsed, in pixels.
22-
#' Defaults to 19.
23-
#' @param collapsedHeight The height of the toggle marker and the minimap when collapsed, in pixels.
24-
#' Defaults to 19.
25-
#' @param zoomLevelOffset The offset applied to the zoom in the minimap compared to the zoom of the main map.
26-
#' Can be positive or negative, defaults to -5.
27-
#' @param zoomLevelFixed Overrides the offset to apply a fixed zoom level to the minimap regardless of the main map zoom.
28-
#' Set it to any valid zoom level, if unset zoomLevelOffset is used instead.
24+
#' @param collapsedWidth The width of the toggle marker and the minimap
25+
#' when collapsed, in pixels. Defaults to 19.
26+
#' @param collapsedHeight The height of the toggle marker and the minimap
27+
#' when collapsed, in pixels. Defaults to 19.
28+
#' @param zoomLevelOffset The offset applied to the zoom in the minimap compared
29+
#' to the zoom of the main map. Can be positive or negative, defaults to -5.
30+
#' @param zoomLevelFixed Overrides the offset to apply a fixed zoom level to
31+
#' the minimap regardless of the main map zoom.
32+
#' Set it to any valid zoom level, if unset zoomLevelOffset is used instead.
33+
#' @param centerFixed Applies a fixed position to the minimap regardless of
34+
#' the main map's view / position. Prevents panning the minimap, but does
35+
#' allow zooming (both in the minimap and the main map).
36+
#' If the minimap is zoomed, it will always zoom around the centerFixed point.
37+
#' You can pass in a LatLng-equivalent object. Defaults to false.
2938
#' @param zoomAnimation Sets whether the minimap should have an animated zoom.
30-
#' (Will cause it to lag a bit after the movement of the main map.) Defaults to false.
39+
#' (Will cause it to lag a bit after the movement of the main map.)
40+
#' Defaults to false.
3141
#' @param toggleDisplay Sets whether the minimap should have a button to minimise it.
32-
#' Defaults to false.
42+
#' Defaults to false.
3343
#' @param autoToggleDisplay Sets whether the minimap should hide automatically,
34-
#' if the parent map bounds does not fit within the minimap bounds.
35-
#' Especially useful when 'zoomLevelFixed' is set.
44+
#' if the parent map bounds does not fit within the minimap bounds.
45+
#' Especially useful when 'zoomLevelFixed' is set.
46+
#' @param minimized Sets whether the minimap should start in a minimized position.
47+
#' @param aimingRectOptions Sets the style of the aiming rectangle by passing in
48+
#' a Path.Options (\url{http://leafletjs.com/reference.html#path-options}) object.
49+
#' (Clickable will always be overridden and set to false.)
50+
#' @param shadowRectOptions Sets the style of the aiming shadow rectangle by passing in
51+
#' a Path.Options (\url{http://leafletjs.com/reference.html#path-options}) object.
52+
#' (Clickable will always be overridden and set to false.)
53+
#' @param strings Overrides the default strings allowing for translation.
54+
#' @param tiles URL for tiles or one of the pre-defined providers.
55+
#' @param mapOptions Sets Leaflet options for the MiniMap map.
56+
#' It does not override the MiniMap default map options but extends them.
3657
#' @examples
3758
#' library(leaflet)
3859
#'
3960
#' leaf <- leaflet() %>%
4061
#' addTiles() %>%
4162
#' addMiniMap()
4263
#'
64+
#' @seealso \code{\link{providers}}
4365
#' @export
4466
addMiniMap <- function(
4567
map,
@@ -49,25 +71,54 @@ addMiniMap <- function(
4971
collapsedWidth = 19,
5072
collapsedHeight = 19,
5173
zoomLevelOffset = -5,
52-
zoomLevelFixed = NULL,
74+
zoomLevelFixed = FALSE,
75+
centerFixed = FALSE,
5376
zoomAnimation = FALSE,
5477
toggleDisplay = FALSE,
55-
autoToggleDisplay = NULL
78+
autoToggleDisplay = FALSE,
79+
minimized = FALSE,
80+
aimingRectOptions = list(color= '#ff7800', weight= 1, clickable= FALSE),
81+
shadowRectOptions = list(color= '#000000', weight= 1, clickable= FALSE,
82+
opacity= 0, fillOpacity= 0),
83+
strings = list(hideText= 'Hide MiniMap', showText= 'Show MiniMap'),
84+
tiles = NULL,
85+
mapOptions = list()
5686
) {
87+
88+
# determin tiles to use
89+
tilesURL <- NULL
90+
tilesProvider <- NULL
91+
if(!is.null(tiles)) {
92+
if(tiles %in% providers) {
93+
map$dependencies <- c(map$dependencies, leafletProviderDependencies())
94+
tilesProvider <- tiles
95+
} else {
96+
tilesURL <- tiles
97+
}
98+
}
99+
57100
map$dependencies <- c(map$dependencies, leafletMiniMapDependencies())
58101
invokeMethod(
59102
map
60103
, getMapData(map)
61104
, 'addMiniMap'
105+
, tilesURL
106+
, tilesProvider
62107
, position
63108
, width
64109
, height
65110
, collapsedWidth
66111
, collapsedHeight
67112
, zoomLevelOffset
68113
, zoomLevelFixed
114+
, centerFixed
69115
, zoomAnimation
70116
, toggleDisplay
71117
, autoToggleDisplay
118+
, minimized
119+
, aimingRectOptions
120+
, shadowRectOptions
121+
, strings
122+
, mapOptions
72123
)
73124
}

R/plugin-omnivore.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ leafletOmnivoreDependencies <- function() {
22
list(
33
htmltools::htmlDependency(
44
"leaflet-omnivore",
5-
"0.3.0",
5+
"0.3.3",
66
system.file("htmlwidgets/lib/leaflet-omnivore", package = "leaflet"),
77
script = "leaflet-omnivore.min.js"
88
)

0 commit comments

Comments
 (0)