├── .Rbuildignore ├── .bowerrc ├── .eslintrc.json ├── .github ├── .gitignore ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── R-CMD-check.yaml ├── .gitignore ├── DESCRIPTION ├── Gruntfile.js ├── LICENSE.note ├── NAMESPACE ├── NEWS.md ├── R ├── colors.R ├── controls.R ├── data.R ├── dependencies.R ├── layers.R ├── leaflet-package.R ├── leaflet.R ├── legacy.R ├── legend.R ├── mapPane.R ├── methods.R ├── normalize-SharedData.R ├── normalize-map.R ├── normalize-sf.R ├── normalize-sp.R ├── normalize-terra.R ├── normalize.R ├── plugin-awesomeMarkers.R ├── plugin-easybutton.R ├── plugin-graticule.R ├── plugin-measure.R ├── plugin-minimap.R ├── plugin-omnivore.R ├── plugin-providers.R ├── plugin-simplegraticule.R ├── plugin-terminator.R ├── scalebar.R ├── selection.R ├── shiny.R ├── staticimports.R ├── utils.R ├── zzz.R └── zzz_viztest.R ├── README.md ├── cran-comments.md ├── data-raw ├── atlStorms2005.R ├── breweries91.R └── gadmCHE.R ├── data ├── atlStorms2005.rda ├── breweries91.rda └── gadmCHE.rda ├── inst ├── csv │ └── uspop2000.csv ├── examples │ ├── Historic_sites_and_monuments_point.kml │ ├── Seamask_medium_res_polygon.kml │ ├── awesomeMarkers.R │ ├── easyButton.R │ ├── emptyData.R │ ├── geojson.R │ ├── graticule.R │ ├── groupOptions.R │ ├── highlight-polygons.R │ ├── icons.R │ ├── labels.R │ ├── leaflet-measure.R │ ├── leaflet.R │ ├── legend.R │ ├── marker-clustering.R │ ├── minimap.R │ ├── normalize.R │ ├── polygon-colors.R │ ├── proj4Leaflet-PolarProjections.R │ ├── proj4Leaflet-TMS.R │ ├── proj4Leaflet.R │ ├── providers-digitalglobe.R │ ├── providers-shiny.R │ ├── providers.R │ ├── shiny-markercluster.R │ ├── shiny.R │ ├── simpleGraticule.R │ ├── terminator.R │ └── test.json ├── htmlwidgets │ ├── assets │ │ └── leaflet.js │ ├── lib │ │ ├── leaflet-measure │ │ │ ├── images │ │ │ │ ├── cancel.png │ │ │ │ ├── cancel_@2X.png │ │ │ │ ├── check.png │ │ │ │ ├── check_@2X.png │ │ │ │ ├── focus.png │ │ │ │ ├── focus_@2X.png │ │ │ │ ├── rulers.png │ │ │ │ ├── rulers_@2X.png │ │ │ │ ├── start.png │ │ │ │ ├── start_@2X.png │ │ │ │ ├── trash.png │ │ │ │ └── trash_@2X.png │ │ │ ├── leaflet-measure.css │ │ │ ├── leaflet-measure.js │ │ │ └── leaflet-measure.min.js │ │ ├── leaflet-omnivore │ │ │ ├── LICENSE │ │ │ ├── index.js │ │ │ ├── leaflet-omnivore.min.js │ │ │ └── package.json │ │ ├── leaflet │ │ │ ├── images │ │ │ │ ├── layers-2x.png │ │ │ │ ├── layers.png │ │ │ │ ├── marker-icon-2x.png │ │ │ │ ├── marker-icon.png │ │ │ │ └── marker-shadow.png │ │ │ ├── leaflet-src.js │ │ │ ├── leaflet-src.js.map │ │ │ ├── leaflet.css │ │ │ ├── leaflet.js │ │ │ └── leaflet.js.map │ │ ├── leafletfix │ │ │ └── leafletfix.css │ │ └── rstudio_leaflet │ │ │ ├── images │ │ │ └── 1px.png │ │ │ └── rstudio_leaflet.css │ └── plugins │ │ ├── Leaflet-MiniMap │ │ ├── Control.MiniMap.css │ │ ├── Control.MiniMap.js │ │ ├── Control.MiniMap.min.css │ │ ├── Control.MiniMap.min.js │ │ ├── Minimap-binding.js │ │ └── images │ │ │ ├── toggle.png │ │ │ └── toggle.svg │ │ ├── Leaflet.EasyButton │ │ ├── EasyButton-binding.js │ │ ├── LICENSE │ │ ├── easy-button.css │ │ └── easy-button.js │ │ ├── Leaflet.Graticule │ │ ├── Graticule-binding.js │ │ ├── L.Graticule.js │ │ └── Leaflet.Graticule.js │ │ ├── Leaflet.SimpleGraticule │ │ ├── L.SimpleGraticule.css │ │ ├── L.SimpleGraticule.js │ │ └── SimpleGraticule-binding.js │ │ ├── Leaflet.Terminator │ │ ├── L.Terminator.js │ │ └── Terminator-binding.js │ │ ├── Leaflet.awesome-markers │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.min.css │ │ ├── bootstrap.min.js │ │ ├── font-awesome.min.css │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ ├── ionicons.eot │ │ │ ├── ionicons.svg │ │ │ ├── ionicons.ttf │ │ │ └── ionicons.woff │ │ ├── images │ │ │ ├── markers-matte.png │ │ │ ├── markers-matte@2x.png │ │ │ ├── markers-plain.png │ │ │ ├── markers-shadow.png │ │ │ ├── markers-shadow@2x.png │ │ │ ├── markers-soft.png │ │ │ └── markers-soft@2x.png │ │ ├── ionicons.min.css │ │ ├── leaflet.awesome-markers.css │ │ ├── leaflet.awesome-markers.js │ │ └── leaflet.awesome-markers.min.js │ │ ├── Leaflet.markercluster │ │ ├── MIT-LICENCE.txt │ │ ├── MarkerCluster.Default.css │ │ ├── MarkerCluster.css │ │ ├── leaflet.markercluster-src.js │ │ ├── leaflet.markercluster.freezable-src.js │ │ ├── leaflet.markercluster.freezable.js │ │ ├── leaflet.markercluster.js │ │ ├── leaflet.markercluster.layersupport-src.js │ │ ├── leaflet.markercluster.layersupport-src.js.map │ │ ├── leaflet.markercluster.layersupport.js │ │ └── package.json │ │ ├── Proj4Leaflet │ │ ├── proj4.min.js │ │ └── proj4leaflet.js │ │ ├── leaflet-locationfilter │ │ ├── img │ │ │ ├── filter-icon.png │ │ │ ├── move-handle.png │ │ │ └── resize-handle.png │ │ ├── locationfilter-bindings.js │ │ ├── locationfilter.css │ │ └── locationfilter.js │ │ └── leaflet-providers-plugin │ │ └── leaflet-providers-plugin.js └── legacy │ ├── examples │ ├── choropleth │ │ ├── DESCRIPTION │ │ ├── Rplots.pdf │ │ ├── global.R │ │ ├── server.R │ │ ├── shinyapps │ │ │ └── jcheng │ │ │ │ └── choropleth3.dcf │ │ └── ui.R │ ├── geojson │ │ ├── server.R │ │ └── ui.R │ └── population │ │ ├── server.R │ │ ├── ui.R │ │ └── www │ │ └── styles.css │ └── www │ ├── binding.js │ ├── images │ ├── layers-2x.png │ ├── layers.png │ ├── marker-icon-2x.png │ ├── marker-icon.png │ └── marker-shadow.png │ ├── leaflet-src.js │ ├── leaflet.css │ └── leaflet.js ├── javascript ├── src │ ├── cluster-layer-store.js │ ├── control-store.js │ ├── crs_utils.js │ ├── dataframe.js │ ├── fixup-default-icon.js │ ├── fixup-default-tooltip.js │ ├── fixup-url-protocol.js │ ├── global │ │ ├── htmlwidgets.js │ │ ├── jquery.js │ │ ├── leaflet.js │ │ ├── proj4leaflet.js │ │ └── shiny.js │ ├── index.js │ ├── layer-manager.js │ ├── methods.js │ ├── mipmapper.js │ └── util.js └── tests │ └── test-dataframe.js ├── leaflet.Rproj ├── man-roxygen └── data-getMapData.R ├── man ├── aaa-test-viztest.Rd ├── addAwesomeMarkers.Rd ├── addGraticule.Rd ├── addLayersControl.Rd ├── addLegend.Rd ├── addMapPane.Rd ├── addMeasure.Rd ├── addMiniMap.Rd ├── addProviderTiles.Rd ├── addRasterImage.Rd ├── addRasterLegend.Rd ├── addScaleBar.Rd ├── addSimpleGraticule.Rd ├── addTerminator.Rd ├── atlStorms2005.Rd ├── awesomeIconList.Rd ├── awesomeIcons.Rd ├── breweries91.Rd ├── colorNumeric.Rd ├── deprecated.Rd ├── derivePoints.Rd ├── dispatch.Rd ├── easyButton.Rd ├── evalFormula.Rd ├── expandLimits.Rd ├── expandLimitsBbox.Rd ├── filterNULL.Rd ├── gadmCHE.Rd ├── getMapData.Rd ├── groupOptions.Rd ├── iconList.Rd ├── icons.Rd ├── leaflet-package.Rd ├── leaflet.Rd ├── leafletDependencies.Rd ├── leafletProxy.Rd ├── leafletSizingPolicy.Rd ├── makeAwesomeIcon.Rd ├── makeIcon.Rd ├── map-layers.Rd ├── map-methods.Rd ├── map-options.Rd ├── map-shiny.Rd ├── mapOptions.Rd ├── previewColors.Rd ├── providers.Rd ├── reexports.Rd ├── remove.Rd ├── safeLabel.Rd ├── showGroup.Rd └── validateCoords.Rd ├── package.json ├── pkgdown ├── _pkgdown.yml └── assets │ ├── json │ ├── countries.geojson │ ├── nycounties.geojson │ ├── us-10m.json │ └── us-states.geojson │ └── nc │ └── oisst-sst.nc ├── revdep ├── .gitignore ├── README.md ├── cran.md ├── failures.md └── problems.md ├── scripts ├── crosstalk_example.R ├── git_clean.R ├── raster.R ├── scratch.Rmd ├── viztest.R └── viztest_testing_notes.md ├── tests ├── testthat.R └── testthat │ ├── _snaps │ ├── normalize-2.md │ └── remote.md │ ├── helper.R │ ├── test-colors.R │ ├── test-evalFormula.R │ ├── test-icon.R │ ├── test-legend.R │ ├── test-measure.R │ ├── test-normalize-2.R │ ├── test-normalize-3.R │ ├── test-normalize.R │ ├── test-raster.R │ ├── test-remote.R │ └── test-tiles.R ├── vignettes ├── .gitignore └── articles │ ├── basemaps.Rmd │ ├── choropleths.Rmd │ ├── colors.Rmd │ ├── extending.Rmd │ ├── images │ ├── shiny1.png │ ├── shiny2.png │ └── shiny3.png │ ├── js │ └── Bing.min.js │ ├── json.Rmd │ ├── leaflet.Rmd │ ├── legends.Rmd │ ├── markers.Rmd │ ├── morefeatures.Rmd │ ├── nc │ └── oisst-sst.nc │ ├── popups.Rmd │ ├── projections.Rmd │ ├── raster.Rmd │ ├── shapes.Rmd │ ├── shiny.Rmd │ ├── showhide.Rmd │ ├── shp │ ├── cb_2013_us_state_20m.dbf │ ├── cb_2013_us_state_20m.prj │ ├── cb_2013_us_state_20m.shp │ ├── cb_2013_us_state_20m.shp.iso.xml │ ├── cb_2013_us_state_20m.shp.xml │ ├── cb_2013_us_state_20m.shx │ └── state_20m.ea.iso.xml │ └── widget.Rmd └── yarn.lock /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | ^inst/csv 5 | ^inst/examples 6 | ^inst/htmlwidgets/sources 7 | \.bower\.json$ 8 | \.bowerrc$ 9 | ^docs$ 10 | ^\.eslintrc\.json$ 11 | ^Gruntfile\.js$ 12 | ^javascript$ 13 | ^package\.json$ 14 | ^node_modules$ 15 | ^data-raw$ 16 | ^yarn\.lock$ 17 | ^\.Rprofile\.local$ 18 | ^inst/htmlwidgets/lib/.*/.*\.map$ 19 | ^inst/htmlwidgets/plugins/.*/.*\.map$ 20 | ^inst/htmlwidgets/lib/jquery/jquery.js$ 21 | ^inst/htmlwidgets/lib/leaflet/leaflet-src.js$ 22 | ^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js$ 23 | ^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js$ 24 | ^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js$ 25 | ^inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js$ 26 | ^inst/htmlwidgets/plugins/Proj4Leaflet/proj4.js$ 27 | ^\.lintr$ 28 | ^\.github$ 29 | ^man-roxygen$ 30 | ^viztest-.* 31 | ^scripts$ 32 | ^cran-comments\.md$ 33 | ^revdep$ 34 | ^CRAN-SUBMISSION$ 35 | ^_dev$ 36 | ^vignettes/articles$ 37 | ^pkgdown$ 38 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | {"directory": "inst/htmlwidgets/lib"} -------------------------------------------------------------------------------- /.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 | } -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to `{leaflet}` 2 | 3 | We welcome contributions to the `{leaflet}` package! 4 | 5 | To submit a contribution: 6 | 7 | 1. [Fork](https://github.com/rstudio/leaflet/fork) the repository and make your changes. 8 | 9 | 2. Ensure that you have signed the [individual](https://www.rstudio.com/wp-content/uploads/2014/06/rstudioindividualcontributoragreement.pdf) or [corporate](https://www.rstudio.com/wp-content/uploads/2014/06/rstudiocorporatecontributoragreement.pdf) contributor agreement as appropriate. You can send the signed copy to contribute@rstudio.com. 10 | 11 | 3. Submit a [pull request](https://help.github.com/articles/using-pull-requests). 12 | 13 | We generally do not merge pull requests that update included web libraries (such as Bootstrap or jQuery) because it is difficult for us to verify that the update is done correctly; we prefer to update these libraries ourselves. 14 | 15 | 16 | ## How to make changes 17 | 18 | Before you submit a pull request, please do the following: 19 | 20 | * Add an entry to NEWS concisely describing what you changed. 21 | 22 | * If appropriate, add unit tests in the tests/ directory. 23 | 24 | * Run Build->Check Package in the RStudio IDE, or `devtools::check()`, to make sure your change did not add any messages, warnings, or errors. 25 | 26 | Doing these things will make it easier for the leaflet development team to evaluate your pull request. Even so, we may still decide to modify your code or even not merge it at all. Factors that may prevent us from merging the pull request include: 27 | 28 | * breaking backward compatibility 29 | * adding a feature that we do not consider relevant for leaflet 30 | * is hard to understand 31 | * is hard to maintain in the future 32 | * is computationally expensive 33 | * is not intuitive for people to use 34 | 35 | We will try to be responsive and provide feedback in case we decide not to merge your pull request. 36 | 37 | 38 | ## Filing issues 39 | 40 | If you find a bug in leaflet, you can also [file an issue](https://github.com/rstudio/leaflet/issues/new). Please provide as much relevant information as you can, and include a minimal reproducible example if possible. 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please briefly describe your problem and what output you expect. If you have a question, please try using StackOverflow first. 2 | 3 | Please include a minimal reprex. The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it. If you've never heard of a reprex before, start by reading , and follow the advice further down the page. Do NOT include session info unless it's explicitly asked for, or you've used `reprex::reprex(..., session_info = TRUE)` to hide it away. Make sure to have `webshot` installed to have `reprex` produces images of the leaflet htmlwidgets. 4 | ```r 5 | # make sure webshot is installed to take pictures of htmlwidgets 6 | if (!("webshot" %in% installed.packages()[, "Package"])) { 7 | install.packages("webshot") 8 | # restart R process to fully integrate with knitr 9 | } 10 | reprex::reprex({ 11 | library(leaflet) 12 | # insert reprex here 13 | leaflet() %>% addTiles() 14 | }) 15 | ``` 16 | 17 | Delete these instructions once you have read them. 18 | 19 | --- 20 | 21 | Brief description of the problem 22 | 23 | ```r 24 | library(leaflet) 25 | # insert reprex here 26 | leaflet() %>% addTiles() 27 | ``` 28 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Pull Request 2 | 3 | Before you submit a pull request, please do the following: 4 | 5 | * Add an entry to NEWS concisely describing what you changed. 6 | 7 | * If appropriate, add unit tests in the tests/testthat directory. 8 | 9 | * Run Build->Check Package in the RStudio IDE, or `devtools::check()`, to make sure your change did not add any messages, warnings, or errors. 10 | 11 | Doing these things will make it easier for the leaflet development team to evaluate your pull request. Even so, we may still decide to modify your code or even not merge it at all. Factors that may prevent us from merging the pull request include: 12 | 13 | * breaking backward compatibility 14 | * adding a feature that we do not consider relevant for leaflet 15 | * is hard to understand 16 | * is hard to maintain in the future 17 | * is computationally expensive 18 | * is not intuitive for people to use 19 | 20 | We will try to be responsive and provide feedback in case we decide not to merge your pull request. 21 | 22 | ## Minimal reproducible example 23 | 24 | Finally, please include a minimal reprex. The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it. If you've never heard of a reprex before, start by reading , and follow the advice further down the page. Do NOT include session info unless it's explicitly asked for, or you've used `reprex::reprex(..., session_info = TRUE)` to hide it away. Make sure to have `webshot` installed to have `reprex` produces images of the leaflet htmlwidgets. 25 | ```r 26 | # make sure webshot is installed to take pictures of htmlwidgets 27 | if (!("webshot" %in% installed.packages()[, "Package"])) { 28 | install.packages("webshot") 29 | # restart R process to fully integrate with knitr 30 | } 31 | reprex::reprex({ 32 | library(leaflet) 33 | # insert reprex here 34 | leaflet() %>% addTiles() 35 | }) 36 | ``` 37 | 38 | Delete these instructions once you have read them. 39 | 40 | --- 41 | 42 | Brief description of the solution 43 | 44 | ```r 45 | # insert reprex here 46 | ``` 47 | 48 | PR task list: 49 | - [ ] Update NEWS 50 | - [ ] Add tests (where appropriate) 51 | - R code tests: `tests/testthat/` 52 | - Visual tests: `R/zzz_viztest.R` 53 | - [ ] Update documentation with `devtools::document()` 54 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/rstudio/shiny-workflows 2 | # 3 | # NOTE: This Shiny team GHA workflow is overkill for most R packages. 4 | # For most R packages it is better to use https://github.com/r-lib/actions 5 | on: 6 | push: 7 | branches: [main, rc-**] 8 | pull_request: 9 | branches: [main] 10 | schedule: 11 | - cron: '0 7 * * 1' # every monday 12 | 13 | name: Package checks 14 | 15 | jobs: 16 | website: 17 | uses: rstudio/shiny-workflows/.github/workflows/website.yaml@v1 18 | routine: 19 | uses: rstudio/shiny-workflows/.github/workflows/routine.yaml@v1 20 | with: 21 | node-version: '12' 22 | R-CMD-check: 23 | uses: rstudio/shiny-workflows/.github/workflows/R-CMD-check.yaml@v1 24 | with: 25 | minimum-r-version: "3.5.0" 26 | ubuntu: "ubuntu-20.04" 27 | -------------------------------------------------------------------------------- /.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 | revdep/checks.noindex 11 | revdep/library.noindex 12 | revdep/data.sqlite 13 | viztest-* 14 | inst/doc 15 | docs 16 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | grunt.initConfig({ 3 | babel: { 4 | options: { 5 | sourceMap: true, 6 | presets: ["@babel/preset-env"], 7 | plugins: ["transform-es2015-modules-commonjs"], 8 | }, 9 | dist: { 10 | files: [ 11 | { 12 | expand: true, 13 | cwd: "javascript/src", 14 | src: ["**/*.js"], 15 | dest: "inst/htmlwidgets/sources", 16 | ext: ".js", 17 | }, 18 | ], 19 | }, 20 | distSpecs: { 21 | files: [ 22 | { 23 | expand: true, 24 | cwd: "javascript/tests", 25 | src: ["**/*.js"], 26 | dest: "inst/htmlwidgets/sources", 27 | ext: ".js", 28 | }, 29 | ], 30 | }, 31 | }, 32 | browserify: { 33 | options: { 34 | browserifyOptions: { 35 | //debug: true 36 | }, 37 | }, 38 | dist: { 39 | files: { 40 | // if the source file has an extension of es6 then 41 | // we change the name of the source file accordingly. 42 | // The result file's extension is always .js 43 | "./inst/htmlwidgets/assets/leaflet.js": [ 44 | "./inst/htmlwidgets/sources/index.js", 45 | ], 46 | }, 47 | }, 48 | }, 49 | eslint: { 50 | target: ["./javascript/src/*.js"], 51 | }, 52 | mochaTest: { 53 | test: { 54 | options: { 55 | reporter: "spec", 56 | require: ["babel-register", "source-map-support/register"], 57 | // captureFile: 'results.txt', // Optionally capture the reporter output to a file 58 | quiet: false, // Optionally suppress output to standard out (defaults to false) 59 | clearRequireCache: false, // Optionally clear the require cache before running tests (defaults to false) 60 | }, 61 | src: ["inst/htmlwidgets/sources/test-*.js"], 62 | }, 63 | }, 64 | watch: { 65 | scripts: { 66 | files: ["./javascript/src/**/*.js", "javascript/tests/**/*.js"], 67 | tasks: ["babel", "browserify", "eslint", "mochaTest"], 68 | }, 69 | }, 70 | }); 71 | 72 | grunt.loadNpmTasks("grunt-babel"); 73 | grunt.loadNpmTasks("grunt-browserify"); 74 | grunt.loadNpmTasks("grunt-contrib-watch"); 75 | grunt.loadNpmTasks("grunt-eslint"); 76 | grunt.loadNpmTasks("grunt-mocha-test"); 77 | 78 | grunt.registerTask("default", ["watch"]); 79 | grunt.registerTask("build", ["babel", "browserify", "eslint", "mochaTest"]); 80 | }; 81 | -------------------------------------------------------------------------------- /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"`, 4 | #' `"bottomleft"`, or `"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 | -------------------------------------------------------------------------------- /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 `City`, `State`, `Lat`, 7 | #' `Long`, and population estimates from 2000 to 2010 (columns 8 | #' `Pop2000` to `Pop2010`). 9 | #' @family built in datasets 10 | #' @source The US Census Bureau: 11 | #' 12 | #' @noRd 13 | #' @examples 14 | #' str(uspop2000) 15 | #' p = uspop2000$Pop2010 16 | #' p = (p - min(p))/(max(p) - min(p)) 17 | #' plot(Lat ~ Long, data = uspop2000, cex = sqrt(p), asp = 1, col = rgb(1, 0, 0, .3)) 18 | 19 | if (FALSE) { 20 | uspop2000 <- NULL 21 | if (file.exists("inst/csv/uspop2000.csv")) { 22 | uspop2000 <- utils::read.csv( 23 | text = readLines("inst/csv/uspop2000.csv", encoding = "UTF-8"), 24 | stringsAsFactors = FALSE 25 | ) 26 | } 27 | } 28 | 29 | #' @docType data 30 | #' @name atlStorms2005 31 | #' @title Atlantic Ocean storms 2005 32 | #' @description Atlantic Ocean storms 2005 33 | #' @details This dataset contains storm tracks for selected storms 34 | #' in the Atlantic Ocean basin for the year 2005 35 | #' @format `sf` object 36 | #' @family built in datasets 37 | NULL 38 | 39 | #' @docType data 40 | #' @name gadmCHE 41 | #' @title Administrative borders of Switzerland (level 1) 42 | #' @description Administrative borders of Switzerland (level 1) 43 | #' @details This dataset comes from . 44 | #' It was downloaded using [raster::getData()]. 45 | #' @format `sf` object 46 | #' @family built in datasets 47 | #' @source 48 | #' 49 | NULL 50 | 51 | #' 52 | #' @docType data 53 | #' @name breweries91 54 | #' @title Selected breweries in Franconia 55 | #' @description Selected breweries in Franconia (zip code starting with 91...) 56 | #' @details This dataset contains selected breweries in Franconia. It is a 57 | #' subset of a larger database that was compiled by students at the 58 | #' University of Marburg for a seminar called 59 | #' "The Geography of Beer, sustainability in the food industry" 60 | #' @format `sf` object 61 | #' @family built in datasets 62 | NULL 63 | -------------------------------------------------------------------------------- /R/leaflet-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | 4 | ## usethis namespace: start 5 | #' @importFrom grDevices col2rgb 6 | #' @importFrom grDevices rgb 7 | #' @importFrom methods substituteDirect 8 | #' @importFrom stats na.omit 9 | #' @importFrom stats quantile 10 | #' @importFrom utils getFromNamespace 11 | #' @importFrom utils packageVersion 12 | #' @importFrom rlang is_installed 13 | ## usethis namespace: end 14 | NULL 15 | 16 | ## Re-exports 17 | #' @importFrom magrittr %>% 18 | #' @export 19 | magrittr::`%>%` 20 | #' @importFrom htmlwidgets JS 21 | #' @export 22 | htmlwidgets::JS 23 | 24 | # Added to the `use_release_issue()` checklist 25 | release_bullets <- function() { 26 | c( 27 | "Update static imports: `staticimports::import()`", 28 | 'Check Super Zip example: `shiny::runGitHub("rstudio/shiny-examples", subdir = "063-superzip-example")`', 29 | "Check licenses if bundled dependencies were updated", 30 | '`source("scripts/viztest.R")`' 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /R/normalize-SharedData.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | metaData.SharedData <- function(obj) { 3 | metaData(obj$data(withSelection = FALSE, 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /R/normalize-terra.R: -------------------------------------------------------------------------------- 1 | # metaData ---------------------------------------------------------------- 2 | 3 | #' @export 4 | metaData.SpatVector <- function(obj) { 5 | data.frame(obj) 6 | } 7 | 8 | 9 | #' @export 10 | pointData.SpatVector <- function(obj) { 11 | check_crs_terra(obj) 12 | xy = data.frame(terra::crds(obj)) 13 | names(xy) = c("lng", "lat") 14 | structure( 15 | xy, 16 | bbox = terra_bbox(obj) 17 | ) 18 | } 19 | 20 | 21 | # polygonData ------------------------------------------------------------- 22 | 23 | #' @export 24 | polygonData.SpatVector <- function(obj) { 25 | check_crs_terra(obj) 26 | 27 | xy = data.frame(terra::geom(obj)) 28 | names(xy)[3:4] = c("lng", "lat") 29 | xy = split(xy[,2:5], xy[,1]) # polygons 30 | names(xy) = NULL # won't work with names 31 | xy = lapply(xy, function(p) { 32 | d = split(p[,-1], p[,1]) # parts 33 | names(d) = NULL 34 | lapply(d, function(p) { # ring and holes 35 | s = split(p[,1:2], p[,3]) 36 | names(s) = NULL 37 | lapply(s, function(i) { rownames(i) = NULL; i }) # for expect_maps_equal 38 | }) 39 | }) 40 | 41 | # with terra >= 1.5-50 you can do this instead 42 | # xy = terra::geom(obj, list=TRUE, xnm="lng", ynm="lat") 43 | 44 | structure( 45 | xy, 46 | bbox = terra_bbox(obj) 47 | ) 48 | } 49 | 50 | 51 | 52 | # helpers ----------------------------------------------------------------- 53 | check_crs_terra <- function(x) { 54 | rlang::check_installed("terra") 55 | crs <- terra::crs(x) 56 | 57 | # Don't have enough information to check 58 | if (is.na(crs) || (crs=="")) 59 | return() 60 | 61 | if (identical(terra::is.lonlat(x), FALSE)) { 62 | warning("SpatVector layer is not long-lat data", call. = FALSE) 63 | } 64 | 65 | prj <- terra::crs(x, proj=TRUE) 66 | if (!grepl("+datum=WGS84", prj, fixed = TRUE)) { 67 | warning( 68 | "SpatVector layer has inconsistent datum (", prj, ").\n", 69 | "Need '+proj=longlat +datum=WGS84'", 70 | call. = FALSE 71 | ) 72 | } 73 | 74 | } 75 | 76 | 77 | terra_bbox <- function(x) { 78 | structure( 79 | matrix(as.vector(terra::ext(x)), ncol = 2, byrow = TRUE), 80 | dimnames = list(c("lng", "lat"), NULL) 81 | ) 82 | } 83 | -------------------------------------------------------------------------------- /R/plugin-graticule.R: -------------------------------------------------------------------------------- 1 | leafletGraticuleDependencies <- function() { 2 | list( 3 | htmltools::htmlDependency( 4 | "leaflet-graticule", 5 | "0.1.0", 6 | "htmlwidgets/plugins/Leaflet.Graticule", 7 | package = "leaflet", 8 | script = c("L.Graticule.js", "Graticule-binding.js") 9 | ) 10 | ) 11 | } 12 | 13 | #' Add a Graticule on the map 14 | #' 15 | #' @seealso 16 | #' @param map a map widget object 17 | #' @param interval The spacing in map units between horizontal and vertical lines. 18 | #' @param sphere boolean. Default `FALSE` 19 | #' @param style path options for the generated lines. See 20 | #' @param layerId the layer id 21 | #' @param group the name of the group this layer belongs to. 22 | #' @param options the path options for the graticule layer 23 | #' @examples 24 | #' leaf <- leaflet() %>% 25 | #' addTiles() %>% 26 | #' addGraticule() 27 | #' leaf 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-omnivore.R: -------------------------------------------------------------------------------- 1 | leafletOmnivoreDependencies <- function() { 2 | list( 3 | htmltools::htmlDependency( 4 | "leaflet-omnivore", 5 | "0.3.3", 6 | "htmlwidgets/lib/leaflet-omnivore", 7 | package = "leaflet", 8 | script = "leaflet-omnivore.min.js" 9 | ) 10 | ) 11 | } 12 | 13 | 14 | #' @param topojson a TopoJSON list, or character vector of length 1 15 | #' @describeIn map-layers Add TopoJSON layers to the map 16 | #' @export 17 | addTopoJSON <- function(map, topojson, layerId = NULL, group = NULL, 18 | stroke = TRUE, 19 | color = "#03F", 20 | weight = 5, 21 | opacity = 0.5, 22 | fill = TRUE, 23 | fillColor = color, 24 | fillOpacity = 0.2, 25 | dashArray = NULL, 26 | smoothFactor = 1.0, 27 | noClip = FALSE, 28 | options = pathOptions() 29 | ) { 30 | map$dependencies <- c(map$dependencies, leafletOmnivoreDependencies()) 31 | options <- c(options, list( 32 | stroke = stroke, color = color, weight = weight, opacity = opacity, 33 | fill = fill, fillColor = fillColor, fillOpacity = fillOpacity, 34 | dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip 35 | )) 36 | invokeMethod(map, getMapData(map), "addTopoJSON", topojson, layerId, group, options) 37 | } 38 | 39 | #' @rdname remove 40 | #' @export 41 | removeTopoJSON <- function(map, layerId) { 42 | invokeMethod(map, getMapData(map), "removeTopoJSON", layerId) 43 | } 44 | 45 | #' @rdname remove 46 | #' @export 47 | clearTopoJSON <- function(map) { 48 | invokeMethod(map, NULL, "clearTopoJSON") 49 | } 50 | -------------------------------------------------------------------------------- /R/plugin-simplegraticule.R: -------------------------------------------------------------------------------- 1 | leafletSimpleGraticuleDependencies <- function() { 2 | list( 3 | htmltools::htmlDependency( 4 | "leaflet-simplegraticule", 5 | "0.1.0", 6 | "htmlwidgets/plugins/Leaflet.SimpleGraticule", 7 | package = "leaflet", 8 | script = c("L.SimpleGraticule.js", "SimpleGraticule-binding.js"), 9 | stylesheet = "L.SimpleGraticule.css" 10 | ) 11 | ) 12 | } 13 | 14 | #' Add a simple Graticule on the map 15 | #' 16 | #' @seealso 17 | #' @param map a map widget object 18 | #' @param interval The spacing in map units between horizontal and vertical lines. 19 | #' @param showOriginLabel true Whether or not to show '(0,0)' at the origin. 20 | #' @param redraw on which map event to redraw the graticule. On move is default but `"moveend"` can be smoother. 21 | #' @param hidden hide on start 22 | #' @param zoomIntervals use different intervals in different zoom levels. If not specified, all zoom levels use value in interval option. 23 | #' @param layerId the layer id 24 | #' @param group the name of the group this layer belongs to. 25 | #' @examples 26 | #' \donttest{leaflet() %>% 27 | #' addTiles() %>% 28 | #' addSimpleGraticule()} 29 | #' 30 | #' @export 31 | addSimpleGraticule <- function( 32 | map, 33 | interval = 20, 34 | showOriginLabel = TRUE, 35 | redraw = "move", 36 | hidden = FALSE, 37 | zoomIntervals = list(), 38 | layerId = NULL, 39 | group = NULL 40 | ) { 41 | map$dependencies <- c(map$dependencies, leafletSimpleGraticuleDependencies()) 42 | invokeMethod( 43 | map 44 | , getMapData(map) 45 | , "addSimpleGraticule" 46 | , interval 47 | , showOriginLabel 48 | , redraw 49 | , hidden 50 | , zoomIntervals 51 | , layerId 52 | , group 53 | ) 54 | } 55 | -------------------------------------------------------------------------------- /R/plugin-terminator.R: -------------------------------------------------------------------------------- 1 | leafletTerminatorDependencies <- function() { 2 | list( 3 | htmltools::htmlDependency( 4 | "leaflet-terminator", 5 | "0.1.0", 6 | "htmlwidgets/plugins/Leaflet.Terminator", 7 | package = "leaflet", 8 | script = c("L.Terminator.js", "Terminator-binding.js") 9 | ) 10 | ) 11 | } 12 | 13 | #' Add a daylight layer on top of the map 14 | #' 15 | #' See 16 | #' 17 | #' @param map a map widget object 18 | #' @param resolution the step size at which the terminator points are computed. 19 | #' The step size is 1 degree/resolution, i.e., higher resolution values have 20 | #' smaller step sizes and more points in the polygon. The default value is 2. 21 | #' @param time Time 22 | #' @param layerId the layer id 23 | #' @param group the name of the group this layer belongs to. 24 | #' @param options the path options for the daynight layer 25 | #' @examples 26 | #' leaf <- leaflet() %>% 27 | #' addTiles() %>% 28 | #' addTerminator() 29 | #' leaf 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 | -------------------------------------------------------------------------------- /R/scalebar.R: -------------------------------------------------------------------------------- 1 | #' Add or remove a scale bar 2 | #' 3 | #' Uses Leaflet's built-in 4 | #' [scale bar](https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#control-scale) 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 `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 `TRUE` (the default), show a scale bar in metric units 32 | #' (m/km) 33 | #' @param imperial if `TRUE` (the default), show a scale bar in imperial 34 | #' units (ft/mi) 35 | #' @param updateWhenIdle if `FALSE` (the default), the scale bar is always 36 | #' up-to-date (updated on `move`). If `TRUE`, the control is updated 37 | #' on `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 | -------------------------------------------------------------------------------- /R/selection.R: -------------------------------------------------------------------------------- 1 | locationFilter2Dependencies <- function() { 2 | list( 3 | htmltools::htmlDependency( 4 | "leaflet-locationfilter2", 5 | "0.1.1", 6 | "htmlwidgets/plugins/leaflet-locationfilter", 7 | package = "leaflet", 8 | script = c("locationfilter.js", "locationfilter-bindings.js"), 9 | stylesheet = c("locationfilter.css") 10 | ) 11 | ) 12 | } 13 | 14 | addSelect <- function(map, data = getMapData(map)) { 15 | map$dependencies <- c(map$dependencies, 16 | leafletEasyButtonDependencies(), 17 | locationFilter2Dependencies()) 18 | map <- addIonIcon(map) 19 | 20 | invokeMethod(map, data, "addSelect", 21 | getCrosstalkOptions(data)[["ctGroup"]] 22 | ) 23 | } 24 | 25 | removeSelect <- function(map) { 26 | invokeMethod(map, NULL, "removeSelect") 27 | } 28 | -------------------------------------------------------------------------------- /R/shiny.R: -------------------------------------------------------------------------------- 1 | #' Wrapper functions for using \pkg{leaflet} in \pkg{shiny} 2 | #' 3 | #' Use `leafletOutput()` to create a UI element, and `renderLeaflet()` 4 | #' to render the map widget. 5 | #' @inheritParams htmlwidgets::shinyWidgetOutput 6 | #' @param width,height the width and height of the map (see 7 | #' [htmlwidgets::shinyWidgetOutput()]) 8 | #' @rdname map-shiny 9 | #' @export 10 | #' @examples # !formatR 11 | #' library(shiny) 12 | #' app <- shinyApp( 13 | #' ui = fluidPage(leafletOutput('myMap')), 14 | #' server = function(input, output) { 15 | #' map = leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17) 16 | #' output$myMap = renderLeaflet(map) 17 | #' } 18 | #' ) 19 | #' 20 | #' \donttest{if (interactive()) app} 21 | leafletOutput <- function(outputId, width = "100%", height = 400) { 22 | htmltools::attachDependencies( 23 | htmlwidgets::shinyWidgetOutput(outputId, "leaflet", width, height, "leaflet"), 24 | leafletBindingDependencies(), 25 | append = TRUE 26 | ) 27 | } 28 | 29 | # use expr description from htmlwidgets to avoid bad inherit params code 30 | #' @param expr An expression that generates an HTML widget (or a 31 | #' [promise](https://rstudio.github.io/promises/) of an HTML widget). 32 | #' @rdname map-shiny 33 | #' @export 34 | renderLeaflet <- function(expr, env = parent.frame(), quoted = FALSE) { 35 | if (!quoted) expr <- substitute(expr) # force quoted 36 | htmlwidgets::shinyRenderWidget(expr, leafletOutput, env, quoted = TRUE) 37 | } 38 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | leaflet_envir <- environment() 2 | .onLoad <- function(...) { 3 | makeActiveBinding("providers", function() { 4 | leaflet.providers::providers_loaded()$providers 5 | }, env = leaflet_envir) 6 | 7 | makeActiveBinding("providers.details", function() { 8 | leaflet.providers::providers_loaded()$providers_details 9 | }, env = leaflet_envir) 10 | 11 | makeActiveBinding("providers.version_num", function() { 12 | leaflet.providers::providers_loaded()$version_num 13 | }, env = leaflet_envir) 14 | 15 | makeActiveBinding("providers.src", function() { 16 | leaflet.providers::providers_loaded()$src 17 | }, env = leaflet_envir) 18 | 19 | makeActiveBinding("providers.dep", function() { 20 | leaflet.providers::providers_loaded()$dep 21 | }, env = leaflet_envir) 22 | } 23 | -------------------------------------------------------------------------------- /R/zzz_viztest.R: -------------------------------------------------------------------------------- 1 | #' Visual Testing scripts for vistest 2 | #' 3 | #' Visual testing examples to be used by the vistest package. 4 | #' 5 | #' @keywords internal 6 | #' @name aaa-test-viztest 7 | #' @rdname aaa-test-viztest 8 | #' @examples 9 | #' 10 | #' 11 | #' 12 | #' \donttest{ 13 | #' 14 | #' 15 | #' ### Start addGeoJSON properties - https://github.com/rstudio/leaflet/pull/625 16 | #' polygon = list( 17 | #' type = "Polygon", 18 | #' coordinates = list( 19 | #' list( 20 | #' c(8.330469, 48.261570), 21 | #' c(8.339052, 48.261570), 22 | #' c(8.339052, 48.258227), 23 | #' c(8.330469, 48.258227), 24 | #' c(8.330469, 48.261570) 25 | #' ) 26 | #' ) 27 | #' ) 28 | #' 29 | #' # should produce an orange-ish rectangle around `Ramsel` 30 | #' leaflet() %>% 31 | #' addTiles() %>% 32 | #' addGeoJSON(polygon, color="#F00") %>% 33 | #' setView(lng = 8.330469, lat = 48.26157, zoom = 15) 34 | #' ### End PR #625 35 | #' 36 | #' 37 | #' } # end donttest 38 | NULL 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # An R Interface to Leaflet Maps 2 | 3 | 4 | [![R build status](https://github.com/rstudio/leaflet/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rstudio/leaflet/actions) 5 | [![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/leaflet)](https://www.r-pkg.org/pkg/leaflet) 6 | [![](https://www.r-pkg.org/badges/version/leaflet)](https://www.r-pkg.org/pkg/leaflet) 7 | [![RStudio community](https://img.shields.io/badge/community-leaflet-blue?style=social&logo=rstudio&logoColor=75AADB)](https://forum.posit.co/new-topic?title=&tags=leaflet&body=%0A%0A%0A%20%20--------%0A%20%20%0A%20%20%3Csup%3EReferred%20here%20by%20%60leaflet%60%27s%20GitHub%3C/sup%3E%0A&u=barret) 8 | 9 | 10 | [Leaflet](https://leafletjs.com) is an open-source JavaScript library for 11 | interactive maps. This R package makes it easy to create Leaflet maps from R. 12 | 13 | ```r 14 | library(leaflet) 15 | m = leaflet() %>% addTiles() 16 | m # a map with the default OSM tile layer 17 | 18 | m = m %>% setView(-93.65, 42.0285, zoom = 17) 19 | m 20 | 21 | m %>% addPopups(-93.65, 42.0285, 'Here is the Department of Statistics, ISU') 22 | ``` 23 | 24 | ## Installation 25 | 26 | You can install this package from CRAN, or the development version from GitHub: 27 | 28 | ```r 29 | # CRAN version 30 | install.packages('leaflet') 31 | 32 | # Or Github version 33 | if (!require('devtools')) install.packages('devtools') 34 | devtools::install_github('rstudio/leaflet') 35 | ``` 36 | 37 | ## Documentation 38 | 39 | In addition to the usual R package documentation, we also have extensive docs and examples at: 40 | [https://rstudio.github.io/leaflet/](https://rstudio.github.io/leaflet/) 41 | 42 | ## Development 43 | 44 | `leaflet`'s JavaScript build tools use Node.js, along with [yarn](https://yarnpkg.com/) to manage the JavaScript packages. 45 | 46 | Install `yarn` using the [official instructions](https://classic.yarnpkg.com/en/docs/install). 47 | 48 | You can test that Node.js and yarn are installed properly by running the following commands: 49 | 50 | ```bash 51 | node --version 52 | yarn --version 53 | ``` 54 | 55 | To make additions or modifications to the JavaScript `htmlwidgets` binding layer, 56 | you must have all Node.js dependencies installed. Now you can build/minify/lint/test using `yarn build`, or run in "watch" mode 57 | by just running `yarn watch`. JS sources go into `javascript/src` and tests go into 58 | `javascript/tests`. 59 | 60 | ```bash 61 | # install dependencies 62 | yarn 63 | 64 | # compile 65 | yarn build 66 | 67 | # watch 68 | yarn watch 69 | ``` 70 | 71 | 72 | ## License 73 | 74 | This package is licensed to you under the terms of the [GNU General Public 75 | License](https://www.gnu.org/licenses/gpl-3.0.html) version 3 or later. 76 | 77 | Copyright 2013-2015 RStudio, Inc. 78 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Comments 2 | 3 | This is a small release to use the latest version of {leaflet.providers}. 4 | 5 | Please let us know if we can provide any more information. 6 | 7 | ## revdepcheck results 8 | 9 | We checked 163 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. 10 | 11 | * We saw 0 new problems 12 | * We failed to check 0 packages 13 | 14 | Issues with CRAN packages are summarised below. 15 | 16 | -------------------------------------------------------------------------------- /data-raw/atlStorms2005.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `atlStorms2005` dataset goes here 2 | # legacy script 3 | 4 | atlStorms2005 <- sf::st_as_sf(atlStorms2005) 5 | 6 | usethis::use_data(atlStorms2005, overwrite = TRUE) 7 | -------------------------------------------------------------------------------- /data-raw/breweries91.R: -------------------------------------------------------------------------------- 1 | ## code to prepare `breweries91` dataset goes here 2 | # legacy script 3 | breweries91 <- sf::st_as_sf(breweries91) 4 | usethis::use_data(breweries91, overwrite = TRUE) 5 | -------------------------------------------------------------------------------- /data-raw/gadmCHE.R: -------------------------------------------------------------------------------- 1 | 2 | # https://gadm.org/download_country.html 3 | # switzerland 4 | # rds 5 | # level 1 6 | # raster::getData() no longer works. geodata is recommended instead. 7 | gadmCHE <- raster::getData("GADM", country = "CHE", level = 1, path = tempdir()) 8 | 9 | gadmCHE$NAME_1 <- iconv(gadmCHE$NAME_1, "UTF-8", "ASCII//TRANSLIT") 10 | gadmCHE$VARNAME_1 <- iconv(gadmCHE$VARNAME_1, "UTF-8", "ASCII//TRANSLIT") 11 | 12 | usethis::use_data(gadmCHE, overwrite = TRUE) 13 | 14 | print(tools::showNonASCIIfile("data/gadmCHE.rda")) 15 | 16 | # Convert to sf object 17 | gadmCHE <- sf::st_as_sf(gadmCHE) 18 | -------------------------------------------------------------------------------- /data/atlStorms2005.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/data/atlStorms2005.rda -------------------------------------------------------------------------------- /data/breweries91.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/data/breweries91.rda -------------------------------------------------------------------------------- /data/gadmCHE.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/data/gadmCHE.rda -------------------------------------------------------------------------------- /inst/examples/awesomeMarkers.R: -------------------------------------------------------------------------------- 1 | library(leaflet) 2 | 3 | icon.glyphicon <- makeAwesomeIcon(icon = "flag", markerColor = "blue", 4 | iconColor = "black", library = "glyphicon", 5 | squareMarker = TRUE) 6 | icon.fa <- makeAwesomeIcon(icon = "flag", markerColor = "red", library = "fa", 7 | iconColor = "black") 8 | icon.ion <- makeAwesomeIcon(icon = "home", markerColor = "green", 9 | library = "ion") 10 | 11 | 12 | # Marker + Label 13 | leaflet() %>% addTiles() %>% 14 | addAwesomeMarkers( 15 | lng = -118.456554, lat = 34.078039, 16 | label = "This is a label", 17 | icon = icon.glyphicon) 18 | 19 | leaflet() %>% addTiles() %>% 20 | addAwesomeMarkers( 21 | lng = -118.456554, lat = 34.078039, 22 | label = "This is a label", 23 | icon = icon.fa) 24 | 25 | leaflet() %>% addTiles() %>% 26 | addAwesomeMarkers( 27 | lng = -118.456554, lat = 34.078039, 28 | label = "This is a label", 29 | icon = icon.ion) 30 | 31 | # Marker + Static Label using custom label options 32 | leaflet() %>% addTiles() %>% 33 | addAwesomeMarkers( 34 | lng = -118.456554, lat = 34.078039, 35 | label = "This is a static label", 36 | labelOptions = labelOptions(noHide = TRUE), 37 | icon = icon.fa) 38 | 39 | 40 | cities <- read.csv(textConnection(" 41 | City,Lat,Long,Pop 42 | Boston,42.3601,-71.0589,645966 43 | Hartford,41.7627,-72.6743,125017 44 | New York City,40.7127,-74.0059,8406000 45 | Philadelphia,39.9500,-75.1667,1553000 46 | Pittsburgh,40.4397,-79.9764,305841 47 | Providence,41.8236,-71.4222,177994 48 | ")) 49 | 50 | library(dplyr) 51 | cities <- cities %>% mutate(PopCat = ifelse(Pop < 500000, "blue", "red")) 52 | 53 | 54 | leaflet(cities) %>% addTiles() %>% 55 | addAwesomeMarkers(lng = ~Long, lat = ~Lat, 56 | label = ~City, 57 | icon = icon.ion) 58 | 59 | icon.pop <- awesomeIcons(icon = "users", 60 | markerColor = ifelse(cities$Pop < 500000, "blue", "red"), 61 | library = "fa", 62 | iconColor = "black") 63 | 64 | leaflet(cities) %>% addTiles() %>% 65 | addAwesomeMarkers(lng = ~Long, lat = ~Lat, 66 | label = ~City, 67 | icon = icon.pop) 68 | 69 | # Make a list of icons (from two different icon libraries). 70 | # We'll index into it based on name. 71 | popIcons <- awesomeIconList( 72 | blue = makeAwesomeIcon(icon = "user", library = "glyphicon", markerColor = "blue"), 73 | red = makeAwesomeIcon(icon = "users", library = "fa", markerColor = "red")) 74 | 75 | leaflet(cities) %>% addProviderTiles(providers$CartoDB.DarkMatter) %>% 76 | addAwesomeMarkers(lng = ~Long, lat = ~Lat, 77 | label = ~City, 78 | labelOptions = rep(labelOptions(noHide = TRUE), nrow(cities)), 79 | icon = ~popIcons[PopCat] ) 80 | -------------------------------------------------------------------------------- /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/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/examples/geojson.R: -------------------------------------------------------------------------------- 1 | library(leaflet) 2 | library(sp) 3 | #'

4 | #' The V8 part is simply to read the JSON embeded in the Javascript.
5 | #' For a geojson file `jsonlite::fromfromJSON()` or `geojsonio::regeojson_read()` will do 6 | #' 7 | jsURL <- "https://rawgit.com/Norkart/Leaflet-MiniMap/master/example/local_pubs_restaurant_norway.js" 8 | v8 <- V8::v8() 9 | v8$source(jsURL) 10 | geoJson <- geojsonio::as.json(v8$get("pubsGeoJSON")) 11 | 12 | # This is the kicker, convert geojson to a Spatial object. 13 | # This then allows us to use formulas in our markers, polygons etc. 14 | spdf <- geojsonio::geojson_sp(geoJson) 15 | 16 | icons <- awesomeIconList( 17 | pub = makeAwesomeIcon(icon = "glass", library = "fa", markerColor = "red"), 18 | restaurant = makeAwesomeIcon(icon = "cutlery", library = "fa", markerColor = "blue") 19 | ) 20 | 21 | leaflet() %>% 22 | addTiles() %>% 23 | setView(10.758276373601069, 59.92448055859924, 13) %>% 24 | addAwesomeMarkers( 25 | data = spdf, 26 | label = ~ stringr::str_c(amenity, ": ", name), 27 | icon = ~ icons[amenity], 28 | options = markerOptions(riseOnHover = TRUE, opacity = 0.75), 29 | group = "pubs" 30 | ) 31 | 32 | 33 | #'

34 | #' Another examples this time with polygons 35 | url <- "https://www.partners-popdev.org/wp-content/themes/original-child/vendor/Geojson/States/Maharashtra.geojson" 36 | 37 | mhSPDF <- geojsonio::geojson_read(url, what = "sp") 38 | 39 | cols <- colorFactor(topo.colors(nrow(mhSPDF)), mhSPDF$NAME_2) 40 | 41 | leaflet() %>% 42 | addProviderTiles(providers$CartoDB.Voyager) %>% 43 | setView(75.7139, 19.7515, 6) %>% 44 | addPolygons( 45 | data = mhSPDF, 46 | opacity = 5, 47 | label = ~NAME_2, 48 | weight = 1, 49 | fillColor = ~ cols(NAME_2) 50 | ) 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /inst/examples/groupOptions.R: -------------------------------------------------------------------------------- 1 | library(leaflet) 2 | pal <- colorQuantile("YlOrRd", quakes$mag) 3 | 4 | leaflet(quakes) %>% 5 | addProviderTiles(providers$Esri.OceanBasemap, group = "basic") %>% 6 | addCircleMarkers(group = "detail", fillOpacity = 0.5, 7 | radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>% 8 | addLegend(pal = pal, values = ~mag, group = "detail", position = "bottomleft") 9 | 10 | l <- leaflet(quakes) %>% 11 | addProviderTiles(providers$Esri.OceanBasemap, group = "basic") %>% 12 | addMarkers(data = quakes, group = "basic") %>% 13 | addCircleMarkers(group = "detail", fillOpacity = 0.5, 14 | radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>% 15 | addLegend(pal = pal, values = ~mag, group = "detail", position = "bottomleft") %>% 16 | groupOptions("detail", zoomLevels = 7:18) %>% 17 | addControl(htmltools::HTML("Zoom Level"), position = "topright", 18 | layerId = "zoom_display") 19 | 20 | # Just to show the zoom level 21 | htmlwidgets::onRender(l, jsCode = htmlwidgets::JS( 22 | "function(el, x) { 23 | debugger; 24 | var map = this; 25 | detailsControl = document.getElementById('zoom_display'); 26 | detailsControl.innerHTML = '
Zoom Level:'+map.getZoom()+'
'; 27 | map.on('zoomend', function(e) { 28 | detailsControl = document.getElementById('zoom_display'); 29 | detailsControl.innerHTML = '
Zoom Level:'+map.getZoom()+'
'; 30 | }); 31 | }")) 32 | -------------------------------------------------------------------------------- /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) # Requires rgdal / rgeos archived. 6 | library(leaflet) 7 | 8 | spdf <- rmapshaper::ms_simplify(usa_composite()) 9 | 10 | pal <- colorNumeric(palette = "Blues", domain = spdf@data$pop_2014) 11 | pal2 <- colorNumeric(palette = "Reds", domain = spdf@data$pop_2013) 12 | 13 | bounds <- c(-125, 24, -75, 45) 14 | 15 | leaflet( 16 | options = 17 | leafletOptions( 18 | worldCopyJump = FALSE, 19 | crs = leafletCRS( 20 | crsClass = "L.Proj.CRS", 21 | code = "EPSG:2163", 22 | proj4def = "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs", 23 | resolutions = c(65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128) 24 | ))) %>% 25 | fitBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>% 26 | setMaxBounds(bounds[1], bounds[2], bounds[3], bounds[4]) %>% 27 | addPolygons(data = spdf, weight = 1, color = "#000000", 28 | fillColor = ~pal(pop_2014), 29 | fillOpacity = 0.7, 30 | label = ~stringr::str_c( 31 | name, " ", 32 | formatC(pop_2014, big.mark = ",", format = "d")), 33 | labelOptions = labelOptions(direction = "auto"), 34 | highlightOptions = highlightOptions( 35 | color = "#ff0000", opacity = 1, weight = 2, fillOpacity = 1, 36 | bringToFront = TRUE, sendToBack = TRUE), 37 | group = "2014") %>% 38 | addPolygons(data = spdf, weight = 1, color = "#000000", 39 | fillColor = ~pal2(pop_2013), 40 | fillOpacity = 0.7, 41 | label = ~stringr::str_c( 42 | name, " ", 43 | formatC(pop_2014, big.mark = ",", format = "d")), 44 | labelOptions = labelOptions(direction = "auto"), 45 | highlightOptions = highlightOptions( 46 | color = "#00ff00", opacity = 1, weight = 2, fillOpacity = 1, 47 | bringToFront = TRUE, sendToBack = TRUE), 48 | group = "2013") %>% 49 | addLayersControl( 50 | baseGroups = c("2014", "2013"), 51 | position = "topleft", 52 | options = layersControlOptions(collapsed = FALSE) 53 | ) 54 | -------------------------------------------------------------------------------- /inst/examples/icons.R: -------------------------------------------------------------------------------- 1 | library(leaflet) 2 | 3 | # adapted from https://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("https://leafletjs.com/examples/custom-icons/leaf-%s.png", group), 16 | shadowUrl = "https://leafletjs.com/examples/custom-icons/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 | \donttest{ 24 | 25 | # use point symbols from base R graphics as icons 26 | pchIcons <- function(pch = 0:14, width = 30, height = 30, ...) { 27 | n <- length(pch) 28 | files <- character(n) 29 | # create a sequence of png images 30 | for (i in seq_len(n)) { 31 | f <- tempfile(fileext = ".png") 32 | png(f, width = width, height = height, bg = "transparent") 33 | par(mar = c(0, 0, 0, 0)) 34 | plot.new() 35 | points(.5, .5, pch = pch[i], cex = min(width, height) / 8, ...) 36 | dev.off() 37 | files[i] <- f 38 | } 39 | files 40 | } 41 | 42 | iconData <- matrix(rnorm(500), ncol = 2) 43 | res <- kmeans(iconData, 10) 44 | iconData <- cbind(iconData, res$cluster) 45 | colnames(iconData) <- c("lat", "lng", "group") 46 | iconData <- as.data.frame(iconData) 47 | 48 | # 10 random point shapes for the 10 clusters in iconData 49 | shapes <- sample(0:14, 10) 50 | iconFiles <- pchIcons(shapes, 40, 40, col = "steelblue", lwd = 2) 51 | 52 | # note the data has 250 rows, and there are 10 icons in iconFiles; they are 53 | # connected by the `group` variable: the i-th row of iconData uses the 54 | # group[i]-th icon in the icon list 55 | leaflet() %>% addMarkers( 56 | data = iconData, 57 | icon = ~ icons( 58 | iconUrl = iconFiles[group], 59 | popupAnchorX = 20, popupAnchorY = 0 60 | ), 61 | popup = ~ sprintf( 62 | "lat = %.4f, long = %.4f, group = %s, pch = %s", lat, lng, group, shapes[group] 63 | ) 64 | ) 65 | 66 | unlink(iconFiles) # clean up the tmp png files that have been embedded 67 | 68 | } 69 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | \donttest{ 12 | 13 | # an automatic legend derived from the color palette 14 | df <- local({ 15 | n <- 300; x <- rnorm(n); y <- rnorm(n) 16 | z <- sqrt(x ^ 2 + y ^ 2); z[sample(n, 10)] <- NA 17 | data.frame(x, y, z) 18 | }) 19 | pal <- colorNumeric("OrRd", df$z) 20 | leaflet(df) %>% 21 | addTiles() %>% 22 | addCircleMarkers(~x, ~y, color = ~pal(z), group = "circles") %>% 23 | addLegend(pal = pal, values = ~z, group = "circles", position = "bottomleft") %>% 24 | addLayersControl(overlayGroups = c("circles")) 25 | 26 | # format legend labels 27 | df <- data.frame(x = rnorm(100), y = rexp(100, 2), z = runif(100)) 28 | pal <- colorBin("PuOr", df$z, bins = c(0, .1, .4, .9, 1)) 29 | leaflet(df) %>% 30 | addTiles() %>% 31 | addCircleMarkers(~x, ~y, color = ~pal(z), group = "circles") %>% 32 | addLegend(pal = pal, values = ~z, group = "circles", position = "bottomleft") %>% 33 | addLayersControl(overlayGroups = c("circles")) 34 | 35 | leaflet(df) %>% 36 | addTiles() %>% 37 | addCircleMarkers(~x, ~y, color = ~pal(z), group = "circles") %>% 38 | addLegend(pal = pal, values = ~z, labFormat = labelFormat( 39 | prefix = "(", suffix = ")%", between = ", ", 40 | transform = function(x) 100 * x 41 | ), group = "circles", position = "bottomleft" ) %>% 42 | addLayersControl(overlayGroups = c("circles")) 43 | } 44 | -------------------------------------------------------------------------------- /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 = TRUE, 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 = FALSE), 43 | labelOptions = labelOptions(noHide = TRUE, 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: '
' + cluster.getChildCount() + '
', 62 | className: 'marker-cluster' 63 | }); 64 | }"))) 65 | -------------------------------------------------------------------------------- /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(viridisLite::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(viridisLite::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(viridisLite::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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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("CartoDB.Positron", 12 | "CartoDB.Voyager", 13 | "CartoDB.DarkMatter") 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 = FALSE) 11 | 12 | #'
13 | #' Custom Resolution + Custom Date and on a toggleable Layer 14 | l %>% 15 | addSimpleGraticule(interval = 40, 16 | showOriginLabel = FALSE, 17 | group = "graticule") %>% 18 | addLayersControl( 19 | overlayGroups = c("graticule"), 20 | options = layersControlOptions(collapsed = FALSE) 21 | ) 22 | -------------------------------------------------------------------------------- /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/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "FeatureCollection", 3 | "features": [ 4 | { 5 | "type": "Feature", 6 | "id": "rectangle", 7 | "properties": {}, 8 | "geometry": { 9 | "type": "Polygon", 10 | "coordinates": [ 11 | [ 12 | [ 13 | -24.960937499999996, 14 | 43.068887774169625 15 | ], 16 | [ 17 | -24.960937499999996, 18 | 60.23981116999893 19 | ], 20 | [ 21 | 18.28125, 22 | 60.23981116999893 23 | ], 24 | [ 25 | 18.28125, 26 | 43.068887774169625 27 | ], 28 | [ 29 | -24.960937499999996, 30 | 43.068887774169625 31 | ] 32 | ] 33 | ] 34 | } 35 | }, 36 | { 37 | "type": "Feature", 38 | "id": "polygon", 39 | "properties": {}, 40 | "geometry": { 41 | "type": "Polygon", 42 | "coordinates": [ 43 | [ 44 | [ 45 | 60.1171875, 46 | 55.97379820507658 47 | ], 48 | [ 49 | 89.296875, 50 | 37.16031654673677 51 | ], 52 | [ 53 | 77.34374999999999, 54 | 15.284185114076445 55 | ], 56 | [ 57 | 49.92187499999999, 58 | 22.917922936146045 59 | ], 60 | [ 61 | 42.890625, 62 | 47.040182144806664 63 | ], 64 | [ 65 | 60.1171875, 66 | 55.97379820507658 67 | ] 68 | ] 69 | ] 70 | } 71 | }, 72 | { 73 | "type": "Feature", 74 | "id": "marker1", 75 | "properties": {}, 76 | "geometry": { 77 | "type": "Point", 78 | "coordinates": [ 79 | 6.6796875, 80 | 14.944784875088372 81 | ] 82 | } 83 | }, 84 | { 85 | "type": "Feature", 86 | "id": "marker2", 87 | "properties": {}, 88 | "geometry": { 89 | "type": "Point", 90 | "coordinates": [ 91 | -11.25, 92 | 20.3034175184893 93 | ] 94 | } 95 | }, 96 | { 97 | "type": "Feature", 98 | "id": "line", 99 | "properties": {}, 100 | "geometry": { 101 | "type": "LineString", 102 | "coordinates": [ 103 | [ 104 | -36.2109375, 105 | 65.94647177615738 106 | ], 107 | [ 108 | -67.1484375, 109 | 36.5978891330702 110 | ] 111 | ] 112 | } 113 | } 114 | ] 115 | } 116 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/cancel.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/cancel_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/cancel_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/check.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/check_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/check_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/focus.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/focus_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/focus_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/rulers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/rulers.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/rulers_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/rulers_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/start.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/start_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/start_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/trash.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-measure/images/trash_@2X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet-measure/images/trash_@2X.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet-omnivore/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leaflet-omnivore", 3 | "version": "0.3.4", 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 | "prepublish": "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 | "files": [ 17 | "index.js", 18 | "leaflet-omnivore.js", 19 | "leaflet-omnivore.min.js" 20 | ], 21 | "browserify": { 22 | "transform": [ 23 | "brfs" 24 | ] 25 | }, 26 | "keywords": [ 27 | "leaflet", 28 | "formats", 29 | "kml", 30 | "csv", 31 | "gpx", 32 | "geojson", 33 | "kml", 34 | "leaflet", 35 | "maps", 36 | "gpx", 37 | "wkt", 38 | "osm", 39 | "polyline", 40 | "topojson", 41 | "format", 42 | "converter" 43 | ], 44 | "author": "Tom MacWright", 45 | "license": "BSD-3-Clause", 46 | "bugs": { 47 | "url": "https://github.com/mapbox/leaflet-omnivore/issues" 48 | }, 49 | "homepage": "https://github.com/mapbox/leaflet-omnivore", 50 | "dependencies": { 51 | "csv2geojson": "~5.0.0", 52 | "togeojson": "0.13.0", 53 | "corslite": "0.0.7", 54 | "wellknown": "0.4.2", 55 | "brfs": "1.4.3", 56 | "topojson": "1.6.26", 57 | "polyline": "0.2.0" 58 | }, 59 | "devDependencies": { 60 | "browserify": "13.0.1", 61 | "tape": "4.5.1", 62 | "uglify-js": "^2.6.2", 63 | "jshint": "2.9.2", 64 | "mocha": "~2.5.3", 65 | "zuul": "~3.10.1", 66 | "st": "1.2.2", 67 | "mapbox.js": "2.4.0", 68 | "phantomjs-prebuilt": "2.1.7" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet/images/layers-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet/images/layers-2x.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet/images/layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet/images/layers.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet/images/marker-icon-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet/images/marker-icon-2x.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet/images/marker-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet/images/marker-icon.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/leaflet/images/marker-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/leaflet/images/marker-shadow.png -------------------------------------------------------------------------------- /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 | .leaflet .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 | .leaflet .legend { 17 | line-height: 18px; 18 | color: #555; 19 | } 20 | .leaflet .legend svg text { 21 | fill: #555; 22 | } 23 | .leaflet .legend svg line { 24 | stroke: #555; 25 | } 26 | .leaflet .legend i { 27 | width: 18px; 28 | height: 18px; 29 | margin-right: 4px; 30 | opacity: 0.7; 31 | display: inline-block; 32 | vertical-align: top; 33 | /*For IE 7*/ 34 | zoom: 1; 35 | *display: inline; 36 | } 37 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/rstudio_leaflet/images/1px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/lib/rstudio_leaflet/images/1px.png -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/rstudio_leaflet/rstudio_leaflet.css: -------------------------------------------------------------------------------- 1 | .leaflet-tooltip.leaflet-tooltip-text-only, 2 | .leaflet-tooltip.leaflet-tooltip-text-only:before, 3 | .leaflet-tooltip.leaflet-tooltip-text-only:after { 4 | background: none; 5 | border: none; 6 | box-shadow: none; 7 | } 8 | 9 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-left { 10 | margin-left: 5px; 11 | } 12 | 13 | .leaflet-tooltip.leaflet-tooltip-text-only.leaflet-tooltip-right { 14 | margin-left: -5px; 15 | } 16 | 17 | .leaflet-tooltip:after { 18 | border-right: 6px solid transparent; 19 | /* right: -16px; */ 20 | } 21 | 22 | .leaflet-popup-pane .leaflet-popup-tip-container { 23 | /* when the tooltip container is clicked, it is closed */ 24 | pointer-events: all; 25 | /* tooltips should display the "hand" icon, just like .leaflet-interactive*/ 26 | cursor: pointer; 27 | } 28 | 29 | /* have the widget be displayed in the right 'layer' */ 30 | .leaflet-map-pane { 31 | z-index: auto; 32 | } 33 | 34 | /* Add missing rule from leaflet for img. 35 | This complete existing leaflet.css. 36 | Fix for https://github.com/rstudio/rmarkdown/issues/1949 */ 37 | .leaflet-container .leaflet-right-pane img, 38 | .leaflet-container .leaflet-left-pane img { 39 | max-width: none !important; 40 | max-height: none !important; 41 | } 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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)} -------------------------------------------------------------------------------- /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/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet-MiniMap/images/toggle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/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/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/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/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/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/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.eot -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.ttf -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/fonts/ionicons.woff -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-matte@2x.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-plain.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-shadow@2x.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/Leaflet.awesome-markers/images/markers-soft@2x.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/leaflet.awesome-markers.css: -------------------------------------------------------------------------------- 1 | /* 2 | Author: L. Voogdt 3 | License: MIT 4 | Version: 1.0 5 | */ 6 | 7 | /* Marker setup */ 8 | .awesome-marker { 9 | background: url('images/markers-soft.png') no-repeat 0 0; 10 | width: 35px; 11 | height: 46px; 12 | position:absolute; 13 | left:0; 14 | top:0; 15 | display: block; 16 | text-align: center; 17 | } 18 | 19 | .awesome-marker-shadow { 20 | background: url('images/markers-shadow.png') no-repeat 0 0; 21 | width: 36px; 22 | height: 16px; 23 | } 24 | 25 | /* Retina displays */ 26 | @media (min--moz-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2), 27 | (-webkit-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5),(min-resolution: 1.5dppx) { 28 | .awesome-marker { 29 | background-image: url('images/markers-soft@2x.png'); 30 | background-size: 720px 92px; 31 | } 32 | .awesome-marker-shadow { 33 | background-image: url('images/markers-shadow@2x.png'); 34 | background-size: 35px 16px; 35 | } 36 | } 37 | 38 | .awesome-marker i { 39 | color: #333; 40 | margin-top: 10px; 41 | display: inline-block; 42 | font-size: 14px; 43 | } 44 | 45 | .awesome-marker .icon-white { 46 | color: #fff; 47 | } 48 | 49 | /* Colors */ 50 | .awesome-marker-icon-red { 51 | background-position: 0 0; 52 | } 53 | 54 | .awesome-marker-icon-darkred { 55 | background-position: -180px 0; 56 | } 57 | 58 | .awesome-marker-icon-lightred { 59 | background-position: -360px 0; 60 | } 61 | 62 | .awesome-marker-icon-orange { 63 | background-position: -36px 0; 64 | } 65 | 66 | .awesome-marker-icon-beige { 67 | background-position: -396px 0; 68 | } 69 | 70 | .awesome-marker-icon-green { 71 | background-position: -72px 0; 72 | } 73 | 74 | .awesome-marker-icon-darkgreen { 75 | background-position: -252px 0; 76 | } 77 | 78 | .awesome-marker-icon-lightgreen { 79 | background-position: -432px 0; 80 | } 81 | 82 | .awesome-marker-icon-blue { 83 | background-position: -108px 0; 84 | } 85 | 86 | .awesome-marker-icon-darkblue { 87 | background-position: -216px 0; 88 | } 89 | 90 | .awesome-marker-icon-lightblue { 91 | background-position: -468px 0; 92 | } 93 | 94 | .awesome-marker-icon-purple { 95 | background-position: -144px 0; 96 | } 97 | 98 | .awesome-marker-icon-darkpurple { 99 | background-position: -288px 0; 100 | } 101 | 102 | .awesome-marker-icon-pink { 103 | background-position: -504px 0; 104 | } 105 | 106 | .awesome-marker-icon-cadetblue { 107 | background-position: -324px 0; 108 | } 109 | 110 | .awesome-marker-icon-white { 111 | background-position: -576px 0; 112 | } 113 | 114 | .awesome-marker-icon-gray { 115 | background-position: -648px 0; 116 | } 117 | 118 | .awesome-marker-icon-lightgray { 119 | background-position: -612px 0; 120 | } 121 | 122 | .awesome-marker-icon-black { 123 | background-position: -682px 0; 124 | } 125 | 126 | .awesome-marker-square { 127 | background-position-y: -46px; 128 | } 129 | -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/Leaflet.awesome-markers/leaflet.awesome-markers.min.js: -------------------------------------------------------------------------------- 1 | (function(window,document,undefined){"use strict";L.AwesomeMarkers={};L.AwesomeMarkers.version="2.0.1";L.AwesomeMarkers.Icon=L.Icon.extend({options:{iconSize:[35,45],iconAnchor:[17,42],popupAnchor:[1,-32],shadowAnchor:[10,12],shadowSize:[36,16],className:"awesome-marker",prefix:"glyphicon",spinClass:"fa-spin",extraClasses:"",icon:"home",markerColor:"blue",iconColor:"white",iconRotate:0,font:"monospace"},initialize:function(options){options=L.Util.setOptions(this,options)},createIcon:function(){var div=document.createElement("div"),options=this.options;if(options.icon){div.innerHTML=this._createInner()}if(options.bgPos){div.style.backgroundPosition=-options.bgPos.x+"px "+-options.bgPos.y+"px"}this._setIconStyles(div,"icon-"+options.markerColor);return div},_createInner:function(){var iconClass,iconSpinClass="",iconColorClass="",iconColorStyle="",options=this.options;if(!options.prefix||options.icon.slice(0,options.prefix.length+1)===options.prefix+"-"){iconClass=options.icon}else{iconClass=options.prefix+"-"+options.icon}if(options.spin&&typeof options.spinClass==="string"){iconSpinClass=options.spinClass}if(options.iconColor){if((options.iconColor==="white"||options.iconColor==="black")&&options.prefix!=="fa"){iconColorClass="icon-"+options.iconColor}else if(options.prefix==="fa"&&options.iconColor==="white"){iconColorClass="fa-inverse"}else{iconColorStyle="color: "+options.iconColor+";"}}if(options.font&&options.text){iconColorStyle+="font-family: "+options.font+";"}if(options.iconRotate&&options.iconRotate!==0){iconColorStyle+="-webkit-transform: rotate("+options.iconRotate+"deg);";iconColorStyle+="-moz-transform: rotate("+options.iconRotate+"deg);";iconColorStyle+="-o-transform: rotate("+options.iconRotate+"deg);";iconColorStyle+="-ms-transform: rotate("+options.iconRotate+"deg);";iconColorStyle+="transform: rotate("+options.iconRotate+"deg);"}if(options.text){return""+options.text+""}return""},_setIconStyles:function(img,name){var options=this.options,size=L.point(options[name==="shadow"?"shadowSize":"iconSize"]),anchor;if(name==="shadow"){anchor=L.point(options.shadowAnchor||options.iconAnchor)}else{anchor=L.point(options.iconAnchor)}if(!anchor&&size){anchor=size.divideBy(2,true)}img.className="awesome-marker-"+name+" "+options.className;if(anchor){img.style.marginLeft=-anchor.x+"px";img.style.marginTop=-anchor.y+"px"}if(size){img.style.width=size.x+"px";img.style.height=size.y+"px"}},createShadow:function(){var div=document.createElement("div");this._setIconStyles(div,"shadow");return div}});L.AwesomeMarkers.icon=function(options){return new L.AwesomeMarkers.Icon(options)}})(this,document); 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/plugins/Leaflet.markercluster/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leaflet.markercluster", 3 | "repository": "https://github.com/Leaflet/Leaflet.markercluster", 4 | "version": "1.1.0", 5 | "description": "Provides Beautiful Animated Marker Clustering functionality for Leaflet", 6 | "devDependencies": { 7 | "jshint": "~2.1.3", 8 | "mocha": "~1.10.0", 9 | "karma": "~0.8.5", 10 | "uglify-js": "~2.6.0", 11 | "jake": "~0.5.16", 12 | "magic-string": "^0.7.0", 13 | "leaflet": "~1.0.3" 14 | }, 15 | "main": "dist/leaflet.markercluster.js", 16 | "scripts": { 17 | "test": "jake test", 18 | "prepublish": "jake" 19 | }, 20 | "keywords": ["gis", "map"], 21 | "license": "MIT" 22 | } 23 | -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/leaflet-locationfilter/img/filter-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/leaflet-locationfilter/img/filter-icon.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/leaflet-locationfilter/img/move-handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/leaflet-locationfilter/img/move-handle.png -------------------------------------------------------------------------------- /inst/htmlwidgets/plugins/leaflet-locationfilter/img/resize-handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/htmlwidgets/plugins/leaflet-locationfilter/img/resize-handle.png -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /inst/legacy/examples/choropleth/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Title: Choropleths with Shiny and Leaflet 2 | DisplayMode: Showcase -------------------------------------------------------------------------------- /inst/legacy/examples/choropleth/Rplots.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/examples/choropleth/Rplots.pdf -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/legacy/examples/choropleth/shinyapps/jcheng/choropleth3.dcf: -------------------------------------------------------------------------------- 1 | name: choropleth3 2 | account: jcheng 3 | bundleId: 17723 4 | url: http://jcheng.shinyapps.io/choropleth3 5 | -------------------------------------------------------------------------------- /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; 9 | border-radius: 6px; box-shadow: 0 0 15px rgba(0,0,0,0.2); } 10 | ")), 11 | 12 | leafletMap( 13 | "map", "100%", 500, 14 | # By default OpenStreetMap tiles are used; we want nothing in this case 15 | #initialTileLayer = NULL, 16 | #initialTileLayerAttribution = NULL, 17 | options = list( 18 | center = c(40, -98.85), 19 | zoom = 4, 20 | maxBounds = list(list(17, -180), list(59, 180)) 21 | ) 22 | ), 23 | 24 | absolutePanel( 25 | right = 30, top = 10, width = 200, class = "floater", 26 | 27 | h4("US Population Density"), 28 | uiOutput("stateInfo") 29 | ), 30 | 31 | absolutePanel( 32 | right = 30, top = 280, style = "", class = "floater", 33 | tags$table( 34 | mapply( 35 | function(from, to, color) { 36 | tags$tr( 37 | tags$td(tags$div( 38 | style = sprintf("width: 16px; height: 16px; background-color: %s;", color) 39 | )), 40 | tags$td(from, "-", to) 41 | ) 42 | }, 43 | densityRanges$from, densityRanges$to, palette, SIMPLIFY = FALSE 44 | ) 45 | ) 46 | ) 47 | )) 48 | -------------------------------------------------------------------------------- /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/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 ", 25 | "cities are displayed." 26 | )) 27 | ) 28 | ) 29 | ), 30 | hr(), 31 | fluidRow( 32 | column(3, 33 | selectInput("year", "Year", c(2000:2010), 2010), 34 | selectInput("maxCities", "Maximum cities to display", choices = c( 35 | 5, 25, 50, 100, 200, 500, 2000, 5000, 10000, All = 100000 36 | ), selected = 100) 37 | ), 38 | column(4, 39 | h4("Visible cities"), 40 | tableOutput("data") 41 | ), 42 | column(5, 43 | h4(id = "cityTimeSeriesLabel", class = "shiny-text-output"), 44 | plotOutput("cityTimeSeries", width = "100%", height = "250px") 45 | ) 46 | ) 47 | )) 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /inst/legacy/www/images/layers-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/www/images/layers-2x.png -------------------------------------------------------------------------------- /inst/legacy/www/images/layers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/www/images/layers.png -------------------------------------------------------------------------------- /inst/legacy/www/images/marker-icon-2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/www/images/marker-icon-2x.png -------------------------------------------------------------------------------- /inst/legacy/www/images/marker-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/www/images/marker-icon.png -------------------------------------------------------------------------------- /inst/legacy/www/images/marker-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/inst/legacy/www/images/marker-shadow.png -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | get(id) { 22 | let control = null; 23 | if (this._controlsById[id]) { 24 | control = this._controlsById[id]; 25 | } 26 | return control; 27 | } 28 | 29 | remove(id) { 30 | if (this._controlsById[id]) { 31 | let control = this._controlsById[id]; 32 | this._map.removeControl(control); 33 | delete this._controlsById[id]; 34 | } 35 | } 36 | 37 | clear() { 38 | for (let i = 0; i < this._controlsNoId.length; i++) { 39 | let control = this._controlsNoId[i]; 40 | this._map.removeControl(control); 41 | } 42 | this._controlsNoId = []; 43 | 44 | for (let key in this._controlsById) { 45 | let control = this._controlsById[key]; 46 | this._map.removeControl(control); 47 | } 48 | this._controlsById = {}; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /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 = new L.Transformation( 27 | crsOptions.options.transformation[0], 28 | crsOptions.options.transformation[1], 29 | crsOptions.options.transformation[2], 30 | crsOptions.options.transformation[3] 31 | ); 32 | } 33 | crs = new Proj4Leaflet.CRS(crsOptions.code, crsOptions.proj4def, crsOptions.options); 34 | break; 35 | case "L.Proj.CRS.TMS": 36 | if(crsOptions.options && crsOptions.options.bounds) { 37 | crsOptions.options.bounds = L.bounds(crsOptions.options.bounds); 38 | } 39 | if(crsOptions.options && crsOptions.options.transformation) { 40 | crsOptions.options.transformation = 41 | L.Transformation( 42 | crsOptions.options.transformation[0], 43 | crsOptions.options.transformation[1], 44 | crsOptions.options.transformation[2], 45 | crsOptions.options.transformation[3] 46 | ); 47 | } 48 | // L.Proj.CRS.TMS is deprecated as of Leaflet 1.x, fall back to L.Proj.CRS 49 | //crs = new Proj4Leaflet.CRS.TMS(crsOptions.code, crsOptions.proj4def, crsOptions.projectedBounds, crsOptions.options); 50 | crs = new Proj4Leaflet.CRS(crsOptions.code, crsOptions.proj4def, crsOptions.options); 51 | break; 52 | } 53 | return crs; 54 | } 55 | -------------------------------------------------------------------------------- /javascript/src/dataframe.js: -------------------------------------------------------------------------------- 1 | import { recycle, asArray } from "./util"; 2 | 3 | export default class DataFrame { 4 | constructor() { 5 | this.columns = []; 6 | this.colnames = []; 7 | this.colstrict = []; 8 | 9 | this.effectiveLength = 0; 10 | this.colindices = {}; 11 | } 12 | 13 | _updateCachedProperties() { 14 | this.effectiveLength = 0; 15 | this.colindices = {}; 16 | 17 | this.columns.forEach((column, i) => { 18 | this.effectiveLength = Math.max(this.effectiveLength, column.length); 19 | this.colindices[this.colnames[i]] = i; 20 | }); 21 | } 22 | 23 | _colIndex(colname) { 24 | let index = this.colindices[colname]; 25 | if (typeof(index) === "undefined") 26 | return -1; 27 | return index; 28 | } 29 | 30 | col(name, values, strict) { 31 | if (typeof(name) !== "string") 32 | throw new Error("Invalid column name \"" + name + "\""); 33 | 34 | let index = this._colIndex(name); 35 | 36 | if (arguments.length === 1) { 37 | if (index < 0) 38 | return null; 39 | else 40 | return recycle(this.columns[index], this.effectiveLength); 41 | } 42 | 43 | if (index < 0) { 44 | index = this.colnames.length; 45 | this.colnames.push(name); 46 | } 47 | this.columns[index] = asArray(values); 48 | this.colstrict[index] = !!strict; 49 | 50 | // TODO: Validate strictness (ensure lengths match up with other stricts) 51 | 52 | this._updateCachedProperties(); 53 | 54 | return this; 55 | } 56 | 57 | cbind(obj, strict) { 58 | Object.keys(obj).forEach((name) => { 59 | let coldata = obj[name]; 60 | this.col(name, coldata); 61 | }); 62 | return this; 63 | } 64 | 65 | get(row, col, missingOK) { 66 | if (row > this.effectiveLength) 67 | throw new Error("Row argument was out of bounds: " + row + " > " + this.effectiveLength); 68 | 69 | let colIndex = -1; 70 | if (typeof(col) === "undefined") { 71 | let rowData = {}; 72 | this.colnames.forEach((name, i) => { 73 | rowData[name] = this.columns[i][row % this.columns[i].length]; 74 | }); 75 | return rowData; 76 | } else if (typeof(col) === "string") { 77 | colIndex = this._colIndex(col); 78 | } else if (typeof(col) === "number") { 79 | colIndex = col; 80 | } 81 | if (colIndex < 0 || colIndex > this.columns.length) { 82 | if (missingOK) 83 | return void 0; 84 | else 85 | throw new Error("Unknown column index: " + col); 86 | } 87 | 88 | return this.columns[colIndex][row % this.columns[colIndex].length]; 89 | } 90 | 91 | nrow() { 92 | return this.effectiveLength; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /javascript/src/fixup-default-icon.js: -------------------------------------------------------------------------------- 1 | import L from "./global/leaflet"; 2 | 3 | // In RMarkdown's self-contained mode, we don't have a way to carry around the 4 | // images that Leaflet needs but doesn't load into the page. Instead, we'll use 5 | // the unpkg CDN. 6 | if (typeof(L.Icon.Default.imagePath) === "undefined") { 7 | L.Icon.Default.imagePath = "https://unpkg.com/leaflet@1.3.1/dist/images/"; 8 | } 9 | -------------------------------------------------------------------------------- /javascript/src/fixup-default-tooltip.js: -------------------------------------------------------------------------------- 1 | import L from "./global/leaflet"; 2 | 3 | // add texxtsize, textOnly, and style 4 | L.Tooltip.prototype.options.textsize = "10px"; 5 | L.Tooltip.prototype.options.textOnly = false; 6 | L.Tooltip.prototype.options.style = null; 7 | 8 | // copy original layout to not completely stomp it. 9 | let initLayoutOriginal = L.Tooltip.prototype._initLayout; 10 | 11 | L.Tooltip.prototype._initLayout = function() { 12 | initLayoutOriginal.call(this); 13 | this._container.style.fontSize = this.options.textsize; 14 | 15 | if (this.options.textOnly) { 16 | L.DomUtil.addClass(this._container, "leaflet-tooltip-text-only"); 17 | } 18 | 19 | if (this.options.style) { 20 | for (let property in this.options.style) { 21 | this._container.style[property] = this.options.style[property]; 22 | } 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /javascript/src/fixup-url-protocol.js: -------------------------------------------------------------------------------- 1 | import L from "./global/leaflet"; 2 | 3 | let protocolRegex = /^\/\//; 4 | let upgrade_protocol = function(urlTemplate) { 5 | if (protocolRegex.test(urlTemplate)) { 6 | if (window.location.protocol === "file:") { 7 | // if in a local file, support http 8 | // http should auto upgrade if necessary 9 | urlTemplate = "http:" + urlTemplate; 10 | } 11 | } 12 | return urlTemplate; 13 | }; 14 | 15 | let originalLTileLayerInitialize = L.TileLayer.prototype.initialize; 16 | L.TileLayer.prototype.initialize = function(urlTemplate, options) { 17 | urlTemplate = upgrade_protocol(urlTemplate); 18 | originalLTileLayerInitialize.call(this, urlTemplate, options); 19 | }; 20 | 21 | let originalLTileLayerWMSInitialize = L.TileLayer.WMS.prototype.initialize; 22 | L.TileLayer.WMS.prototype.initialize = function(urlTemplate, options) { 23 | urlTemplate = upgrade_protocol(urlTemplate); 24 | originalLTileLayerWMSInitialize.call(this, urlTemplate, options); 25 | }; 26 | -------------------------------------------------------------------------------- /javascript/src/global/htmlwidgets.js: -------------------------------------------------------------------------------- 1 | export default global.HTMLWidgets; 2 | -------------------------------------------------------------------------------- /javascript/src/global/jquery.js: -------------------------------------------------------------------------------- 1 | export default global.jQuery; 2 | -------------------------------------------------------------------------------- /javascript/src/global/leaflet.js: -------------------------------------------------------------------------------- 1 | export default global.L; 2 | -------------------------------------------------------------------------------- /javascript/src/global/proj4leaflet.js: -------------------------------------------------------------------------------- 1 | export default global.L.Proj; 2 | -------------------------------------------------------------------------------- /javascript/src/global/shiny.js: -------------------------------------------------------------------------------- 1 | export default global.Shiny; 2 | -------------------------------------------------------------------------------- /javascript/src/mipmapper.js: -------------------------------------------------------------------------------- 1 | // This class simulates a mipmap, which shrinks images by powers of two. This 2 | // stepwise reduction results in "pixel-perfect downscaling" (where every 3 | // pixel of the original image has some contribution to the downscaled image) 4 | // as opposed to a single-step downscaling which will discard a lot of data 5 | // (and with sparse images at small scales can give very surprising results). 6 | export default class Mipmapper { 7 | constructor(img) { 8 | this._layers = [img]; 9 | } 10 | 11 | // The various functions on this class take a callback function BUT MAY OR MAY 12 | // NOT actually behave asynchronously. 13 | getBySize(desiredWidth, desiredHeight, callback) { 14 | let i = 0; 15 | let lastImg = this._layers[0]; 16 | let testNext = () => { 17 | this.getByIndex(i, function(img) { 18 | // If current image is invalid (i.e. too small to be rendered) or 19 | // it's smaller than what we wanted, return the last known good image. 20 | if (!img || img.width < desiredWidth || img.height < desiredHeight) { 21 | callback(lastImg); 22 | return; 23 | } else { 24 | lastImg = img; 25 | i++; 26 | testNext(); 27 | return; 28 | } 29 | }); 30 | }; 31 | testNext(); 32 | } 33 | 34 | getByIndex(i, callback) { 35 | if (this._layers[i]) { 36 | callback(this._layers[i]); 37 | return; 38 | } 39 | 40 | this.getByIndex(i-1, (prevImg) => { 41 | if (!prevImg) { 42 | // prevImg could not be calculated (too small, possibly) 43 | callback(null); 44 | return; 45 | } 46 | if (prevImg.width < 2 || prevImg.height < 2) { 47 | // Can't reduce this image any further 48 | callback(null); 49 | return; 50 | } 51 | // If reduce ever becomes truly asynchronous, we should stuff a promise or 52 | // something into this._layers[i] before calling this.reduce(), to prevent 53 | // redundant reduce operations from happening. 54 | this.reduce(prevImg, (reducedImg) => { 55 | this._layers[i] = reducedImg; 56 | callback(reducedImg); 57 | return; 58 | }); 59 | }); 60 | } 61 | 62 | reduce(img, callback) { 63 | let imgDataCanvas = document.createElement("canvas"); 64 | imgDataCanvas.width = Math.ceil(img.width / 2); 65 | imgDataCanvas.height = Math.ceil(img.height / 2); 66 | imgDataCanvas.style.display = "none"; 67 | document.body.appendChild(imgDataCanvas); 68 | try { 69 | let imgDataCtx = imgDataCanvas.getContext("2d"); 70 | imgDataCtx.drawImage(img, 0, 0, img.width/2, img.height/2); 71 | callback(imgDataCanvas); 72 | } finally { 73 | document.body.removeChild(imgDataCanvas); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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-roxygen/data-getMapData.R: -------------------------------------------------------------------------------- 1 | #' @param data the data object from which the argument values are derived; by 2 | #' default, it is the \code{data} object provided to \code{leaflet()} 3 | #' initially, but can be overridden 4 | -------------------------------------------------------------------------------- /man/aaa-test-viztest.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/zzz_viztest.R 3 | \name{aaa-test-viztest} 4 | \alias{aaa-test-viztest} 5 | \title{Visual Testing scripts for vistest} 6 | \description{ 7 | Visual testing examples to be used by the vistest package. 8 | } 9 | \examples{ 10 | 11 | 12 | 13 | \donttest{ 14 | 15 | 16 | ### Start addGeoJSON properties - https://github.com/rstudio/leaflet/pull/625 17 | polygon = list( 18 | type = "Polygon", 19 | coordinates = list( 20 | list( 21 | c(8.330469, 48.261570), 22 | c(8.339052, 48.261570), 23 | c(8.339052, 48.258227), 24 | c(8.330469, 48.258227), 25 | c(8.330469, 48.261570) 26 | ) 27 | ) 28 | ) 29 | 30 | # should produce an orange-ish rectangle around `Ramsel` 31 | leaflet() \%>\% 32 | addTiles() \%>\% 33 | addGeoJSON(polygon, color="#F00") \%>\% 34 | setView(lng = 8.330469, lat = 48.26157, zoom = 15) 35 | ### End PR #625 36 | 37 | 38 | } # end donttest 39 | } 40 | \keyword{internal} 41 | -------------------------------------------------------------------------------- /man/addAwesomeMarkers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugin-awesomeMarkers.R 3 | \name{addAwesomeMarkers} 4 | \alias{addAwesomeMarkers} 5 | \title{Add Awesome Markers} 6 | \usage{ 7 | addAwesomeMarkers( 8 | map, 9 | lng = NULL, 10 | lat = NULL, 11 | layerId = NULL, 12 | group = NULL, 13 | icon = NULL, 14 | popup = NULL, 15 | popupOptions = NULL, 16 | label = NULL, 17 | labelOptions = NULL, 18 | options = markerOptions(), 19 | clusterOptions = NULL, 20 | clusterId = NULL, 21 | data = getMapData(map) 22 | ) 23 | } 24 | \arguments{ 25 | \item{map}{the map to add awesome Markers to.} 26 | 27 | \item{lng}{a numeric vector of longitudes, or a one-sided formula of the form 28 | \code{~x} where \code{x} is a variable in \code{data}; by default (if not 29 | explicitly provided), it will be automatically inferred from \code{data} by 30 | looking for a column named \code{lng}, \code{long}, or \code{longitude} 31 | (case-insensitively)} 32 | 33 | \item{lat}{a vector of latitudes or a formula (similar to the \code{lng} 34 | argument; the names \code{lat} and \code{latitude} are used when guessing 35 | the latitude column from \code{data})} 36 | 37 | \item{layerId}{the layer id} 38 | 39 | \item{group}{the name of the group the newly created layers should belong to 40 | (for \code{\link[=clearGroup]{clearGroup()}} and \code{\link[=addLayersControl]{addLayersControl()}} purposes). 41 | Human-friendly group names are permitted--they need not be short, 42 | identifier-style names. Any number of layers and even different types of 43 | layers (e.g., markers and polygons) can share the same group name.} 44 | 45 | \item{icon}{the icon(s) for markers;} 46 | 47 | \item{popup}{a character vector of the HTML content for the popups (you are 48 | recommended to escape the text using \code{\link[htmltools:htmlEscape]{htmltools::htmlEscape()}} 49 | for security reasons)} 50 | 51 | \item{popupOptions}{A Vector of \code{\link[=popupOptions]{popupOptions()}} to provide popups} 52 | 53 | \item{label}{a character vector of the HTML content for the labels} 54 | 55 | \item{labelOptions}{A Vector of \code{\link[=labelOptions]{labelOptions()}} to provide label 56 | options for each label. Default \code{NULL}} 57 | 58 | \item{options}{a list of extra options for tile layers, popups, paths 59 | (circles, rectangles, polygons, ...), or other map elements} 60 | 61 | \item{clusterOptions}{if not \code{NULL}, markers will be clustered using 62 | \href{https://github.com/Leaflet/Leaflet.markercluster}{Leaflet.markercluster}; 63 | you can use \code{\link[=markerClusterOptions]{markerClusterOptions()}} to specify marker cluster 64 | options} 65 | 66 | \item{clusterId}{the id for the marker cluster layer} 67 | 68 | \item{data}{the data object from which the argument values are derived; by 69 | default, it is the \code{data} object provided to \code{leaflet()} 70 | initially, but can be overridden} 71 | } 72 | \description{ 73 | Add Awesome Markers 74 | } 75 | -------------------------------------------------------------------------------- /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 | \usage{ 7 | addGraticule( 8 | map, 9 | interval = 20, 10 | sphere = FALSE, 11 | style = list(color = "#333", weight = 1), 12 | layerId = NULL, 13 | group = NULL, 14 | options = pathOptions(pointerEvents = "none", clickable = FALSE) 15 | ) 16 | } 17 | \arguments{ 18 | \item{map}{a map widget object} 19 | 20 | \item{interval}{The spacing in map units between horizontal and vertical lines.} 21 | 22 | \item{sphere}{boolean. Default \code{FALSE}} 23 | 24 | \item{style}{path options for the generated lines. See \url{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#path-option}} 25 | 26 | \item{layerId}{the layer id} 27 | 28 | \item{group}{the name of the group this layer belongs to.} 29 | 30 | \item{options}{the path options for the graticule layer} 31 | } 32 | \description{ 33 | Add a Graticule on the map 34 | } 35 | \examples{ 36 | leaf <- leaflet() \%>\% 37 | addTiles() \%>\% 38 | addGraticule() 39 | leaf 40 | 41 | } 42 | \seealso{ 43 | \url{https://github.com/turban/Leaflet.Graticule} 44 | } 45 | -------------------------------------------------------------------------------- /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( 10 | map, 11 | baseGroups = character(0), 12 | overlayGroups = character(0), 13 | position = c("topright", "bottomright", "bottomleft", "topleft"), 14 | options = layersControlOptions(), 15 | data = getMapData(map) 16 | ) 17 | 18 | layersControlOptions(collapsed = TRUE, autoZIndex = TRUE, ...) 19 | 20 | removeLayersControl(map) 21 | } 22 | \arguments{ 23 | \item{map}{the map to add the layers control to} 24 | 25 | \item{baseGroups}{character vector where each element is the name of a group. 26 | The user will be able to choose one base group (only) at a time. This is 27 | most commonly used for mostly-opaque tile layers.} 28 | 29 | \item{overlayGroups}{character vector where each element is the name of a 30 | group. The user can turn each overlay group on or off independently.} 31 | 32 | \item{position}{position of control: \code{"topleft"}, \code{"topright"}, 33 | \code{"bottomleft"}, or \code{"bottomright"}.} 34 | 35 | \item{options}{a list of additional options, intended to be provided by 36 | a call to \code{layersControlOptions()}} 37 | 38 | \item{data}{the data object from which the argument values are derived; by 39 | default, it is the \code{data} object provided to \code{leaflet()} 40 | initially, but can be overridden} 41 | 42 | \item{collapsed}{if \code{TRUE} (the default), the layers control will be 43 | rendered as an icon that expands when hovered over. Set to \code{FALSE} 44 | to have the layers control always appear in its expanded state.} 45 | 46 | \item{autoZIndex}{if \code{TRUE}, the control will automatically maintain 47 | the z-order of its various groups as overlays are switched on and off.} 48 | 49 | \item{...}{other options for \code{layersControlOptions()}} 50 | } 51 | \description{ 52 | Uses Leaflet's built-in 53 | \href{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#control-layers}{layers control} 54 | feature to allow users to choose one of several base layers, and to choose 55 | any number of overlay layers to view. 56 | } 57 | \examples{ 58 | \donttest{ 59 | leaflet() \%>\% 60 | addTiles(group = "OpenStreetMap") \%>\% 61 | addProviderTiles("CartoDB.Voyager", group = "Carto Voyager") \%>\% 62 | addMarkers(runif(20, -75, -74), runif(20, 41, 42), group = "Markers") \%>\% 63 | addLayersControl( 64 | baseGroups = c("OpenStreetMap", "Carto Voyager"), 65 | overlayGroups = c("Markers") 66 | ) 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /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( 9 | map, 10 | provider, 11 | layerId = NULL, 12 | group = NULL, 13 | options = providerTileOptions(), 14 | check = TRUE 15 | ) 16 | 17 | providerTileOptions( 18 | errorTileUrl = "", 19 | noWrap = FALSE, 20 | opacity = NULL, 21 | zIndex = NULL, 22 | updateWhenIdle = NULL, 23 | detectRetina = FALSE, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{map}{the map to add the tile layer to} 29 | 30 | \item{provider}{the name of the provider (see 31 | \url{https://leaflet-extras.github.io/leaflet-providers/preview/} and 32 | \url{https://github.com/leaflet-extras/leaflet-providers})} 33 | 34 | \item{layerId}{the layer id to assign} 35 | 36 | \item{group}{the name of the group the newly created layers should belong to 37 | (for \code{\link[=clearGroup]{clearGroup()}} and \code{\link[=addLayersControl]{addLayersControl()}} purposes). Human-friendly 38 | group names are permitted--they need not be short, identifier-style names.} 39 | 40 | \item{options}{tile options} 41 | 42 | \item{check}{Check that the specified \code{provider} matches the available 43 | currently loaded leaflet providers? Defaults to \code{TRUE}, but can be toggled 44 | to \code{FALSE} for advanced users.} 45 | 46 | \item{errorTileUrl, noWrap, opacity, zIndex, updateWhenIdle, detectRetina}{the tile layer options; see 47 | \url{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#tilelayer}} 48 | 49 | \item{...}{named parameters to add to the options} 50 | } 51 | \value{ 52 | modified map object 53 | } 54 | \description{ 55 | Add a tile layer from a known map provider 56 | } 57 | \examples{ 58 | leaflet() \%>\% 59 | addProviderTiles("Esri.WorldTopoMap") \%>\% 60 | addProviderTiles("CartoDB.DarkMatter") 61 | 62 | } 63 | -------------------------------------------------------------------------------- /man/addRasterLegend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/layers.R 3 | \name{addRasterLegend} 4 | \alias{addRasterLegend} 5 | \title{Add a color legend for a SpatRaster to a map} 6 | \usage{ 7 | addRasterLegend(map, x, layer = 1, ...) 8 | } 9 | \arguments{ 10 | \item{map}{a map widget object} 11 | 12 | \item{x}{a \link[terra:SpatRaster-class]{SpatRaster} object with a color table} 13 | 14 | \item{layer}{the layer of the raster to target} 15 | 16 | \item{...}{additional arguments to pass through to \code{\link[=addLegend]{addLegend()}}} 17 | } 18 | \description{ 19 | A function for adding a \link[=addLegend]{legend} that is specifically designed 20 | for \link[terra:SpatRaster-class]{terra::SpatRaster} objects, with categorical values, that carry their 21 | own \link[terra:colors]{color table}. 22 | } 23 | \examples{ 24 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 25 | 26 | library(terra) 27 | 28 | r <- rast("/vsicurl/https://geodata.ucdavis.edu/test/pr_nlcd.tif") 29 | leaflet() \%>\% 30 | addTiles() \%>\% 31 | addRasterImage(r, opacity = 0.75) \%>\% 32 | addRasterLegend(r, opacity = 0.75) 33 | 34 | plot.new() # pause in interactive mode 35 | 36 | rr <- r 37 | levels(rr) <- NULL 38 | leaflet() \%>\% 39 | addTiles() \%>\% 40 | addRasterImage(rr, opacity = 0.75) \%>\% 41 | addRasterLegend(rr, opacity = 0.75) 42 | \dontshow{\}) # examplesIf} 43 | } 44 | \seealso{ 45 | \code{\link[=addRasterImage]{addRasterImage()}} 46 | } 47 | -------------------------------------------------------------------------------- /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{scaleBarOptions} 6 | \alias{removeScaleBar} 7 | \title{Add or remove a scale bar} 8 | \usage{ 9 | addScaleBar( 10 | map, 11 | position = c("topright", "bottomright", "bottomleft", "topleft"), 12 | options = scaleBarOptions() 13 | ) 14 | 15 | scaleBarOptions( 16 | maxWidth = 100, 17 | metric = TRUE, 18 | imperial = TRUE, 19 | updateWhenIdle = TRUE 20 | ) 21 | 22 | removeScaleBar(map) 23 | } 24 | \arguments{ 25 | \item{map}{the map to add the scale bar to} 26 | 27 | \item{position}{position of control: \code{"topleft"}, \code{"topright"}, \code{"bottomleft"}, or 28 | \code{"bottomright"}.} 29 | 30 | \item{options}{a list of additional options, intended to be provided by 31 | a call to \code{scaleBarOptions()}} 32 | 33 | \item{maxWidth}{maximum width of the control in pixels (default 100)} 34 | 35 | \item{metric}{if \code{TRUE} (the default), show a scale bar in metric units 36 | (m/km)} 37 | 38 | \item{imperial}{if \code{TRUE} (the default), show a scale bar in imperial 39 | units (ft/mi)} 40 | 41 | \item{updateWhenIdle}{if \code{FALSE} (the default), the scale bar is always 42 | up-to-date (updated on \code{move}). If \code{TRUE}, the control is updated 43 | on \code{moveend}.} 44 | } 45 | \description{ 46 | Uses Leaflet's built-in 47 | \href{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#control-scale}{scale bar} 48 | feature to add a scale bar. 49 | } 50 | \examples{ 51 | \donttest{ 52 | leaflet() \%>\% 53 | addTiles() \%>\% 54 | addScaleBar() 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /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 | \usage{ 7 | addSimpleGraticule( 8 | map, 9 | interval = 20, 10 | showOriginLabel = TRUE, 11 | redraw = "move", 12 | hidden = FALSE, 13 | zoomIntervals = list(), 14 | layerId = NULL, 15 | group = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{map}{a map widget object} 20 | 21 | \item{interval}{The spacing in map units between horizontal and vertical lines.} 22 | 23 | \item{showOriginLabel}{true Whether or not to show '(0,0)' at the origin.} 24 | 25 | \item{redraw}{on which map event to redraw the graticule. On move is default but \code{"moveend"} can be smoother.} 26 | 27 | \item{hidden}{hide on start} 28 | 29 | \item{zoomIntervals}{use different intervals in different zoom levels. If not specified, all zoom levels use value in interval option.} 30 | 31 | \item{layerId}{the layer id} 32 | 33 | \item{group}{the name of the group this layer belongs to.} 34 | } 35 | \description{ 36 | Add a simple Graticule on the map 37 | } 38 | \examples{ 39 | \donttest{leaflet() \%>\% 40 | addTiles() \%>\% 41 | addSimpleGraticule()} 42 | 43 | } 44 | \seealso{ 45 | \url{https://github.com/ablakey/Leaflet.SimpleGraticule} 46 | } 47 | -------------------------------------------------------------------------------- /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( 8 | map, 9 | resolution = 2, 10 | time = NULL, 11 | layerId = NULL, 12 | group = NULL, 13 | options = pathOptions(pointerEvents = "none", clickable = FALSE) 14 | ) 15 | } 16 | \arguments{ 17 | \item{map}{a map widget object} 18 | 19 | \item{resolution}{the step size at which the terminator points are computed. 20 | The step size is 1 degree/resolution, i.e., higher resolution values have 21 | smaller step sizes and more points in the polygon. The default value is 2.} 22 | 23 | \item{time}{Time} 24 | 25 | \item{layerId}{the layer id} 26 | 27 | \item{group}{the name of the group this layer belongs to.} 28 | 29 | \item{options}{the path options for the daynight layer} 30 | } 31 | \description{ 32 | See \url{https://github.com/joergdietrich/Leaflet.Terminator} 33 | } 34 | \examples{ 35 | leaf <- leaflet() \%>\% 36 | addTiles() \%>\% 37 | addTerminator() 38 | leaf 39 | 40 | } 41 | -------------------------------------------------------------------------------- /man/atlStorms2005.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{atlStorms2005} 5 | \alias{atlStorms2005} 6 | \title{Atlantic Ocean storms 2005} 7 | \format{ 8 | \code{sf} object 9 | } 10 | \description{ 11 | Atlantic Ocean storms 2005 12 | } 13 | \details{ 14 | This dataset contains storm tracks for selected storms 15 | in the Atlantic Ocean basin for the year 2005 16 | } 17 | \seealso{ 18 | Other built in datasets: 19 | \code{\link{breweries91}}, 20 | \code{\link{gadmCHE}} 21 | } 22 | \concept{built in datasets} 23 | -------------------------------------------------------------------------------- /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]{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 | -------------------------------------------------------------------------------- /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} 6 | \usage{ 7 | awesomeIcons( 8 | icon = "home", 9 | library = "glyphicon", 10 | markerColor = "blue", 11 | iconColor = "white", 12 | spin = FALSE, 13 | extraClasses = NULL, 14 | squareMarker = FALSE, 15 | iconRotate = 0, 16 | fontFamily = "monospace", 17 | text = NULL 18 | ) 19 | } 20 | \arguments{ 21 | \item{icon}{Name of the icon} 22 | 23 | \item{library}{Which icon library. Default \code{"glyphicon"}, other possible 24 | values are \code{"fa"} (fontawesome) or \code{"ion"} (ionicons).} 25 | 26 | \item{markerColor}{Possible values are \code{"red"}, \code{"darkred"}, \code{"lightred"}, \code{"orange"}, 27 | \code{"beige"}, \code{"green"}, \code{"darkgreen"}, \code{"lightgreen"}, \code{"blue"}, 28 | \code{"darkblue"}, \code{"lightblue"}, \code{"purple"}, \code{"darkpurple"}, \code{"pink"}, 29 | \code{"cadetblue"}, \code{"white"}, \code{"gray"}, \code{"lightgray"}, \code{"black"}} 30 | 31 | \item{iconColor}{The color to use for the icon itself. Use any CSS-valid 32 | color (hex, rgba, etc.) or a named web color.} 33 | 34 | \item{spin}{If \code{TRUE}, make the icon spin (only works when \code{library = "fa"})} 35 | 36 | \item{extraClasses}{Additional css classes to include on the icon.} 37 | 38 | \item{squareMarker}{Whether to use a square marker.} 39 | 40 | \item{iconRotate}{Rotate the icon by a given angle.} 41 | 42 | \item{fontFamily}{Used when \code{text} option is specified.} 43 | 44 | \item{text}{Use this text string instead of an icon. Argument of 45 | \code{\link[=addAwesomeMarkers]{addAwesomeMarkers()}}.} 46 | } 47 | \value{ 48 | A list of awesome-icon data that can be passed to the \code{icon} 49 | } 50 | \description{ 51 | An icon can be represented as a list of the form \code{list(icon, library, ...)}. This function is vectorized over its arguments to create a list of 52 | icon data. Shorter argument values will be recycled. \code{NULL} values for 53 | these arguments will be ignored. 54 | } 55 | \seealso{ 56 | \url{https://github.com/lennardv2/Leaflet.awesome-markers} 57 | } 58 | -------------------------------------------------------------------------------- /man/breweries91.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{breweries91} 5 | \alias{breweries91} 6 | \title{Selected breweries in Franconia} 7 | \format{ 8 | \code{sf} object 9 | } 10 | \description{ 11 | Selected breweries in Franconia (zip code starting with 91...) 12 | } 13 | \details{ 14 | This dataset contains selected breweries in Franconia. It is a 15 | subset of a larger database that was compiled by students at the 16 | University of Marburg for a seminar called 17 | "The Geography of Beer, sustainability in the food industry" 18 | } 19 | \seealso{ 20 | Other built in datasets: 21 | \code{\link{atlStorms2005}}, 22 | \code{\link{gadmCHE}} 23 | } 24 | \concept{built in datasets} 25 | -------------------------------------------------------------------------------- /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( 11 | outputId, 12 | width, 13 | height, 14 | initialTileLayer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", 15 | initialTileLayerAttribution = NULL, 16 | options = NULL 17 | ) 18 | } 19 | \arguments{ 20 | \item{session, outputId}{Deprecated} 21 | 22 | \item{width, height, initialTileLayer, initialTileLayerAttribution, options}{Deprecated} 23 | } 24 | \description{ 25 | These functions are provided for backwards compatibility with the first 26 | iteration of the leaflet bindings 27 | (\url{https://github.com/jcheng5/leaflet-shiny}). 28 | } 29 | \keyword{internal} 30 | -------------------------------------------------------------------------------- /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 | \alias{derivePolygons} 6 | \title{Normalize data to a data frame or Spatial object.} 7 | \usage{ 8 | derivePoints( 9 | data, 10 | lng = NULL, 11 | lat = NULL, 12 | missingLng = missing(lng), 13 | missingLat = missing(lat), 14 | funcName = "f" 15 | ) 16 | 17 | derivePolygons( 18 | data, 19 | lng = NULL, 20 | lat = NULL, 21 | missingLng = missing(lng), 22 | missingLat = missing(lat), 23 | funcName = "f" 24 | ) 25 | } 26 | \arguments{ 27 | \item{data}{map data} 28 | 29 | \item{lng, lat}{longitude and latitude} 30 | 31 | \item{missingLng}{whether lng is missing} 32 | 33 | \item{missingLat}{whether lat is missing} 34 | 35 | \item{funcName}{Name of calling function (for logging)} 36 | } 37 | \value{ 38 | \itemize{ 39 | \item \code{derivePoints()} returns a lng/lat data frame. 40 | \item \code{derivePolygons()} returns a list with bbox attributes. 41 | } 42 | } 43 | \description{ 44 | Given a data object and lng/lat arguments (which may be \code{NULL}) 45 | [meaning infer from data], formula [which should be evaluated with respect to the data], or 46 | vector data [which should be used as-is]) return a lng/lat data frame. 47 | } 48 | \keyword{internal} 49 | -------------------------------------------------------------------------------- /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( 9 | map, 10 | funcName, 11 | leaflet = stop(paste(funcName, "requires a map proxy object")), 12 | leaflet_proxy = stop(paste(funcName, "does not support map proxy objects")) 13 | ) 14 | 15 | invokeMethod(map, data, method, ...) 16 | } 17 | \arguments{ 18 | \item{map}{a map object, as returned from \code{\link[=leaflet]{leaflet()}} or \code{\link[=leafletProxy]{leafletProxy()}}} 19 | 20 | \item{funcName}{the name of the function that the user called that caused 21 | this \code{dispatch} call; for error message purposes} 22 | 23 | \item{leaflet}{an action to be performed if the map is from \code{\link[=leaflet]{leaflet()}}} 24 | 25 | \item{leaflet_proxy}{an action to be performed if the map is from \code{\link[=leafletProxy]{leafletProxy()}}.} 26 | 27 | \item{data}{a data object that will be used when evaluating formulas in \code{...}} 28 | 29 | \item{method}{the name of the JavaScript method to invoke} 30 | 31 | \item{...}{unnamed arguments to be passed to the JavaScript method} 32 | } 33 | \value{ 34 | \code{dispatch()} returns the value of \code{leaflet} or 35 | \code{leaflet_proxy()}, or an error. \code{invokeMethod()} returns the 36 | \code{map} object that was passed in, possibly modified. 37 | } 38 | \description{ 39 | Extension points for plugins 40 | } 41 | -------------------------------------------------------------------------------- /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{easyButtonState} 5 | \alias{easyButton} 6 | \alias{addEasyButton} 7 | \alias{addEasyButtonBar} 8 | \title{Create an easyButton statestate} 9 | \usage{ 10 | easyButtonState(stateName, icon, title, onClick) 11 | 12 | easyButton( 13 | icon = NULL, 14 | title = NULL, 15 | onClick = NULL, 16 | position = "topleft", 17 | id = NULL, 18 | states = NULL 19 | ) 20 | 21 | addEasyButton(map, button) 22 | 23 | addEasyButtonBar(map, ..., position = "topleft", id = NULL) 24 | } 25 | \arguments{ 26 | \item{stateName}{a unique name for the state} 27 | 28 | \item{icon}{the button icon} 29 | 30 | \item{title}{text to show on hover} 31 | 32 | \item{onClick}{the action to take} 33 | 34 | \item{position}{topleft|topright|bottomleft|bottomright} 35 | 36 | \item{id}{id for the button} 37 | 38 | \item{states}{the states} 39 | 40 | \item{map}{a map widget object} 41 | 42 | \item{button}{the button object created with \code{\link[=easyButton]{easyButton()}}} 43 | 44 | \item{...}{a list of buttons created with \code{\link[=easyButton]{easyButton()}}} 45 | } 46 | \description{ 47 | Create an easyButton statestate 48 | 49 | Creates an easy button. 50 | 51 | Add a EasyButton on the map 52 | see \url{https://github.com/CliffCloud/Leaflet.EasyButton} 53 | 54 | Add a easyButton bar on the map 55 | see \url{https://github.com/CliffCloud/Leaflet.EasyButton} 56 | } 57 | \section{Functions}{ 58 | \itemize{ 59 | \item \code{easyButtonState()}: state of an easyButton. 60 | 61 | \item \code{addEasyButton()}: add an EasyButton to the map 62 | 63 | \item \code{addEasyButtonBar()}: add an EasyButton to the map 64 | 65 | }} 66 | \examples{ 67 | leaf <- leaflet() \%>\% 68 | addTiles() \%>\% 69 | addEasyButton(easyButton( 70 | icon = htmltools::span(class = "star", htmltools::HTML("★")), 71 | onClick = JS("function(btn, map){ map.setZoom(1);}"))) 72 | leaf 73 | 74 | leaf <- leaflet() \%>\% 75 | addTiles() \%>\% 76 | addEasyButtonBar( 77 | easyButton( 78 | icon = htmltools::span(class = "star", htmltools::HTML("★")), 79 | onClick = JS("function(btn, map){ alert(\"Button 1\");}")), 80 | easyButton( 81 | icon = htmltools::span(class = "star", htmltools::HTML("⌖")), 82 | onClick = JS("function(btn, map){ alert(\"Button 2\");}"))) 83 | leaf 84 | 85 | 86 | } 87 | \seealso{ 88 | \code{\link[=easyButton]{easyButton()}} 89 | 90 | \url{https://github.com/CliffCloud/Leaflet.EasyButton} 91 | 92 | \code{\link[=addEasyButton]{addEasyButton()}} 93 | } 94 | -------------------------------------------------------------------------------- /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 | \usage{ 7 | evalFormula(list, data) 8 | } 9 | \arguments{ 10 | \item{list}{with members as formulae} 11 | 12 | \item{data}{map data} 13 | } 14 | \description{ 15 | Evaluates if provided. Otherwise, the formula environment is evaluated. 16 | } 17 | \keyword{internal} 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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{Notifies the map of polygons of interest on the map} 6 | \usage{ 7 | expandLimitsBbox(map, poly) 8 | } 9 | \arguments{ 10 | \item{map}{map object} 11 | 12 | \item{poly}{A spatial object representing a polygon.} 13 | } 14 | \description{ 15 | Same as \code{expandLimits()}, but takes a polygon (that presumably has a bbox attr) 16 | rather than lat/lng. 17 | } 18 | -------------------------------------------------------------------------------- /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.} 11 | } 12 | \value{ 13 | A list with \code{NULL} elements filtered out. 14 | } 15 | \description{ 16 | Remove NULL elements from a list 17 | } 18 | \keyword{internal} 19 | -------------------------------------------------------------------------------- /man/gadmCHE.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data.R 3 | \docType{data} 4 | \name{gadmCHE} 5 | \alias{gadmCHE} 6 | \title{Administrative borders of Switzerland (level 1)} 7 | \format{ 8 | \code{sf} object 9 | } 10 | \source{ 11 | \url{https://gadm.org} 12 | } 13 | \description{ 14 | Administrative borders of Switzerland (level 1) 15 | } 16 | \details{ 17 | This dataset comes from \url{https://gadm.org}. 18 | It was downloaded using \code{\link[raster:getData]{raster::getData()}}. 19 | } 20 | \seealso{ 21 | Other built in datasets: 22 | \code{\link{atlStorms2005}}, 23 | \code{\link{breweries91}} 24 | } 25 | \concept{built in datasets} 26 | -------------------------------------------------------------------------------- /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{Extract the map's data} 6 | \usage{ 7 | getMapData(map) 8 | } 9 | \arguments{ 10 | \item{map}{the map} 11 | } 12 | \value{ 13 | The map's data 14 | } 15 | \description{ 16 | Extract the map's data 17 | } 18 | -------------------------------------------------------------------------------- /man/groupOptions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/layers.R 3 | \name{groupOptions} 4 | \alias{groupOptions} 5 | \title{Set options on layer groups} 6 | \usage{ 7 | groupOptions(map, group, zoomLevels = NULL) 8 | } 9 | \arguments{ 10 | \item{map}{the map to modify} 11 | 12 | \item{group}{character vector of one or more group names to set options on} 13 | 14 | \item{zoomLevels}{numeric vector of zoom levels at which group(s) should be 15 | visible, or \code{TRUE} to display at all zoom levels} 16 | } 17 | \description{ 18 | Change options on layer groups. Currently the only option is to control what 19 | zoom levels a layer group will be displayed at. The \code{zoomLevels} option 20 | is not compatible with \link[=addLayersControl]{layers control}; do not both 21 | assign a group to zoom levels and use it with \code{addLayersControl()}. 22 | } 23 | \examples{ 24 | pal <- colorQuantile("YlOrRd", quakes$mag) 25 | 26 | leaflet() \%>\% 27 | # Basic markers 28 | addTiles(group = "basic") \%>\% 29 | addMarkers(data = quakes, group = "basic") \%>\% 30 | # When zoomed in, we'll show circles at the base of each marker whose 31 | # radius and color reflect the magnitude 32 | addProviderTiles(providers$Esri.WorldTopoMap, group = "detail") \%>\% 33 | addCircleMarkers(data = quakes, group = "detail", fillOpacity = 0.5, 34 | radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) \%>\% 35 | # Set the detail group to only appear when zoomed in 36 | groupOptions("detail", zoomLevels = 7:18) 37 | 38 | } 39 | -------------------------------------------------------------------------------- /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]{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 | -------------------------------------------------------------------------------- /man/leaflet-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/leaflet-package.R 3 | \docType{package} 4 | \name{leaflet-package} 5 | \alias{leaflet-package} 6 | \title{leaflet: Create Interactive Web Maps with the JavaScript 'Leaflet' Library} 7 | \description{ 8 | Create and customize interactive maps using the 'Leaflet' JavaScript library and the 'htmlwidgets' package. These maps can be used directly from the R console, from 'RStudio', in Shiny applications and R Markdown documents. 9 | } 10 | \seealso{ 11 | Useful links: 12 | \itemize{ 13 | \item \url{https://rstudio.github.io/leaflet/} 14 | \item \url{https://github.com/rstudio/leaflet} 15 | \item Report bugs at \url{https://github.com/rstudio/leaflet/issues} 16 | } 17 | 18 | } 19 | \author{ 20 | \strong{Maintainer}: Joe Cheng \email{joe@posit.co} 21 | 22 | Authors: 23 | \itemize{ 24 | \item Barret Schloerke \email{barret@posit.co} (\href{https://orcid.org/0000-0001-9986-114X}{ORCID}) 25 | \item Bhaskar Karambelkar 26 | \item Yihui Xie 27 | } 28 | 29 | Other contributors: 30 | \itemize{ 31 | \item Hadley Wickham [contributor] 32 | \item Kenton Russell [contributor] 33 | \item Kent Johnson [contributor] 34 | \item Vladimir Agafonkin (Leaflet library) [contributor, copyright holder] 35 | \item CloudMade (Leaflet library) [copyright holder] 36 | \item Leaflet contributors (Leaflet library) [contributor] 37 | \item Brandon Copeland (leaflet-measure plugin) [contributor, copyright holder] 38 | \item Joerg Dietrich (Leaflet.Terminator plugin) [contributor, copyright holder] 39 | \item Benjamin Becquet (Leaflet.MagnifyingGlass plugin) [contributor, copyright holder] 40 | \item Norkart AS (Leaflet.MiniMap plugin) [contributor, copyright holder] 41 | \item L. Voogdt (Leaflet.awesome-markers plugin) [contributor, copyright holder] 42 | \item Daniel Montague (Leaflet.EasyButton plugin) [contributor, copyright holder] 43 | \item Kartena AB (Proj4Leaflet plugin) [contributor, copyright holder] 44 | \item Robert Kajic (leaflet-locationfilter plugin) [contributor, copyright holder] 45 | \item Mapbox (leaflet-omnivore plugin) [contributor, copyright holder] 46 | \item Michael Bostock (topojson) [contributor, copyright holder] 47 | \item Posit Software, PBC [copyright holder, funder] 48 | } 49 | 50 | } 51 | \keyword{internal} 52 | -------------------------------------------------------------------------------- /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{ 8 | An object of class \code{list} of length 13. 9 | } 10 | \usage{ 11 | leafletDependencies 12 | } 13 | \description{ 14 | Various leaflet dependency functions for use in downstream packages 15 | } 16 | \examples{ 17 | \dontrun{ 18 | addBootStrap <- function(map) { 19 | map$dependencies <- c(map$dependencies, leafletDependencies$bootstrap()) 20 | map 21 | } 22 | } 23 | } 24 | \keyword{datasets} 25 | -------------------------------------------------------------------------------- /man/leafletProxy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{leafletProxy} 4 | \alias{leafletProxy} 5 | \title{Send commands to a Leaflet instance in a Shiny app} 6 | \usage{ 7 | leafletProxy( 8 | mapId, 9 | session = shiny::getDefaultReactiveDomain(), 10 | data = NULL, 11 | deferUntilFlush = TRUE 12 | ) 13 | } 14 | \arguments{ 15 | \item{mapId}{single-element character vector indicating the output ID of the 16 | map to modify (if invoked from a Shiny module, the namespace will be added 17 | automatically)} 18 | 19 | \item{session}{the Shiny session object to which the map belongs; usually the 20 | default value will suffice} 21 | 22 | \item{data}{a data object; see Details under the \code{\link[=leaflet]{leaflet()}} help 23 | topic} 24 | 25 | \item{deferUntilFlush}{indicates whether actions performed against this 26 | instance should be carried out right away, or whether they should be held 27 | until after the next time all of the outputs are updated; defaults to 28 | \code{TRUE}} 29 | } 30 | \description{ 31 | Creates a map-like object that can be used to customize and control a map 32 | that has already been rendered. For use in Shiny apps and Shiny docs only. 33 | } 34 | \details{ 35 | Normally, you create a Leaflet map using \code{\link[=leaflet]{leaflet()}}. 36 | This creates an in-memory representation of a map that you can customize 37 | using functions like \code{\link[=addPolygons]{addPolygons()}} and \code{\link[=setView]{setView()}}. 38 | Such a map can be printed at the R console, included in an R Markdown 39 | document, or rendered as a Shiny output. 40 | 41 | In the case of Shiny, you may want to further customize a map, even after it 42 | is rendered to an output. At this point, the in-memory representation of the 43 | map is long gone, and the user's web browser has already realized the Leaflet 44 | map instance. 45 | 46 | This is where \code{leafletProxy()} comes in. It returns an object that can 47 | stand in for the usual Leaflet map object. The usual map functions like 48 | \code{\link[=addPolygons]{addPolygons()}} and \code{\link[=setView]{setView()}} can be called, and 49 | instead of customizing an in-memory representation, these commands will 50 | execute on the live Leaflet map instance. 51 | } 52 | \examples{ 53 | library(shiny) 54 | 55 | ui <- fluidPage( 56 | leafletOutput("map1") 57 | ) 58 | 59 | map <- leaflet() \%>\% addCircleMarkers( 60 | lng = runif(10), 61 | lat = runif(10), 62 | layerId = paste0("marker", 1:10)) 63 | server <- function(input, output, session) { 64 | output$map1 <- renderLeaflet(map) 65 | 66 | observeEvent(input$map1_marker_click, { 67 | leafletProxy("map1", session) \%>\% 68 | removeMarker(input$map1_marker_click$id) 69 | }) 70 | } 71 | 72 | app <- shinyApp(ui, server) 73 | \donttest{if (interactive()) app} 74 | 75 | } 76 | -------------------------------------------------------------------------------- /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( 8 | icon = "home", 9 | library = "glyphicon", 10 | markerColor = "blue", 11 | iconColor = "white", 12 | spin = FALSE, 13 | extraClasses = NULL, 14 | squareMarker = FALSE, 15 | iconRotate = 0, 16 | fontFamily = "monospace", 17 | text = NULL 18 | ) 19 | } 20 | \arguments{ 21 | \item{icon}{Name of the icon} 22 | 23 | \item{library}{Which icon library. Default \code{"glyphicon"}, other possible 24 | values are \code{"fa"} (fontawesome) or \code{"ion"} (ionicons).} 25 | 26 | \item{markerColor}{Possible values are \code{"red"}, \code{"darkred"}, \code{"lightred"}, \code{"orange"}, 27 | \code{"beige"}, \code{"green"}, \code{"darkgreen"}, \code{"lightgreen"}, \code{"blue"}, 28 | \code{"darkblue"}, \code{"lightblue"}, \code{"purple"}, \code{"darkpurple"}, \code{"pink"}, 29 | \code{"cadetblue"}, \code{"white"}, \code{"gray"}, \code{"lightgray"}, \code{"black"}} 30 | 31 | \item{iconColor}{The color to use for the icon itself. Use any CSS-valid 32 | color (hex, rgba, etc.) or a named web color.} 33 | 34 | \item{spin}{If \code{TRUE}, make the icon spin (only works when \code{library = "fa"})} 35 | 36 | \item{extraClasses}{Additional css classes to include on the icon.} 37 | 38 | \item{squareMarker}{Whether to use a square marker.} 39 | 40 | \item{iconRotate}{Rotate the icon by a given angle.} 41 | 42 | \item{fontFamily}{Used when \code{text} option is specified.} 43 | 44 | \item{text}{Use this text string instead of an icon. Argument of 45 | \code{\link[=addAwesomeMarkers]{addAwesomeMarkers()}}.} 46 | } 47 | \description{ 48 | Make Awesome Icon 49 | } 50 | -------------------------------------------------------------------------------- /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( 8 | iconUrl = NULL, 9 | iconRetinaUrl = NULL, 10 | iconWidth = NULL, 11 | iconHeight = NULL, 12 | iconAnchorX = NULL, 13 | iconAnchorY = NULL, 14 | shadowUrl = NULL, 15 | shadowRetinaUrl = NULL, 16 | shadowWidth = NULL, 17 | shadowHeight = NULL, 18 | shadowAnchorX = NULL, 19 | shadowAnchorY = NULL, 20 | popupAnchorX = NULL, 21 | popupAnchorY = NULL, 22 | className = NULL 23 | ) 24 | } 25 | \arguments{ 26 | \item{iconUrl}{the URL or file path to the icon image} 27 | 28 | \item{iconRetinaUrl}{the URL or file path to a retina sized version of the 29 | icon image} 30 | 31 | \item{iconWidth, iconHeight}{size of the icon image in pixels} 32 | 33 | \item{iconAnchorX, iconAnchorY}{the coordinates of the "tip" of the icon 34 | (relative to its top left corner, i.e., the top left corner means 35 | \code{iconAnchorX = 0} and \code{iconAnchorY = 0}), and the icon will be 36 | aligned so that this point is at the marker's geographical location} 37 | 38 | \item{shadowUrl}{the URL or file path to the icon shadow image} 39 | 40 | \item{shadowRetinaUrl}{the URL or file path to the retina sized version of 41 | the icon shadow image} 42 | 43 | \item{shadowWidth, shadowHeight}{size of the shadow image in pixels} 44 | 45 | \item{shadowAnchorX, shadowAnchorY}{the coordinates of the "tip" of the shadow} 46 | 47 | \item{popupAnchorX, popupAnchorY}{the coordinates of the point from which 48 | popups will "open", relative to the icon anchor} 49 | 50 | \item{className}{a custom class name to assign to both icon and shadow images} 51 | } 52 | \description{ 53 | Define icon sets 54 | } 55 | -------------------------------------------------------------------------------- /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{setView} 5 | \alias{flyTo} 6 | \alias{fitBounds} 7 | \alias{flyToBounds} 8 | \alias{setMaxBounds} 9 | \alias{clearBounds} 10 | \title{Methods to manipulate the map widget} 11 | \usage{ 12 | setView(map, lng, lat, zoom, options = list()) 13 | 14 | flyTo(map, lng, lat, zoom, options = list()) 15 | 16 | fitBounds(map, lng1, lat1, lng2, lat2, options = list()) 17 | 18 | flyToBounds(map, lng1, lat1, lng2, lat2, options = list()) 19 | 20 | setMaxBounds(map, lng1, lat1, lng2, lat2) 21 | 22 | clearBounds(map) 23 | } 24 | \arguments{ 25 | \item{map}{a map widget object created from \code{\link[=leaflet]{leaflet()}}} 26 | 27 | \item{lng}{The longitude of the map center} 28 | 29 | \item{lat}{The latitude of the map center} 30 | 31 | \item{zoom}{the zoom level} 32 | 33 | \item{options}{a list of zoom/pan options (see 34 | \url{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#zoom/pan-options})} 35 | 36 | \item{lng1, lat1, lng2, lat2}{the coordinates of the map bounds} 37 | } 38 | \value{ 39 | The modified map widget. 40 | } 41 | \description{ 42 | A series of methods to manipulate the map. 43 | } 44 | \section{Functions}{ 45 | \itemize{ 46 | \item \code{setView()}: Set the view of the map (center and zoom level) 47 | 48 | \item \code{flyTo()}: Flys to a given location/zoom-level using smooth pan-zoom. 49 | 50 | \item \code{fitBounds()}: Set the bounds of a map 51 | 52 | \item \code{flyToBounds()}: Flys to given bound using smooth pan/zoom. 53 | 54 | \item \code{setMaxBounds()}: Restricts the map view to the given bounds 55 | 56 | \item \code{clearBounds()}: Clear the bounds of a map, and the bounds will be 57 | automatically determined from latitudes and longitudes of the map elements 58 | if available (otherwise the full world view is used) 59 | 60 | }} 61 | \examples{ 62 | \donttest{m <- leaflet() \%>\% addTiles() \%>\% setView(-71.0382679, 42.3489054, zoom = 18) 63 | m # the RStudio 'headquarter' 64 | m \%>\% fitBounds(-72, 40, -70, 43) 65 | m \%>\% clearBounds() # world view 66 | } 67 | } 68 | \references{ 69 | \url{https://web.archive.org/web/20220702182250/https://leafletjs.com/reference-1.3.4.html#map-methods-for-modifying-map-state} 70 | } 71 | -------------------------------------------------------------------------------- /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:htmlwidgets-shiny]{htmlwidgets::shinyWidgetOutput()}})} 17 | 18 | \item{expr}{An expression that generates an HTML widget (or a 19 | \href{https://rstudio.github.io/promises/}{promise} of an HTML widget).} 20 | 21 | \item{env}{The environment in which to evaluate \code{expr}.} 22 | 23 | \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This 24 | is useful if you want to save an expression in a variable.} 25 | } 26 | \description{ 27 | Use \code{leafletOutput()} to create a UI element, and \code{renderLeaflet()} 28 | to render the map widget. 29 | } 30 | \examples{ 31 | # !formatR 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 | \donttest{if (interactive()) app} 42 | } 43 | -------------------------------------------------------------------------------- /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]{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 | -------------------------------------------------------------------------------- /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]{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 | -------------------------------------------------------------------------------- /man/providers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plugin-providers.R 3 | \name{providers} 4 | \alias{providers} 5 | \alias{providers.details} 6 | \title{Providers} 7 | \format{ 8 | A list of characters 9 | } 10 | \source{ 11 | \url{https://github.com/leaflet-extras/leaflet-providers/blob/0a9e27f8c6c26956b4e78c26e1945d748e3c2869/leaflet-providers.js} 12 | } 13 | \description{ 14 | List of all providers with their variations 15 | } 16 | \examples{ 17 | providers 18 | } 19 | -------------------------------------------------------------------------------- /man/reexports.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/leaflet-package.R 3 | \docType{import} 4 | \name{reexports} 5 | \alias{reexports} 6 | \alias{\%>\%} 7 | \alias{JS} 8 | \title{Objects exported from other packages} 9 | \keyword{internal} 10 | \description{ 11 | These objects are imported from other packages. Follow the links 12 | below to see their documentation. 13 | 14 | \describe{ 15 | \item{htmlwidgets}{\code{\link[htmlwidgets]{JS}}} 16 | 17 | \item{magrittr}{\code{\link[magrittr:pipe]{\%>\%}}} 18 | }} 19 | 20 | -------------------------------------------------------------------------------- /man/safeLabel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/layers.R 3 | \name{safeLabel} 4 | \alias{safeLabel} 5 | \title{Sanitize textual labels} 6 | \usage{ 7 | safeLabel(label, data) 8 | } 9 | \arguments{ 10 | \item{label}{A vector or list of plain characters or HTML (marked by 11 | \code{\link[htmltools:HTML]{htmltools::HTML()}}), or a formula that resolves to such a value.} 12 | 13 | \item{data}{A data frame over which the formula is evaluated.} 14 | } 15 | \description{ 16 | This is a helper function used internally to HTML-escape user-provided 17 | labels. It prevents strings from unintentionally being treated as HTML when 18 | they are intended to be plaintext. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /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{showGroup} 5 | \alias{hideGroup} 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]{addLayersControl()}} to allow users to show/hide layer 24 | groups interactively 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 = TRUE, mode = c("point", "polygon")) 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 | \item{mode}{if \code{"point"} then warn about any \code{NA} lng/lat values; 19 | if \code{"polygon"} then \code{NA} values are expected to be used as 20 | polygon delimiters} 21 | } 22 | \description{ 23 | Utility function to check if a coordinates is valid 24 | } 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leaflet-r-package", 3 | "private": true, 4 | "scripts": { 5 | "build": "grunt build", 6 | "watch": "grunt" 7 | }, 8 | "license": "GPL-3.0", 9 | "devDependencies": { 10 | "@babel/core": "^7.11.4", 11 | "@babel/preset-env": "^7.11.0", 12 | "babel-plugin-transform-es2015-modules-commonjs": "^6.14.0", 13 | "babel-register": "^6.14.0", 14 | "babelify": "^10.0.0", 15 | "browserify": "^17.0.0", 16 | "eslint": ">=7.7.0", 17 | "grunt": "^1.3.0", 18 | "grunt-babel": "^8.0.0", 19 | "grunt-browserify": "^6.0.0", 20 | "grunt-cli": "^1.2.0", 21 | "grunt-contrib-watch": "^1.0.0", 22 | "grunt-eslint": "^23.0.0", 23 | "grunt-mocha-test": "^0.13.3", 24 | "mocha": "^9.1.2", 25 | "source-map-support": "^0.5.19" 26 | }, 27 | "files": [] 28 | } 29 | -------------------------------------------------------------------------------- /pkgdown/assets/nc/oisst-sst.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/pkgdown/assets/nc/oisst-sst.nc -------------------------------------------------------------------------------- /revdep/.gitignore: -------------------------------------------------------------------------------- 1 | checks 2 | library 3 | *.noindex 4 | data.sqlite 5 | *.html 6 | -------------------------------------------------------------------------------- /revdep/README.md: -------------------------------------------------------------------------------- 1 | # Revdeps 2 | 3 | ## Failed to check (5) 4 | 5 | |package |version |error |warning |note | 6 | |:--------------------|:-------|:-----|:-------|:----| 7 | |inlmisc |? | | | | 8 | |leaflet.multiopacity |? | | | | 9 | |leaflet.opacity |? | | | | 10 | |modchart |? | | | | 11 | |palmid |? | | | | 12 | 13 | -------------------------------------------------------------------------------- /revdep/cran.md: -------------------------------------------------------------------------------- 1 | ## revdepcheck results 2 | 3 | We checked 167 reverse dependencies (162 from CRAN + 5 from Bioconductor), comparing R CMD check results across CRAN and dev versions of this package. 4 | 5 | * We saw 0 new problems 6 | * We failed to check 0 packages 7 | 8 | -------------------------------------------------------------------------------- /revdep/failures.md: -------------------------------------------------------------------------------- 1 | # inlmisc 2 | 3 |
4 | 5 | * Version: NA 6 | * GitHub: NA 7 | * Source code: https://github.com/cran/inlmisc 8 | * Number of recursive dependencies: 137 9 | 10 | Run `revdepcheck::cloud_details(, "inlmisc")` for more info 11 | 12 |
13 | 14 | ## Error before installation 15 | 16 | ### Devel 17 | 18 | ``` 19 | 20 | 21 | 22 | 23 | 24 | 25 | ``` 26 | ### CRAN 27 | 28 | ``` 29 | 30 | 31 | 32 | 33 | 34 | 35 | ``` 36 | # leaflet.multiopacity 37 | 38 |
39 | 40 | * Version: NA 41 | * GitHub: NA 42 | * Source code: https://github.com/cran/leaflet.multiopacity 43 | * Number of recursive dependencies: 84 44 | 45 | Run `revdepcheck::cloud_details(, "leaflet.multiopacity")` for more info 46 | 47 |
48 | 49 | ## Error before installation 50 | 51 | ### Devel 52 | 53 | ``` 54 | 55 | 56 | 57 | 58 | 59 | 60 | ``` 61 | ### CRAN 62 | 63 | ``` 64 | 65 | 66 | 67 | 68 | 69 | 70 | ``` 71 | # leaflet.opacity 72 | 73 |
74 | 75 | * Version: NA 76 | * GitHub: NA 77 | * Source code: https://github.com/cran/leaflet.opacity 78 | * Number of recursive dependencies: 77 79 | 80 | Run `revdepcheck::cloud_details(, "leaflet.opacity")` for more info 81 | 82 |
83 | 84 | ## Error before installation 85 | 86 | ### Devel 87 | 88 | ``` 89 | 90 | 91 | 92 | 93 | 94 | 95 | ``` 96 | ### CRAN 97 | 98 | ``` 99 | 100 | 101 | 102 | 103 | 104 | 105 | ``` 106 | # modchart 107 | 108 |
109 | 110 | * Version: NA 111 | * GitHub: NA 112 | * Source code: https://github.com/cran/modchart 113 | * Number of recursive dependencies: 123 114 | 115 | Run `revdepcheck::cloud_details(, "modchart")` for more info 116 | 117 |
118 | 119 | ## Error before installation 120 | 121 | ### Devel 122 | 123 | ``` 124 | 125 | 126 | 127 | 128 | 129 | 130 | ``` 131 | ### CRAN 132 | 133 | ``` 134 | 135 | 136 | 137 | 138 | 139 | 140 | ``` 141 | # palmid 142 | 143 |
144 | 145 | * Version: NA 146 | * GitHub: NA 147 | * Source code: https://github.com/cran/palmid 148 | * Number of recursive dependencies: 128 149 | 150 | Run `revdepcheck::cloud_details(, "palmid")` for more info 151 | 152 |
153 | 154 | ## Error before installation 155 | 156 | ### Devel 157 | 158 | ``` 159 | 160 | 161 | 162 | 163 | 164 | 165 | ``` 166 | ### CRAN 167 | 168 | ``` 169 | 170 | 171 | 172 | 173 | 174 | 175 | ``` 176 | -------------------------------------------------------------------------------- /revdep/problems.md: -------------------------------------------------------------------------------- 1 | *Wow, no problems at all. :)* -------------------------------------------------------------------------------- /scripts/crosstalk_example.R: -------------------------------------------------------------------------------- 1 | # devtools::install_github("jcheng5/d3scatter") 2 | library(d3scatter) 3 | library(crosstalk) 4 | 5 | # library(leaflet) 6 | 7 | shared_quakes <- SharedData$new(quakes[sample(nrow(quakes), 100),]) 8 | bscols( 9 | leaflet(shared_quakes, width = "100%", height = 300) %>% 10 | addTiles() %>% 11 | addMarkers(), 12 | d3scatter(shared_quakes, ~depth, ~mag, width = "100%", height = 300) 13 | ) 14 | -------------------------------------------------------------------------------- /scripts/git_clean.R: -------------------------------------------------------------------------------- 1 | # Check files that should be cleaned (ignoring directories) 2 | needs_cleaned <- system("git clean -xf --dry-run") 3 | 4 | if (length(needs_cleaned)) { 5 | stop( 6 | "There are untracked files in the repo. Please run", 7 | "`git clean -xf --dry-run` to see what will be removed. ", 8 | "Add --force to force removal of untracked files." 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /scripts/raster.R: -------------------------------------------------------------------------------- 1 | library(raster) 2 | r <- raster(xmn = -110, xmx = -90, ymn = 40, ymx = 60, ncols = 40, nrows = 40) 3 | r <- setValues(r, 1:ncell(r)) 4 | projection(r) 5 | # proj.4 projection description 6 | newproj <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +ellps=WGS84" 7 | 8 | #simplest approach 9 | pr1 <- projectRaster(r, crs = newproj) 10 | 11 | prb <- projectRaster(r, pr1, method = "bilinear") 12 | invb <- projectRaster(prb, r, method = "bilinear") 13 | 14 | prn <- projectRaster(r, pr1, method = "ngb") 15 | invn <- projectRaster(prn, r, method = "ngb") 16 | 17 | 18 | par(mfrow = c(1, 2)) 19 | plot(r - invb) 20 | plot(r - invn) 21 | 22 | 23 | 24 | r <- raster(xmn = -60, xmx = -25, ymn = 70, ymx = 81, nrows = 30, ncols = 30) 25 | set.seed(0) 26 | values(r) <- matrix(sample(1:5, 900, replace = TRUE), nrow(r), ncol(r), byrow = TRUE) 27 | # crs(r) <- CRS("+init=epsg:4326") 28 | l <- function(method = "auto") { 29 | leaflet() %>% 30 | addTiles() %>% 31 | addRasterImage(r, colors = "Spectral", opacity = 0.8, method = method) %>% 32 | addMeasure() %>% 33 | addLegend( 34 | title = paste0("Raster\nMethod: ", method), 35 | pal = rasterLegendColor("Spectral", r), 36 | values = values(r) 37 | ) 38 | } 39 | l() 40 | a <- l("bilinear") 41 | l("ngb") 42 | r <- as.factor(r) 43 | l("bilinear") 44 | l("ngb") 45 | -------------------------------------------------------------------------------- /scripts/viztest.R: -------------------------------------------------------------------------------- 1 | remotes::install_github("schloerke/viztest") 2 | # source("scripts/viztest.R") 3 | 4 | 5 | # compare to leaflet.js v0.7.x 6 | # viztest::viztest(".", "rstudio/leaflet@d489e2c", resize = FALSE, stomp = TRUE) 7 | viztest::viztest( 8 | ".", 9 | "leaflet", 10 | output_dir = paste( 11 | "../viztest", 12 | devtools::as.package(".")$package, 13 | devtools::as.package(".")$version, 14 | sep = "-" 15 | ), 16 | resize = FALSE, 17 | stomp = TRUE 18 | ) 19 | 20 | # viztest::viztest(".", "rstudio/leaflet", resize = FALSE, stomp = TRUE, skip_old = TRUE) 21 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(leaflet) 3 | 4 | test_check("leaflet") 5 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/normalize-2.md: -------------------------------------------------------------------------------- 1 | # normalize sp 2 | 3 | [[1]] 4 | [[1]][[1]] 5 | [[1]][[1]][[1]] 6 | lng lat 7 | 1 -1 1 8 | 2 1 1 9 | 3 1 -1 10 | 4 -1 -1 11 | 5 -1 1 12 | 13 | [[1]][[1]][[2]] 14 | lng lat 15 | 1 -0.5 -0.5 16 | 2 0.5 -0.5 17 | 3 0.5 0.5 18 | 4 -0.5 0.5 19 | 5 -0.5 -0.5 20 | 21 | 22 | [[1]][[2]] 23 | [[1]][[2]][[1]] 24 | lng lat 25 | 1 4 6 26 | 2 6 6 27 | 3 6 4 28 | 4 4 4 29 | 5 4 6 30 | 31 | [[1]][[2]][[2]] 32 | lng lat 33 | 1 4.05 4.05 34 | 2 4.45 4.05 35 | 3 4.45 4.45 36 | 4 4.05 4.45 37 | 5 4.05 4.05 38 | 39 | [[1]][[2]][[3]] 40 | lng lat 41 | 1 4.5 4.5 42 | 2 5.5 4.5 43 | 3 5.5 5.5 44 | 4 4.5 5.5 45 | 5 4.5 4.5 46 | 47 | 48 | 49 | attr(,"bbox") 50 | [,1] [,2] 51 | lng -1 6 52 | lat -1 6 53 | 54 | -------------------------------------------------------------------------------- /tests/testthat/helper.R: -------------------------------------------------------------------------------- 1 | create_square <- function(width = 2, lng = 0, lat = 0, hole = FALSE, type = sp::Polygon) { 2 | lngs <- c(lng - width / 2, lng + width / 2, lng + width / 2, lng - width / 2) 3 | lats <- c(lat + width / 2, lat + width / 2, lat - width / 2, lat - width / 2) 4 | 5 | if (hole) { 6 | lngs <- rev(lngs) 7 | lats <- rev(lats) 8 | } 9 | 10 | if ("hole" %in% names(formals(type))) { 11 | type(cbind(lng = lngs, lat = lats), hole = hole) 12 | } else { 13 | type(cbind(lng = lngs, lat = lats)) 14 | } 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/testthat/test-evalFormula.R: -------------------------------------------------------------------------------- 1 | test_that("evalFormula() does not discard the class of a list", { 2 | res <- evalFormula(structure(list(1, ~x, ~x + 1), class = "FOO"), data.frame(x = 2)) 3 | 4 | expect_s3_class(res, "FOO") 5 | }) 6 | 7 | test_that("evalFormula() evaluates formulae in a list", { 8 | res <- evalFormula(structure(list(1, ~x, ~x + 1), class = "FOO"), data.frame(x = 2)) 9 | 10 | expect_equal(res[[2]], 2) 11 | expect_equal(res[[3]], 3) 12 | }) 13 | -------------------------------------------------------------------------------- /tests/testthat/test-icon.R: -------------------------------------------------------------------------------- 1 | test_that("icon deduping works", { 2 | icons <- c("leaf-green.png", "leaf-red.png") 3 | m <- 4 | 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 | expect_equal( 12 | length(m$x$calls[[1]]$args[[3]]$iconUrl$data), 13 | 2 14 | ) 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-measure.R: -------------------------------------------------------------------------------- 1 | test_that("dependency got added", { 2 | expect_true( 3 | !is.na(Position( 4 | function(dep) dep$name == "leaflet-measure", 5 | addMeasure(leaflet())$dependencies 6 | )) 7 | ) 8 | }) 9 | 10 | test_that("call got added", { 11 | expect_true( 12 | !is.na(Position( 13 | function(cl) cl$method == "addMeasure", 14 | addMeasure(leaflet())$x$calls 15 | )) 16 | ) 17 | }) 18 | 19 | test_that("options added as expected", { 20 | expect_true( 21 | Filter( 22 | function(cl) cl$method == "addMeasure", 23 | addMeasure(leaflet(), position = "bottomleft")$x$calls 24 | )[[1]]$args[[1]]$position == "bottomleft" 25 | ) 26 | }) 27 | 28 | # are null options removed 29 | # were options added as expected 30 | test_that("null options removed", { 31 | expect_true( 32 | !("position" %in% names(Filter( 33 | function(cl) cl$method == "addMeasure" 34 | , addMeasure(leaflet(), position = NULL )$x$calls 35 | )[[1]]$args[[1]])) 36 | ) 37 | }) 38 | -------------------------------------------------------------------------------- /tests/testthat/test-raster.R: -------------------------------------------------------------------------------- 1 | 2 | expect_maps_equal <- function(m1, m2) { 3 | attr(m1$x, "leafletData") <- NULL 4 | attr(m2$x, "leafletData") <- NULL 5 | expect_equal(m1, m2, ignore_function_env = TRUE, ignore_formula_env = TRUE) 6 | } 7 | 8 | # Some proj4string values differ only by one having whole numbers represented as 9 | # x while others have x.0. So, strip each trailing .0 value. 10 | normalize_zero_values <- function(str) { 11 | gsub("=(\\d+).0( |$)", "=\\1\\2", str) 12 | } 13 | 14 | test_that("rasters", { 15 | skip_if_not_installed("terra") 16 | 17 | library(terra) 18 | library(raster) 19 | 20 | lux <- terra::rast(system.file("ex/elev.tif", package="terra")) 21 | pmerc <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs" 22 | 23 | plux <- projectRasterForLeaflet(lux, "bilinear") 24 | expect_equal(normalize_zero_values(crs(plux, proj=TRUE)), pmerc) 25 | test <- projectRasterForLeaflet(raster(lux), "bilinear") 26 | expect_equal(normalize_zero_values(proj4string(test)), pmerc) 27 | 28 | # terra and raster have different projection algorithms, and while 29 | # their outputs are very similar, they are not identical. Hence we need 30 | # to use pre-projected rasters and project=FALSE 31 | rtest <- function(x) { 32 | leaflet() %>% addTiles() %>% addRasterImage(x, project=FALSE) 33 | } 34 | 35 | (r1 <- rtest(plux)) 36 | (r2 <- rtest(raster::raster(plux))) 37 | 38 | expect_maps_equal(r1, r2) 39 | 40 | # test with color map 41 | r <- terra::rast(ncols=10, nrows=10, vals=rep_len(10:15, length.out=100), xmin=0, xmax=10^6, ymin=0, ymax=10^6, crs=pmerc) 42 | r[5,] <- NA 43 | coltab(r) <- c(rep("#FFFFFF", 10), rainbow(6, end=.9)) 44 | (r3 <- rtest(r)) 45 | 46 | }) 47 | 48 | -------------------------------------------------------------------------------- /tests/testthat/test-tiles.R: -------------------------------------------------------------------------------- 1 | 2 | testthat::test_that("Checking of tile providers works correctly", { 3 | expect_no_error( 4 | leaflet() %>% addProviderTiles(providers[[1]]) 5 | ) 6 | 7 | expect_no_error( 8 | leaflet() %>% addProviderTiles("FAKETILESET123", check = FALSE) 9 | ) 10 | 11 | expect_error( 12 | leaflet() %>% addProviderTiles("FAKETILESET123") 13 | ) 14 | }) 15 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/articles/images/shiny1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/images/shiny1.png -------------------------------------------------------------------------------- /vignettes/articles/images/shiny2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/images/shiny2.png -------------------------------------------------------------------------------- /vignettes/articles/images/shiny3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/images/shiny3.png -------------------------------------------------------------------------------- /vignettes/articles/js/Bing.min.js: -------------------------------------------------------------------------------- 1 | L.BingLayer=L.TileLayer.extend({options:{subdomains:[0,1,2,3],type:"Aerial",attribution:"Bing",culture:""},initialize:function(t,i){L.Util.setOptions(this,i),this._key=t,this._url=null,this._providers=[],this.metaRequested=!1},tile2quad:function(t,i,e){for(var o="",a=e;a>0;a--){var r=0,n=1<=o.zoomMin&&t.intersects(o.bounds)?(!o.active&&this._map.attributionControl&&this._map.attributionControl.addAttribution(o.attrib),o.active=!0):(o.active&&this._map.attributionControl&&this._map.attributionControl.removeAttribution(o.attrib),o.active=!1)}},onAdd:function(t){this.loadMetadata(),L.TileLayer.prototype.onAdd.apply(this,[t])},onRemove:function(t){for(var i=0;i% addTiles() 24 | ``` 25 | 26 | Use the `addLegend()` function to add a legend. The easiest way to use `addLegend()` is to provide `pal` (a palette function, as generated from `colorNumeric()` et al.) and `values`, and let it calculate the colors and labels for you. 27 | 28 | In most cases you will simply be separating the function and argument you passed into `addPolygons(color=...)`, as in this example: 29 | 30 | ```{r fig.height=2.75} 31 | pal <- colorNumeric( 32 | palette = "YlGnBu", 33 | domain = countries$gdp_md_est 34 | ) 35 | map %>% 36 | addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1, 37 | color = ~pal(gdp_md_est) 38 | ) %>% 39 | addLegend("bottomright", pal = pal, values = ~gdp_md_est, 40 | title = "Est. GDP (2010)", 41 | labFormat = labelFormat(prefix = "$"), 42 | opacity = 1 43 | ) 44 | ``` 45 | 46 | The `addLegend()` function is aware of the different types of palette functions, and will create an appropriate default rendering for each type. For example, contrast the legend created for the `colorNumeric()`-based palette above with the `colorQuantile()`-based palette below. The latter shows probability ranges, with a value range tooltip. 47 | 48 | ```{r} 49 | qpal <- colorQuantile("RdYlBu", countries$gdp_md_est, n = 5) 50 | map %>% 51 | addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1, 52 | color = ~qpal(gdp_md_est) 53 | ) %>% 54 | addLegend(pal = qpal, values = ~gdp_md_est, opacity = 1) 55 | ``` 56 | 57 | `addLegend()` has several other parameters that allows you to customize the legend in various ways. Rather than using `pal` and `values`, you can explicitly pass in `colors` and `labels`. You can change the title and color opacity. 58 | 59 | You can also conveniently customize the label appearance by passing `labFormat=labelFormat()`. `labelFormat()` has parameters that customize the separator between ranges, the number of digits to render, and prefix/suffix for each label. If your label formatting needs extend beyond what `labelFormat()` can provide, you can also use a custom function as the `labFormat` argument; see the Details section in `?addLegend` for a description. 60 | -------------------------------------------------------------------------------- /vignettes/articles/nc/oisst-sst.nc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/nc/oisst-sst.nc -------------------------------------------------------------------------------- /vignettes/articles/shp/cb_2013_us_state_20m.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/shp/cb_2013_us_state_20m.dbf -------------------------------------------------------------------------------- /vignettes/articles/shp/cb_2013_us_state_20m.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /vignettes/articles/shp/cb_2013_us_state_20m.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/shp/cb_2013_us_state_20m.shp -------------------------------------------------------------------------------- /vignettes/articles/shp/cb_2013_us_state_20m.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rstudio/leaflet/947ea176d177fe519ac6d6a9a2366bef033c4c81/vignettes/articles/shp/cb_2013_us_state_20m.shx --------------------------------------------------------------------------------