Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by roxygen2 (4.0.2): do not edit by hand

export("%>%")
export(fitBounds)
export(leaflet)
Expand Down
3 changes: 2 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#' @source The US Census Bureau:
#' \url{http://www.census.gov/popest/data/intercensal/cities/cities2010.html}
#' @export
#' @examples library(leaflet)
#' @examples
#' library(leaflet)
#' str(uspop2000)
#' p <- uspop2000$Pop2010
#' p <- (p - min(p))/(max(p) - min(p))
Expand Down
1 change: 0 additions & 1 deletion R/leaflet.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#' @param height the height of the map
#' @param padding the padding of the map
#' @return A HTML widget object.
#' @example inst/examples/leaflet.R
#' @export
leaflet = function(id = NULL, width = NULL, height = NULL, padding = 0) {
htmlwidgets::createWidget(
Expand Down
10 changes: 10 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ appendList = function(x, val) {
x[[n + 1]] = val
x
}

#' Pipe operator
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL
4 changes: 2 additions & 2 deletions leaflet.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageInstallArgs: -v && Rscript -e "Rd2roxygen::rab('leaflet', install=TRUE)" #
PackageCheckArgs: --as-cran --no-manual
PackageUseDevtools: Yes
PackageRoxygenize: rd,collate,namespace
9 changes: 0 additions & 9 deletions man/leaflet-imports.Rd

This file was deleted.

115 changes: 1 addition & 114 deletions man/leaflet.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Please edit documentation in R/leaflet.R
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{leaflet}
\alias{leaflet}
\title{Create a Leaflet map widget}
Expand All @@ -23,117 +23,4 @@ This function creates a Leaflet map widget using \pkg{htmlwidgets}. The
widget can be rendered on HTML pages generated from R Markdown, Shiny, or
other applications.
}
\examples{
library(leaflet)
m = leaflet() \%>\% tileLayer()
m # a map with the default OSM tile layer

# set bounds
m \%>\% fitBounds(40, 0, 50, 10)

# move the center to Snedecor Hall
m = m \%>\% setView(c(42.0285, -93.65), zoom = 17)
m

# popup
m \%>\% mapPopup(42.0285, -93.65, 'Here is the <b>Department of Statistics</b>, ISU')
rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
rand_lng = function(n = 10) rnorm(n, -93.65, .01)

# TODO: only one popup can be opened; need to bind all popups in a layer and show all
m \%>\% mapPopup(rand_lat(), rand_lng(), 'Random popups')

# marker
m \%>\% mapMarker(rand_lat(), rand_lng())

# circle (units in metres)
m \%>\% mapCircle(rand_lat(50), rand_lng(50), radius = runif(50, 5, 15))

# circle marker (units in pixels)
m \%>\% mapCircleMarker(rand_lat(50), rand_lng(50), options = list(color = '#ff0000'))
m \%>\% mapCircleMarker(rand_lat(100), rand_lng(100), radius = runif(100, 5, 15))

# rectangle
m \%>\% mapRectangle(
rand_lat(), rand_lng(), rand_lat(), rand_lng(),
options = list(color = 'red', fill = FALSE, dashArray = '5,5', weight = 3)
)

# polyline
m \%>\% mapPolyline(rand_lat(50), rand_lng(50))

# polygon
m \%>\% mapPolygon(rand_lat(), rand_lng(), layerId = 'foo')

# geoJSON
seattle_geojson <- list(
type = "Feature",
geometry = list(
type = "MultiPolygon",
coordinates = list(list(list(
c(-122.36075812146, 47.6759920119894),
c(-122.360781646764, 47.6668890126755),
c(-122.360782108665, 47.6614990696722),
c(-122.366199035722, 47.6614990696722),
c(-122.366199035722, 47.6592874248973),
c(-122.364582509469, 47.6576254522105),
c(-122.363887331445, 47.6569107302038),
c(-122.360865528129, 47.6538418253251),
c(-122.360866157644, 47.6535254473167),
c(-122.360866581103, 47.6533126275176),
c(-122.362526540691, 47.6541872926348),
c(-122.364442114483, 47.6551892850798),
c(-122.366077719797, 47.6560733960606),
c(-122.368818463838, 47.6579742346694),
c(-122.370115159943, 47.6588730808334),
c(-122.372295967029, 47.6604350102328),
c(-122.37381369088, 47.660582362063),
c(-122.375522972109, 47.6606413027949),
c(-122.376079703095, 47.6608793094619),
c(-122.376206315662, 47.6609242364243),
c(-122.377610811371, 47.6606160735197),
c(-122.379857378879, 47.6610306942278),
c(-122.382454873022, 47.6627496239169),
c(-122.385357955057, 47.6638573778241),
c(-122.386007328104, 47.6640865692306),
c(-122.387186331506, 47.6654326177161),
c(-122.387802656231, 47.6661492860294),
c(-122.388108244121, 47.6664548739202),
c(-122.389177800763, 47.6663784774359),
c(-122.390582858689, 47.6665072251861),
c(-122.390793942299, 47.6659699214511),
c(-122.391507906234, 47.6659200946229),
c(-122.392883050767, 47.6664166747017),
c(-122.392847210144, 47.6678696739431),
c(-122.392904778401, 47.6709016021624),
c(-122.39296705153, 47.6732047491624),
c(-122.393000803496, 47.6759322346303),
c(-122.37666945305, 47.6759896300663),
c(-122.376486363943, 47.6759891899754),
c(-122.366078869215, 47.6759641734893),
c(-122.36075812146, 47.6759920119894)
)))
),
properties = list(
name = "Ballard",
population = 48000,
# You can inline styles if you want
style = list(
fillColor = "yellow",
weight = 2,
color = "#000000"
)
),
id = "ballard"
)
m \%>\% setView(c(47.6759920119894, -122.36075812146), zoom = 13) \%>\% mapGeoJSON(seattle_geojson)


# use the OSM BW layer
leaflet() \%>\% tileLayer('http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png', list(
attribution = paste(
'&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,',
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
)
))
}
3 changes: 2 additions & 1 deletion man/leafletController.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Please edit documentation in R/shiny.R
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{leafletController}
\alias{leafletController}
\title{Create a Leaflet map controller}
Expand All @@ -20,3 +20,4 @@ A list of methods. See the package vignette \code{vignette('intro',
This function is called from \file{server.R} and returns an object that can
be used to manipulate the Leaflet map from R.
}

12 changes: 12 additions & 0 deletions man/pipe.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
% Generated by roxygen2 (4.0.2): do not edit by hand
\name{\%>\%}
\alias{\%>\%}
\title{Pipe operator}
\usage{
lhs \%>\% rhs
}
\description{
Pipe operator
}
\keyword{internal}

5 changes: 3 additions & 2 deletions man/uspop2000.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% Please edit documentation in R/data.R
% Generated by roxygen2 (4.0.2): do not edit by hand
\docType{data}
\name{uspop2000}
\alias{uspop2000}
Expand All @@ -22,6 +22,7 @@ library(leaflet)
str(uspop2000)
p <- uspop2000$Pop2010
p <- (p - min(p))/(max(p) - min(p))
plot(Lat ~ Long, data = uspop2000, cex = sqrt(p), asp = 1, col = rgb(1, 0, 0, 0.3))
plot(Lat ~ Long, data = uspop2000, cex = sqrt(p), asp = 1, col = rgb(1, 0, 0, .3))
}
\keyword{datasets}