Learn R Programming

googleway (version 2.0.0)

add_rectangles: Add Rectangles

Description

Adds a rectangle to a google map

Usage

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, z_index = NULL)

Arguments

map

a googleway map object created from google_map()

data

data frame containing the bounds for the rectangles

north

String specifying the column of data that contains the northern most latitude coordinate

east

String specifying the column of data that contains the eastern most longitude

south

String specifying the column of data that contains the southern most latitude coordinate

west

String specifying the column of data that contains the western most longitude

id

string specifying the column containing an identifier for a rectangle

draggable

string specifying the column of data defining if the rectangle is 'draggable' (either TRUE or FALSE)

editable

string specifying the column of data defining if the rectangle is 'editable' (either TRUE or FALSE)

stroke_colour

either a string specifying the column of data containing the stroke colour of each rectangle, or a valid hexadecimal numeric HTML style to be applied to all the rectangle

stroke_opacity

either a string specifying the column of data containing the stroke opacity of each rectangle, or a value between 0 and 1 that will be applied to all the rectangle

stroke_weight

either a string specifying the column of data containing the stroke weight of each rectangle, or a number indicating the width of pixels in the line to be applied to all the rectangle

fill_colour

either a string specifying the column of data containing the fill colour of each rectangle, or a valid hexadecimal numeric HTML style to be applied to all the rectangle

fill_opacity

either a string specifying the column of data containing the fill opacity of each rectangle, or a value between 0 and 1 that will be applied to all the rectangles

mouse_over

string specifying the column of data to display when the mouse rolls over the rectangle

mouse_over_group

string specifying the column of data specifying which groups of rectangle to highlight on mouseover

info_window

string specifying the column of data to display in an info window when a rectangle is clicked

layer_id

single value specifying an id for the layer.

z_index

single value specifying where the rectangles appear in the layering of the map objects. Layers with a higher z_index appear on top of those with a lower z_index. See details.

Details

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

Examples

Run this code
# 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')

# }

Run the code above in your browser using DataLab