1+ globalVariables(c(' providers' )) # To make R CMD Check happy
2+
13leafletMiniMapDependencies <- 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
4466addMiniMap <- 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}
0 commit comments