1
+ globalVariables(c(' providers' )) # To make R CMD Check happy
2
+
1
3
leafletMiniMapDependencies <- function () {
2
4
list (
3
5
htmltools :: htmlDependency(
4
6
" leaflet-minimap" ,
5
- " 0.1.0 " ,
7
+ " 3.3.1 " ,
6
8
system.file(" htmlwidgets/plugins/Leaflet-MiniMap" , package = " leaflet" ),
7
9
script = c(' Control.MiniMap.min.js' , ' Minimap-binding.js' ),
8
10
stylesheet = c(' Control.MiniMap.min.css' )
@@ -14,32 +16,52 @@ leafletMiniMapDependencies <- function() {
14
16
# ' \url{https://github.com/Norkart/Leaflet-MiniMap}
15
17
# '
16
18
# ' @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.
18
21
# ' Defaults to 'bottomright'.
19
22
# ' @param width The width of the minimap in pixels. Defaults to 150.
20
23
# ' @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.
29
38
# ' @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.
31
41
# ' @param toggleDisplay Sets whether the minimap should have a button to minimise it.
32
- # ' Defaults to false.
42
+ # ' Defaults to false.
33
43
# ' @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.
36
57
# ' @examples
37
58
# ' library(leaflet)
38
59
# '
39
60
# ' leaf <- leaflet() %>%
40
61
# ' addTiles() %>%
41
62
# ' addMiniMap()
42
63
# '
64
+ # ' @seealso \code{\link{providers}}
43
65
# ' @export
44
66
addMiniMap <- function (
45
67
map ,
@@ -49,25 +71,54 @@ addMiniMap <- function(
49
71
collapsedWidth = 19 ,
50
72
collapsedHeight = 19 ,
51
73
zoomLevelOffset = - 5 ,
52
- zoomLevelFixed = NULL ,
74
+ zoomLevelFixed = FALSE ,
75
+ centerFixed = FALSE ,
53
76
zoomAnimation = FALSE ,
54
77
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 ()
56
86
) {
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
+
57
100
map $ dependencies <- c(map $ dependencies , leafletMiniMapDependencies())
58
101
invokeMethod(
59
102
map
60
103
, getMapData(map )
61
104
, ' addMiniMap'
105
+ , tilesURL
106
+ , tilesProvider
62
107
, position
63
108
, width
64
109
, height
65
110
, collapsedWidth
66
111
, collapsedHeight
67
112
, zoomLevelOffset
68
113
, zoomLevelFixed
114
+ , centerFixed
69
115
, zoomAnimation
70
116
, toggleDisplay
71
117
, autoToggleDisplay
118
+ , minimized
119
+ , aimingRectOptions
120
+ , shadowRectOptions
121
+ , strings
122
+ , mapOptions
72
123
)
73
124
}
0 commit comments