spocc (version 0.1.2)

mapleaflet: Make an interactive map to view in the browser

Description

Make an interactive map to view in the browser

Usage

mapleaflet(data, popup = TRUE, map_provider = "osm", zoom = 3,
  title = "map", size, centerview = c(30, -73.9), dest = ".",
  overwrite = TRUE, incl.data = TRUE)

Arguments

data
A data.frame, with any number of columns, but with at least the following: name (the taxonomic name), latitude (in dec. deg.), longitude (in dec. deg.)
popup
If TRUE (default) popup tooltips are created for each point with metadta for that point.
map_provider
Base map to use. One or a list of 'osm' (OpenStreetMap standard map), 'tls' (Thunderforest Landscape), 'cm' (CloudMade), 'mqosm' (MapQuest OSM) or 'mqsat' (MapQuest Open Aerial). Default is 'osm'. See leaflet<
zoom
Map zoom, 0 being most zoomed out, and 18 most zoomed out. See leaflet for more information.
size
Height and width (in pixels) of map as a length 2 vector. If missing, a fullscreen (browser window) map is generated.
centerview
Lat/long position to center map
dest
Specify a path to save an html file of your map. You can open this in your browser to view it. If left as NULL (the default) the map opens up in your default browser, or if you have a newer version of RStudio open in RStudio Viewer pane.
overwrite
Default is TRUE. Set to FALSE to prevent overwriting local files
incl.data
Default is TRUE. Writes geoJSON data into the html file to get around security restrictions in browsers like Google Chrome. Set to FALSE to read from a separate local geoJSON file.
title
Map title

Details

NOTE that with some map_provider options you will have no map layer show up at first. This may be because there is no map at that particular zoom level. Just zoom in or out to see the map.

Examples

Run this code
spp <- c('Danaus plexippus','Accipiter striatus','Pinus contorta')
dat <- occ(query = spp, from = 'gbif', gbifopts = list(hasCoordinate = TRUE))
data <- occ2df(dat)
mapleaflet(data = data, dest = ".")

# An example with more species, a different base map, and different color palette
spp <- c('Danaus plexippus','Accipiter striatus','Pinus contorta','Puma concolor',
'Ursus americanus','Gymnogyps californianus')
dat <- occ(query = spp, from = 'gbif', gbifopts = list(hasCoordinate = TRUE))
data <- occ2df(dat)
mapleaflet(data, map_provider = 'toner')

Run the code above in your browser using DataLab