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
36evalFormula = 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
2128expandLimits = 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
3848expandLimitsBbox = 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
425439safeLabel <- 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
552571markerClusterDependencies = 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
0 commit comments