├── .bowerrc
├── javascript
├── src
│ ├── global
│ │ ├── leaflet.js
│ │ ├── shiny.js
│ │ ├── jquery.js
│ │ ├── proj4leaflet.js
│ │ └── htmlwidgets.js
│ ├── cluster-layer-store.js
│ ├── util.js
│ ├── control-store.js
│ ├── crs_utils.js
│ ├── dataframe.js
│ └── mipmapper.js
└── tests
│ └── test-dataframe.js
├── tests
├── test-all.R
├── testthat.R
└── testit
│ ├── test-utils.R
│ ├── test-icon.R
│ ├── test-measure.R
│ ├── test-legend.R
│ └── test-colors.R
├── data
├── providers.rda
└── providers.details.rda
├── inst
├── extdata
│ ├── gadmCHE.rds
│ ├── breweries91.rds
│ └── atlStorms2005.rds
├── legacy
│ ├── examples
│ │ ├── choropleth
│ │ │ ├── DESCRIPTION
│ │ │ ├── Rplots.pdf
│ │ │ ├── shinyapps
│ │ │ │ └── jcheng
│ │ │ │ │ └── choropleth3.dcf
│ │ │ ├── ui.R
│ │ │ ├── global.R
│ │ │ └── server.R
│ │ ├── geojson
│ │ │ └── ui.R
│ │ └── population
│ │ │ ├── www
│ │ │ └── styles.css
│ │ │ └── ui.R
│ └── www
│ │ └── images
│ │ ├── layers.png
│ │ ├── layers-2x.png
│ │ ├── marker-icon.png
│ │ ├── marker-icon-2x.png
│ │ └── marker-shadow.png
├── htmlwidgets
│ ├── lib
│ │ ├── leaflet
│ │ │ ├── images
│ │ │ │ ├── 1px.png
│ │ │ │ ├── layers.png
│ │ │ │ ├── layers-2x.png
│ │ │ │ ├── marker-icon.png
│ │ │ │ ├── marker-icon-2x.png
│ │ │ │ └── marker-shadow.png
│ │ │ └── .bower.json
│ │ ├── Leaflet.label
│ │ │ ├── images
│ │ │ │ └── death.png
│ │ │ └── leaflet.label.css
│ │ ├── leaflet-measure
│ │ │ ├── images
│ │ │ │ ├── cancel.png
│ │ │ │ ├── check.png
│ │ │ │ ├── focus.png
│ │ │ │ ├── rulers.png
│ │ │ │ ├── start.png
│ │ │ │ ├── trash.png
│ │ │ │ ├── check_@2X.png
│ │ │ │ ├── focus_@2X.png
│ │ │ │ ├── start_@2X.png
│ │ │ │ ├── trash_@2X.png
│ │ │ │ ├── cancel_@2X.png
│ │ │ │ └── rulers_@2X.png
│ │ │ └── leaflet-measure.css
│ │ ├── leaflet-providers
│ │ │ ├── CONTRIBUTING.md
│ │ │ ├── bower.json
│ │ │ ├── .bower.json
│ │ │ ├── license.md
│ │ │ ├── package.json
│ │ │ ├── css
│ │ │ │ └── gh-fork-ribbon.ie.css
│ │ │ └── README.md
│ │ ├── leafletfix
│ │ │ └── leafletfix.css
│ │ └── leaflet-omnivore
│ │ │ └── package.json
│ ├── plugins
│ │ ├── Leaflet-MiniMap
│ │ │ ├── images
│ │ │ │ ├── toggle.png
│ │ │ │ └── toggle.svg
│ │ │ ├── Control.MiniMap.min.css
│ │ │ ├── Minimap-binding.js
│ │ │ └── Control.MiniMap.css
│ │ ├── Leaflet.awesome-markers
│ │ │ ├── fonts
│ │ │ │ ├── ionicons.eot
│ │ │ │ ├── ionicons.ttf
│ │ │ │ ├── ionicons.woff
│ │ │ │ ├── FontAwesome.otf
│ │ │ │ ├── fontawesome-webfont.eot
│ │ │ │ ├── fontawesome-webfont.ttf
│ │ │ │ ├── fontawesome-webfont.woff
│ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ └── glyphicons-halflings-regular.woff
│ │ │ ├── images
│ │ │ │ ├── markers-soft.png
│ │ │ │ ├── markers-matte.png
│ │ │ │ ├── markers-plain.png
│ │ │ │ ├── markers-shadow.png
│ │ │ │ ├── markers-matte@2x.png
│ │ │ │ ├── markers-shadow@2x.png
│ │ │ │ └── markers-soft@2x.png
│ │ │ ├── leaflet.awesome-markers.min.js
│ │ │ └── leaflet.awesome-markers.css
│ │ ├── leaflet-locationfilter
│ │ │ ├── img
│ │ │ │ ├── filter-icon.png
│ │ │ │ ├── move-handle.png
│ │ │ │ └── resize-handle.png
│ │ │ └── locationfilter-bindings.js
│ │ ├── leaflet-providers-plugin
│ │ │ └── leaflet-providers-plugin.js
│ │ ├── Leaflet.SimpleGraticule
│ │ │ ├── L.SimpleGraticule.css
│ │ │ └── SimpleGraticule-binding.js
│ │ ├── Leaflet.Graticule
│ │ │ ├── Graticule-binding.js
│ │ │ └── L.Graticule.js
│ │ ├── Leaflet.Terminator
│ │ │ └── Terminator-binding.js
│ │ ├── Leaflet.markercluster
│ │ │ ├── MarkerCluster.css
│ │ │ ├── MIT-LICENCE.txt
│ │ │ └── MarkerCluster.Default.css
│ │ └── Leaflet.EasyButton
│ │ │ ├── LICENSE
│ │ │ ├── EasyButton-binding.js
│ │ │ └── easy-button.css
│ └── leaflet.yaml
└── examples
│ ├── graticule.R
│ ├── terminator.R
│ ├── simpleGraticule.R
│ ├── leaflet-measure.R
│ ├── providers-shiny.R
│ ├── providers-digitalglobe.R
│ ├── shiny-markercluster.R
│ ├── legend.R
│ ├── emptyData.R
│ ├── geojson.R
│ ├── providers.R
│ ├── shiny.R
│ ├── easyButton.R
│ ├── highlight-polygons.R
│ ├── icons.R
│ ├── polygon-colors.R
│ ├── marker-clustering.R
│ ├── awesomeMarkers.R
│ └── test.json
├── .gitignore
├── R
├── normalize-map.R
├── package.R
├── normalize-SharedData.R
├── selection.R
├── data.R
├── controls.R
├── shiny.R
├── dependencies.R
├── plugin-omnivore.R
├── plugin-graticule.R
├── plugin-terminator.R
├── scalebar.R
├── plugin-simplegraticule.R
├── methods.R
├── plugin-providers.R
└── normalize-sf.R
├── .Rbuildignore
├── man
├── getMapData.Rd
├── filterNULL.Rd
├── leaflet-imports.Rd
├── providers.Rd
├── expandLimits.Rd
├── providers.details.Rd
├── previewColors.Rd
├── iconList.Rd
├── expandLimitsBbox.Rd
├── evalFormula.Rd
├── awesomeIconList.Rd
├── validateCoords.Rd
├── leafletDependencies.Rd
├── showGroup.Rd
├── deprecated.Rd
├── derivePoints.Rd
├── derivePolygons.Rd
├── addTerminator.Rd
├── mapOptions.Rd
├── addGraticule.Rd
├── addSimpleGraticule.Rd
├── map-shiny.Rd
├── dispatch.Rd
├── addScaleBar.Rd
├── addProviderTiles.Rd
├── makeAwesomeIcon.Rd
├── map-methods.Rd
├── awesomeIcons.Rd
├── makeIcon.Rd
├── addLayersControl.Rd
├── easyButton.Rd
├── leafletProxy.Rd
├── addAwesomeMarkers.Rd
├── remove.Rd
├── addMeasure.Rd
└── addRasterImage.Rd
├── .travis.yml
├── leaflet.Rproj
├── data-raw
└── providerNames.R
├── .eslintrc.json
├── package.json
├── README.md
├── Gruntfile.js
├── DESCRIPTION
└── NEWS
/.bowerrc:
--------------------------------------------------------------------------------
1 | {"directory": "inst/htmlwidgets/lib"}
--------------------------------------------------------------------------------
/javascript/src/global/leaflet.js:
--------------------------------------------------------------------------------
1 | export default global.L;
2 |
--------------------------------------------------------------------------------
/javascript/src/global/shiny.js:
--------------------------------------------------------------------------------
1 | export default global.Shiny;
2 |
--------------------------------------------------------------------------------
/tests/test-all.R:
--------------------------------------------------------------------------------
1 | library(testit)
2 | test_pkg('leaflet')
3 |
--------------------------------------------------------------------------------
/javascript/src/global/jquery.js:
--------------------------------------------------------------------------------
1 | export default global.jQuery;
2 |
--------------------------------------------------------------------------------
/javascript/src/global/proj4leaflet.js:
--------------------------------------------------------------------------------
1 | export default global.L.Proj;
2 |
--------------------------------------------------------------------------------
/javascript/src/global/htmlwidgets.js:
--------------------------------------------------------------------------------
1 | export default global.HTMLWidgets;
2 |
--------------------------------------------------------------------------------
/data/providers.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/data/providers.rda
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(leaflet)
3 |
4 | test_check("leaflet")
5 |
--------------------------------------------------------------------------------
/inst/extdata/gadmCHE.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/extdata/gadmCHE.rds
--------------------------------------------------------------------------------
/data/providers.details.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/data/providers.details.rda
--------------------------------------------------------------------------------
/inst/extdata/breweries91.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/extdata/breweries91.rds
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Title: Choropleths with Shiny and Leaflet
2 | DisplayMode: Showcase
--------------------------------------------------------------------------------
/inst/extdata/atlStorms2005.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/extdata/atlStorms2005.rds
--------------------------------------------------------------------------------
/inst/legacy/www/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/www/images/layers.png
--------------------------------------------------------------------------------
/inst/legacy/www/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/www/images/layers-2x.png
--------------------------------------------------------------------------------
/inst/legacy/www/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/www/images/marker-icon.png
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/Rplots.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/examples/choropleth/Rplots.pdf
--------------------------------------------------------------------------------
/inst/legacy/www/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/www/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/inst/legacy/www/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/legacy/www/images/marker-shadow.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/1px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/1px.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/layers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/layers.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/layers-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/layers-2x.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/Leaflet.label/images/death.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/Leaflet.label/images/death.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/marker-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/marker-icon.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/cancel.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/check.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/check.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/focus.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/rulers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/rulers.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/start.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/trash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/trash.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/marker-icon-2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/marker-icon-2x.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/images/marker-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet/images/marker-shadow.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/check_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/check_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/focus_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/focus_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/start_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/start_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/trash_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/trash_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/cancel_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/cancel_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-measure/images/rulers_@2X.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/lib/leaflet-measure/images/rulers_@2X.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.png
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/shinyapps/jcheng/choropleth3.dcf:
--------------------------------------------------------------------------------
1 | name: choropleth3
2 | account: jcheng
3 | bundleId: 17723
4 | url: http://jcheng.shinyapps.io/choropleth3
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | node_modules
5 | inst/htmlwidgets/sources
6 | *.swp
7 | inst/examples/rsconnect
8 | inst/examples/*.html
9 | R/tags
10 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.eot
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.ttf
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/leaflet-locationfilter/img/filter-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/leaflet-locationfilter/img/filter-icon.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/leaflet-locationfilter/img/move-handle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/leaflet-locationfilter/img/move-handle.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.woff
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/leaflet-locationfilter/img/resize-handle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/leaflet-locationfilter/img/resize-handle.png
--------------------------------------------------------------------------------
/R/normalize-map.R:
--------------------------------------------------------------------------------
1 | #' @export
2 | metaData.map <- function(obj) {
3 | obj
4 | }
5 |
6 | #' @export
7 | polygonData.map <- function(obj) {
8 | polygonData(cbind(obj$x, obj$y))
9 | }
10 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-plain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-plain.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte@2x.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow@2x.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft@2x.png
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lchiffon/leaflet/master/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/inst/legacy/examples/geojson/ui.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | shinyUI(fluidPage(
4 | leafletMap("map", 600, 400, options = list(
5 | center = c(47.6659641734893, -122.376078869215),
6 | zoom = 13
7 | )),
8 | htmlOutput("details")
9 | ))
10 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/leaflet-providers-plugin/leaflet-providers-plugin.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addProviderTiles = function(provider, layerId, group, options) {
2 | this.layerManager.addLayer(L.tileLayer.provider(provider, options), "tile", layerId, group);
3 | };
4 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^.*\.Rproj$
2 | ^\.Rproj\.user$
3 | ^\.travis\.yml$
4 | ^inst/csv
5 | ^inst/examples
6 | \.bower\.json$
7 | \.bowerrc$
8 | ^docs/
9 | ^\.eslintrc\.json$
10 | ^Gruntfile\.js$
11 | ^javascript$
12 | ^package\.json$
13 | ^node_modules$
14 |
15 | ^data-raw$
16 |
--------------------------------------------------------------------------------
/R/package.R:
--------------------------------------------------------------------------------
1 | #' @importFrom magrittr %>%
2 | #' @export %>%
3 | #' @importFrom htmlwidgets JS
4 | #' @importFrom grDevices col2rgb rgb
5 | #' @importFrom methods substituteDirect
6 | #' @importFrom stats na.omit quantile
7 | #' @importFrom utils getFromNamespace packageVersion
8 | #' @export JS
9 | NULL
10 |
--------------------------------------------------------------------------------
/man/getMapData.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/leaflet.R
3 | \name{getMapData}
4 | \alias{getMapData}
5 | \title{returns the map's data}
6 | \usage{
7 | getMapData(map)
8 | }
9 | \arguments{
10 | \item{map}{the map}
11 | }
12 | \description{
13 | returns the map's data
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/tests/testit/test-utils.R:
--------------------------------------------------------------------------------
1 | library(testit)
2 |
3 | res = evalFormula(structure(list(1, ~x, ~x + 1), class = 'FOO'), data.frame(x = 2))
4 |
5 | assert(
6 | 'evalFormula() does not discard the class of a list',
7 | identical(class(res), c('FOO'))
8 | )
9 |
10 | assert(
11 | 'evalFormula() evaluates formulae in a list',
12 | res[[2]] == 2, res[[3]] == 3
13 | )
14 |
--------------------------------------------------------------------------------
/man/filterNULL.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{filterNULL}
4 | \alias{filterNULL}
5 | \title{remove NULL elements from a list}
6 | \usage{
7 | filterNULL(x)
8 | }
9 | \arguments{
10 | \item{x}{A list whose NULL elements will be filtered}
11 | }
12 | \description{
13 | remove NULL elements from a list
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/man/leaflet-imports.Rd:
--------------------------------------------------------------------------------
1 | \name{leaflet-imports}
2 | \alias{JS}
3 | \alias{\%>\%}
4 | \docType{import}
5 | \title{Objects imported from other packages}
6 | \description{
7 | These objects are imported from other packages. Follow the links to their documentation.
8 | \describe{
9 | \item{htmlwidgets}{\code{\link[htmlwidgets:JS]{JS}}}
10 | \item{magrittr}{\code{\link[magrittr:\%>\%]{\%>\%}}}
11 | }}
12 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: r
2 | sudo: required
3 | cache: packages
4 | dist: trusty
5 |
6 | before_install:
7 | - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
8 | - sudo apt-get --yes --force-yes update -qq
9 | - sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev
10 |
11 | notifications:
12 | email:
13 | on_success: change
14 | on_failure: change
15 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.SimpleGraticule/L.SimpleGraticule.css:
--------------------------------------------------------------------------------
1 | .leaflet-grid-label .gridlabel-vert {
2 | margin-left: 8px;
3 | -webkit-transform: rotate(90deg);
4 | transform: rotate(90deg);
5 | }
6 |
7 | .leaflet-grid-label .gridlabel-vert,
8 | .leaflet-grid-label .gridlabel-horiz {
9 | padding-left:2px;
10 | text-shadow: -2px 0 #FFFFFF, 0 2px #FFFFFF, 2px 0 #FFFFFF, 0 -2px #FFFFFF;
11 | }
12 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-providers/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | So you want to add a layer?
2 | =======
3 |
4 | Yay! go add it to the leaflet-providers.js as long as it follows the following
5 | rules:
6 |
7 | - Don't violate a providers TOS (if it exists, include a link to it)
8 | - Don't pre-populate api keys with working keys.
9 | - It should be a basic tile source, no exteral libraries etc.
10 | - The owner hasn't asked us to remove it (hasn't happened yet)
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.Graticule/Graticule-binding.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addGraticule = function(interval, sphere, style,
2 | layerId, group, options) {
3 | (function() {
4 | this.layerManager.addLayer(
5 | L.graticule($.extend({
6 | interval: interval,
7 | sphere: sphere,
8 | style: style
9 | }, options || {})),
10 | 'shape', layerId, group);
11 | }).call(this);
12 | };
13 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.Terminator/Terminator-binding.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addTerminator = function(resolution, time,
2 | layerId, group, options) {
3 | (function() {
4 | this.layerManager.addLayer(
5 | L.terminator($.extend({
6 | resolution: resolution,
7 | time: time,
8 | group: group
9 | }, options || {})),
10 | 'shape', layerId, group);
11 | }).call(this);
12 | };
13 |
14 |
15 |
--------------------------------------------------------------------------------
/R/normalize-SharedData.R:
--------------------------------------------------------------------------------
1 | #' @export
2 | metaData.sharedData <- function(obj) {
3 | obj$data(withSelection = TRUE, withFilter = FALSE, withKey = TRUE)
4 | }
5 |
6 | #' @export
7 | pointData.SharedData <- function(obj) {
8 | pointData(obj$data(withSelection = FALSE, withFilter = FALSE, withKey = FALSE))
9 | }
10 |
11 | #' @export
12 | polygonData.SharedData <- function(obj) {
13 | polygonData(obj$data(withSelection = FALSE, withFilter = FALSE, withKey = FALSE))
14 | }
15 |
--------------------------------------------------------------------------------
/man/providers.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-providers.R
3 | \docType{data}
4 | \name{providers}
5 | \alias{providers}
6 | \title{Providers}
7 | \format{A list of characters}
8 | \source{
9 | \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
10 | }
11 | \usage{
12 | providers
13 | }
14 | \description{
15 | List of all providers with their variations
16 | }
17 | \keyword{datasets}
18 |
19 |
--------------------------------------------------------------------------------
/inst/examples/graticule.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | # Default
3 | l <- leaflet() %>% addTiles() %>% setView(0,0,2)
4 |
5 | #' Default Graticule
6 | l %>% addGraticule()
7 |
8 | #'
9 | #' Custom Params
10 | l %>% addGraticule(interval = 40, style = list(color='#FF0000', weight=1))
11 |
12 | #'
13 | #' on a toggleable Layer
14 | l %>%
15 | addGraticule(group="graticule") %>%
16 | addLayersControl(
17 | overlayGroups = c("graticule"),
18 | options = layersControlOptions(collapsed = FALSE)
19 | )
20 |
--------------------------------------------------------------------------------
/leaflet.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: knitr
13 | LaTeX: pdfLaTeX
14 |
15 | AutoAppendNewline: Yes
16 | StripTrailingWhitespace: Yes
17 |
18 | BuildType: Package
19 | PackageUseDevtools: Yes
20 | PackageInstallArgs: --with-keep.source
21 | PackageCheckArgs: --as-cran --no-manual --run-donttest
22 | PackageRoxygenize: rd,collate,namespace
23 |
--------------------------------------------------------------------------------
/man/expandLimits.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{expandLimits}
4 | \alias{expandLimits}
5 | \title{Notifies the map of new latitude/longitude of items of interest on the map}
6 | \usage{
7 | expandLimits(map, lat, lng)
8 | }
9 | \arguments{
10 | \item{map}{map object}
11 |
12 | \item{lat}{vector of latitudes}
13 |
14 | \item{lng}{vector of longitudes}
15 | }
16 | \description{
17 | Notifies the map of new latitude/longitude of items of interest on the map
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/man/providers.details.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-providers.R
3 | \docType{data}
4 | \name{providers.details}
5 | \alias{providers.details}
6 | \title{Providers Details}
7 | \format{A list of lists (JSON)}
8 | \source{
9 | \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
10 | }
11 | \usage{
12 | providers.details
13 | }
14 | \description{
15 | List of all providers with their variations and additional info
16 | }
17 | \keyword{datasets}
18 |
19 |
--------------------------------------------------------------------------------
/man/previewColors.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/colors.R
3 | \name{previewColors}
4 | \alias{previewColors}
5 | \title{Color previewing utility}
6 | \usage{
7 | previewColors(pal, values)
8 | }
9 | \arguments{
10 | \item{pal}{A color mapping function, like those returned from \code{\link{colorNumeric}}, et al}
11 |
12 | \item{values}{A set of values to preview colors for}
13 | }
14 | \value{
15 | An HTML-based list of the colors and values
16 | }
17 | \description{
18 | Color previewing utility
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.SimpleGraticule/SimpleGraticule-binding.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addSimpleGraticule = function(interval, showOriginLabel,
2 | redraw, hidden, zoomIntervals, layerId, group) {
3 | (function() {
4 | this.layerManager.addLayer(
5 | L.simpleGraticule({
6 | interval: interval,
7 | showOriginLabel: showOriginLabel,
8 | redraw: redraw,
9 | hidden: hidden,
10 | zoomIntervals: zoomIntervals
11 | }),
12 | 'shape', layerId, group);
13 | }).call(this);
14 | };
15 |
--------------------------------------------------------------------------------
/man/iconList.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{iconList}
4 | \alias{iconList}
5 | \title{Make icon set}
6 | \usage{
7 | iconList(...)
8 | }
9 | \arguments{
10 | \item{...}{icons created from \code{\link{makeIcon}()}}
11 | }
12 | \description{
13 | Make icon set
14 | }
15 | \examples{
16 |
17 | iconSet = iconList(
18 | red = makeIcon("leaf-red.png", iconWidth=32, iconHeight=32),
19 | green = makeIcon("leaf-green.png", iconWidth=32, iconHeight=32)
20 | )
21 |
22 | iconSet[c('red', 'green', 'red')]
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/man/expandLimitsBbox.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{expandLimitsBbox}
4 | \alias{expandLimitsBbox}
5 | \title{Same as expandLimits, but takes a polygon (that presumably has a bbox attr)
6 | rather than lat/lng.}
7 | \usage{
8 | expandLimitsBbox(map, poly)
9 | }
10 | \arguments{
11 | \item{map}{map object}
12 |
13 | \item{poly}{A spatial object representing a polygon.}
14 | }
15 | \description{
16 | Same as expandLimits, but takes a polygon (that presumably has a bbox attr)
17 | rather than lat/lng.
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/tests/testit/test-icon.R:
--------------------------------------------------------------------------------
1 | library(testit)
2 |
3 | icons <- c("leaf-green.png", "leaf-red.png")
4 | m <- leaflet(data = data.frame(color = sample.int(2, 30, replace = TRUE))) %>%
5 | addMarkers(1:30, 30:1, icon = icons(
6 | iconUrl = ~icons[color],
7 | shadowUrl = c("leaf-shadow.png"),
8 | iconWidth = 38, iconHeight = 95, iconAnchorX = 22, iconAnchorY = 94,
9 | shadowWidth = 50, shadowHeight = 64, shadowAnchorX = 4, shadowAnchorY = 62
10 | ))
11 | assert(
12 | 'icon deduping works',
13 | identical(length(m$x$calls[[1]]$args[[3]]$iconUrl$data), 2L),
14 | TRUE
15 | )
16 |
--------------------------------------------------------------------------------
/man/evalFormula.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{evalFormula}
4 | \alias{evalFormula}
5 | \title{Evaluate list members that are formulae, using the map data as the environment
6 | (if provided, otherwise the formula environment)}
7 | \usage{
8 | evalFormula(list, data)
9 | }
10 | \arguments{
11 | \item{list}{with members as formulae}
12 |
13 | \item{data}{map data}
14 | }
15 | \description{
16 | Evaluate list members that are formulae, using the map data as the environment
17 | (if provided, otherwise the formula environment)
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/man/awesomeIconList.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-awesomeMarkers.R
3 | \name{awesomeIconList}
4 | \alias{awesomeIconList}
5 | \title{Make awesome-icon set}
6 | \usage{
7 | awesomeIconList(...)
8 | }
9 | \arguments{
10 | \item{...}{icons created from \code{\link{makeAwesomeIcon}()}}
11 | }
12 | \description{
13 | Make awesome-icon set
14 | }
15 | \examples{
16 |
17 | iconSet = awesomeIconList(
18 | home = makeAwesomeIcon(icon='Home', library='fa'),
19 | flag = makeAwesomeIcon(icon='Flag', library='fa')
20 | )
21 |
22 | iconSet[c('home', 'flag')]
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/inst/examples/terminator.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | # Default Resolution
3 | leaflet() %>% addTiles() %>% addTerminator()
4 |
5 | # Custom Resolutions
6 | leaflet() %>% addTiles() %>% addTerminator(resolution=1)
7 | leaflet() %>% addTiles() %>% addTerminator(resolution=100)
8 |
9 | # Custom Resolution + Custom Date and on a toggleable Layer
10 | leaflet() %>% addTiles() %>%
11 | addTerminator(resolution=10,
12 | time='2013-06-20T21:00:00Z',
13 | group="daylight") %>%
14 | addLayersControl(
15 | overlayGroups = c("daylight"),
16 | options = layersControlOptions(collapsed = FALSE)
17 | )
18 |
--------------------------------------------------------------------------------
/inst/examples/simpleGraticule.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | # Default
3 | l <- leaflet() %>% addTiles() %>% setView(0,0,1)
4 |
5 | #' Default simple Graticule
6 | l %>% addSimpleGraticule()
7 |
8 | #'
9 | #' Custom Params
10 | l %>% addSimpleGraticule(interval = 40, showOriginLabel = F)
11 |
12 | #'
13 | #' Custom Resolution + Custom Date and on a toggleable Layer
14 | l %>%
15 | addSimpleGraticule(interval=40,
16 | showOriginLabel = F,
17 | group="graticule") %>%
18 | addLayersControl(
19 | overlayGroups = c("graticule"),
20 | options = layersControlOptions(collapsed = FALSE)
21 | )
22 |
--------------------------------------------------------------------------------
/inst/examples/leaflet-measure.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | leaf <- leaflet() %>%
4 | addTiles()
5 |
6 | #'
7 | #' Default Behavior
8 | leaf %>%
9 | # central park
10 | fitBounds(-73.9, 40.75, -73.95,40.8) %>%
11 | addMeasure()
12 |
13 | #'
14 | #' Customization
15 | leaf %>%
16 | # Berling, Germany with German localization
17 | fitBounds(13.76134, 52.675499, 13.0884, 52.33812) %>%
18 | addMeasure(
19 | position = "bottomleft",
20 | primaryLengthUnit = "meters",
21 | primaryAreaUnit = "sqmeters",
22 | activeColor = "#3D535D",
23 | completedColor = "#7D4479",
24 | localization='de'
25 | )
26 |
--------------------------------------------------------------------------------
/man/validateCoords.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{validateCoords}
4 | \alias{validateCoords}
5 | \title{Utility function to check if a coordinates is valid}
6 | \usage{
7 | validateCoords(lng, lat, funcName, warn = T)
8 | }
9 | \arguments{
10 | \item{lng}{vector with longitude values}
11 |
12 | \item{lat}{vector with latitude values}
13 |
14 | \item{funcName}{Name of calling function}
15 |
16 | \item{warn}{A boolean. Whether to generate a warning message if there are rows with missing/invalid data}
17 | }
18 | \description{
19 | Utility function to check if a coordinates is valid
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-providers/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet-providers",
3 | "version": "1.1.15",
4 | "homepage": "https://github.com/leaflet-extras/leaflet-providers",
5 | "description": "An extension to Leaflet that contains configurations for various free tile providers.",
6 | "dependencies": {
7 | "leaflet": "~0.7.3"
8 | },
9 | "main": "leaflet-providers.js",
10 | "keywords": [
11 | "leaflet",
12 | "stamen",
13 | "osm"
14 | ],
15 | "license": "BSD-2-Clause",
16 | "ignore": [
17 | "**/.*",
18 | "node_modules",
19 | "bower_components",
20 | "test",
21 | "tests",
22 | "preview",
23 | "*.html"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/man/leafletDependencies.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dependencies.R
3 | \docType{data}
4 | \name{leafletDependencies}
5 | \alias{leafletDependencies}
6 | \title{Various leaflet dependency functions for use in downstream packages}
7 | \format{An object of class \code{list} of length 13.}
8 | \usage{
9 | leafletDependencies
10 | }
11 | \description{
12 | Various leaflet dependency functions for use in downstream packages
13 | }
14 | \examples{
15 | \dontrun{
16 | addBootStrap <- function(map) {
17 | map$dependencies <- c(map$dependencies, leafletDependencies$bootstrap())
18 | map
19 | }
20 | }
21 | }
22 | \keyword{datasets}
23 |
24 |
--------------------------------------------------------------------------------
/inst/legacy/examples/population/www/styles.css:
--------------------------------------------------------------------------------
1 | @import url(//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600);
2 |
3 | body {
4 | overflow-y: scroll;
5 | padding-bottom: 20px;
6 | }
7 |
8 | body {
9 | font-family: Source Sans Pro;
10 | color: #444;
11 | font-weight: 300;
12 | }
13 |
14 | #map {
15 | position: absolute;
16 | top: 0;
17 | left: 0;
18 | right: 0;
19 | bottom: 400;
20 | }
21 |
22 | #data table {
23 | width: 100%;
24 | }
25 | #data td+td {
26 | width: 80px;
27 | }
28 |
29 | .container-fluid {
30 | padding-top: 400px;
31 | }
32 |
33 | #desc { font-size: 16px; }
34 |
35 | #desc span {
36 | color: #944;
37 | font-weight: 400;
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/man/showGroup.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{showGroup}
4 | \alias{hideGroup}
5 | \alias{showGroup}
6 | \title{Show or hide layer groups}
7 | \usage{
8 | showGroup(map, group)
9 |
10 | hideGroup(map, group)
11 | }
12 | \arguments{
13 | \item{map}{the map to modify}
14 |
15 | \item{group}{character vector of one or more group names to show or hide}
16 | }
17 | \description{
18 | Hide groups of layers without removing them from the map entirely. Groups are
19 | created using the \code{group} parameter that is included on most layer
20 | adding functions.
21 | }
22 | \seealso{
23 | \code{\link{addLayersControl}} to allow users to show/hide layer
24 | groups interactively
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/leaflet.yaml:
--------------------------------------------------------------------------------
1 | dependencies:
2 | - name: jquery
3 | version: 1.12.4
4 | src: "htmlwidgets/lib/jquery"
5 | script: jquery.min.js
6 | - name: leaflet
7 | version: 0.7.7
8 | src: "htmlwidgets/lib/leaflet"
9 | script: leaflet.js
10 | stylesheet: leaflet.css
11 | - name: leafletfix
12 | version: 1.0.0
13 | src: "htmlwidgets/lib/leafletfix"
14 | stylesheet: leafletfix.css
15 | - name: leaflet-label
16 | version: 0.2.2
17 | src: "htmlwidgets/lib/Leaflet.label"
18 | script: leaflet.label.js
19 | stylesheet: leaflet.label.css
20 | - name: Proj4Leaflet
21 | version: 0.7.2
22 | src: "htmlwidgets/plugins/Proj4Leaflet"
23 | script:
24 | - proj4-compressed.js
25 | - proj4leaflet.js
26 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leafletfix/leafletfix.css:
--------------------------------------------------------------------------------
1 | /* Work around CSS properties introduced on img by bootstrap */
2 | img.leaflet-tile {
3 | padding: 0;
4 | margin: 0;
5 | border-radius: 0;
6 | border: none;
7 | }
8 | .info {
9 | padding: 6px 8px;
10 | font: 14px/16px Arial, Helvetica, sans-serif;
11 | background: white;
12 | background: rgba(255,255,255,0.8);
13 | box-shadow: 0 0 15px rgba(0,0,0,0.2);
14 | border-radius: 5px;
15 | }
16 | .legend {
17 | line-height: 18px;
18 | color: #555;
19 | }
20 | .legend svg text {
21 | fill: #555;
22 | }
23 | .legend svg line {
24 | stroke: #555;
25 | }
26 | .legend i {
27 | width: 18px;
28 | height: 18px;
29 | float: left;
30 | margin-right: 8px;
31 | opacity: 0.7;
32 | }
33 |
--------------------------------------------------------------------------------
/data-raw/providerNames.R:
--------------------------------------------------------------------------------
1 | # The JSON was extracted and fixed from ...
2 | # https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js
3 |
4 | providers.details <- jsonlite::fromJSON(
5 | './inst/htmlwidgets/lib/leaflet-providers/providers.json')
6 |
7 | variants <- purrr::map(providers.details, ~ names(.$variants))
8 |
9 | providers <- purrr::map(names(providers.details), function(provider) {
10 | if(is.null(variants[[provider]])) {
11 | provider
12 | } else {
13 | c(provider, stringr::str_c(provider,'.',variants[[provider]]))
14 | }
15 | }) %>% purrr::flatten_chr()
16 |
17 | providers <- setNames(as.list(providers), providers)
18 |
19 | devtools::use_data(providers.details, overwrite = TRUE)
20 | devtools::use_data(providers, overwrite = TRUE)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/inst/examples/providers-shiny.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | library(leaflet)
3 |
4 | ui <- fluidPage(
5 | fluidRow(
6 | column(
7 | 3,
8 | selectInput(
9 | "providerName",
10 | "Tile set",
11 | c("Stamen.Toner",
12 | "Stamen.TonerLite",
13 | "Stamen.Watercolor")
14 | )
15 | ),
16 | column(
17 | 9,
18 | leafletOutput("map")
19 |
20 | )
21 | )
22 | )
23 |
24 | server <- function(input, output, session) {
25 | output$map <- renderLeaflet({
26 | leaflet() %>% addTiles(layerId = "tiles") %>% setView(0, 0, 1)
27 | })
28 |
29 | observeEvent(input$providerName, {
30 | leafletProxy("map", session) %>%
31 | addProviderTiles(input$providerName, layerId = "tiles")
32 | })
33 | }
34 |
35 | shinyApp(ui, server)
36 |
--------------------------------------------------------------------------------
/man/deprecated.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/legacy.R
3 | \name{createLeafletMap}
4 | \alias{createLeafletMap}
5 | \alias{leafletMap}
6 | \title{Legacy functions}
7 | \usage{
8 | createLeafletMap(session, outputId)
9 |
10 | leafletMap(outputId, width, height,
11 | initialTileLayer = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
12 | initialTileLayerAttribution = NULL, options = NULL)
13 | }
14 | \arguments{
15 | \item{session, outputId}{Deprecated}
16 |
17 | \item{width, height, initialTileLayer, initialTileLayerAttribution, options}{Deprecated}
18 | }
19 | \description{
20 | These functions are provided for backwards compatibility with the first
21 | iteration of the leaflet bindings
22 | (\url{https://github.com/jcheng5/leaflet-shiny}).
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/R/selection.R:
--------------------------------------------------------------------------------
1 | locationFilter2Dependencies <- function() {
2 | list(
3 | htmltools::htmlDependency(
4 | "leaflet-locationfilter2",
5 | "0.1.0",
6 | system.file("htmlwidgets/plugins/leaflet-locationfilter", package = "leaflet"),
7 | script = c("locationfilter.js", "locationfilter-bindings.js"),
8 | stylesheet = c("locationfilter.css")
9 | )
10 | )
11 | }
12 |
13 | addSelect <- function(map, data = getMapData(map)) {
14 | map$dependencies <- c(map$dependencies,
15 | leafletEasyButtonDependencies(),
16 | locationFilter2Dependencies())
17 | map <- addIonIcon(map)
18 |
19 | invokeMethod(map, data, "addSelect",
20 | getCrosstalkOptions(data)[["ctGroup"]]
21 | )
22 | }
23 |
24 | removeSelect <- function(map) {
25 | invokeMethod(map, NULL, "removeSelect")
26 | }
27 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es6": true
5 | },
6 | "extends": "eslint:recommended",
7 | "parserOptions": {
8 | "sourceType": "module"
9 | },
10 | "rules": {
11 | "indent": [
12 | "error",
13 | 2
14 | ],
15 | "linebreak-style": [
16 | "error",
17 | "unix"
18 | ],
19 | "quotes": [
20 | "error",
21 | "double"
22 | ],
23 | "no-undef": [
24 | "error"
25 | ],
26 |
27 | "no-console": "warn",
28 | "no-unused-vars": ["error", {"args": "none"}],
29 | "semi": "error",
30 | "no-extra-semi": "error",
31 | "indent": ["error", 2]
32 | },
33 | "globals": {
34 | "global": true
35 | }
36 | }
--------------------------------------------------------------------------------
/tests/testit/test-measure.R:
--------------------------------------------------------------------------------
1 | library(testit)
2 |
3 | # did the dependency get added?
4 | assert(
5 | !is.na(Position(
6 | function(dep) dep$name == "leaflet-measure"
7 | , addMeasure(leaflet())$dependencies
8 | ))
9 | )
10 |
11 | # did the call get added?
12 | assert(
13 | !is.na(Position(
14 | function(cl) cl$method == "addMeasure"
15 | , addMeasure(leaflet())$x$calls
16 | ))
17 | )
18 |
19 | # were options added as expected
20 | assert(
21 | Filter(
22 | function(cl) cl$method == "addMeasure"
23 | , addMeasure(leaflet(), position = "bottomleft")$x$calls
24 | )[[1]]$args[[1]]$position == "bottomleft"
25 | )
26 |
27 | # are null options removed
28 | # were options added as expected
29 | assert(
30 | !("position" %in% names(Filter(
31 | function(cl) cl$method == "addMeasure"
32 | , addMeasure(leaflet(), position = NULL )$x$calls
33 | )[[1]]$args[[1]]))
34 | )
35 |
--------------------------------------------------------------------------------
/javascript/src/cluster-layer-store.js:
--------------------------------------------------------------------------------
1 | import { asArray } from "./util";
2 |
3 | export default class ClusterLayerStore {
4 | constructor(group) {
5 | this._layers = {};
6 | this._group = group;
7 | }
8 |
9 | add(layer, id) {
10 | if (typeof(id) !== "undefined" && id !== null) {
11 | if (this._layers[id]) {
12 | this._group.removeLayer(this._layers[id]);
13 | }
14 | this._layers[id] = layer;
15 | }
16 | this._group.addLayer(layer);
17 | }
18 |
19 | remove(id) {
20 | if (typeof(id) === "undefined" || id === null) {
21 | return;
22 | }
23 |
24 | id = asArray(id);
25 | for (let i = 0; i < id.length; i++) {
26 | if (this._layers[id[i]]) {
27 | this._group.removeLayer(this._layers[id[i]]);
28 | delete this._layers[id[i]];
29 | }
30 | }
31 | }
32 |
33 | clear() {
34 | this._layers = {};
35 | this._group.clearLayers();
36 | }
37 | }
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.markercluster/MarkerCluster.css:
--------------------------------------------------------------------------------
1 | .leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
2 | -webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
3 | -moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
4 | -o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
5 | transition: transform 0.3s ease-out, opacity 0.3s ease-in;
6 | }
7 |
8 | .leaflet-cluster-spider-leg {
9 | /* stroke-dashoffset (duration and function) should match with leaflet-marker-icon transform in order to track it exactly */
10 | -webkit-transition: -webkit-stroke-dashoffset 0.3s ease-out, -webkit-stroke-opacity 0.3s ease-in;
11 | -moz-transition: -moz-stroke-dashoffset 0.3s ease-out, -moz-stroke-opacity 0.3s ease-in;
12 | -o-transition: -o-stroke-dashoffset 0.3s ease-out, -o-stroke-opacity 0.3s ease-in;
13 | transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in;
14 | }
15 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet",
3 | "version": "0.7.3",
4 | "description": "JavaScript library for mobile-friendly interactive maps",
5 | "main": [
6 | "dist/leaflet.js",
7 | "dist/leaflet.css",
8 | "dist/leaflet-src.js",
9 | "dist/images/layers-2x.png",
10 | "dist/images/layers.png",
11 | "dist/images/marker-icon-2x.png",
12 | "dist/images/marker-icon.png",
13 | "dist/images/marker-shadow.png"
14 | ],
15 | "ignore": [
16 | ".*",
17 | "CHANGELOG.json",
18 | "FAQ.md",
19 | "debug",
20 | "spec",
21 | "src",
22 | "build"
23 | ],
24 | "homepage": "https://github.com/Leaflet/Leaflet",
25 | "_release": "0.7.3",
26 | "_resolution": {
27 | "type": "version",
28 | "tag": "v0.7.3",
29 | "commit": "8a5fdfc6e3db2807b8f0dd617474e4ab2949142b"
30 | },
31 | "_source": "git://github.com/Leaflet/Leaflet.git",
32 | "_target": "~0.7.3",
33 | "_originalSource": "leaflet"
34 | }
--------------------------------------------------------------------------------
/javascript/src/util.js:
--------------------------------------------------------------------------------
1 | export function log(message) {
2 | /* eslint-disable no-console */
3 | if (console && console.log) console.log(message);
4 | /* eslint-enable no-console */
5 | }
6 |
7 | export function recycle(values, length, inPlace) {
8 | if (length === 0 && !inPlace)
9 | return [];
10 |
11 | if (!(values instanceof Array)) {
12 | if (inPlace) {
13 | throw new Error("Can't do in-place recycling of a non-Array value");
14 | }
15 | values = [values];
16 | }
17 | if (typeof(length) === "undefined")
18 | length = values.length;
19 |
20 | let dest = inPlace ? values : [];
21 | let origLength = values.length;
22 | while (dest.length < length) {
23 | dest.push(values[dest.length % origLength]);
24 | }
25 | if (dest.length > length) {
26 | dest.splice(length, dest.length - length);
27 | }
28 | return dest;
29 | }
30 |
31 | export function asArray(value) {
32 | if (value instanceof Array)
33 | return value;
34 | else
35 | return [value];
36 | }
37 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-providers/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet-providers",
3 | "version": "1.0.27",
4 | "homepage": "https://github.com/leaflet-extras/leaflet-providers",
5 | "description": "An extension to Leaflet that contains configurations for various free tile providers.",
6 | "dependencies": {
7 | "leaflet": "~0.7.3"
8 | },
9 | "main": "leaflet-providers.js",
10 | "keywords": [
11 | "leaflet",
12 | "stamen",
13 | "osm"
14 | ],
15 | "license": "BSD-2-Clause",
16 | "ignore": [
17 | "**/.*",
18 | "node_modules",
19 | "bower_components",
20 | "test",
21 | "tests",
22 | "preview",
23 | "*.html"
24 | ],
25 | "_release": "1.0.27",
26 | "_resolution": {
27 | "type": "version",
28 | "tag": "1.0.27",
29 | "commit": "cd61a578f5fc77c0ef65270a9069c80fb59907a5"
30 | },
31 | "_source": "git://github.com/leaflet-extras/leaflet-providers.git",
32 | "_target": "~1.0.27",
33 | "_originalSource": "leaflet-providers",
34 | "_direct": true
35 | }
--------------------------------------------------------------------------------
/R/data.R:
--------------------------------------------------------------------------------
1 | #' City and town intercensal US population estimates (2000-2010)
2 | #'
3 | #' Intercensal estimates of the resident population for Incorporated Places and
4 | #' Minor Civil Divisions: April 1, 2000 to July 1, 2010.
5 | #' @docType data
6 | #' @format A data frame containing \code{City}, \code{State}, \code{Lat},
7 | #' \code{Long}, and population estimates from 2000 to 2010 (columns
8 | #' \code{Pop2000} to \code{Pop2010}).
9 | #' @source The US Census Bureau:
10 | #' \url{http://www.census.gov/popest/data/intercensal/cities/cities2010.html}
11 | #' @noRd
12 | #' @examples library(leaflet)
13 | #' str(uspop2000)
14 | #' p = uspop2000$Pop2010
15 | #' p = (p - min(p))/(max(p) - min(p))
16 | #' plot(Lat ~ Long, data = uspop2000, cex = sqrt(p), asp = 1, col = rgb(1, 0, 0, .3))
17 |
18 | if(FALSE){
19 | uspop2000 = NULL
20 | if (file.exists('inst/csv/uspop2000.csv')) {
21 | uspop2000 = read.csv(
22 | text = readLines('inst/csv/uspop2000.csv', encoding = 'UTF-8'),
23 | stringsAsFactors = FALSE
24 | )
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/inst/examples/providers-digitalglobe.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | mapbox.tileIds <- list('Recent Imagery with Streets'='digitalglobe.nal0mpda',
3 | 'Recent Imagery'='digitalglobe.nal0g75k',
4 | 'Street Map'='digitalglobe.nako6329',
5 | 'Terrain Map'='digitalglobe.nako1fhg')
6 |
7 | m <- leaflet() %>% setView(0,0,1)
8 |
9 | names(mapbox.tileIds) %>%
10 | purrr::walk(function(x) {
11 | m <<- m %>%
12 | addProviderTiles(providers$MapBox, group = x,
13 | options = providerTileOptions(
14 | detectRetina = TRUE,
15 | # id and accessToken are Mapbox specific options
16 | id = mapbox.tileIds[[x]] ,
17 | accessToken = Sys.getenv('DIGITALGLOBE_API_KEY')
18 | ))
19 | })
20 |
21 | m %>%
22 | setView(-77.0353, 38.8895, 15) %>%
23 | addLayersControl(
24 | baseGroups = names(mapbox.tileIds),
25 | options = layersControlOptions(collapsed = FALSE)
26 | )
27 |
--------------------------------------------------------------------------------
/man/derivePoints.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/normalize.R
3 | \name{derivePoints}
4 | \alias{derivePoints}
5 | \title{Given a data object and lng/lat arguments (which may be NULL [meaning infer
6 | from data], formula [which should be evaluated with respect to the data], or
7 | vector data [which should be used as-is]) return a lng/lat data frame.}
8 | \usage{
9 | derivePoints(data, lng = NULL, lat = NULL, missingLng = missing(lng),
10 | missingLat = missing(lat), funcName = "f")
11 | }
12 | \arguments{
13 | \item{data}{map data}
14 |
15 | \item{lng}{longitude}
16 |
17 | \item{lat}{latitude}
18 |
19 | \item{missingLng}{whether lng is missing}
20 |
21 | \item{missingLat}{whether lat is missing}
22 |
23 | \item{funcName}{Name of calling function (for logging)}
24 | }
25 | \description{
26 | Given a data object and lng/lat arguments (which may be NULL [meaning infer
27 | from data], formula [which should be evaluated with respect to the data], or
28 | vector data [which should be used as-is]) return a lng/lat data frame.
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/man/derivePolygons.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/normalize.R
3 | \name{derivePolygons}
4 | \alias{derivePolygons}
5 | \title{Given a data object and lng/lat arguments (which may be NULL [meaning infer
6 | from data], formula [which should be evaluated with respect to the data], or
7 | vector data [which should be used as-is]) return a spatial object}
8 | \usage{
9 | derivePolygons(data, lng = NULL, lat = NULL, missingLng = missing(lng),
10 | missingLat = missing(lat), funcName = "f")
11 | }
12 | \arguments{
13 | \item{data}{map data}
14 |
15 | \item{lng}{longitude}
16 |
17 | \item{lat}{latitude}
18 |
19 | \item{missingLng}{whether lng is missing}
20 |
21 | \item{missingLat}{whether lat is missing}
22 |
23 | \item{funcName}{Name of calling function (for logging)}
24 | }
25 | \description{
26 | Given a data object and lng/lat arguments (which may be NULL [meaning infer
27 | from data], formula [which should be evaluated with respect to the data], or
28 | vector data [which should be used as-is]) return a spatial object
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/inst/examples/shiny-markercluster.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | library(leaflet)
3 |
4 | shinyApp(
5 | ui = fluidPage(
6 | leafletOutput('map1'),
7 | actionButton('add', 'Add marker cluster'),
8 | actionButton('clear', 'Clear marker cluster'),
9 | selectizeInput('remove1', 'Remove markers', rownames(quakes), multiple = TRUE)
10 | ),
11 | server = function(input, output, session) {
12 | output$map1 = renderLeaflet({
13 | leaflet() %>% addTiles() %>% setView(180, -24, 4)
14 | })
15 | observeEvent(input$add, {
16 | leafletProxy('map1') %>% addMarkers(
17 | data = quakes,
18 | popup = ~sprintf('magnitude = %s', mag), layerId = rownames(quakes),
19 | clusterOptions = markerClusterOptions(), clusterId = 'cluster1'
20 | )
21 | })
22 | observeEvent(input$clear, {
23 | leafletProxy('map1') %>% clearMarkerClusters()
24 | })
25 | observe({
26 | leafletProxy('map1') %>% removeMarkerFromCluster(input$remove1, 'cluster1')
27 | })
28 | observe({
29 | print(input$map1_marker_click)
30 | })
31 | }
32 | )
33 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.EasyButton/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2014 Daniel Montague
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/man/addTerminator.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-terminator.R
3 | \name{addTerminator}
4 | \alias{addTerminator}
5 | \title{Add a daylight layer on top of the map}
6 | \usage{
7 | addTerminator(map, resolution = 2, time = NULL, layerId = NULL,
8 | group = NULL, options = pathOptions(pointerEvents = "none", clickable =
9 | FALSE))
10 | }
11 | \arguments{
12 | \item{map}{a map widget object}
13 |
14 | \item{resolution}{the step size at which the terminator points are computed.
15 | The step size is 1 degree/resolution, i.e. higher resolution values have
16 | smaller step sizes and more points in the polygon. The default value is 2.}
17 |
18 | \item{time}{Time}
19 |
20 | \item{layerId}{the layer id}
21 |
22 | \item{group}{the name of the group this layer belongs to.}
23 |
24 | \item{options}{the path options for the daynight layer}
25 | }
26 | \description{
27 | See \url{https://github.com/joergdietrich/Leaflet.Terminator}
28 | }
29 | \examples{
30 | library(leaflet)
31 |
32 | leaf <- leaflet() \%>\%
33 | addTiles() \%>\%
34 | addTerminator()
35 |
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/inst/examples/legend.R:
--------------------------------------------------------------------------------
1 | # !formatR
2 | library(leaflet)
3 | # a manual legend
4 | leaflet() %>% addTiles() %>% addLegend(
5 | position = 'bottomright',
6 | colors = rgb(t(col2rgb(palette())) / 255),
7 | labels = palette(), opacity = 1,
8 | title = 'An Obvious Legend'
9 | )
10 |
11 | # an automatic legend derived from the color palette
12 | df = local({
13 | n = 300; x = rnorm(n); y = rnorm(n)
14 | z = sqrt(x^2 + y^2); z[sample(n, 10)] = NA
15 | data.frame(x, y, z)
16 | })
17 | pal = colorNumeric('OrRd', df$z)
18 | leaflet(df) %>%
19 | addCircleMarkers(~x, ~y, color = ~pal(z)) %>%
20 | addLegend(pal = pal, values = ~z)
21 |
22 | # format legend labels
23 | df = data.frame(x = rnorm(100), y = rexp(100, 2), z = runif(100))
24 | pal = colorBin('PuOr', df$z, bins = c(0, .1, .4, .9, 1))
25 | leaflet(df) %>%
26 | addCircleMarkers(~x, ~y, color = ~pal(z)) %>%
27 | addLegend(pal = pal, values = ~z)
28 |
29 | leaflet(df) %>%
30 | addCircleMarkers(~x, ~y, color = ~pal(z)) %>%
31 | addLegend(pal = pal, values = ~z, labFormat = labelFormat(
32 | prefix = '(', suffix = ')%', between = ', ',
33 | transform = function(x) 100 * x
34 | ))
35 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.EasyButton/EasyButton-binding.js:
--------------------------------------------------------------------------------
1 | getEasyButton = function(button) {
2 |
3 | var options = {};
4 |
5 | options.position = button.position;
6 |
7 | // only add ID if provided
8 | if(button.id) {
9 | options.id = button.id;
10 | }
11 |
12 | // if custom states provided use that
13 | // else use provided icon and onClick
14 | if(button.states) {
15 | options.states = button.states;
16 | return L.easyButton(options);
17 | } else {
18 | return L.easyButton(button.icon, button.onClick,
19 | button.title, options );
20 | }
21 | };
22 |
23 | LeafletWidget.methods.addEasyButton = function(button) {
24 | getEasyButton(button).addTo(this);
25 | };
26 |
27 | LeafletWidget.methods.addEasyButtonBar = function(buttons, position, id) {
28 |
29 | var options = {};
30 |
31 | options.position = position;
32 |
33 | // only add ID if provided
34 | if(id) {
35 | options.id = id;
36 | }
37 |
38 | var easyButtons = [];
39 | for(var i=0; i < buttons.length; i++) {
40 | easyButtons[i] = getEasyButton(buttons[i]);
41 | }
42 | L.easyBar(easyButtons).addTo(this);
43 |
44 | };
45 |
--------------------------------------------------------------------------------
/man/mapOptions.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/leaflet.R
3 | \name{mapOptions}
4 | \alias{mapOptions}
5 | \title{Set options on a leaflet map object}
6 | \usage{
7 | mapOptions(map, zoomToLimits = c("always", "first", "never"))
8 | }
9 | \arguments{
10 | \item{map}{A map widget object created from \code{\link{leaflet}()}}
11 |
12 | \item{zoomToLimits}{Controls whether the map is zooms to the limits of the
13 | elements on the map. This is useful for interactive applications where the
14 | map data is updated. If \code{"always"} (the default), the map always
15 | re-zooms when new data is received; if \code{"first"}, it zooms to the
16 | elements on the first rendering, but does not re-zoom for subsequent data;
17 | if \code{"never"}, it never re-zooms, not even for the first rendering.}
18 | }
19 | \description{
20 | Set options on a leaflet map object
21 | }
22 | \examples{
23 | # Don't auto-zoom to the objects (can be useful in interactive applications)
24 | leaflet() \%>\%
25 | addTiles() \%>\%
26 | addPopups(174.7690922, -36.8523071, 'R was born here!') \%>\%
27 | mapOptions(zoomToLimits = "first")
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.markercluster/MIT-LICENCE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2012 David Leaver
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/javascript/src/control-store.js:
--------------------------------------------------------------------------------
1 | export default class ControlStore {
2 |
3 | constructor(map) {
4 | this._controlsNoId = [];
5 | this._controlsById = {};
6 | this._map = map;
7 | }
8 |
9 | add(control, id, html) {
10 | if (typeof(id) !== "undefined" && id !== null) {
11 | if (this._controlsById[id]) {
12 | this._map.removeControl(this._controlsById[id]);
13 | }
14 | this._controlsById[id] = control;
15 | } else {
16 | this._controlsNoId.push(control);
17 | }
18 | this._map.addControl(control);
19 | }
20 |
21 | remove(id) {
22 | if (this._controlsById[id]) {
23 | let control = this._controlsById[id];
24 | this._map.removeControl(control);
25 | delete this._controlsById[id];
26 | }
27 | }
28 |
29 | clear() {
30 | for (let i = 0; i < this._controlsNoId.length; i++) {
31 | let control = this._controlsNoId[i];
32 | this._map.removeControl(control);
33 | }
34 | this._controlsNoId = [];
35 |
36 | for (let key in this._controlsById) {
37 | let control = this._controlsById[key];
38 | this._map.removeControl(control);
39 | }
40 | this._controlsById = {};
41 | }
42 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet-r-package",
3 | "version": "0.0.0",
4 | "description": "",
5 | "main": "javascript/src/index.js",
6 | "directories": {
7 | "man": "man",
8 | "test": "tests"
9 | },
10 | "scripts": {
11 | "test": "echo \"Error: no test specified\" && exit 1"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/rstudio/leaflet.git"
16 | },
17 | "author": "",
18 | "license": "GPL-3.0",
19 | "bugs": {
20 | "url": "https://github.com/rstudio/leaflet/issues"
21 | },
22 | "homepage": "https://github.com/rstudio/leaflet#readme",
23 | "devDependencies": {
24 | "babel": "^6.5.2",
25 | "babel-preset-es2015": "^6.6.0",
26 | "babel-plugin-transform-es2015-modules-commonjs": "^6.14.0",
27 | "babel-register": "^6.14.0",
28 | "babelify": "^7.3.0",
29 | "browserify": "^13.0.0",
30 | "eslint": "^2.9.0",
31 | "grunt": "^1.0.1",
32 | "grunt-babel": "^6.0.0",
33 | "grunt-browserify": "^5.0.0",
34 | "grunt-contrib-watch": "^1.0.0",
35 | "grunt-eslint": "^18.1.0",
36 | "grunt-mocha-test": "^0.12.7",
37 | "mocha": "^2.4.5",
38 | "source-map-support": "^0.4.0"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/R/controls.R:
--------------------------------------------------------------------------------
1 | #' @param html the content of the control. May be provided as string or as HTML
2 | #' generated with Shiny/htmltools tags
3 | #' @param position position of control: 'topleft', 'topright', 'bottomleft', or
4 | #' 'bottomright'
5 | #' @param className extra CSS classes to append to the control, space separated
6 | #'
7 | #' @describeIn map-layers Add arbitrary HTML controls to the map
8 | #' @export
9 | addControl <- function(
10 | map, html, position = c('topleft', 'topright', 'bottomleft', 'bottomright'),
11 | layerId = NULL, className = "info legend", data = getMapData(map)
12 | ) {
13 |
14 | position = match.arg(position)
15 |
16 | deps = htmltools::resolveDependencies(htmltools::findDependencies(html))
17 | html = as.character(html)
18 |
19 | map$dependencies = c(map$dependencies, deps)
20 | invokeMethod(map, data, 'addControl', html, position, layerId, className)
21 | }
22 |
23 | #' @export
24 | #' @rdname remove
25 | removeControl <- function(map, layerId) {
26 | invokeMethod(map, NULL, 'removeControl', layerId)
27 | }
28 |
29 | #' @export
30 | #' @rdname remove
31 | clearControls <- function(map) {
32 | invokeMethod(map, NULL, 'clearControls')
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/R/shiny.R:
--------------------------------------------------------------------------------
1 | #' Wrapper functions for using \pkg{leaflet} in \pkg{shiny}
2 | #'
3 | #' Use \code{leafletOutput()} to create a UI element, and \code{renderLeaflet()}
4 | #' to render the map widget.
5 | #' @inheritParams htmlwidgets::shinyWidgetOutput
6 | #' @param width,height the width and height of the map (see
7 | #' \code{\link[htmlwidgets]{shinyWidgetOutput}})
8 | #' @rdname map-shiny
9 | #' @export
10 | #' @examples # !formatR
11 | #' \donttest{library(leaflet)
12 | #' library(shiny)
13 | #' app = shinyApp(
14 | #' ui = fluidPage(leafletOutput('myMap')),
15 | #' server = function(input, output) {
16 | #' map = leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17)
17 | #' output$myMap = renderLeaflet(map)
18 | #' }
19 | #' )
20 | #'
21 | #' if (interactive()) print(app)}
22 | leafletOutput <- function(outputId, width = "100%", height = 400) {
23 | htmlwidgets::shinyWidgetOutput(outputId, "leaflet", width, height, "leaflet")
24 | }
25 |
26 | #' @rdname map-shiny
27 | #' @export
28 | renderLeaflet <- function(expr, env = parent.frame(), quoted = FALSE) {
29 | if (!quoted) expr = substitute(expr) # force quoted
30 | htmlwidgets::shinyRenderWidget(expr, leafletOutput, env, quoted = TRUE)
31 | }
32 |
--------------------------------------------------------------------------------
/man/addGraticule.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-graticule.R
3 | \name{addGraticule}
4 | \alias{addGraticule}
5 | \title{Add a Graticule on the map
6 | see \url{https://github.com/turban/Leaflet.Graticule}}
7 | \usage{
8 | addGraticule(map, interval = 20, sphere = FALSE, style = list(color =
9 | "#333", weight = 1), layerId = NULL, group = NULL,
10 | options = pathOptions(pointerEvents = "none", clickable = FALSE))
11 | }
12 | \arguments{
13 | \item{map}{a map widget object}
14 |
15 | \item{interval}{The spacing in map units between horizontal and vertical lines.}
16 |
17 | \item{sphere}{boolean. Default FALSE}
18 |
19 | \item{style}{path options for the generated lines. See \url{http://leafletjs.com/reference.html#path-options}}
20 |
21 | \item{layerId}{the layer id}
22 |
23 | \item{group}{the name of the group this layer belongs to.}
24 |
25 | \item{options}{the path options for the graticule layer}
26 | }
27 | \description{
28 | Add a Graticule on the map
29 | see \url{https://github.com/turban/Leaflet.Graticule}
30 | }
31 | \examples{
32 | library(leaflet)
33 |
34 | leaf <- leaflet() \%>\%
35 | addTiles() \%>\%
36 | addGraticule()
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/javascript/tests/test-dataframe.js:
--------------------------------------------------------------------------------
1 | import DataFrame from "./dataframe";
2 | import assert from "assert";
3 |
4 | describe("DataFrame", () => {
5 | let speed = [4, 4, 7, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20, 20, 20, 20, 20, 22, 23, 24, 24, 24, 24, 25];
6 | let dist = [2, 10, 4, 22, 16, 10, 18, 26, 34, 17, 28, 14, 20, 24, 28, 26, 34, 34, 46, 26, 36, 60, 80, 20, 26, 54, 32, 40, 32, 40, 50, 42, 56, 76, 84, 36, 46, 68, 32, 48, 52, 56, 64, 66, 54, 70, 92, 93, 120, 85];
7 | let df = new DataFrame();
8 | df.col("speed", speed)
9 | .col("dist", dist)
10 | .col("color", ["yellow", "red"])
11 | .cbind({
12 | "Make" : ["Toyota", "Cadillac", "BMW"],
13 | "Model" : ["Corolla", "CTS", "435i"]
14 | });
15 |
16 | it("can index into rows", () => {
17 | assert.equal(df.get(9, "speed"), 11);
18 | assert.equal(df.get(9, "dist"), 17);
19 | });
20 |
21 | it("recycles column values", () => {
22 | assert.equal(df.get(9, "color"), "red");
23 | });
24 |
25 | it("recycles when cbinding", () => {
26 | assert.equal(df.get(9, "Make"), "Toyota");
27 | assert.equal(df.get(9, "Model"), "Corolla");
28 | });
29 | });
30 |
--------------------------------------------------------------------------------
/R/dependencies.R:
--------------------------------------------------------------------------------
1 | #' Various leaflet dependency functions for use in downstream packages
2 | #' @examples \dontrun{
3 | #' addBootStrap <- function(map) {
4 | #' map$dependencies <- c(map$dependencies, leafletDependencies$bootstrap())
5 | #' map
6 | #' }
7 | #' }
8 | #' @export
9 | leafletDependencies <- list(
10 | markerCluster = function() {markerClusterDependencies()},
11 | awesomeMarkers = function(){leafletAwesomeMarkersDependencies()},
12 | bootstrap = function(){leafletAmBootstrapDependencies()},
13 | fontawesome = function(){leafletAmFontAwesomeDependencies()},
14 | ionicon = function(){leafletAmIonIconDependencies()},
15 | omnivore = function(){leafletOmnivoreDependencies()},
16 | # the ones below are not really expected to be used directly
17 | # but are included for completeness sake.
18 | graticule = function(){leafletGraticuleDependencies()},
19 | simpleGraticule = function(){leafletSimpleGraticuleDependencies()},
20 | easyButton = function(){leafletEasyButtonDependencies()},
21 | measure = function(){leafletMeasureDependencies()},
22 | terminator = function(){leafletTerminatorDependencies()},
23 | minimap = function(){leafletMiniMapDependencies()},
24 | providers = function(){leafletProviderDependencies()}
25 | )
26 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.EasyButton/easy-button.css:
--------------------------------------------------------------------------------
1 | .leaflet-bar button,
2 | .leaflet-bar button:hover {
3 | background-color: #fff;
4 | border: none;
5 | border-bottom: 1px solid #ccc;
6 | width: 26px;
7 | height: 26px;
8 | line-height: 26px;
9 | display: block;
10 | text-align: center;
11 | text-decoration: none;
12 | color: black;
13 | }
14 |
15 | .leaflet-bar button {
16 | background-position: 50% 50%;
17 | background-repeat: no-repeat;
18 | overflow: hidden;
19 | display: block;
20 | }
21 |
22 | .leaflet-bar button:hover {
23 | background-color: #f4f4f4;
24 | }
25 |
26 | .leaflet-bar button:first-of-type {
27 | border-top-left-radius: 4px;
28 | border-top-right-radius: 4px;
29 | }
30 |
31 | .leaflet-bar button:last-of-type {
32 | border-bottom-left-radius: 4px;
33 | border-bottom-right-radius: 4px;
34 | border-bottom: none;
35 | }
36 |
37 | .leaflet-bar.disabled,
38 | .leaflet-bar button.disabled {
39 | cursor: default;
40 | pointer-events: none;
41 | opacity: .4;
42 | }
43 |
44 | .easy-button-button .button-state{
45 | display: block;
46 | width: 100%;
47 | height: 100%;
48 | position: relative;
49 | }
50 |
51 |
52 | .leaflet-touch .leaflet-bar button {
53 | width: 30px;
54 | height: 30px;
55 | line-height: 30px;
56 | }
57 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-providers/license.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Leaflet Providers contributors
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8 |
9 | _THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE._
--------------------------------------------------------------------------------
/man/addSimpleGraticule.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-simplegraticule.R
3 | \name{addSimpleGraticule}
4 | \alias{addSimpleGraticule}
5 | \title{Add a simple Graticule on the map
6 | see \url{https://github.com/ablakey/Leaflet.SimpleGraticule}}
7 | \usage{
8 | addSimpleGraticule(map, interval = 20, showOriginLabel = TRUE,
9 | redraw = "move", hidden = FALSE, zoomIntervals = list(),
10 | layerId = NULL, group = NULL)
11 | }
12 | \arguments{
13 | \item{map}{a map widget object}
14 |
15 | \item{interval}{The spacing in map units between horizontal and vertical lines.}
16 |
17 | \item{showOriginLabel}{true Whether or not to show '(0,0)' at the origin.}
18 |
19 | \item{redraw}{on which map event to redraw the graticule. On move is default but moveend can be smoother.}
20 |
21 | \item{hidden}{hide on start}
22 |
23 | \item{zoomIntervals}{use different intervals in different zoom levels. If not specified, all zoom levels use value in interval option.}
24 |
25 | \item{layerId}{the layer id}
26 |
27 | \item{group}{the name of the group this layer belongs to.}
28 | }
29 | \description{
30 | Add a simple Graticule on the map
31 | see \url{https://github.com/ablakey/Leaflet.SimpleGraticule}
32 | }
33 | \examples{
34 | library(leaflet)
35 |
36 | leaflet() \%>\%
37 | addTiles() \%>\%
38 | addSimpleGraticule()
39 |
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/man/map-shiny.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/shiny.R
3 | \name{leafletOutput}
4 | \alias{leafletOutput}
5 | \alias{renderLeaflet}
6 | \title{Wrapper functions for using \pkg{leaflet} in \pkg{shiny}}
7 | \usage{
8 | leafletOutput(outputId, width = "100\%", height = 400)
9 |
10 | renderLeaflet(expr, env = parent.frame(), quoted = FALSE)
11 | }
12 | \arguments{
13 | \item{outputId}{output variable to read from}
14 |
15 | \item{width, height}{the width and height of the map (see
16 | \code{\link[htmlwidgets]{shinyWidgetOutput}})}
17 |
18 | \item{expr}{An expression that generates an HTML widget}
19 |
20 | \item{env}{The environment in which to evaluate \code{expr}.}
21 |
22 | \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This
23 | is useful if you want to save an expression in a variable.}
24 | }
25 | \description{
26 | Use \code{leafletOutput()} to create a UI element, and \code{renderLeaflet()}
27 | to render the map widget.
28 | }
29 | \examples{
30 | # !formatR
31 | \donttest{library(leaflet)
32 | library(shiny)
33 | app = shinyApp(
34 | ui = fluidPage(leafletOutput('myMap')),
35 | server = function(input, output) {
36 | map = leaflet() \%>\% addTiles() \%>\% setView(-93.65, 42.0285, zoom = 17)
37 | output$myMap = renderLeaflet(map)
38 | }
39 | )
40 |
41 | if (interactive()) print(app)}
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/ui.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | shinyUI(fluidPage(
4 |
5 | # Add a little CSS to make the map background pure white
6 | tags$head(tags$style("
7 | #showcase-code-position-toggle, #showcase-sxs-code { display: none; }
8 | .floater { background-color: white; padding: 8px; opacity: 0.7; border-radius: 6px; box-shadow: 0 0 15px rgba(0,0,0,0.2); }
9 | ")),
10 |
11 | leafletMap(
12 | "map", "100%", 500,
13 | # By default OpenStreetMap tiles are used; we want nothing in this case
14 | #initialTileLayer = NULL,
15 | #initialTileLayerAttribution = NULL,
16 | options=list(
17 | center = c(40, -98.85),
18 | zoom = 4,
19 | maxBounds = list(list(17, -180), list(59, 180))
20 | )
21 | ),
22 |
23 | absolutePanel(
24 | right = 30, top = 10, width = 200, class = "floater",
25 |
26 | h4("US Population Density"),
27 | uiOutput("stateInfo")
28 | ),
29 |
30 | absolutePanel(
31 | right = 30, top = 280, style = "", class = "floater",
32 | tags$table(
33 | mapply(function(from, to, color) {
34 | tags$tr(
35 | tags$td(tags$div(
36 | style = sprintf("width: 16px; height: 16px; background-color: %s;", color)
37 | )),
38 | tags$td(from, "-", to)
39 | )
40 | }, densityRanges$from, densityRanges$to, palette, SIMPLIFY=FALSE)
41 | )
42 | )
43 | ))
44 |
--------------------------------------------------------------------------------
/man/dispatch.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utils.R
3 | \name{dispatch}
4 | \alias{dispatch}
5 | \alias{invokeMethod}
6 | \title{Extension points for plugins}
7 | \usage{
8 | dispatch(map, funcName, leaflet = stop(paste(funcName,
9 | "requires a map proxy object")), leaflet_proxy = stop(paste(funcName,
10 | "does not support map proxy objects")))
11 |
12 | invokeMethod(map, data, method, ...)
13 | }
14 | \arguments{
15 | \item{map}{a map object, as returned from \code{\link{leaflet}} or
16 | \code{\link{leafletProxy}}}
17 |
18 | \item{funcName}{the name of the function that the user called that caused
19 | this \code{dispatch} call; for error message purposes}
20 |
21 | \item{leaflet}{an action to be performed if the map is from
22 | \code{\link{leaflet}}}
23 |
24 | \item{leaflet_proxy}{an action to be performed if the map is from
25 | \code{\link{leafletProxy}}}
26 |
27 | \item{data}{a data object that will be used when evaluating formulas in
28 | \code{...}}
29 |
30 | \item{method}{the name of the JavaScript method to invoke}
31 |
32 | \item{...}{unnamed arguments to be passed to the JavaScript method}
33 | }
34 | \value{
35 | \code{dispatch} returns the value of \code{leaflet} or
36 | \code{leaflet_proxy}, or an error. \code{invokeMethod} returns the
37 | \code{map} object that was passed in, possibly modified.
38 | }
39 | \description{
40 | Extension points for plugins
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/inst/examples/emptyData.R:
--------------------------------------------------------------------------------
1 | library(dplyr)
2 | library(leaflet)
3 | library(sp)
4 |
5 | # Markers with empty data
6 |
7 | leaflet(quakes[FALSE,]) %>% addMarkers()
8 | leaflet(quakes[FALSE,]) %>% addAwesomeMarkers()
9 | leaflet(quakes[FALSE,]) %>% addCircleMarkers()
10 | leaflet(quakes[FALSE,]) %>% addCircles()
11 |
12 | # Markers with missing data
13 | # NewYork has missing Long
14 | cities <- read.csv(textConnection("
15 | City,Lat,Long,Pop
16 | Boston,42.3601,-71.0589,645966
17 | Hartford,41.7627,-72.6743,125017
18 | New York City,40.7127,NA,8406000
19 | Philadelphia,39.9500,-75.1667,1553000
20 | Pittsburgh,40.4397,-79.9764,305841
21 | Providence,41.8236,-71.4222,177994"))
22 |
23 | leaflet(cities) %>% addTiles() %>% addMarkers()
24 | leaflet(cities) %>% addTiles() %>% addAwesomeMarkers()
25 | leaflet(cities) %>% addTiles() %>% addCircleMarkers()
26 | leaflet(cities) %>% addTiles() %>% addCircles(radius = ~sqrt(Pop) * 30)
27 | leaflet(cities) %>% addTiles() %>% addPopups(popup=~as.character(City))
28 |
29 | # Polylines with empty data
30 |
31 | coords <- matrix(c(1,2,3,4), nrow=2)
32 | line <- Line(coords)
33 | sp_lines <- SpatialLines(list(Lines(list(line), ID=1)))
34 | sp_lines_df <- sp::SpatialLinesDataFrame(sp_lines, data=data.frame(x=1))
35 |
36 | # This works ok
37 | sp_lines_df %>% leaflet() %>% addPolylines()
38 |
39 | # Subset the data to get SpatialLinesDataFrame without data
40 | sub_df <- sp_lines_df[sp_lines_df$x > 1,]
41 |
42 | sub_df %>% leaflet() %>% addPolylines()
43 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-providers/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet-providers",
3 | "version": "1.1.15",
4 | "description": "An extension to Leaflet that contains configurations for various free tile providers.",
5 | "main": "leaflet-providers.js",
6 | "repository": {
7 | "type": "git",
8 | "url": "git://github.com/leaflet-extras/leaflet-providers.git"
9 | },
10 | "scripts": {
11 | "test": "npm run lint && npm run testsuite",
12 | "testsuite": "mocha-phantomjs tests/index.html",
13 | "lint": "eslint --config .eslintrc leaflet-providers.js index.html preview/*.js preview/*.html tests/*",
14 | "min": "uglifyjs leaflet-providers.js -mc -o leaflet-providers.min.js",
15 | "release": "mversion patch -m"
16 | },
17 | "license": "BSD-2-Clause",
18 | "bugs": {
19 | "url": "https://github.com/leaflet-extras/leaflet-providers/issues"
20 | },
21 | "files": [
22 | "leaflet-providers.js",
23 | "README.md",
24 | "CHANGELOG.md",
25 | "licence.md"
26 | ],
27 | "devDependencies": {
28 | "chai": "^2.3.0",
29 | "eslint": "^2.7.0",
30 | "eslint-plugin-html": "^1.4.0",
31 | "mocha": "^2.2.4",
32 | "mocha-phantomjs": "^3.5.3",
33 | "mversion": "^1.3.0",
34 | "phantomjs": "1.9.7-15",
35 | "uglify-js": "^2.4.15"
36 | },
37 | "autoupdate": {
38 | "source": "git",
39 | "target": "git://github.com/leaflet-extras/leaflet-providers.git",
40 | "basePath": "/",
41 | "files": [
42 | "leaflet-providers.js"
43 | ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/R/plugin-omnivore.R:
--------------------------------------------------------------------------------
1 | leafletOmnivoreDependencies <- function() {
2 | list(
3 | htmltools::htmlDependency(
4 | "leaflet-omnivore",
5 | "0.3.3",
6 | system.file("htmlwidgets/lib/leaflet-omnivore", package = "leaflet"),
7 | script = "leaflet-omnivore.min.js"
8 | )
9 | )
10 | }
11 |
12 |
13 | #' @param topojson a TopoJSON list, or character vector of length 1
14 | #' @describeIn map-layers Add TopoJSON layers to the map
15 | #' @export
16 | addTopoJSON <- function(map, topojson, layerId = NULL, group = NULL,
17 | stroke = TRUE,
18 | color = "#03F",
19 | weight = 5,
20 | opacity = 0.5,
21 | fill = TRUE,
22 | fillColor = color,
23 | fillOpacity = 0.2,
24 | dashArray = NULL,
25 | smoothFactor = 1.0,
26 | noClip = FALSE,
27 | options = pathOptions()
28 | ) {
29 | map$dependencies <- c(map$dependencies, leafletOmnivoreDependencies())
30 | options = c(options, list(
31 | stroke = stroke, color = color, weight = weight, opacity = opacity,
32 | fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
33 | dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
34 | ))
35 | invokeMethod(map, getMapData(map), 'addTopoJSON', topojson, layerId, group, options)
36 | }
37 |
38 | #' @rdname remove
39 | #' @export
40 | removeTopoJSON <- function(map, layerId) {
41 | invokeMethod(map, getMapData(map), 'removeTopoJSON', layerId)
42 | }
43 |
44 | #' @rdname remove
45 | #' @export
46 | clearTopoJSON <- function(map) {
47 | invokeMethod(map, NULL, 'clearTopoJSON')
48 | }
49 |
--------------------------------------------------------------------------------
/man/addScaleBar.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/scalebar.R
3 | \name{addScaleBar}
4 | \alias{addScaleBar}
5 | \alias{removeScaleBar}
6 | \alias{scaleBarOptions}
7 | \title{Add or remove a scale bar}
8 | \usage{
9 | addScaleBar(map, position = c("topright", "bottomright", "bottomleft",
10 | "topleft"), options = scaleBarOptions())
11 |
12 | scaleBarOptions(maxWidth = 100, metric = TRUE, imperial = TRUE,
13 | updateWhenIdle = TRUE)
14 |
15 | removeScaleBar(map)
16 | }
17 | \arguments{
18 | \item{map}{the map to add the scale bar to}
19 |
20 | \item{position}{position of control: 'topleft', 'topright', 'bottomleft', or
21 | 'bottomright'}
22 |
23 | \item{options}{a list of additional options, intended to be provided by
24 | a call to \code{scaleBarOptions}}
25 |
26 | \item{maxWidth}{maximum width of the control in pixels (default 100)}
27 |
28 | \item{metric}{if \code{TRUE} (the default), show a scale bar in metric units
29 | (m/km)}
30 |
31 | \item{imperial}{if \code{TRUE} (the default), show a scale bar in imperial
32 | units (ft/mi)}
33 |
34 | \item{updateWhenIdle}{if \code{FALSE} (the default), the scale bar is always
35 | up-to-date (updated on \code{move}). If \code{TRUE}, the control is updated
36 | on \code{moveend}.}
37 | }
38 | \description{
39 | Uses Leaflet's built-in
40 | \href{http://leafletjs.com/reference.html#control-scale}{scale bar}
41 | feature to add a scale bar.
42 | }
43 | \examples{
44 | \donttest{
45 | leaflet() \%>\%
46 | addTiles() \%>\%
47 | addScaleBar()
48 | }
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/R/plugin-graticule.R:
--------------------------------------------------------------------------------
1 | leafletGraticuleDependencies <- function() {
2 | list(
3 | htmltools::htmlDependency(
4 | "leaflet-graticule",
5 | "0.1.0",
6 | system.file("htmlwidgets/plugins/Leaflet.Graticule", package = "leaflet"),
7 | script = c("L.Graticule.js", "Graticule-binding.js")
8 | )
9 | )
10 | }
11 |
12 | #' Add a Graticule on the map
13 | #' see \url{https://github.com/turban/Leaflet.Graticule}
14 | #'
15 | #' @param map a map widget object
16 | #' @param interval The spacing in map units between horizontal and vertical lines.
17 | #' @param sphere boolean. Default FALSE
18 | #' @param style path options for the generated lines. See \url{http://leafletjs.com/reference.html#path-options}
19 | #' @param layerId the layer id
20 | #' @param group the name of the group this layer belongs to.
21 | #' @param options the path options for the graticule layer
22 | #' @examples
23 | #' library(leaflet)
24 | #'
25 | #' leaf <- leaflet() %>%
26 | #' addTiles() %>%
27 | #' addGraticule()
28 | #'
29 | #' @export
30 | addGraticule <- function(
31 | map,
32 | interval = 20,
33 | sphere = FALSE,
34 | style = list(color= '#333', weight= 1),
35 | layerId = NULL,
36 | group=NULL,
37 | options = pathOptions(pointerEvents="none", clickable=FALSE) # Default unclickable
38 | ) {
39 | map$dependencies <- c(map$dependencies, leafletGraticuleDependencies())
40 | invokeMethod(
41 | map,
42 | getMapData(map),
43 | 'addGraticule',
44 | interval,
45 | sphere,
46 | style,
47 | layerId,
48 | group,
49 | options
50 | )
51 | }
52 |
--------------------------------------------------------------------------------
/R/plugin-terminator.R:
--------------------------------------------------------------------------------
1 | leafletTerminatorDependencies <- function() {
2 | list(
3 | htmltools::htmlDependency(
4 | "leaflet-terminator",
5 | "0.1.0",
6 | system.file("htmlwidgets/plugins/Leaflet.Terminator", package = "leaflet"),
7 | script = c("L.Terminator.js", "Terminator-binding.js")
8 | )
9 | )
10 | }
11 |
12 | #' Add a daylight layer on top of the map
13 | #'
14 | #' See \url{https://github.com/joergdietrich/Leaflet.Terminator}
15 | #'
16 | #' @param map a map widget object
17 | #' @param resolution the step size at which the terminator points are computed.
18 | #' The step size is 1 degree/resolution, i.e. higher resolution values have
19 | #' smaller step sizes and more points in the polygon. The default value is 2.
20 | #' @param time Time
21 | #' @param layerId the layer id
22 | #' @param group the name of the group this layer belongs to.
23 | #' @param options the path options for the daynight layer
24 | #' @examples
25 | #' library(leaflet)
26 | #'
27 | #' leaf <- leaflet() %>%
28 | #' addTiles() %>%
29 | #' addTerminator()
30 | #'
31 | #' @export
32 | addTerminator <- function(
33 | map,
34 | resolution = 2,
35 | time = NULL,
36 | layerId = NULL,
37 | group=NULL,
38 | options = pathOptions(pointerEvents="none", clickable=FALSE) # Default unclickable
39 | ) {
40 | map$dependencies <- c(map$dependencies, leafletTerminatorDependencies())
41 | invokeMethod(
42 | map,
43 | getMapData(map),
44 | 'addTerminator',
45 | resolution,
46 | time,
47 | layerId,
48 | group,
49 | options
50 | )
51 | }
52 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet.markercluster/MarkerCluster.Default.css:
--------------------------------------------------------------------------------
1 | .marker-cluster-small {
2 | background-color: rgba(181, 226, 140, 0.6);
3 | }
4 | .marker-cluster-small div {
5 | background-color: rgba(110, 204, 57, 0.6);
6 | }
7 |
8 | .marker-cluster-medium {
9 | background-color: rgba(241, 211, 87, 0.6);
10 | }
11 | .marker-cluster-medium div {
12 | background-color: rgba(240, 194, 12, 0.6);
13 | }
14 |
15 | .marker-cluster-large {
16 | background-color: rgba(253, 156, 115, 0.6);
17 | }
18 | .marker-cluster-large div {
19 | background-color: rgba(241, 128, 23, 0.6);
20 | }
21 |
22 | /* IE 6-8 fallback colors */
23 | .leaflet-oldie .marker-cluster-small {
24 | background-color: rgb(181, 226, 140);
25 | }
26 | .leaflet-oldie .marker-cluster-small div {
27 | background-color: rgb(110, 204, 57);
28 | }
29 |
30 | .leaflet-oldie .marker-cluster-medium {
31 | background-color: rgb(241, 211, 87);
32 | }
33 | .leaflet-oldie .marker-cluster-medium div {
34 | background-color: rgb(240, 194, 12);
35 | }
36 |
37 | .leaflet-oldie .marker-cluster-large {
38 | background-color: rgb(253, 156, 115);
39 | }
40 | .leaflet-oldie .marker-cluster-large div {
41 | background-color: rgb(241, 128, 23);
42 | }
43 |
44 | .marker-cluster {
45 | background-clip: padding-box;
46 | border-radius: 20px;
47 | }
48 | .marker-cluster div {
49 | width: 30px;
50 | height: 30px;
51 | margin-left: 5px;
52 | margin-top: 5px;
53 |
54 | text-align: center;
55 | border-radius: 15px;
56 | font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
57 | }
58 | .marker-cluster span {
59 | line-height: 30px;
60 | }
--------------------------------------------------------------------------------
/inst/legacy/examples/population/ui.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | library(ShinyDash)
3 |
4 | shinyUI(fluidPage(
5 | tags$head(tags$link(rel='stylesheet', type='text/css', href='styles.css')),
6 | leafletMap(
7 | "map", "100%", 400,
8 | initialTileLayer = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
9 | initialTileLayerAttribution = HTML('Maps by Mapbox'),
10 | options=list(
11 | center = c(37.45, -93.85),
12 | zoom = 4,
13 | maxBounds = list(list(17, -180), list(59, 180))
14 | )
15 | ),
16 | fluidRow(
17 | column(8, offset=3,
18 | h2('Population of US cities'),
19 | htmlWidgetOutput(
20 | outputId = 'desc',
21 | HTML(paste(
22 | 'The map is centered at , ',
23 | 'with a zoom level of .
',
24 | 'Top out of visible cities are displayed.'
25 | ))
26 | )
27 | )
28 | ),
29 | hr(),
30 | fluidRow(
31 | column(3,
32 | selectInput('year', 'Year', c(2000:2010), 2010),
33 | selectInput('maxCities', 'Maximum cities to display', choices=c(
34 | 5, 25, 50, 100, 200, 500, 2000, 5000, 10000, All = 100000
35 | ), selected = 100)
36 | ),
37 | column(4,
38 | h4('Visible cities'),
39 | tableOutput('data')
40 | ),
41 | column(5,
42 | h4(id='cityTimeSeriesLabel', class='shiny-text-output'),
43 | plotOutput('cityTimeSeries', width='100%', height='250px')
44 | )
45 | )
46 | ))
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.min.css:
--------------------------------------------------------------------------------
1 | .leaflet-control-minimap{border:rgba(255,255,255,1) solid;box-shadow:0 1px 5px rgba(0,0,0,.65);border-radius:3px;background:#f8f8f9;transition:all .6s}.leaflet-control-minimap a{background-color:rgba(255,255,255,1);background-repeat:no-repeat;z-index:99999;transition:all .6s}.leaflet-control-minimap a.minimized-bottomright{-webkit-transform:rotate(180deg);transform:rotate(180deg);border-radius:0}.leaflet-control-minimap a.minimized-topleft{-webkit-transform:rotate(0deg);transform:rotate(0deg);border-radius:0}.leaflet-control-minimap a.minimized-bottomleft{-webkit-transform:rotate(270deg);transform:rotate(270deg);border-radius:0}.leaflet-control-minimap a.minimized-topright{-webkit-transform:rotate(90deg);transform:rotate(90deg);border-radius:0}.leaflet-control-minimap-toggle-display{background-image:url(images/toggle.svg);background-size:cover;position:absolute;border-radius:3px 0 0}.leaflet-oldie .leaflet-control-minimap-toggle-display{background-image:url(images/toggle.png)}.leaflet-control-minimap-toggle-display-bottomright{bottom:0;right:0}.leaflet-control-minimap-toggle-display-topleft{top:0;left:0;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.leaflet-control-minimap-toggle-display-bottomleft{bottom:0;left:0;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.leaflet-control-minimap-toggle-display-topright{top:0;right:0;-webkit-transform:rotate(270deg);transform:rotate(270deg)}.leaflet-oldie .leaflet-control-minimap{border:1px solid #999}.leaflet-oldie .leaflet-control-minimap a{background-color:#fff}.leaflet-oldie .leaflet-control-minimap a.minimized{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2)}
--------------------------------------------------------------------------------
/man/addProviderTiles.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-providers.R
3 | \name{addProviderTiles}
4 | \alias{addProviderTiles}
5 | \alias{providerTileOptions}
6 | \title{Add a tile layer from a known map provider}
7 | \usage{
8 | addProviderTiles(map, provider, layerId = NULL, group = NULL,
9 | options = providerTileOptions())
10 |
11 | providerTileOptions(errorTileUrl = "", noWrap = FALSE, opacity = NULL,
12 | zIndex = NULL, unloadInvisibleTiles = NULL, updateWhenIdle = NULL,
13 | detectRetina = FALSE, reuseTiles = FALSE, ...)
14 | }
15 | \arguments{
16 | \item{map}{the map to add the tile layer to}
17 |
18 | \item{provider}{the name of the provider (see
19 | \url{http://leaflet-extras.github.io/leaflet-providers/preview/} and
20 | \url{https://github.com/leaflet-extras/leaflet-providers})}
21 |
22 | \item{layerId}{the layer id to assign}
23 |
24 | \item{group}{the name of the group the newly created layers should belong to
25 | (for \code{\link{clearGroup}} and \code{\link{addLayersControl}} purposes).
26 | Human-friendly group names are permitted--they need not be short,
27 | identifier-style names.}
28 |
29 | \item{options}{tile options}
30 |
31 | \item{errorTileUrl, noWrap, opacity, zIndex, unloadInvisibleTiles, updateWhenIdle, detectRetina, reuseTiles}{the tile layer options; see
32 | \url{http://leafletjs.com/reference.html#tilelayer}}
33 |
34 | \item{...}{named parameters to add to the options}
35 | }
36 | \value{
37 | modified map object
38 | }
39 | \description{
40 | Add a tile layer from a known map provider
41 | }
42 | \examples{
43 | leaflet() \%>\%
44 | addProviderTiles("Stamen.Watercolor") \%>\%
45 | addProviderTiles("Stamen.TonerHybrid")
46 |
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/man/makeAwesomeIcon.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-awesomeMarkers.R
3 | \name{makeAwesomeIcon}
4 | \alias{makeAwesomeIcon}
5 | \title{Make Awesome Icon}
6 | \usage{
7 | makeAwesomeIcon(icon = "home", library = "glyphicon",
8 | markerColor = "blue", iconColor = "white", spin = FALSE,
9 | extraClasses = NULL, squareMarker = FALSE, iconRotate = 0,
10 | fontFamily = "monospace", text = NULL)
11 | }
12 | \arguments{
13 | \item{icon}{Name of the icon}
14 |
15 | \item{library}{Which icon library. Default \code{'glyphicon'}, other possible
16 | values are \code{'fa'} (fontawesome) or \code{'ion'} (ionicons).}
17 |
18 | \item{markerColor}{Possible values are \code{'red'}, \code{'darkred'}, \code{'lightred'}, \code{'orange'},
19 | \code{'beige'}, \code{'green'}, \code{'darkgreen'}, \code{'lightgreen'}, \code{'blue'},
20 | \code{'darkblue'}, \code{'lightblue'}, \code{'purple'}, \code{'darkpurple'}, \code{'pink'},
21 | \code{'cadetblue'}, \code{'white'}, \code{'gray'}, \code{'lightgray'}, \code{'black'}}
22 |
23 | \item{iconColor}{The color to use for the icon itself. Use any CSS-valid
24 | color (hex, rgba, etc.) or a named web color.}
25 |
26 | \item{spin}{If \code{TRUE}, make the icon spin (only works when \code{library
27 | = 'fa'})}
28 |
29 | \item{extraClasses}{Additional css classes to include on the icon.}
30 |
31 | \item{squareMarker}{Whether to use a sqare marker.}
32 |
33 | \item{iconRotate}{Rotate the icon by a given angle.}
34 |
35 | \item{fontFamily}{Used when \code{text} option is specified.}
36 |
37 | \item{text}{Use this text string instead of an icon.
38 | argument of \code{\link{addAwesomeMarkers}()}.}
39 | }
40 | \description{
41 | Make Awesome Icon
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet-MiniMap/Minimap-binding.js:
--------------------------------------------------------------------------------
1 | LeafletWidget.methods.addMiniMap =
2 | function(tilesURL, tilesProvider, position,
3 | width, height, collapsedWidth, collapsedHeight , zoomLevelOffset,
4 | zoomLevelFixed, centerFixed, zoomAnimation , toggleDisplay, autoToggleDisplay,
5 | minimized, aimingRectOptions, shadowRectOptions, strings, mapOptions) {
6 |
7 | (function() {
8 | if(this.minimap) {
9 | this.minimap.removeFrom( this );
10 | }
11 |
12 | // determin the tiles for the minimap
13 | // default to OSM tiles
14 | layer = new L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
15 | if(tilesProvider) {
16 | // use a custom tiles provider if specified.
17 | layer = new L.tileLayer.provider(tilesProvider);
18 | } else if(tilesURL) {
19 | // else use a custom tiles URL if specified.
20 | layer = new L.tileLayer(tilesURL);
21 | }
22 |
23 | this.minimap = new L.Control.MiniMap(layer, {
24 | position: position,
25 | width: width,
26 | height: height,
27 | collapsedWidth: collapsedWidth,
28 | collapsedHeight: collapsedWidth,
29 | zoomLevelOffset: zoomLevelOffset,
30 | zoomLevelFixed: zoomLevelFixed,
31 | centerFixed: centerFixed,
32 | zoomAnimation: zoomAnimation,
33 | toggleDisplay: toggleDisplay,
34 | autoToggleDisplay: autoToggleDisplay,
35 | minimized: minimized,
36 | aimingRectOptions: aimingRectOptions,
37 | shadowRectOptions: shadowRectOptions,
38 | strings: strings,
39 | mapOptions: mapOptions
40 | });
41 | this.minimap.addTo(this);
42 | }).call(this);
43 | };
44 |
--------------------------------------------------------------------------------
/inst/examples/geojson.R:
--------------------------------------------------------------------------------
1 |
2 | library(leaflet)
3 | library(sp)
4 | #'
5 | #' The V8 part is simply to read the JSON embeded in the Javascript.
6 | #' For a geojson file `jsonlite::fromfromJSON()` or `geojsonio::regeojson_read()` will do
7 | #'
8 | jsURL <- 'https://rawgit.com/Norkart/Leaflet-MiniMap/master/example/local_pubs_restaurant_norway.js'
9 | v8 <- V8::v8()
10 | v8$source(jsURL)
11 | geoJson <- geojsonio::as.json(v8$get('pubsGeoJSON'))
12 |
13 | # This is the kicker, convert geojson to a Spatial object.
14 | # This then allows us to use formulas in our markers, polygons etc.
15 | spdf <- geojsonio::geojson_sp(geoJson)
16 |
17 | icons <- awesomeIconList(
18 | pub = makeAwesomeIcon(icon='glass', library='fa', markerColor = 'red'),
19 | restaurant = makeAwesomeIcon(icon='cutlery', library='fa', markerColor = 'blue')
20 | )
21 |
22 | leaflet() %>% addTiles() %>%
23 | setView(10.758276373601069, 59.92448055859924, 13) %>%
24 | addAwesomeMarkers(data=spdf,
25 | label=~stringr::str_c(amenity,': ', name),
26 | icon = ~icons[amenity],
27 | options = markerOptions(riseOnHover = TRUE, opacity = 0.75),
28 | group = 'pubs')
29 |
30 |
31 | #'
32 | #' Another examples this time with polygons
33 | url <- 'http://www.partners-popdev.org/wp-content/themes/original-child/vendor/Geojson/States/Maharashtra.geojson'
34 |
35 | mhSPDF <- geojsonio::geojson_read(url, what="sp")
36 |
37 | cols <- colorFactor(topo.colors(nrow(mhSPDF)),mhSPDF$NAME_2)
38 |
39 | leaflet() %>% addProviderTiles(providers$Stamen.TonerLite) %>%
40 | setView(75.7139, 19.7515, 6) %>%
41 | addPolygons(data=mhSPDF, opacity = 5,
42 | label=~NAME_2, weight = 1,
43 | fillColor = ~cols(NAME_2))
44 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/R/scalebar.R:
--------------------------------------------------------------------------------
1 | #' Add or remove a scale bar
2 | #'
3 | #' Uses Leaflet's built-in
4 | #' \href{http://leafletjs.com/reference.html#control-scale}{scale bar}
5 | #' feature to add a scale bar.
6 | #'
7 | #' @param map the map to add the scale bar to
8 | #' @param position position of control: 'topleft', 'topright', 'bottomleft', or
9 | #' 'bottomright'
10 | #' @param options a list of additional options, intended to be provided by
11 | #' a call to \code{scaleBarOptions}
12 | #'
13 | #' @examples
14 | #' \donttest{
15 | #' leaflet() %>%
16 | #' addTiles() %>%
17 | #' addScaleBar()
18 | #' }
19 | #'
20 | #' @export
21 | addScaleBar <- function(map,
22 | position = c('topright', 'bottomright', 'bottomleft', 'topleft'),
23 | options = scaleBarOptions()) {
24 |
25 | options = c(options, list(position = match.arg(position)))
26 | invokeMethod(map, getMapData(map), 'addScaleBar', options)
27 | }
28 |
29 | #' @rdname addScaleBar
30 | #' @param maxWidth maximum width of the control in pixels (default 100)
31 | #' @param metric if \code{TRUE} (the default), show a scale bar in metric units
32 | #' (m/km)
33 | #' @param imperial if \code{TRUE} (the default), show a scale bar in imperial
34 | #' units (ft/mi)
35 | #' @param updateWhenIdle if \code{FALSE} (the default), the scale bar is always
36 | #' up-to-date (updated on \code{move}). If \code{TRUE}, the control is updated
37 | #' on \code{moveend}.
38 | #' @export
39 | scaleBarOptions <- function(maxWidth = 100, metric = TRUE, imperial = TRUE,
40 | updateWhenIdle = TRUE) {
41 | list(maxWidth=maxWidth, metric=metric, imperial=imperial,
42 | updateWhenIdle=updateWhenIdle)
43 | }
44 |
45 | #' @rdname addScaleBar
46 | #' @export
47 | removeScaleBar <- function(map) {
48 | invokeMethod(map, NULL, 'removeScaleBar')
49 | }
50 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/lib/leaflet-omnivore/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "leaflet-omnivore",
3 | "version": "0.3.2",
4 | "description": "a geospatial format parser for Leaflet",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "zuul --local -- test/test.js",
8 | "test-remote": "zuul -- test/test.js",
9 | "test-headless": "zuul --phantom -- test/test.js",
10 | "build": "browserify -s omnivore index.js > leaflet-omnivore.js && uglifyjs leaflet-omnivore.js -c -m > leaflet-omnivore.min.js"
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "git@github.com:mapbox/leaflet-omnivore.git"
15 | },
16 | "browserify": {
17 | "transform": [
18 | "brfs"
19 | ]
20 | },
21 | "keywords": [
22 | "leaflet",
23 | "formats",
24 | "kml",
25 | "csv",
26 | "gpx",
27 | "geojson",
28 | "kml",
29 | "leaflet",
30 | "maps",
31 | "gpx",
32 | "wkt",
33 | "osm",
34 | "polyline",
35 | "topojson",
36 | "format",
37 | "converter"
38 | ],
39 | "author": "Tom MacWright",
40 | "license": "BSD-3-Clause",
41 | "bugs": {
42 | "url": "https://github.com/mapbox/leaflet-omnivore/issues"
43 | },
44 | "homepage": "https://github.com/mapbox/leaflet-omnivore",
45 | "dependencies": {
46 | "csv2geojson": "~5.0.0",
47 | "togeojson": "0.13.0",
48 | "corslite": "0.0.7",
49 | "wellknown": "0.4.2",
50 | "brfs": "1.4.3",
51 | "topojson": "1.6.26",
52 | "polyline": "0.2.0"
53 | },
54 | "devDependencies": {
55 | "browserify": "13.0.1",
56 | "tape": "4.5.1",
57 | "uglify-js": "^2.6.2",
58 | "jshint": "2.9.2",
59 | "mocha": "~2.5.3",
60 | "zuul": "~3.10.1",
61 | "st": "1.1.0",
62 | "mapbox.js": "2.4.0",
63 | "phantomjs-prebuilt": "2.1.7"
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/inst/examples/providers.R:
--------------------------------------------------------------------------------
1 | #' Now that there is a providers list
2 | #' You can programmatically add providers.
3 | #' Here I show how to add all 'ESRI' provided basemaps.
4 | #' Checkout the `providers` list for all available providers.
5 | #'
6 | library(leaflet)
7 |
8 | m <- leaflet() %>% setView(0,0,1)
9 |
10 | # Take out ESRI provided tiles
11 | esri <- providers %>%
12 | purrr::keep(~ grepl('^Esri',.))
13 |
14 | esri %>%
15 | purrr::walk(function(x) m <<- m %>% addProviderTiles(x,group=x))
16 |
17 | m %>%
18 | addLayersControl(
19 | baseGroups = names(esri),
20 | options = layersControlOptions(collapsed = TRUE)
21 | )
22 |
23 | #'
24 | #' providers with options
25 | #' Change the accessToken with your mapbox token in options below
26 | #' The one here may not work always
27 | mapbox.tileIds <- list(Satellite='mapbox.satellite',
28 | Terrian='mapbox.mapbox-terrain-v2',
29 | Comic='bhaskarvk.1cm89o4e',
30 | 'High Contrast'='bhaskarvk.1biainl5')
31 |
32 | m <- leaflet() %>% setView(0,0,1)
33 |
34 | names(mapbox.tileIds) %>%
35 | purrr::walk(function(x) {
36 | m <<- m %>%
37 | addProviderTiles(providers$MapBox, group = x,
38 | options = providerTileOptions(
39 | detectRetina = TRUE,
40 | # id and accessToken are Mapbox specific options
41 | id = mapbox.tileIds[[x]] ,
42 | accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN')
43 | ))
44 | })
45 |
46 | m %>%
47 | addLayersControl(
48 | baseGroups = names(mapbox.tileIds),
49 | options = layersControlOptions(collapsed = FALSE)
50 | )
51 |
--------------------------------------------------------------------------------
/R/plugin-simplegraticule.R:
--------------------------------------------------------------------------------
1 | leafletSimpleGraticuleDependencies <- function() {
2 | list(
3 | htmltools::htmlDependency(
4 | "leaflet-simplegraticule",
5 | "0.1.0",
6 | system.file("htmlwidgets/plugins/Leaflet.SimpleGraticule", package = "leaflet"),
7 | script = c("L.SimpleGraticule.js", "SimpleGraticule-binding.js"),
8 | stylesheet = "L.SimpleGraticule.css"
9 | )
10 | )
11 | }
12 |
13 | #' Add a simple Graticule on the map
14 | #' see \url{https://github.com/ablakey/Leaflet.SimpleGraticule}
15 | #'
16 | #' @param map a map widget object
17 | #' @param interval The spacing in map units between horizontal and vertical lines.
18 | #' @param showOriginLabel true Whether or not to show '(0,0)' at the origin.
19 | #' @param redraw on which map event to redraw the graticule. On move is default but moveend can be smoother.
20 | #' @param hidden hide on start
21 | #' @param zoomIntervals use different intervals in different zoom levels. If not specified, all zoom levels use value in interval option.
22 |
23 | #' @param layerId the layer id
24 | #' @param group the name of the group this layer belongs to.
25 | #' @examples
26 | #' library(leaflet)
27 | #'
28 | #' leaflet() %>%
29 | #' addTiles() %>%
30 | #' addSimpleGraticule()
31 | #'
32 | #' @export
33 | addSimpleGraticule <- function(
34 | map,
35 | interval = 20,
36 | showOriginLabel = TRUE,
37 | redraw = 'move',
38 | hidden = FALSE,
39 | zoomIntervals = list(),
40 | layerId = NULL,
41 | group=NULL
42 | ) {
43 | map$dependencies <- c(map$dependencies, leafletSimpleGraticuleDependencies())
44 | invokeMethod(
45 | map
46 | , getMapData(map)
47 | , 'addSimpleGraticule'
48 | , interval
49 | , showOriginLabel
50 | , redraw
51 | , hidden
52 | , zoomIntervals
53 | , layerId
54 | , group
55 | )
56 | }
57 |
--------------------------------------------------------------------------------
/man/map-methods.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/methods.R
3 | \name{setView}
4 | \alias{clearBounds}
5 | \alias{fitBounds}
6 | \alias{setMaxBounds}
7 | \alias{setView}
8 | \title{Methods to manipulate the map widget}
9 | \usage{
10 | setView(map, lng, lat, zoom, options = list())
11 |
12 | fitBounds(map, lng1, lat1, lng2, lat2)
13 |
14 | setMaxBounds(map, lng1, lat1, lng2, lat2)
15 |
16 | clearBounds(map)
17 | }
18 | \arguments{
19 | \item{map}{a map widget object created from \code{\link{leaflet}()}}
20 |
21 | \item{lng}{The longitude of the map center}
22 |
23 | \item{lat}{The latitude of the map center}
24 |
25 | \item{zoom}{the zoom level}
26 |
27 | \item{options}{a list of zoom/pan options (see
28 | \url{http://leafletjs.com/reference.html#map-zoompanoptions})}
29 |
30 | \item{lng1, lat1, lng2, lat2}{the coordinates of the map bounds}
31 | }
32 | \value{
33 | The modified map widget.
34 | }
35 | \description{
36 | A series of methods to manipulate the map.
37 | }
38 | \section{Functions}{
39 | \itemize{
40 | \item \code{setView}: Set the view of the map (center and zoom level)
41 |
42 | \item \code{fitBounds}: Set the bounds of a map
43 |
44 | \item \code{setMaxBounds}: Restricts the map view to the given bounds
45 |
46 | \item \code{clearBounds}: Clear the bounds of a map, and the bounds will be
47 | automatically determined from latitudes and longitudes of the map elements
48 | if available (otherwise the full world view is used)
49 | }}
50 | \examples{
51 | library(leaflet)
52 | m = leaflet() \%>\% addTiles() \%>\% setView(-71.0382679, 42.3489054, zoom = 18)
53 | m # the RStudio 'headquarter'
54 | m \%>\% fitBounds(-72, 40, -70, 43)
55 | m \%>\% clearBounds() # world view
56 | }
57 | \references{
58 | \url{http://leafletjs.com/reference.html#map-set-methods}
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/javascript/src/crs_utils.js:
--------------------------------------------------------------------------------
1 | import L from "./global/leaflet";
2 | import Proj4Leaflet from "./global/proj4leaflet";
3 |
4 | // Helper function to instanciate a ICRS instance.
5 | export function getCRS(crsOptions) {
6 | let crs = L.CRS.EPSG3857; // Default Spherical Mercator
7 |
8 | switch(crsOptions.crsClass) {
9 | case "L.CRS.EPSG3857":
10 | crs = L.CRS.EPSG3857;
11 | break;
12 | case "L.CRS.EPSG4326":
13 | crs = L.CRS.EPSG4326;
14 | break;
15 | case "L.CRS.EPSG3395":
16 | crs = L.CRS.EPSG3395;
17 | break;
18 | case "L.CRS.Simple":
19 | crs =L.CRS.Simple;
20 | break;
21 | case "L.Proj.CRS":
22 | if(crsOptions.options && crsOptions.options.bounds) {
23 | crsOptions.options.bounds = L.bounds(crsOptions.options.bounds);
24 | }
25 | if(crsOptions.options && crsOptions.options.transformation) {
26 | crsOptions.options.transformation =
27 | L.Transformation(
28 | crsOptions.options.transformation[0],
29 | crsOptions.options.transformation[1],
30 | crsOptions.options.transformation[2],
31 | crsOptions.options.transformation[3]
32 | );
33 | }
34 | crs = new Proj4Leaflet.CRS(crsOptions.code, crsOptions.proj4def,
35 | crsOptions.options);
36 | break;
37 | case "L.Proj.CRS.TMS":
38 | if(crsOptions.options && crsOptions.options.bounds) {
39 | crsOptions.options.bounds = L.bounds(crsOptions.options.bounds);
40 | }
41 | if(crsOptions.options && crsOptions.options.transformation) {
42 | crsOptions.options.transformation =
43 | L.Transformation(
44 | crsOptions.options.transformation[0],
45 | crsOptions.options.transformation[1],
46 | crsOptions.options.transformation[2],
47 | crsOptions.options.transformation[3]
48 | );
49 | }
50 | crs = new Proj4Leaflet.CRS.TMS(crsOptions.code, crsOptions.proj4def,
51 | crsOptions.projectedBounds, crsOptions.options);
52 | break;
53 | }
54 | return crs;
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # An R Interface to Leaflet Maps
2 |
3 | [](https://travis-ci.org/rstudio/leaflet)
4 |
5 | [Leaflet](http://leafletjs.com) is an open-source JavaScript library for
6 | interactive maps. This R package makes it easy to create Leaflet maps from R.
7 |
8 | ```r
9 | library(leaflet)
10 | m = leaflet() %>% addTiles()
11 | m # a map with the default OSM tile layer
12 |
13 | m = m %>% setView(-93.65, 42.0285, zoom = 17)
14 | m
15 |
16 | m %>% addPopups(-93.65, 42.0285, 'Here is the Department of Statistics, ISU')
17 | ```
18 |
19 | ## Installation
20 |
21 | You can install this package from CRAN, or the development version from Github:
22 |
23 | ```r
24 | # CRAN version
25 | install.packages('leaflet')
26 |
27 | # Or Github version
28 | if (!require('devtools')) install.packages('devtools')
29 | devtools::install_github('rstudio/leaflet')
30 | ```
31 |
32 | ## Documentation
33 |
34 | In addition to the usual R package documentation, we also have extensive docs and examples at:
35 | http://rstudio.github.io/leaflet You may use [Github issues](https://github.com/rstudio/leaflet/issues) to file bug reports or feature requests, and ask questions on [StackOverflow](http://stackoverflow.com/questions/tagged/r+leaflet) or in the [Shiny mailing list](https://groups.google.com/forum/#!forum/shiny-discuss).
36 |
37 | ## Development
38 |
39 | To make additions or modifications to the JavaScript htmlwidgets binding layer,
40 | you must use Grunt to build and test. Please make sure Node.js is installed on
41 | your system, then run:
42 |
43 | ```
44 | npm install -g grunt-cli
45 | npm install
46 | ```
47 |
48 | Now you can build/minify/lint/test using `grunt build`, or run in "watch" mode
49 | by just running `grunt`. JS sources go into `javascript/src` and tests go into
50 | `javascript/tests`.
51 |
52 | ## License
53 |
54 | This package is licensed to you under the terms of the [GNU General Public
55 | License](http://www.gnu.org/licenses/gpl.html) version 3 or later.
56 |
57 | Copyright 2013-2015 RStudio, Inc.
58 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/leaflet-locationfilter/locationfilter-bindings.js:
--------------------------------------------------------------------------------
1 | /* global LeafletWidget, L, Shiny, HTMLWidgets, $ */
2 |
3 | function getLocationFilterBounds(locationFilter) {
4 | if(locationFilter && locationFilter.getBounds) {
5 | var bounds = locationFilter.getBounds();
6 | var boundsJSON =
7 | {
8 | "sw_lat" : bounds.getSouth(),
9 | "sw_lng" : bounds.getWest(),
10 | "ne_lat" : bounds.getNorth(),
11 | "ne_lng" : bounds.getEast()
12 | };
13 | return boundsJSON;
14 | } else {
15 | return null;
16 | }
17 | }
18 |
19 | LeafletWidget.methods.addLocationFilter = function(options) {
20 | (function() {
21 | var map = this;
22 |
23 | if(map.locationFilter) {
24 | map.locationFilter.remove();
25 | map.locationFilter = null;
26 | }
27 |
28 | if(!$.isEmptyObject(options.bounds)) {
29 | options.bounds = L.latLngBounds(options.bounds);
30 | }
31 |
32 | map.locationFilter = new L.LocationFilter(options);
33 |
34 | map.locationFilter.on("change", function(e) {
35 | if (!HTMLWidgets.shinyMode) return;
36 | Shiny.onInputChange(map.id+"_location_filter_changed",
37 | getLocationFilterBounds(map.locationFilter));
38 | });
39 | map.locationFilter.on("enabled", function(e) {
40 | if (!HTMLWidgets.shinyMode) return;
41 | Shiny.onInputChange(map.id+"_location_filter_enabled",
42 | getLocationFilterBounds(map.locationFilter));
43 | });
44 | map.locationFilter.on("disabled", function(e) {
45 | if (!HTMLWidgets.shinyMode) return;
46 | Shiny.onInputChange(map.id+"_location_filter_disabled",
47 | getLocationFilterBounds(map.locationFilter));
48 | });
49 |
50 | map.locationFilter.addTo(map);
51 |
52 | }).call(this);
53 | };
54 |
55 | LeafletWidget.methods.removeLocationFilter = function() {
56 | (function() {
57 | var map = this;
58 |
59 | if(map.locationFilter) {
60 | map.locationFilter.remove();
61 | map.locationFilter = null;
62 | }
63 |
64 | }).call(this);
65 | };
66 |
67 |
--------------------------------------------------------------------------------
/inst/examples/shiny.R:
--------------------------------------------------------------------------------
1 | library(shiny)
2 | library(leaflet)
3 |
4 | geodata <- paste(readLines(system.file("examples/test.json", package = "leaflet")), collapse = "\n")
5 |
6 | ui <- fluidPage(
7 | leafletOutput("map1"),
8 | checkboxInput("addMarker", "Add marker on click"),
9 | actionButton("clearMarkers", "Clear all markers"),
10 | textOutput("message", container = h3)
11 | )
12 |
13 | server <- function(input, output, session) {
14 | v <- reactiveValues(msg = "")
15 |
16 | output$map1 <- renderLeaflet({
17 | leaflet() %>%
18 | addGeoJSON(geodata) %>%
19 | addCircles(-60, 60, radius = 5e5, layerId = "circle") %>%
20 | fitBounds(-87.1875, 71.4131, 128.3203, 0.3515)
21 | })
22 |
23 | observeEvent(input$map1_geojson_mouseover, {
24 | v$msg <- paste("Mouse is over", input$map1_geojson_mouseover$featureId)
25 | })
26 | observeEvent(input$map1_geojson_mouseout, {
27 | v$msg <- ""
28 | })
29 | observeEvent(input$map1_geojson_click, {
30 | v$msg <- paste("Clicked on", input$map1_geojson_click$featureId)
31 | })
32 | observeEvent(input$map1_shape_mouseover, {
33 | v$msg <- paste("Mouse is over shape", input$map1_shape_mouseover$id)
34 | })
35 | observeEvent(input$map1_shape_mouseout, {
36 | v$msg <- ""
37 | })
38 | observeEvent(input$map1_shape_click, {
39 | v$msg <- paste("Clicked shape", input$map1_shape_click$id)
40 | })
41 | observeEvent(input$map1_click, {
42 | v$msg <- paste("Clicked map at", input$map1_click$lat, "/", input$map1_click$lng)
43 | if (input$addMarker) {
44 | leafletProxy("map1") %>%
45 | addMarkers(lng = input$map1_click$lng, lat = input$map1_click$lat)
46 | }
47 | })
48 | observeEvent(input$map1_zoom, {
49 | v$msg <- paste("Zoom changed to", input$map1_zoom)
50 | })
51 | observeEvent(input$map1_bounds, {
52 | v$msg <- paste("Bounds changed to", paste(input$map1_bounds, collapse = ", "))
53 | })
54 | observeEvent(input$clearMarkers, {
55 | leafletProxy("map1") %>% clearMarkers()
56 | })
57 |
58 | output$message <- renderText(v$msg)
59 | }
60 |
61 | shinyApp(ui, server)
62 |
--------------------------------------------------------------------------------
/man/awesomeIcons.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-awesomeMarkers.R
3 | \name{awesomeIcons}
4 | \alias{awesomeIcons}
5 | \title{Create a list of awesome icon data see
6 | \url{https://github.com/lvoogdt/Leaflet.awesome-markers}}
7 | \usage{
8 | awesomeIcons(icon = "home", library = "glyphicon", markerColor = "blue",
9 | iconColor = "white", spin = FALSE, extraClasses = NULL,
10 | squareMarker = FALSE, iconRotate = 0, fontFamily = "monospace",
11 | text = NULL)
12 | }
13 | \arguments{
14 | \item{icon}{Name of the icon}
15 |
16 | \item{library}{Which icon library. Default \code{'glyphicon'}, other possible
17 | values are \code{'fa'} (fontawesome) or \code{'ion'} (ionicons).}
18 |
19 | \item{markerColor}{Possible values are \code{'red'}, \code{'darkred'}, \code{'lightred'}, \code{'orange'},
20 | \code{'beige'}, \code{'green'}, \code{'darkgreen'}, \code{'lightgreen'}, \code{'blue'},
21 | \code{'darkblue'}, \code{'lightblue'}, \code{'purple'}, \code{'darkpurple'}, \code{'pink'},
22 | \code{'cadetblue'}, \code{'white'}, \code{'gray'}, \code{'lightgray'}, \code{'black'}}
23 |
24 | \item{iconColor}{The color to use for the icon itself. Use any CSS-valid
25 | color (hex, rgba, etc.) or a named web color.}
26 |
27 | \item{spin}{If \code{TRUE}, make the icon spin (only works when \code{library
28 | = 'fa'})}
29 |
30 | \item{extraClasses}{Additional css classes to include on the icon.}
31 |
32 | \item{squareMarker}{Whether to use a sqare marker.}
33 |
34 | \item{iconRotate}{Rotate the icon by a given angle.}
35 |
36 | \item{fontFamily}{Used when \code{text} option is specified.}
37 |
38 | \item{text}{Use this text string instead of an icon.
39 | argument of \code{\link{addAwesomeMarkers}()}.}
40 | }
41 | \value{
42 | A list of awesome-icon data that can be passed to the \code{icon}
43 | }
44 | \description{
45 | An icon can be represented as a list of the form \code{list(icon, library,
46 | ...)}. This function is vectorized over its arguments to create a list of
47 | icon data. Shorter argument values will be re-cycled. \code{NULL} values for
48 | these arguments will be ignored.
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/inst/examples/easyButton.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | #' Add two easy buttons.
4 | #' first to set zoom level to 1,
5 | #' second to find your self
6 | leaflet() %>% addTiles() %>%
7 | addEasyButton(easyButton(
8 | icon='fa-globe', title='Zoom to Level 1',
9 | onClick=JS("function(btn, map){ map.setZoom(1);}"))) %>%
10 | addEasyButton(easyButton(
11 | icon='fa-crosshairs', title='Locate Me',
12 | onClick=JS("function(btn, map){ map.locate({setView: true});}")))
13 |
14 | #'
Toggle Button to freeze/unfreeze clustering at a zoom level.
15 | leaflet() %>% addTiles() %>%
16 | addMarkers(data=quakes,
17 | clusterOptions = markerClusterOptions(),
18 | clusterId = 'quakesCluster') %>%
19 | addEasyButton(easyButton(
20 | states = list(
21 | easyButtonState(
22 | stateName='unfrozen-markers',
23 | icon='ion-toggle',
24 | title='Freeze Clusters',
25 | onClick = JS("
26 | function(btn, map) {
27 | var clusterManager =
28 | map.layerManager.getLayer('cluster',
29 | 'quakesCluster');
30 | clusterManager.freezeAtZoom();
31 | btn.state('frozen-markers');
32 | }")
33 | ),
34 | easyButtonState(
35 | stateName='frozen-markers',
36 | icon='ion-toggle-filled',
37 | title='UnFreeze Clusters',
38 | onClick = JS("
39 | function(btn, map) {
40 | var clusterManager =
41 | map.layerManager.getLayer('cluster',
42 | 'quakesCluster');
43 | clusterManager.unfreeze();
44 | btn.state('unfrozen-markers');
45 | }")
46 | )
47 | )
48 | ))
49 |
50 | #'
Add two easy buttons in a bar
51 | #' first to set zoom level to 1
52 | #' second to find your self
53 | leaflet() %>% addTiles() %>%
54 | addEasyButtonBar(
55 | easyButton(
56 | icon='fa-globe', title='Zoom to Level 1',
57 | onClick=JS("function(btn, map){ map.setZoom(1);}")),
58 | easyButton(
59 | icon='fa-crosshairs', title='Locate Me',
60 | onClick=JS("function(btn, map){ map.locate({setView: true});}"))
61 | )
62 |
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/global.R:
--------------------------------------------------------------------------------
1 | density = c(
2 | "Alabama" = 94.65,
3 | "Arizona" = 57.05,
4 | "Arkansas" = 56.43,
5 | "California" = 241.7,
6 | "Colorado" = 49.33,
7 | "Connecticut" = 739.1,
8 | "Delaware" = 464.3,
9 | "District of Columbia" = 10065,
10 | "Florida" = 353.4,
11 | "Georgia" = 169.5,
12 | "Idaho" = 19.15,
13 | "Illinois" = 231.5,
14 | "Indiana" = 181.7,
15 | "Iowa" = 54.81,
16 | "Kansas" = 35.09,
17 | "Kentucky" = 110,
18 | "Louisiana" = 105,
19 | "Maine" = 43.04,
20 | "Maryland" = 596.3,
21 | "Massachusetts" = 840.2,
22 | "Michigan" = 173.9,
23 | "Minnesota" = 67.14,
24 | "Mississippi" = 63.50,
25 | "Missouri" = 87.26,
26 | "Montana" = 6.858,
27 | "Nebraska" = 23.97,
28 | "Nevada" = 24.80,
29 | "New Hampshire" = 147,
30 | "New Jersey" = 1189 ,
31 | "New Mexico" = 17.16,
32 | "New York" = 412.3,
33 | "North Carolina" = 198.2,
34 | "North Dakota" = 9.916,
35 | "Ohio" = 281.9,
36 | "Oklahoma" = 55.22,
37 | "Oregon" = 40.33,
38 | "Pennsylvania" = 284.3,
39 | "Rhode Island" = 1006 ,
40 | "South Carolina" = 155.4,
41 | "South Dakota" = 98.07,
42 | "Tennessee" = 88.08,
43 | "Texas" = 98.07,
44 | "Utah" = 34.30,
45 | "Vermont" = 67.73,
46 | "Virginia" = 204.5,
47 | "Washington" = 102.6,
48 | "West Virginia" = 77.06,
49 | "Wisconsin" = 105.2,
50 | "Wyoming" = 5.851
51 | )
52 |
53 | # Breaks we'll use for coloring
54 | densityBreaks <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
55 | # Construct break ranges for displaying in the legend
56 | densityRanges <- data.frame(
57 | from = head(densityBreaks, length(densityBreaks)-1),
58 | to = tail(densityBreaks, length(densityBreaks)-1)
59 | )
60 |
61 | # Eight colors for eight buckets
62 | palette <- c("#FFEDA0", "#FED976", "#FEB24C", "#FD8D3C",
63 | "#FC4E2A", "#E31A1C", "#BD0026", "#800026")
64 | # Assign colors to states
65 | colors <- structure(
66 | palette[cut(density, densityBreaks)],
67 | names = tolower(names(density))
68 | )
69 |
70 | # The state names that come back from the maps package's state database has
71 | # state:qualifier format. This function strips off the qualifier.
72 | getStateName <- function(id) {
73 | strsplit(id, ":")[[1]][1]
74 | }
75 |
--------------------------------------------------------------------------------
/man/makeIcon.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{makeIcon}
4 | \alias{makeIcon}
5 | \title{Define icon sets}
6 | \usage{
7 | makeIcon(iconUrl = NULL, iconRetinaUrl = NULL, iconWidth = NULL,
8 | iconHeight = NULL, iconAnchorX = NULL, iconAnchorY = NULL,
9 | shadowUrl = NULL, shadowRetinaUrl = NULL, shadowWidth = NULL,
10 | shadowHeight = NULL, shadowAnchorX = NULL, shadowAnchorY = NULL,
11 | popupAnchorX = NULL, popupAnchorY = NULL, className = NULL)
12 | }
13 | \arguments{
14 | \item{iconUrl}{the URL or file path to the icon image}
15 |
16 | \item{iconRetinaUrl}{the URL or file path to a retina sized version of the
17 | icon image}
18 |
19 | \item{iconWidth}{size of the icon image in pixels}
20 |
21 | \item{iconHeight}{size of the icon image in pixels}
22 |
23 | \item{iconAnchorX}{the coordinates of the "tip" of the icon
24 | (relative to its top left corner, i.e. the top left corner means
25 | \code{iconAnchorX = 0} and \code{iconAnchorY = 0)}, and the icon will be
26 | aligned so that this point is at the marker's geographical location}
27 |
28 | \item{iconAnchorY}{the coordinates of the "tip" of the icon
29 | (relative to its top left corner, i.e. the top left corner means
30 | \code{iconAnchorX = 0} and \code{iconAnchorY = 0)}, and the icon will be
31 | aligned so that this point is at the marker's geographical location}
32 |
33 | \item{shadowUrl}{the URL or file path to the icon shadow image}
34 |
35 | \item{shadowRetinaUrl}{the URL or file path to the retina sized version of
36 | the icon shadow image}
37 |
38 | \item{shadowWidth}{size of the shadow image in pixels}
39 |
40 | \item{shadowHeight}{size of the shadow image in pixels}
41 |
42 | \item{shadowAnchorX}{the coordinates of the "tip" of the shadow}
43 |
44 | \item{shadowAnchorY}{the coordinates of the "tip" of the shadow}
45 |
46 | \item{popupAnchorX}{the coordinates of the point from which
47 | popups will "open", relative to the icon anchor}
48 |
49 | \item{popupAnchorY}{the coordinates of the point from which
50 | popups will "open", relative to the icon anchor}
51 |
52 | \item{className}{a custom class name to assign to both icon and shadow images}
53 | }
54 | \description{
55 | Define icon sets
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/inst/examples/highlight-polygons.R:
--------------------------------------------------------------------------------
1 | #'
2 | #' An example to show how to highlight polygons on hover using `onRender`
3 | #'
4 | library(sp)
5 | library(albersusa)
6 | library(maptools)
7 | library(leaflet)
8 |
9 | spdf <- rmapshaper::ms_simplify(usa_composite())
10 |
11 | pal <- colorNumeric(palette = "Blues", domain = spdf@data$pop_2014)
12 | pal2 <- colorNumeric(palette = "Reds", domain = spdf@data$pop_2013)
13 |
14 | bounds <- c(-125, 24 ,-75, 45)
15 |
16 | leaflet(
17 | options=
18 | leafletOptions(
19 | worldCopyJump = FALSE,
20 | crs=leafletCRS(
21 | crsClass="L.Proj.CRS",
22 | code='EPSG:2163',
23 | proj4def='+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs',
24 | resolutions = c(65536, 32768, 16384, 8192, 4096, 2048,1024, 512, 256, 128)
25 | ))) %>%
26 | fitBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>%
27 | setMaxBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>%
28 | addPolygons(data=spdf, weight = 1, color = "#000000",
29 | fillColor=~pal(pop_2014),
30 | fillOpacity=0.7,
31 | label=~stringr::str_c(
32 | name,' ',
33 | formatC(pop_2014, big.mark = ',', format='d')),
34 | labelOptions= labelOptions(direction = 'auto'),
35 | highlightOptions = highlightOptions(
36 | color='#ff0000', opacity = 1, weight = 2, fillOpacity = 1,
37 | bringToFront = TRUE, sendToBack = TRUE),
38 | group="2014") %>%
39 | addPolygons(data=spdf, weight = 1, color = "#000000",
40 | fillColor=~pal2(pop_2013),
41 | fillOpacity=0.7,
42 | label=~stringr::str_c(
43 | name,' ',
44 | formatC(pop_2014, big.mark = ',', format='d')),
45 | labelOptions= labelOptions(direction = 'auto'),
46 | highlightOptions = highlightOptions(
47 | color='#00ff00', opacity = 1, weight = 2, fillOpacity = 1,
48 | bringToFront = TRUE, sendToBack = TRUE),
49 | group="2013") %>%
50 | addLayersControl(
51 | baseGroups=c("2014", "2013"),
52 | position = "topleft",
53 | options = layersControlOptions(collapsed = FALSE)
54 | )
55 |
--------------------------------------------------------------------------------
/inst/examples/icons.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | # adapted from http://leafletjs.com/examples/custom-icons.html
4 |
5 | iconData = data.frame(
6 | lat = c(rnorm(10, 0), rnorm(10, 1), rnorm(10, 2)),
7 | lng = c(rnorm(10, 0), rnorm(10, 3), rnorm(10, 6)),
8 | group = rep(sort(c('green', 'red', 'orange')), each = 10),
9 | stringsAsFactors = FALSE
10 | )
11 |
12 | leaflet() %>% addMarkers(
13 | data = iconData,
14 | icon = ~ icons(
15 | iconUrl = sprintf('http://leafletjs.com/docs/images/leaf-%s.png', group),
16 | shadowUrl = 'http://leafletjs.com/docs/images/leaf-shadow.png',
17 | iconWidth = 38, iconHeight = 95, shadowWidth = 50, shadowHeight = 64,
18 | iconAnchorX = 22, iconAnchorY = 94, shadowAnchorX = 4, shadowAnchorY = 62,
19 | popupAnchorX = -3, popupAnchorY = -76
20 | )
21 | )
22 |
23 |
24 | # use point symbols from base R graphics as icons
25 | pchIcons = function(pch = 0:14, width = 30, height = 30, ...) {
26 | n = length(pch)
27 | files = character(n)
28 | # create a sequence of png images
29 | for (i in seq_len(n)) {
30 | f = tempfile(fileext = '.png')
31 | png(f, width = width, height = height, bg = 'transparent')
32 | par(mar = c(0, 0, 0, 0))
33 | plot.new()
34 | points(.5, .5, pch = pch[i], cex = min(width, height) / 8, ...)
35 | dev.off()
36 | files[i] = f
37 | }
38 | files
39 | }
40 |
41 | iconData = matrix(rnorm(500), ncol = 2)
42 | res = kmeans(iconData, 10)
43 | iconData = cbind(iconData, res$cluster)
44 | colnames(iconData) = c('lat', 'lng', 'group')
45 | iconData = as.data.frame(iconData)
46 |
47 | # 10 random point shapes for the 10 clusters in iconData
48 | shapes = sample(0:14, 10)
49 | iconFiles = pchIcons(shapes, 40, 40, col = 'steelblue', lwd = 2)
50 |
51 | # note the data has 250 rows, and there are 10 icons in iconFiles; they are
52 | # connected by the `group` variable: the i-th row of iconData uses the
53 | # group[i]-th icon in the icon list
54 | leaflet() %>% addMarkers(
55 | data = iconData,
56 | icon = ~ icons(
57 | iconUrl = iconFiles[group],
58 | popupAnchorX = 20, popupAnchorY = 0
59 | ),
60 | popup = ~ sprintf(
61 | 'lat = %.4f, long = %.4f, group = %s, pch = %s', lat, lng, group, shapes[group]
62 | )
63 | )
64 |
65 | unlink(iconFiles) # clean up the tmp png files that have been embedded
66 |
--------------------------------------------------------------------------------
/inst/examples/polygon-colors.R:
--------------------------------------------------------------------------------
1 | library(magrittr)
2 |
3 | fName <- 'https://raw.githubusercontent.com/MinnPost/simple-map-d3/master/example-data/world-population.geo.json'
4 |
5 | readGeoJson_ <- function(fName) {
6 | rmapshaper::ms_simplify(paste0(readLines(fName)))
7 | }
8 |
9 | readGeoJson <- memoise::memoise(readGeoJson_)
10 | geoJson <- readGeoJson(fName)
11 |
12 | spdf <- geojsonio::geojson_sp(geoJson)
13 |
14 | #'
15 | #'
16 | #' Calculate population density only for countries with AREA & POP > 1.
17 | spdf@data %<>% dplyr::mutate(
18 | AREA = as.numeric(as.character(AREA)),
19 | POP2005 = as.numeric(as.character(POP2005))
20 | )
21 |
22 | spdf <- subset(
23 | spdf,
24 | !(is.na(AREA) | AREA <1 | is.na(POP2005) | POP2005<1)
25 | )
26 |
27 | spdf@data %<>%
28 | dplyr::mutate(
29 | POPDENSITY = POP2005/AREA
30 | )
31 | #'
32 | #'
33 | DT::datatable(spdf@data %>% dplyr::select(NAME,POP2005,AREA,POPDENSITY),
34 | options = list(pageLength=5))
35 | #'
36 | #'
37 |
38 | library(leaflet)
39 | leaf <- leaflet(spdf)
40 |
41 | #'
42 | #'
43 | #' ### Quantiles
44 |
45 | qpal <- colorQuantile(rev(viridis::viridis(10)), spdf$POPDENSITY, n=10)
46 |
47 | leaf %>%
48 | addPolygons(weight=1,color='#333333', fillOpacity = 1,
49 | fillColor = ~qpal(POPDENSITY) ) %>%
50 | addLegend("bottomleft", pal = qpal, values = ~POPDENSITY,
51 | title = htmltools::HTML("Population Density
(2005)"),
52 | opacity = 1 )
53 |
54 |
55 | #'
56 | #'
57 | #' ### Bins
58 | binpal <- colorBin(rev(viridis::viridis(10)), spdf$POPDENSITY, bins=10)
59 |
60 | leaf %>%
61 | addPolygons(weight=1,color='#333333', fillOpacity = 1,
62 | fillColor = ~binpal(POPDENSITY)) %>%
63 | addLegend("bottomleft", pal = binpal, values = ~POPDENSITY,
64 | title = htmltools::HTML("Population Density
(2005)"),
65 | opacity = 1 )
66 |
67 | #'
68 | #'
69 | #' ### Numeric
70 | numpal <- colorNumeric(rev(viridis::viridis(256)), spdf$POPDENSITY)
71 |
72 | leaf %>%
73 | addPolygons(weight=1,color='#333333', fillOpacity = 1,
74 | fillColor = ~numpal(POPDENSITY)) %>%
75 | addLegend("bottomleft", pal = numpal, values = ~POPDENSITY,
76 | title = htmltools::HTML("Population Density
(2005)"),
77 | opacity = 1 )
78 | #'
79 | #'
80 |
81 |
--------------------------------------------------------------------------------
/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.css:
--------------------------------------------------------------------------------
1 | .leaflet-control-minimap {
2 | border:solid rgba(255, 255, 255, 1.0) 4px;
3 | box-shadow: 0 1px 5px rgba(0,0,0,0.65);
4 | border-radius: 3px;
5 | background: #f8f8f9;
6 | transition: all .6s;
7 | }
8 |
9 | .leaflet-control-minimap a {
10 | background-color: rgba(255, 255, 255, 1.0);
11 | background-repeat: no-repeat;
12 | z-index: 99999;
13 | transition: all .6s;
14 | }
15 |
16 | .leaflet-control-minimap a.minimized-bottomright {
17 | -webkit-transform: rotate(180deg);
18 | transform: rotate(180deg);
19 | border-radius: 0px;
20 | }
21 |
22 | .leaflet-control-minimap a.minimized-topleft {
23 | -webkit-transform: rotate(0deg);
24 | transform: rotate(0deg);
25 | border-radius: 0px;
26 | }
27 |
28 | .leaflet-control-minimap a.minimized-bottomleft {
29 | -webkit-transform: rotate(270deg);
30 | transform: rotate(270deg);
31 | border-radius: 0px;
32 | }
33 |
34 | .leaflet-control-minimap a.minimized-topright {
35 | -webkit-transform: rotate(90deg);
36 | transform: rotate(90deg);
37 | border-radius: 0px;
38 | }
39 |
40 | .leaflet-control-minimap-toggle-display{
41 | background-image: url("images/toggle.svg");
42 | background-size: cover;
43 | position: absolute;
44 | border-radius: 3px 0px 0px 0px;
45 | }
46 |
47 | .leaflet-oldie .leaflet-control-minimap-toggle-display{
48 | background-image: url("images/toggle.png");
49 | }
50 |
51 | .leaflet-control-minimap-toggle-display-bottomright {
52 | bottom: 0;
53 | right: 0;
54 | }
55 |
56 | .leaflet-control-minimap-toggle-display-topleft{
57 | top: 0;
58 | left: 0;
59 | -webkit-transform: rotate(180deg);
60 | transform: rotate(180deg);
61 | }
62 |
63 | .leaflet-control-minimap-toggle-display-bottomleft{
64 | bottom: 0;
65 | left: 0;
66 | -webkit-transform: rotate(90deg);
67 | transform: rotate(90deg);
68 | }
69 |
70 | .leaflet-control-minimap-toggle-display-topright{
71 | top: 0;
72 | right: 0;
73 | -webkit-transform: rotate(270deg);
74 | transform: rotate(270deg);
75 | }
76 |
77 | /* Old IE */
78 | .leaflet-oldie .leaflet-control-minimap {
79 | border: 1px solid #999;
80 | }
81 |
82 | .leaflet-oldie .leaflet-control-minimap a {
83 | background-color: #fff;
84 | }
85 |
86 | .leaflet-oldie .leaflet-control-minimap a.minimized {
87 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
88 | }
89 |
--------------------------------------------------------------------------------
/man/addLayersControl.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/layers.R
3 | \name{addLayersControl}
4 | \alias{addLayersControl}
5 | \alias{layersControlOptions}
6 | \alias{removeLayersControl}
7 | \title{Add UI controls to switch layers on and off}
8 | \usage{
9 | addLayersControl(map, baseGroups = character(0),
10 | overlayGroups = character(0), position = c("topright", "bottomright",
11 | "bottomleft", "topleft"), options = layersControlOptions())
12 |
13 | layersControlOptions(collapsed = TRUE, autoZIndex = TRUE, ...)
14 |
15 | removeLayersControl(map)
16 | }
17 | \arguments{
18 | \item{map}{the map to add the layers control to}
19 |
20 | \item{baseGroups}{character vector where each element is the name of a group.
21 | The user will be able to choose one base group (only) at a time. This is
22 | most commonly used for mostly-opaque tile layers.}
23 |
24 | \item{overlayGroups}{character vector where each element is the name of a
25 | group. The user can turn each overlay group on or off independently.}
26 |
27 | \item{position}{position of control: 'topleft', 'topright', 'bottomleft', or
28 | 'bottomright'}
29 |
30 | \item{options}{a list of additional options, intended to be provided by
31 | a call to \code{layersControlOptions}}
32 |
33 | \item{collapsed}{if \code{TRUE} (the default), the layers control will be
34 | rendered as an icon that expands when hovered over. Set to \code{FALSE}
35 | to have the layers control always appear in its expanded state.}
36 |
37 | \item{autoZIndex}{if \code{TRUE}, the control will automatically maintain
38 | the z-order of its various groups as overlays are switched on and off.}
39 |
40 | \item{...}{other options for \code{layersControlOptions()}}
41 | }
42 | \description{
43 | Uses Leaflet's built-in
44 | \href{http://leafletjs.com/reference.html#control-layers}{layers control}
45 | feature to allow users to choose one of several base layers, and to choose
46 | any number of overlay layers to view.
47 | }
48 | \examples{
49 | \donttest{
50 | leaflet() \%>\%
51 | addTiles(group = "OpenStreetMap") \%>\%
52 | addProviderTiles("Stamen.Toner", group = "Toner by Stamen") \%>\%
53 | addMarkers(runif(20, -75, -74), runif(20, 41, 42), group = "Markers") \%>\%
54 | addLayersControl(
55 | baseGroups = c("OpenStreetMap", "Toner by Stamen"),
56 | overlayGroups = c("Markers")
57 | )
58 | }
59 |
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | grunt.initConfig({
3 | babel: {
4 | options: {
5 | sourceMap: true,
6 | presets: ["es2015"],
7 | plugins: ["transform-es2015-modules-commonjs"]
8 | },
9 | dist: {
10 | files: [{
11 | expand: true,
12 | cwd: 'javascript/src',
13 | src: ['**/*.js'],
14 | dest: 'inst/htmlwidgets/sources',
15 | ext:'.js'
16 | }]
17 | },
18 | distSpecs: {
19 | files: [{
20 | expand: true,
21 | cwd: 'javascript/tests',
22 | src: ['**/*.js'],
23 | dest: 'inst/htmlwidgets/sources',
24 | ext:'.js'
25 | }]
26 | }
27 | },
28 | browserify: {
29 | options: {
30 | browserifyOptions: {
31 | //debug: true
32 | }
33 | },
34 | dist: {
35 | files: {
36 | // if the source file has an extension of es6 then
37 | // we change the name of the source file accordingly.
38 | // The result file's extension is always .js
39 | "./inst/htmlwidgets/leaflet.js": ["./inst/htmlwidgets/sources/index.js"]
40 | }
41 | }
42 | },
43 | eslint: {
44 | target: ["./javascript/src/*.js"]
45 | },
46 | mochaTest: {
47 | test: {
48 | options: {
49 | reporter: "spec",
50 | require: ["babel-register", "source-map-support/register"],
51 | // captureFile: 'results.txt', // Optionally capture the reporter output to a file
52 | quiet: false, // Optionally suppress output to standard out (defaults to false)
53 | clearRequireCache: false // Optionally clear the require cache before running tests (defaults to false)
54 | },
55 | src: ["inst/htmlwidgets/sources/test-*.js"]
56 | }
57 | },
58 | watch: {
59 | scripts: {
60 | files: ["./javascript/src/**/*.js", "javascript/tests/**/*.js"],
61 | tasks: ["babel", "browserify", "eslint", "mochaTest"]
62 | }
63 | }
64 | });
65 |
66 | grunt.loadNpmTasks("grunt-babel");
67 | grunt.loadNpmTasks("grunt-browserify");
68 | grunt.loadNpmTasks("grunt-contrib-watch");
69 | grunt.loadNpmTasks("grunt-eslint");
70 | grunt.loadNpmTasks("grunt-mocha-test");
71 |
72 | grunt.registerTask("default", ["watch"]);
73 | grunt.registerTask("build", ["babel", "browserify", "eslint", "mochaTest"]);
74 | };
--------------------------------------------------------------------------------
/man/easyButton.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/plugin-easybutton.R
3 | \name{easyButtonState}
4 | \alias{addEasyButton}
5 | \alias{addEasyButtonBar}
6 | \alias{easyButton}
7 | \alias{easyButtonState}
8 | \title{Create an easyButton statestate}
9 | \usage{
10 | easyButtonState(stateName, icon, title, onClick)
11 |
12 | easyButton(icon = NULL, title = NULL, onClick = NULL,
13 | position = "topleft", id = NULL, states = NULL)
14 |
15 | addEasyButton(map, button)
16 |
17 | addEasyButtonBar(map, ..., position = "topleft", id = NULL)
18 | }
19 | \arguments{
20 | \item{stateName}{a unique name for the state}
21 |
22 | \item{icon}{the button icon}
23 |
24 | \item{title}{text to show on hover}
25 |
26 | \item{onClick}{the action to take}
27 |
28 | \item{position}{topleft|topright|bottomleft|bottomright}
29 |
30 | \item{id}{id for the button}
31 |
32 | \item{states}{the states}
33 |
34 | \item{map}{a map widget object}
35 |
36 | \item{button}{the button object created with \code{\link{easyButton}}}
37 |
38 | \item{...}{a list of buttons created with \code{\link{easyButton}}}
39 | }
40 | \description{
41 | Create an easyButton statestate
42 |
43 | Creates an easy button.
44 |
45 | Add a EasyButton on the map
46 | see \url{https://github.com/CliffCloud/Leaflet.EasyButton}
47 |
48 | Add a easyButton bar on the map
49 | see \url{https://github.com/CliffCloud/Leaflet.EasyButton}
50 | }
51 | \section{Functions}{
52 | \itemize{
53 | \item \code{easyButtonState}: state of an easyButton.
54 |
55 | \item \code{addEasyButton}: add an EasyButton to the map
56 |
57 | \item \code{addEasyButtonBar}: add an EasyButton to the map
58 | }}
59 | \examples{
60 | library(leaflet)
61 |
62 | leaf <- leaflet() \%>\%
63 | addTiles() \%>\%
64 | addEasyButton(easyButton(
65 | icon = htmltools::span(class='star','★'),
66 | onClick = JS("function(btn, map){ map.setZoom(1);}")))
67 |
68 | library(leaflet)
69 |
70 | leaf <- leaflet() \%>\%
71 | addTiles() \%>\%
72 | addEasyButtonBar(
73 | easyButton(
74 | icon = htmltools::span(class='star','★'),
75 | onClick = JS("function(btn, map){ alert('Button 1');}")),
76 | easyButton(
77 | icon = htmltools::span(class='star','⌖'),
78 | onClick = JS("function(btn, map){ alert('Button 2');}")))
79 |
80 |
81 | }
82 | \seealso{
83 | \code{\link{easyButton}}
84 |
85 | \url{https://github.com/CliffCloud/Leaflet.EasyButton}
86 |
87 | \code{\link{addEasyButton}}
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/R/methods.R:
--------------------------------------------------------------------------------
1 | #' Methods to manipulate the map widget
2 | #'
3 | #' A series of methods to manipulate the map.
4 | #' @param map a map widget object created from \code{\link{leaflet}()}
5 | #' @param lng The longitude of the map center
6 | #' @param lat The latitude of the map center
7 | #' @param zoom the zoom level
8 | #' @param options a list of zoom/pan options (see
9 | #' \url{http://leafletjs.com/reference.html#map-zoompanoptions})
10 | #' @references \url{http://leafletjs.com/reference.html#map-set-methods}
11 | #' @return The modified map widget.
12 | #' @describeIn map-methods Set the view of the map (center and zoom level)
13 | #' @export
14 | #' @examples library(leaflet)
15 | #' m = leaflet() %>% addTiles() %>% setView(-71.0382679, 42.3489054, zoom = 18)
16 | #' m # the RStudio 'headquarter'
17 | #' m %>% fitBounds(-72, 40, -70, 43)
18 | #' m %>% clearBounds() # world view
19 | setView <- function(map, lng, lat, zoom, options = list()) {
20 | view = evalFormula(list(c(lat, lng), zoom, options))
21 |
22 | dispatch(map,
23 | "setView",
24 | leaflet = {
25 | map$x$setView = view
26 | map$x$fitBounds = NULL
27 | map
28 | },
29 | leaflet_proxy = {
30 | invokeRemote(map, "setView", view)
31 | map
32 | }
33 | )
34 | }
35 |
36 | #' @describeIn map-methods Set the bounds of a map
37 | #' @param lng1,lat1,lng2,lat2 the coordinates of the map bounds
38 | #' @export
39 | fitBounds <- function(map, lng1, lat1, lng2, lat2) {
40 | bounds = evalFormula(list(lat1, lng1, lat2, lng2), getMapData(map))
41 |
42 | dispatch(map,
43 | "fitBounds",
44 | leaflet = {
45 | map$x$fitBounds = bounds
46 | map$x$setView = NULL
47 | map
48 | },
49 | leaflet_proxy = {
50 | invokeRemote(map, "fitBounds", bounds)
51 | map
52 | }
53 | )
54 | }
55 |
56 | #' @describeIn map-methods Restricts the map view to the given bounds
57 | #' @export
58 | setMaxBounds <- function(map, lng1, lat1, lng2, lat2) {
59 | invokeMethod(map, getMapData(map), 'setMaxBounds', lat1, lng1, lat2, lng2)
60 | }
61 |
62 | #' @describeIn map-methods Clear the bounds of a map, and the bounds will be
63 | #' automatically determined from latitudes and longitudes of the map elements
64 | #' if available (otherwise the full world view is used)
65 | #' @export
66 | clearBounds <- function(map) {
67 | dispatch(map,
68 | "clearBounds",
69 | leaflet = {
70 | map$x$fitBounds = NULL
71 | map$x$setView = NULL
72 | map
73 | }
74 | )
75 | }
76 |
--------------------------------------------------------------------------------
/inst/legacy/examples/choropleth/server.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 | library(RColorBrewer)
3 | library(maps)
4 |
5 | shinyServer(function(input, output, session) {
6 | values <- reactiveValues(highlight = c())
7 |
8 | map <- createLeafletMap(session, "map")
9 |
10 | # Draw the given states, with or without highlighting
11 | drawStates <- function(stateNames, highlight = FALSE) {
12 | states <- map("state", stateNames, plot=FALSE, fill=TRUE)
13 | map$addPolygon(I(states$y), I(states$x), I(states$names),
14 | I(lapply(states$names, function(x) {
15 | x <- strsplit(x, ":")[[1]][1]
16 | list(fillColor = colors[[x]])
17 | })),
18 | I(list(fill=TRUE, fillOpacity=0.7,
19 | stroke=TRUE, opacity=1, color="white", weight=ifelse(highlight, 4, 1)
20 | ))
21 | )
22 | }
23 |
24 | observe({
25 | print(input$map_zoom)
26 | map$clearShapes()
27 | if (!is.null(input$map_zoom) && input$map_zoom > 6) {
28 | # Get shapes from the maps package
29 | drawStates(names(density))
30 | }
31 | })
32 |
33 | # input$map_shape_mouseover gets updated a lot, even if the id doesn't change.
34 | # We don't want to update the polygons and stateInfo except when the id
35 | # changes, so use values$highlight to insulate the downstream reactives (as
36 | # writing to values$highlight doesn't trigger reactivity unless the new value
37 | # is different than the previous value).
38 | observe({
39 | values$highlight <- input$map_shape_mouseover$id
40 | })
41 |
42 | # Dynamically render the box in the upper-right
43 | output$stateInfo <- renderUI({
44 | if (is.null(values$highlight)) {
45 | return(tags$div("Hover over a state"))
46 | } else {
47 | # Get a properly formatted state name
48 | stateName <- names(density)[getStateName(values$highlight) == tolower(names(density))]
49 | return(tags$div(
50 | tags$strong(stateName),
51 | tags$div(density[stateName], HTML("people/m2"))
52 | ))
53 | }
54 | })
55 |
56 | lastHighlighted <- c()
57 | # When values$highlight changes, unhighlight the old state (if any) and
58 | # highlight the new state
59 | observe({
60 | if (length(lastHighlighted) > 0)
61 | drawStates(getStateName(lastHighlighted), FALSE)
62 | lastHighlighted <<- values$highlight
63 |
64 | if (is.null(values$highlight))
65 | return()
66 |
67 | isolate({
68 | drawStates(getStateName(values$highlight), TRUE)
69 | })
70 | })
71 | })
72 |
--------------------------------------------------------------------------------
/inst/examples/marker-clustering.R:
--------------------------------------------------------------------------------
1 | library(leaflet)
2 |
3 | #' Add a Level factor to quakes
4 | quakes <- quakes %>%
5 | dplyr::mutate(mag.level = cut(mag,c(3,4,5,6),
6 | labels = c('>3 & <=4', '>4 & <=5', '>5 & <=6')))
7 |
8 | l <- leaflet() %>% addTiles()
9 |
10 | #'
11 | #' Default Clustering
12 | l %>%
13 | addMarkers(data=quakes, clusterOptions = markerClusterOptions())
14 |
15 | #'
16 | #' Clustering Frozen at level 5
17 | l %>%
18 | addMarkers(data=quakes, clusterOptions = markerClusterOptions(freezeAtZoom=6))
19 |
20 | #'
21 | #' Clustering of Label Only Clusters
22 | l %>%
23 | addLabelOnlyMarkers(data=quakes,
24 | lng=~long, lat=~lat,
25 | label=~as.character(mag),
26 | clusterOptions = markerClusterOptions(),
27 | labelOptions = labelOptions(noHide = T,
28 | direction = 'auto'))
29 | #'
30 | #' Clustering + Layers
31 | quakes.df <- split(quakes, quakes$mag.level)
32 |
33 | l2 <- l
34 | names(quakes.df) %>%
35 | purrr::walk( function(df) {
36 | l2 <<- l2 %>%
37 | addMarkers(data=quakes.df[[df]],
38 | lng=~long, lat=~lat,
39 | label=~as.character(mag),
40 | popup=~as.character(mag),
41 | group = df,
42 | clusterOptions = markerClusterOptions(removeOutsideVisibleBounds = F),
43 | labelOptions = labelOptions(noHide = T,
44 | direction = 'auto'))
45 | })
46 |
47 | l2 %>%
48 | addLayersControl(
49 | overlayGroups = names(quakes.df),
50 | options = layersControlOptions(collapsed = FALSE)
51 | )
52 |
53 | #'
54 | #' Clustering with custom iconCreateFunction
55 | leaflet(quakes) %>% addTiles() %>%
56 | addMarkers(clusterOptions =
57 | markerClusterOptions(iconCreateFunction =
58 | JS("
59 | function(cluster) {
60 | return new L.DivIcon({
61 | html: '