diff --git a/NEWS.md b/NEWS.md index f4109791..6cdbd9f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # mapdeck 0.3 + * `show_view_state` option to overlay the current View State [issue238](https://github.com/SymbolixAU/mapdeck/issues/238) * performance improvements for dates and factors [issue235](https://github.com/SymbolixAU/mapdeck/issues/235) * `add_bitmap()` to add a bitmap / image to the map diff --git a/R/map_layer_greatcircle.R b/R/map_layer_greatcircle.R index 57296d6b..d654eba9 100644 --- a/R/map_layer_greatcircle.R +++ b/R/map_layer_greatcircle.R @@ -117,6 +117,7 @@ add_greatcircle <- function( focus_layer = FALSE, transitions = NULL, digits = 6 + #brush_radius = NULL ) { brush_radius = NULL diff --git a/R/map_layer_line.R b/R/map_layer_line.R index 20f2dd6e..8993d315 100644 --- a/R/map_layer_line.R +++ b/R/map_layer_line.R @@ -117,7 +117,8 @@ add_line <- function( update_view = TRUE, focus_layer = FALSE, digits = 6, - transitions = NULL + transitions = NULL, + brush_radius = NULL ) { l <- list() @@ -179,7 +180,7 @@ add_line <- function( invoke_method( map, "add_line_geo", map_type( map ), shape[["data"]], layer_id, auto_highlight, highlight_colour, shape[["legend"]], bbox, update_view, focus_layer, - js_transitions + js_transitions, brush_radius ) } diff --git a/R/map_layer_mesh.R b/R/map_layer_mesh.R index 0e42fe07..6c2b29db 100644 --- a/R/map_layer_mesh.R +++ b/R/map_layer_mesh.R @@ -70,7 +70,8 @@ add_mesh <- function( update_view = TRUE, focus_layer = FALSE, digits = 6, - transitions = NULL + transitions = NULL, + brush_radius = NULL ) { #if( is.null( stroke_colour )) stroke_colour <- fill_colour @@ -171,7 +172,7 @@ add_mesh <- function( invoke_method( map, jsfunc, map_type( map ), shape[["data"]], layer_id, light_settings, auto_highlight, highlight_colour, shape[["legend"]], bbox, update_view, focus_layer, - js_transitions, is_extruded + js_transitions, is_extruded, brush_radius ) } diff --git a/R/map_layer_path.R b/R/map_layer_path.R index 271c9655..385605ee 100644 --- a/R/map_layer_path.R +++ b/R/map_layer_path.R @@ -93,7 +93,8 @@ add_path <- function( update_view = TRUE, focus_layer = FALSE, digits = 6, - transitions = NULL + transitions = NULL, + brush_radius = NULL ) { l <- list() @@ -154,7 +155,7 @@ add_path <- function( invoke_method( map, jsfunc, map_type( map ), shape[["data"]], layer_id, auto_highlight, highlight_colour, shape[["legend"]], bbox, update_view, focus_layer, - js_transitions, billboard + js_transitions, billboard, brush_radius ) } diff --git a/R/map_layer_polygon.R b/R/map_layer_polygon.R index 9bd171d6..1d2fc872 100644 --- a/R/map_layer_polygon.R +++ b/R/map_layer_polygon.R @@ -134,7 +134,8 @@ add_polygon <- function( update_view = TRUE, focus_layer = FALSE, digits = 6, - transitions = NULL + transitions = NULL, + brush_radius = NULL ) { #if( is.null( stroke_colour )) stroke_colour <- fill_colour @@ -218,7 +219,7 @@ add_polygon <- function( invoke_method( map, jsfunc, map_type( map ), shape[["data"]], layer_id, light_settings, auto_highlight, highlight_colour, shape[["legend"]], bbox, update_view, focus_layer, - js_transitions, is_extruded, elevation_scale + js_transitions, is_extruded, elevation_scale, brush_radius ) } diff --git a/inst/htmlwidgets/lib/line/line.js b/inst/htmlwidgets/lib/line/line.js index 10b3e8bc..2c0eacfb 100644 --- a/inst/htmlwidgets/lib/line/line.js +++ b/inst/htmlwidgets/lib/line/line.js @@ -1,6 +1,12 @@ -function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition ) { +function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, brush_radius ) { + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } + const lineLayer = new LineLayer({ map_id: map_id, id: 'line-'+layer_id, @@ -17,7 +23,9 @@ function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, hi onHover: md_update_tooltip, autoHighlight: auto_highlight, highlightColor: md_hexToRGBA( highlight_colour ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { @@ -33,8 +41,14 @@ function add_line_geo( map_id, map_type, line_data, layer_id, auto_highlight, hi } -function add_line_polyline( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition ) { +function add_line_polyline( map_id, map_type, line_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, brush_radius ) { + + var extensions = []; + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } + const lineLayer = new LineLayer({ map_id: map_id, id: 'line-'+layer_id, @@ -51,7 +65,9 @@ function add_line_polyline( map_id, map_type, line_data, layer_id, auto_highligh onHover: md_update_tooltip, autoHighlight: auto_highlight, highlightColor: md_hexToRGBA( highlight_colour ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { diff --git a/inst/htmlwidgets/lib/mesh/mesh.js b/inst/htmlwidgets/lib/mesh/mesh.js index 91d03f35..860ba120 100644 --- a/inst/htmlwidgets/lib/mesh/mesh.js +++ b/inst/htmlwidgets/lib/mesh/mesh.js @@ -1,5 +1,5 @@ -function add_mesh( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded ) { +function add_mesh( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, brush_radius ) { /* @@ -34,6 +34,11 @@ function add_mesh( map_id, map_type, polygon_data, layer_id, light_settings, aut MeshLayer.layerName = 'MeshLayer'; */ + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } const meshLayer = new PolygonLayer({ map_id: map_id, @@ -55,7 +60,9 @@ function add_mesh( map_id, map_type, polygon_data, layer_id, light_settings, aut highlightColor: md_hexToRGBA( highlight_colour ), onHover: md_update_tooltip, onClick: info => md_layer_click( map_id, "mesh", info ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); console.log( meshLayer ); diff --git a/inst/htmlwidgets/lib/path/path.js b/inst/htmlwidgets/lib/path/path.js index f48bb19b..057da3fd 100644 --- a/inst/htmlwidgets/lib/path/path.js +++ b/inst/htmlwidgets/lib/path/path.js @@ -1,7 +1,12 @@ -function add_path_geo( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour, -legend, bbox, update_view, focus_layer, js_transition, billboard ) { +function add_path_geo( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, billboard, brush_radius ) { + + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } const pathLayer = new PathLayer({ map_id: map_id, @@ -23,7 +28,9 @@ legend, bbox, update_view, focus_layer, js_transition, billboard ) { onHover: md_update_tooltip, autoHighlight: auto_highlight, highlightColor: md_hexToRGBA( highlight_colour ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { @@ -38,7 +45,13 @@ legend, bbox, update_view, focus_layer, js_transition, billboard ) { md_layer_view( map_id, map_type, layer_id, focus_layer, bbox, update_view ); } -function add_path_polyline( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, billboard ) { +function add_path_polyline( map_id, map_type, path_data, layer_id, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, billboard, brush_radius ) { + + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } const pathLayer = new PathLayer({ map_id: map_id, @@ -60,7 +73,9 @@ function add_path_polyline( map_id, map_type, path_data, layer_id, auto_highligh onHover: md_update_tooltip, autoHighlight: auto_highlight, highlightColor: md_hexToRGBA( highlight_colour ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { diff --git a/inst/htmlwidgets/lib/polygon/polygon.js b/inst/htmlwidgets/lib/polygon/polygon.js index 7b73cb48..a0fa9405 100644 --- a/inst/htmlwidgets/lib/polygon/polygon.js +++ b/inst/htmlwidgets/lib/polygon/polygon.js @@ -1,5 +1,11 @@ -function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale ) { +function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale, brush_radius ) { + + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } const polygonLayer = new PolygonLayer({ map_id: map_id, @@ -22,7 +28,9 @@ function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settin highlightColor: md_hexToRGBA( highlight_colour ), onHover: md_update_tooltip, onClick: info => md_layer_click( map_id, "polygon", info ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { @@ -39,7 +47,13 @@ function add_polygon_geo( map_id, map_type, polygon_data, layer_id, light_settin } -function add_polygon_polyline( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale ) { +function add_polygon_polyline( map_id, map_type, polygon_data, layer_id, light_settings, auto_highlight, highlight_colour, legend, bbox, update_view, focus_layer, js_transition, is_extruded, elevation_scale, brush_radius ) { + + var extensions = []; + + if ( brush_radius > 0 ) { + extensions.push( new BrushingExtension() ); + } const polygonLayer = new PolygonLayer({ map_id: map_id, @@ -62,7 +76,9 @@ function add_polygon_polyline( map_id, map_type, polygon_data, layer_id, light_s highlightColor: md_hexToRGBA( highlight_colour ), onHover: md_update_tooltip, onClick: info => md_layer_click( map_id, "polygon", info ), - transitions: js_transition || {} + transitions: js_transition || {}, + brushingRadius: brush_radius, + extensions: extensions }); if( map_type == "google_map") { diff --git a/man/add_column.Rd b/man/add_column.Rd index dc379201..65ac2497 100644 --- a/man/add_column.Rd +++ b/man/add_column.Rd @@ -89,6 +89,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The ColumnLayer can be used to render a heatmap of vertical cylinders. It renders diff --git a/man/add_line.Rd b/man/add_line.Rd index cada8d60..1d809ad9 100644 --- a/man/add_line.Rd +++ b/man/add_line.Rd @@ -10,7 +10,7 @@ add_line(map, data = get_map_data(map), layer_id = NULL, origin, highlight_colour = "#AAFFFFFF", palette = "viridis", na_colour = "#808080FF", legend = FALSE, legend_options = NULL, legend_format = NULL, update_view = TRUE, focus_layer = FALSE, - digits = 6, transitions = NULL) + digits = 6, transitions = NULL, brush_radius = NULL) } \arguments{ \item{map}{a mapdeck map object} @@ -63,6 +63,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Line Layer renders raised lines joining pairs of source and target coordinates diff --git a/man/add_mesh.Rd b/man/add_mesh.Rd index 2090ba4a..50483209 100644 --- a/man/add_mesh.Rd +++ b/man/add_mesh.Rd @@ -10,7 +10,7 @@ add_mesh(map, data = get_map_data(map), fill_opacity = NULL, layer_id = NULL, id = NULL, palette = "viridis", na_colour = "#808080FF", legend = FALSE, legend_options = NULL, legend_format = NULL, update_view = TRUE, focus_layer = FALSE, - digits = 6, transitions = NULL) + digits = 6, transitions = NULL, brush_radius = NULL) } \arguments{ \item{map}{a mapdeck map object} @@ -60,6 +60,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ Adds polygons to the map from a \code{quadmesh} object diff --git a/man/add_path.Rd b/man/add_path.Rd index a95a750b..c3e53db0 100644 --- a/man/add_path.Rd +++ b/man/add_path.Rd @@ -11,7 +11,8 @@ add_path(map, data = get_map_data(map), polyline = NULL, auto_highlight = FALSE, highlight_colour = "#AAFFFFFF", palette = "viridis", na_colour = "#808080FF", legend = FALSE, legend_options = NULL, legend_format = NULL, update_view = TRUE, - focus_layer = FALSE, digits = 6, transitions = NULL) + focus_layer = FALSE, digits = 6, transitions = NULL, + brush_radius = NULL) } \arguments{ \item{map}{a mapdeck map object} @@ -66,6 +67,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Path Layer takes in lists of coordinate points and renders them as diff --git a/man/add_pointcloud.Rd b/man/add_pointcloud.Rd index df8ca847..e24c1809 100644 --- a/man/add_pointcloud.Rd +++ b/man/add_pointcloud.Rd @@ -72,6 +72,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Pointcloud Layer takes in coordinate points and renders them as circles diff --git a/man/add_polygon.Rd b/man/add_polygon.Rd index 43338965..62925847 100644 --- a/man/add_polygon.Rd +++ b/man/add_polygon.Rd @@ -12,7 +12,7 @@ add_polygon(map, data = get_map_data(map), polyline = NULL, layer_id = NULL, id = NULL, palette = "viridis", na_colour = "#808080FF", legend = FALSE, legend_options = NULL, legend_format = NULL, update_view = TRUE, focus_layer = FALSE, - digits = 6, transitions = NULL) + digits = 6, transitions = NULL, brush_radius = NULL) } \arguments{ \item{map}{a mapdeck map object} @@ -75,6 +75,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Polygon Layer renders filled and/or stroked polygons. diff --git a/man/add_scatterplot.Rd b/man/add_scatterplot.Rd index 66e447cc..9aab7560 100644 --- a/man/add_scatterplot.Rd +++ b/man/add_scatterplot.Rd @@ -82,6 +82,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Scatterplot Layer takes in coordinate points and renders them as circles diff --git a/man/add_text.Rd b/man/add_text.Rd index 3c06a554..79faf48d 100644 --- a/man/add_text.Rd +++ b/man/add_text.Rd @@ -90,6 +90,10 @@ a named list indicating which colour attributes should be included in the legend \item{focus_layer}{logical indicating if the map should update the bounds to only include this layer} \item{transitions}{list specifying the duration of transitions.} + +\item{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} } \description{ The Text Layer renders text labels on the map