add_markers: Add markers

Description Usage Arguments Details Examples

View source: R/google_map_layer_marker.R

Description

Add markers to a google map

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
add_markers(
  map,
  data = get_map_data(map),
  id = NULL,
  colour = NULL,
  lat = NULL,
  lon = NULL,
  polyline = NULL,
  title = NULL,
  draggable = NULL,
  opacity = NULL,
  label = NULL,
  info_window = NULL,
  mouse_over = NULL,
  mouse_over_group = NULL,
  marker_icon = NULL,
  layer_id = NULL,
  cluster = FALSE,
  cluster_options = list(),
  update_map_view = TRUE,
  digits = 4,
  load_interval = 0,
  focus_layer = FALSE,
  close_info_window = FALSE
)

Arguments

map

a googleway map object created from google_map()

data

data frame containing the data to use in the layer. If Null, the data passed into google_map() will be used.

id

string specifying the column containing an identifier for a shape

colour

string specifying the column containing the 'colour' to use for the markers. One of 'red', 'blue', 'green' or 'lavender'.

lat

string specifying the column of data containing the 'latitude' coordinates. If left NULL, a best-guess will be made

lon

string specifying the column of data containing the 'longitude' coordinates. If left NULL, a best-guess will be made

polyline

string specifying the column of data containing the encoded polyline. For circles and markers the encoded string will represent a single point.

title

string specifying the column of data containing the 'title' of the markers. The title is displayed when you hover over a marker. If blank, no title will be displayed for the markers.

draggable

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

opacity

string specifying the column of data defining the 'opacity' of the maker. Values must be between 0 and 1 (inclusive).

label

string specifying the column of data defining the character to appear in the centre of the marker. Values will be coerced to strings, and only the first character will be used.

info_window

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

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

marker_icon

string specifying the column of data containing a link/URL to an image to use for a marker

layer_id

single value specifying an id for the layer. Use this value to distinguish between shape layers for when using any update_ function, and for separating legends.

cluster

logical indicating if co-located markers should be clustered when the map zoomed out

cluster_options

list of options used in clustering. See details.

update_map_view

logical specifying if the map should re-centre according to the shapes

digits

integer. Use this parameter to specify how many digits (decimal places) should be used for the latitude / longitude coordinates.

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

close_info_window

logical indicating if all info_windows should close when the user clicks on the map

Details

Cluster Options can be supplied as a named list. The available names are

opts <- list( minimumClusterSize = 3 )

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Not run: 

map_key <- "your api key"

google_map(
  key = map_key
  , data = tram_stops
  ) %>%
 add_markers(
   lat = "stop_lat"
   , lon = "stop_lon"
   , info_window = "stop_name"
   )


## using marker icons
iconUrl <- paste0("https://developers.google.com/maps/documentation/",
"javascript/examples/full/images/beachflag.png")

tram_stops$icon <- iconUrl

google_map(
  key = map_key
  , data = tram_stops
  ) %>%
  add_markers(
    lat = "stop_lat"
    , lon = "stop_lon"
    , marker_icon = "icon"
  )

## Clustering
google_map(
  key = map_key
  , data = tram_stops
  ) %>%
 add_markers(
   lat = "stop_lat"
   , lon = "stop_lon"
   , info_window = "stop_name"
   , cluster = TRUE
   , cluster_options = list( minimumClusterSize = 5 )
   )


## End(Not run)

Example output



googleway documentation built on Nov. 16, 2020, 9:08 a.m.