google_map.Rd
Generates a google map object
google_map(data = NULL, key = get_api_key("map"), location = NULL, zoom = NULL, width = NULL, height = NULL, padding = 0, styles = NULL, search_box = FALSE, update_map_view = TRUE, zoom_control = TRUE, map_type_control = TRUE, scale_control = FALSE, street_view_control = TRUE, rotate_control = TRUE, fullscreen_control = TRUE, libraries = NULL, split_view = NULL, split_view_options = NULL, geolocation = FALSE, event_return_type = c("list", "json"))
data | data to be used on the map. Either a data.frame, or an |
---|---|
key | A valid Google Maps API key. |
location |
|
zoom |
|
width | the width of the map |
height | the height of the map |
padding | the padding of the map |
styles | JSON string representation of a valid Google Maps styles Array. See the Google documentation for details https://developers.google.com/maps/documentation/javascript/styling |
search_box |
|
update_map_view | logical indicating if the map should center on the searched location |
zoom_control | logical indicating if the zoom control should be displayed |
map_type_control | logical indicating if the map type control should be displayed |
scale_control | logical indicating if the scale control should be displayed |
street_view_control | logical indicating if the street view control should be displayed |
rotate_control | logical indicating if the rotate control should be displayed |
fullscreen_control | logical indicating if the full screen control should be displayed |
libraries | vector containing the libraries you want to load. See details |
split_view | string giving the name of a UI output element in which to place a streetview representation of the map. Will only work in an interactive environment (shiny). |
split_view_options | list of options to pass to the split street view.
valid list elements are |
geolocation | logical indicating if you want geolocation enabled |
event_return_type | the type of data to return to R from an interactive environment (shiny), either an R list, or raw json string. |
In order to use Google Maps you need a valid Google Maps Web JavaScript API key. See the Google Maps API documentation https://developers.google.com/maps/
The data argument is only needed if you call other functions to add layers to the map,
such as add_markers()
or add_polylines
. However, the data argument
can also be passed into those functions as well.
The data can either be a data.frame containing longitude and latitude columns
or an encoded polyline for plotting polylines and polygons, or an sf
object.
The supported sf
object types are
POINT
MULTIPOINT
LINESTRING
MULTILINESTRING
POLYGON
MULTIPOLYGON
GEOMETRY
The libraries argument can be used to turn-off certain libraries from being called. By default the map will load
visualization - includes the HeatmapLayer for visualising heatmaps https://developers.google.com/maps/documentation/javascript/visualization
geometry - utility functions for computation of geometric data on the surface of the earth, including plotting encoded polylines. https://developers.google.com/maps/documentation/javascript/geometry
places - enables searching for places. https://developers.google.com/maps/documentation/javascript/places
drawing - provides a graphical interface for users to draw polygons, rectangles, circles and markers on the map. https://developers.google.com/maps/documentation/javascript/drawinglayer
# NOT RUN { map_key <- "your_api_key" google_map(key = map_key, data = tram_stops) %>% add_markers() %>% add_traffic() ## style map using 'cobalt simplified' style style <- '[{"featureType":"all","elementType":"all","stylers":[{"invert_lightness":true}, {"saturation":10},{"lightness":30},{"gamma":0.5},{"hue":"#435158"}]}, {"featureType":"road.arterial","elementType":"all","stylers":[{"visibility":"simplified"}]}, {"featureType":"transit.station","elementType":"labels.text","stylers":[{"visibility":"off"}]}]' google_map(key = map_key, styles = style) # }