add_markers {googleway} | R Documentation |
Add markers
Description
Add markers to a google map
Usage
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 |
data |
data frame containing the data to use in the layer. If Null, the
data passed into |
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 |
lon |
string specifying the column of |
polyline |
string specifying the column of |
title |
string specifying the column of |
draggable |
string specifying the column of |
opacity |
string specifying the column of |
label |
string specifying the column of |
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 |
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 |
Details
Cluster Options can be supplied as a named list. The available names are
gridSize (number) - The grid size of a cluster in pixels
maxZoom (number) - The maximum zoom level that a marker can be part of a cluster
zoomOnClick (logical) - Whether the default behaviour of clicking on a cluster is to zoom into it
averageCenter (logical) - Whether the center of each cluster should be the average of all markers in the cluster
minimumClusterSize (number) - The minimum number of markers required for a cluster
opts <- list( minimumClusterSize = 3 )
Examples
## 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)