Skip to content

Commit

Permalink
clear legend and view args for #252
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Jan 27, 2020
1 parent fa18032 commit 9c0b148
Show file tree
Hide file tree
Showing 45 changed files with 267 additions and 106 deletions.
13 changes: 9 additions & 4 deletions R/map_layer_arc.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mapdeckArcDependency <- function() {
#' @param brush_radius radius of the brush in metres. Default NULL. If supplied,
#' the arcs will only show if the origin or destination are within the radius of the mouse.
#' If NULL, all arcs are displayed
#' @param ... \code{clear_legend} and \code{clear_view} arguments passed to 'clear_()' functions
#'
#' @section data:
#'
Expand Down Expand Up @@ -232,11 +233,12 @@ add_arc <- function(
focus_layer = FALSE,
transitions = NULL,
digits = 6,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_arc( map, layer_id ) )
return( clear_arc( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -324,8 +326,11 @@ add_arc <- function(
#' @rdname clear
#' @param map a mapdeck map object
#' @param layer_id the layer_id of the layer you want to clear
#' @param clear_legend logical indicating if the legend should be removed
#' @param clear_view logical indicating if the view should update (TRUE) or not (FALSE)
#' when the data is cleared
#' @export
clear_arc <- function( map, layer_id = NULL ) {
clear_arc <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE ) {
layer_id <- layerId(layer_id, "arc")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "arc" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "arc", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_column.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ add_column <- function(
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_column( map, layer_id ) )
return( clear_column( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -198,7 +199,7 @@ add_column <- function(

#' @rdname clear
#' @export
clear_column <- function( map, layer_id = NULL) {
clear_column <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "column")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "column" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "column", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_geojson.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ add_geojson <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

l <- list()
Expand Down Expand Up @@ -292,7 +293,7 @@ add_geojson <- function(
if( tp == "sf" ) {

if( nrow( data ) == 0 ) {
return( clear_geojson( map, layer_id ) )
return( clear_geojson( map, layer_id, ...) )
}

shape <- rcpp_geojson_geojson( data, l, "geometry", digits)
Expand Down Expand Up @@ -325,7 +326,7 @@ add_geojson <- function(

#' @rdname clear
#' @export
clear_geojson <- function( map, layer_id = NULL) {
clear_geojson <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "geojson")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "geojson" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "geojson", clear_legend, clear_view )
}
11 changes: 5 additions & 6 deletions R/map_layer_greatcircle.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ add_greatcircle <- function(
update_view = TRUE,
focus_layer = FALSE,
transitions = NULL,
digits = 6
digits = 6,
...
) {
brush_radius = NULL

if( nrow( data ) == 0 ) {
return( clear_greatcircle( map, layer_id ) )
return( clear_greatcircle( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -197,10 +198,8 @@ add_greatcircle <- function(
#' Clear greatcircle
#'
#' @rdname clear
#' @param map a mapdeck map object
#' @param layer_id the layer_id of the layer you want to clear
#' @export
clear_greatcircle <- function( map, layer_id = NULL ) {
clear_greatcircle <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE ) {
layer_id <- layerId(layer_id, "greatcircle")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "greatcircle" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "greatcircle", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ add_grid <- function(
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_grid( map, layer_id ) )
return( clear_grid( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -217,7 +218,7 @@ add_grid <- function(

#' @rdname clear
#' @export
clear_grid <- function( map, layer_id = NULL) {
clear_grid <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE ) {
layer_id <- layerId(layer_id, "grid")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "grid" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "grid", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ add_heatmap <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_heatmap( map, layer_id ) )
return( clear_heatmap( map, layer_id, ...) )
}

l <- list()
Expand Down Expand Up @@ -184,7 +185,7 @@ add_heatmap <- function(

#' @rdname clear
#' @export
clear_heatmap <- function( map, layer_id = NULL) {
clear_heatmap <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "heatmap")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "heatmap" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "heatmap", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_hexagon.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ add_hexagon <- function(
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_hexagon( map, layer_id ) )
return( clear_hexagon( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -242,7 +243,7 @@ add_hexagon <- function(

#' @rdname clear
#' @export
clear_hexagon <- function( map, layer_id = NULL) {
clear_hexagon <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE ) {
layer_id <- layerId(layer_id, "hexagon")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "hexagon" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "hexagon", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_line.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ add_line <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_line( map, layer_id ) )
return( clear_line( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -191,8 +192,8 @@ add_line <- function(

#' @rdname clear
#' @export
clear_line <- function( map, layer_id = NULL) {
clear_line <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "line")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "line" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "line", clear_legend, clear_view )
}

11 changes: 5 additions & 6 deletions R/map_layer_mesh.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ add_mesh <- function(
transitions = NULL
) {

#if( is.null( stroke_colour )) stroke_colour <- fill_colour
experimental_layer( "mesh" )

if(!inherits(data, "mesh3d")) {
Expand Down Expand Up @@ -182,14 +181,14 @@ add_mesh2 <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

#if( is.null( stroke_colour )) stroke_colour <- fill_colour
experimental_layer( "mesh" )

if( nrow( data ) == 0 ) {
return( clear_mesh( map, layer_id ) )
return( clear_mesh( map, layer_id, ... ) )
}

if(!inherits(data, "mesh3d")) {
Expand Down Expand Up @@ -296,9 +295,9 @@ add_mesh2 <- function(

#' @rdname clear
#' @export
clear_mesh <- function( map, layer_id = NULL) {
clear_mesh <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "mesh")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "mesh" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "mesh", clear_legend, clear_view )
}


9 changes: 5 additions & 4 deletions R/map_layer_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ add_path <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_path( map, layer_id ) )
return( clear_path( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -165,9 +166,9 @@ add_path <- function(

#' @rdname clear
#' @export
clear_path <- function( map, layer_id = NULL) {
clear_path <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "path")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "path" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "path", clear_legend, clear_view )
}


Expand Down
9 changes: 5 additions & 4 deletions R/map_layer_pointcloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ add_pointcloud <- function(
focus_layer = FALSE,
digits = 6,
transitions = NULL,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_pointcloud( map, layer_id ) )
return( clear_pointcloud( map, layer_id, ...) )
}

l <- list()
Expand Down Expand Up @@ -193,8 +194,8 @@ add_pointcloud <- function(

#' @rdname clear
#' @export
clear_pointcloud <- function( map, layer_id = NULL) {
clear_pointcloud <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId( layer_id, "pointcloud" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "pointcloud" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "pointcloud", clear_legend, clear_view )
}

9 changes: 5 additions & 4 deletions R/map_layer_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ add_polygon <- function(
update_view = TRUE,
focus_layer = FALSE,
digits = 6,
transitions = NULL
transitions = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_polygon( map, layer_id ) )
return( clear_polygon( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -228,9 +229,9 @@ add_polygon <- function(

#' @rdname clear
#' @export
clear_polygon <- function( map, layer_id = NULL) {
clear_polygon <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "polygon")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "polygon" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "polygon", clear_legend, clear_view )
}


9 changes: 5 additions & 4 deletions R/map_layer_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ add_scatterplot <- function(
update_view = TRUE,
focus_layer = FALSE,
transitions = NULL,
brush_radius = NULL
brush_radius = NULL,
...
) {

if( nrow( data ) == 0 ) {
return( clear_scatterplot( map, layer_id ) )
return( clear_scatterplot( map, layer_id, ... ) )
}

l <- list()
Expand Down Expand Up @@ -230,7 +231,7 @@ add_scatterplot <- function(

#' @rdname clear
#' @export
clear_scatterplot <- function( map, layer_id = NULL) {
clear_scatterplot <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE ) {
layer_id <- layerId(layer_id, "scatterplot")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "scatterplot" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "scatterplot", clear_legend, clear_view )
}
9 changes: 5 additions & 4 deletions R/map_layer_screengrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ add_screengrid <- function(
layer_id = NULL,
update_view = TRUE,
focus_layer = FALSE,
digits = 6
digits = 6,
...
) {

if( nrow( data ) == 0 ) {
return( clear_screengrid( map, layer_id ) )
return( clear_screengrid( map, layer_id, ... ) )
}

brush_radius = NULL
Expand Down Expand Up @@ -164,8 +165,8 @@ add_screengrid <- function(

#' @rdname clear
#' @export
clear_screengrid <- function( map, layer_id = NULL) {
clear_screengrid <- function( map, layer_id = NULL, clear_legend = TRUE, clear_view = TRUE) {
layer_id <- layerId(layer_id, "screengrid")
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "screengrid" )
invoke_method(map, "md_layer_clear", map_type( map ), layer_id, "screengrid", clear_legend, clear_view )
}

Loading

0 comments on commit 9c0b148

Please sign in to comment.