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
3
6
evalFormula = function (list , data ) {
4
7
evalAll = function (x ) {
5
8
if (is.list(x )) {
@@ -15,9 +18,13 @@ evalFormula = function(list, data) {
15
18
# polygon lists (returned from polygonData()) use `attr(x, "bbox")` (though at
16
19
# least they are the same shape as the Spatial bounding boxes).
17
20
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
20
23
# 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
21
28
expandLimits = function (map , lat , lng ) {
22
29
if (is.null(map $ x $ limits )) map $ x $ limits = list ()
23
30
@@ -33,8 +40,11 @@ expandLimits = function(map, lat, lng) {
33
40
map
34
41
}
35
42
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
38
48
expandLimitsBbox = function (map , poly ) {
39
49
bbox = attr(poly , " bbox" , exact = TRUE )
40
50
if (is.null(bbox )) stop(" Polygon data had no bbox" )
@@ -358,6 +368,7 @@ WMSTileOptions = function(
358
368
# ' the latitude column from \code{data})
359
369
# ' @param popup a character vector of the HTML content for the popups (you are
360
370
# ' recommended to escape the text using \code{\link[htmltools]{htmlEscape}()}
371
+ # ' @param popupOptions A Vector of \code{\link{popupOptions}} to provide popups
361
372
# ' for security reasons)
362
373
# ' @param layerId the layer id
363
374
# ' @param group the name of the group the newly created layers should belong to
@@ -380,6 +391,7 @@ addPopups = function(
380
391
expandLimits(pts $ lat , pts $ lng )
381
392
}
382
393
394
+ # ' options for specify popup realted options
383
395
# ' @param className a CSS class name set on an element
384
396
# ' @param
385
397
# ' maxWidth,minWidth,maxHeight,autoPan,keepInView,closeButton,zoomAnimation,closeOnClick
@@ -421,7 +433,9 @@ clearPopups = function(map) {
421
433
invokeMethod(map , NULL , ' clearPopups' )
422
434
}
423
435
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
425
439
safeLabel <- function (label , data ) {
426
440
if (is.null(label )) {
427
441
return (label )
@@ -484,6 +498,7 @@ addMarkers = function(
484
498
map , lng = NULL , lat = NULL , layerId = NULL , group = NULL ,
485
499
icon = NULL ,
486
500
popup = NULL ,
501
+ popupOptions = NULL ,
487
502
label = NULL ,
488
503
labelOptions = NULL ,
489
504
options = markerOptions(),
@@ -518,8 +533,9 @@ addMarkers = function(
518
533
519
534
pts = derivePoints(data , lng , lat , missing(lng ), missing(lat ), " addMarkers" )
520
535
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
523
539
) %> % expandLimits(pts $ lat , pts $ lng )
524
540
}
525
541
@@ -549,6 +565,9 @@ addLabelOnlyMarkers = function(
549
565
data = data )
550
566
}
551
567
568
+ # ' Adds marker-cluster-plugin HTML dependency
569
+ # ' @export
570
+ # ' @describeIn map-layers add maker cluster plugin
552
571
markerClusterDependencies = function () {
553
572
list (
554
573
htmltools :: htmlDependency(
@@ -802,6 +821,7 @@ addCircleMarkers = function(
802
821
fillOpacity = 0.2 ,
803
822
dashArray = NULL ,
804
823
popup = NULL ,
824
+ popupOptions = NULL ,
805
825
label = NULL ,
806
826
labelOptions = NULL ,
807
827
options = pathOptions(),
@@ -818,7 +838,8 @@ addCircleMarkers = function(
818
838
map $ dependencies = c(map $ dependencies , markerClusterDependencies())
819
839
pts = derivePoints(data , lng , lat , missing(lng ), missing(lat ), " addCircleMarkers" )
820
840
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 ) %> %
822
843
expandLimits(pts $ lat , pts $ lng )
823
844
}
824
845
@@ -891,6 +912,7 @@ addCircles = function(
891
912
fillOpacity = 0.2 ,
892
913
dashArray = NULL ,
893
914
popup = NULL ,
915
+ popupOptions = NULL ,
894
916
label = NULL ,
895
917
labelOptions = NULL ,
896
918
options = pathOptions(),
@@ -902,7 +924,8 @@ addCircles = function(
902
924
dashArray = dashArray
903
925
))
904
926
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 ) %> %
906
929
expandLimits(pts $ lat , pts $ lng )
907
930
}
908
931
@@ -924,6 +947,7 @@ addPolylines = function(
924
947
smoothFactor = 1.0 ,
925
948
noClip = FALSE ,
926
949
popup = NULL ,
950
+ popupOptions = NULL ,
927
951
label = NULL ,
928
952
labelOptions = NULL ,
929
953
options = pathOptions(),
@@ -935,7 +959,8 @@ addPolylines = function(
935
959
dashArray = dashArray , smoothFactor = smoothFactor , noClip = noClip
936
960
))
937
961
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 ) %> %
939
964
expandLimitsBbox(pgons )
940
965
}
941
966
@@ -956,6 +981,7 @@ addRectangles = function(
956
981
smoothFactor = 1.0 ,
957
982
noClip = FALSE ,
958
983
popup = NULL ,
984
+ popupOptions = NULL ,
959
985
label = NULL ,
960
986
labelOptions = NULL ,
961
987
options = pathOptions(),
@@ -970,7 +996,7 @@ addRectangles = function(
970
996
lat1 = resolveFormula(lat1 , data )
971
997
lng2 = resolveFormula(lng2 , data )
972
998
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 ) %> %
974
1000
expandLimits(c(lat1 , lat2 ), c(lng1 , lng2 ))
975
1001
}
976
1002
@@ -989,6 +1015,7 @@ addPolygons = function(
989
1015
smoothFactor = 1.0 ,
990
1016
noClip = FALSE ,
991
1017
popup = NULL ,
1018
+ popupOptions = NULL ,
992
1019
label = NULL ,
993
1020
labelOptions = NULL ,
994
1021
options = pathOptions(),
@@ -1000,7 +1027,7 @@ addPolygons = function(
1000
1027
dashArray = dashArray , smoothFactor = smoothFactor , noClip = noClip
1001
1028
))
1002
1029
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 ) %> %
1004
1031
expandLimitsBbox(pgons )
1005
1032
}
1006
1033
0 commit comments