add_rectangles.Rd
Adds a rectangle to a google map
add_rectangles(map, data = get_map_data(map), north, east, south, west, id = NULL, draggable = NULL, editable = NULL, stroke_colour = NULL, stroke_opacity = NULL, stroke_weight = NULL, fill_colour = NULL, fill_opacity = NULL, mouse_over = NULL, mouse_over_group = NULL, info_window = NULL, layer_id = NULL, update_map_view = TRUE, z_index = NULL, digits = 4, palette = NULL, legend = F, legend_options = NULL, load_interval = 0, focus_layer = FALSE)
map | a googleway map object created from |
---|---|
data | data frame containing the bounds for the rectangles |
north | String specifying the column of |
east | String specifying the column of |
south | String specifying the column of |
west | String specifying the column of |
id | string specifying the column containing an identifier for a shape |
draggable | string specifying the column of |
editable | String specifying the column of |
stroke_colour | either a string specifying the column of |
stroke_opacity | either a string specifying the column of |
stroke_weight | either a string specifying the column of |
fill_colour | either a string specifying the column of |
fill_opacity | either a string specifying the column of |
mouse_over | string specifying the column of data to display when the mouse rolls over the shape |
mouse_over_group | string specifying the column of data specifying which groups of shapes to highlight on mouseover |
info_window | string specifying the column of data to display in an info window when a shape is clicked. |
layer_id | single value specifying an id for the layer. Use this value to
distinguish between shape layers for when using any |
update_map_view | logical specifying if the map should re-centre according to the shapes |
z_index | single value specifying where the circles appear in the layering
of the map objects. Layers with a higher |
digits | integer. Use this parameter to specify how many digits (decimal places) should be used for the latitude / longitude coordinates. |
palette | a function, or list of functions, that generates hex colours given a single number as an input. See details. |
legend | either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. |
legend_options | A list of options for controlling the legend. |
load_interval | time in miliseconds to wait between plotting each shape |
focus_layer | logical indicating if the map should re-centre according to this layer |
z_index
values define the order in which objects appear on the map.
Those with a higher value appear on top of those with a lower value. The default
order of objects is (1 being underneath all other objects)
1. Polygon
2. Rectangle
3. Polyline
4. Circle
Markers are always the top layer
The palette
is used to specify the colours that will map to variables.
You can specify a single function to map to all variables, or a named list
that specifies a separate function to map to each variable. The elements must
be named either fill_colour
or stroke_colour
, and their values
are the colour generating functions. The default is viridisLite::viridis
The legend_options
can be used to control the appearance of the legend.
This should be a named list, where the names are one of
css - a string of valid css
for controlling the appearance of the legend
title - a string to use for the title of the legend
if legend_options
are NULL, the default values will apply
If you are displaying two legends, one for stroke_colour
and one
for fill_colour
, you can specify different options for the different
colour attributes. See examples for add_circles.
# NOT RUN { map_key <- 'your_api_key' df <- data.frame(north = 33.685, south = 33.671, east = -116.234, west = -116.251) google_map(key = map_key) %>% add_rectangles(data = df, north = 'north', south = 'south', east = 'east', west = 'west') ## editable rectangle df <- data.frame(north = -37.8459, south = -37.8508, east = 144.9378, west = 144.9236, editable = T, draggable = T) google_map(key = map_key) %>% add_rectangles(data = df, north = 'north', south = 'south', east = 'east', west = 'west', editable = 'editable', draggable = 'draggable') # }