diff --git a/.bundlemonrc.json b/.bundlemonrc.json new file mode 100644 index 00000000000..e9bba3c5344 --- /dev/null +++ b/.bundlemonrc.json @@ -0,0 +1,18 @@ +{ + "baseDir": "dist", + "files": [ + { + "path": "leaflet.js" + } + ], + "reportOutput": [ + [ + "github", + { + "checkRun": true, + "commitStatus": true, + "prComment": false + } + ] + ] +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..0a5e51c2013 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: / + open-pull-requests-limit: 999 + rebase-strategy: disabled + schedule: + interval: weekly + ignore: + - dependency-name: eslint-config-mourner + update-types: ["version-update:semver-major"] + - dependency-name: sinon + update-types: ["version-update:semver-major"] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8e2d571139..cd21f6252c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,10 @@ env: NODE_VERSION: 16 jobs: setup: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-2019] steps: - name: Check out repository uses: actions/checkout@v2 @@ -29,25 +32,27 @@ jobs: - name: Build project run: npm run build + env: + NODE_ENV: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || '' }} - name: Cache setup uses: actions/cache@v2 with: path: ./* - key: ${{ github.sha }} + key: ${{ runner.os }}-${{ github.sha }} run: needs: setup runs-on: ubuntu-latest strategy: matrix: - command: [lint] + command: [lint, bundlemon] steps: - name: Restore setup uses: actions/cache@v2 with: path: ./* - key: ${{ github.sha }} + key: ${{ runner.os }}-${{ github.sha }} - name: Set up Node uses: actions/setup-node@v2 @@ -56,26 +61,30 @@ jobs: - name: Run ${{ matrix.command }} task run: npm run ${{ matrix.command }} + env: + BUNDLEMON_PROJECT_ID: 61e0545915f6c3000980d0ed + CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }} test: needs: setup - runs-on: ubuntu-latest + runs-on: ${{ matrix.os || 'ubuntu-latest' }} strategy: + fail-fast: false matrix: - browser: - [ - PhantomJSCustom, - Chrome1280x1024, - FirefoxPointer, - FirefoxTouch, - FirefoxPointerTouch, - ] + include: + - browser: Chrome1280x1024 + - browser: FirefoxTouch + - browser: FirefoxNoTouch + - browser: IE + os: windows-2019 + - browser: IE10 + os: windows-2019 steps: - name: Restore setup uses: actions/cache@v2 with: path: ./* - key: ${{ github.sha }} + key: ${{ runner.os }}-${{ github.sha }} - name: Set up Node uses: actions/setup-node@v2 @@ -85,31 +94,16 @@ jobs: - name: Run tests on ${{ matrix.browser }} run: npm test -- --browsers ${{ matrix.browser }} - check-secrets: - needs: [setup] - runs-on: ubuntu-latest + publish-artifacts: + needs: setup if: github.repository_owner == 'Leaflet' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) - outputs: - ok: ${{ steps.ok.outputs.defined }} - steps: - - id: ok - env: - AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - if: env.AWS_S3_BUCKET && env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY - run: echo "::set-output name=defined::true" - - deploy: - needs: [check-secrets] - if: needs.check-secrets.outputs.ok == 'true' runs-on: ubuntu-latest steps: - name: Restore setup uses: actions/cache@v2 with: path: ./* - key: ${{ github.sha }} + key: ${{ runner.os }}-${{ github.sha }} - name: Compress artifacts working-directory: dist @@ -121,13 +115,35 @@ jobs: VERSION=$(git tag --points-at HEAD) echo "::set-output name=path::content/leaflet/${VERSION:-master}" - - name: Deploy artifacts + - name: Publish artifacts uses: jakejarvis/s3-sync-action@v0.5.1 with: - args: --acl public-read --delete + args: --acl public-read --delete --exact-timestamps env: AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} SOURCE_DIR: dist DEST_DIR: ${{ steps.artifacts-directory.outputs.path }} + + publish-npm: + needs: setup + if: github.repository_owner == 'Leaflet' && startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Restore setup + uses: actions/cache@v2 + with: + path: ./* + key: ${{ runner.os }}-${{ github.sha }} + + - name: Set up Node + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: https://registry.npmjs.org + + - name: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 0d912d9eec3..2e410f4f4a2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ dist/reference.html coverage/ *.js.html .mailmap -bower.json component.json debug/local/ Gemfile.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index adf1fec0a0c..ad3f54a5218 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,15 +118,13 @@ on rebuilding the bundles whenever any source file changes. ## Running the Tests -To run the tests from the command line, -install [PhantomJS](http://phantomjs.org/) (and make sure it's in your `PATH`), -then run: +To run the tests from the command line, install [Google Chrome](https://www.google.com/chrome/) then run: ``` npm test ``` -To run all the tests in actual browsers at the same time, you can do: +To run the tests in other browsers at the same time, you can do: ``` npm test -- -- --browsers Firefox,Chrome,Safari,IE diff --git a/FAQ.md b/FAQ.md index 4a675214c83..8949ee80109 100644 --- a/FAQ.md +++ b/FAQ.md @@ -137,5 +137,3 @@ updated automatically on each commit to the repo. We removed the built versions from the repository because it's a chore to build and commit them manually on each change, and it often complicates merging branches and managing contributions. - -There's a common complaint that Leaflet can't be used with [Bower](http://bower.io/) because of that, but we'll resolve the issue soon. diff --git a/LICENSE b/LICENSE index 0cb916b4523..7e994c8773c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,23 +1,26 @@ -Copyright (c) 2010-2021, Vladimir Agafonkin +BSD 2-Clause License + +Copyright (c) 2010-2022, Vladimir Agafonkin Copyright (c) 2010-2011, CloudMade All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/PLUGIN-GUIDE.md b/PLUGIN-GUIDE.md index 09e1cc97089..9aff1985d00 100644 --- a/PLUGIN-GUIDE.md +++ b/PLUGIN-GUIDE.md @@ -213,7 +213,7 @@ Now your plugin is available as an AMD and CommonJS module and can be used in mo Once your plugin is published, it is a good idea to add it to the [Leaflet plugins list](http://leafletjs.com/plugins.html). To do so: * [Fork](https://help.github.com/articles/fork-a-repo/) the Leaflet repo. -* In the `docs/plugins.md` file, find the section your plugin should go in, and add a table row with information and links about your plugin. +* In the `docs/_plugins/` folder, copy the `template.md` file and add it to a category folder. Then put the information and links about your plugin into the new plugin file. * Commit the code to your fork. * [Open a pull request](https://help.github.com/articles/creating-a-pull-request/) from your fork to Leaflet's original repo. diff --git a/RELEASE.md b/RELEASE.md index bd366d0271b..cf4b0a9869f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,28 +1,21 @@ -Documentation for the release process of Leaflet. +## Releasing a new version of Leaflet -**Please note that you will need to have a git remote called `origin` that points to Leaflet's GitHub repo, since the publish script assumes it** -- [ ] Make a new release branch (for example named `prepare-X.Y.Z`) -- [ ] Make sure you do not have any `package.lock.json` or `yarn.lock` locally, since they can potentially make you build with the wrong package versions -- [ ] Update [the changelog](https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md) since last release and commit to the release branch -- [ ] Write a blog post about the new release and put in `/docs/_posts` and commit to the release branch -- [ ] Bump version number in `package.json` and commit to `master` -- [ ] Run `npm run release` +- [ ] Update [the changelog](https://github.com/Leaflet/Leaflet/blob/master/CHANGELOG.md) since last release and commit. +- [ ] Run `npm version ` (this will bump the version in `package.json` and create a new tag). +- [ ] Run `git push --follow-tags` to push the commit created by NPM to Github (together with the tag). +- [ ] Wait for the CI to complete and follow the logs to make sure it runs successfully. - [ ] Verify that the release was correctly published to NPM by checking: - [ ] [Leaflet NPM package page](https://www.npmjs.com/package/leaflet) - [ ] files on [Leaflet unpkg page](https://unpkg.com/leaflet@latest/) -- [ ] Update API docs: - - [ ] run `npm run docs` - - [ ] Copy the built docs from `dist/reference-X.Y.Z.html` to `docs/reference-X.Y.Z.html`, remove content before first and after second "CUT HERE" comment - - [ ] Insert YAML front matter, see old `docs/reference-X.Y.Z.html` for reference - - [ ] Commit the new docs to the release branch -- [ ] Update `docs/reference.html` to redirect to the new version and commit the change to the release branch -- [ ] Update integrity hashes: - - [ ] Checkout the release tag (`git checkout vX.Y.Z`) - - [ ] Run `npm run integrity` or simply `node ./build/integrity.js` if you're not on Debian - - [ ] Copy the hashes and update `integrity_hash_css`, `integrity_hash_source` and `integrity_hash_uglified` in `docs/_config.yml`; commit changes to the release branch -- [ ] Update link to latest release in `docs/download.html`, and commit to the release branch -- [ ] Add link to new version reference in `docs/reference-versions.html`, and commit to the release branch -- [ ] Update `latest_leaflet_version` (and possibly `latest_leaflet_reference`) in `docs/_config.yml` and commit to the release branch -- [ ] Update the announcement section in `docs/index.html` and commit to the release branch -- [ ] If it looks like everything is good at this point, merge the release branch into `master` - [ ] Make a new release on [Leaflet's GitHub release page](https://github.com/Leaflet/Leaflet/releases/) with the most important parts of the changelog + +### Updating docs after the release + +- [ ] Make a new branch for the update +- [ ] Write a blog post about the new release and put it in `/docs/_posts` +- [ ] If necessary to preserve previous version's docs, rename `dist/reference.html` to `dist/reference-X.Y.Z.html` and add it to the list in `docs/reference-versions.html` +- [ ] Run `npm run docs` to generate the new `docs/reference.html` +- [ ] Run `npm run integrity` and make sure `docs/_config.yml` is updated with new hashes +- [ ] Update link to latest release in `docs/download.md` +- [ ] Update the announcement section in `docs/index.html` +- [ ] Commit all the changes and submit a PR for someone to review diff --git a/build/banner.js b/build/banner.js index 82dee2acbda..327745a70e0 100644 --- a/build/banner.js +++ b/build/banner.js @@ -1,6 +1,6 @@ export function createBanner(version) { return `/* @preserve - * Leaflet ${version}, a JS library for interactive maps. http://leafletjs.com + * Leaflet ${version}, a JS library for interactive maps. https://leafletjs.com * (c) 2010-${new Date().getFullYear()} Vladimir Agafonkin, (c) 2010-2011 CloudMade */ `; diff --git a/build/docs.js b/build/docs.js index 4f0599a6e7d..e90544849a4 100755 --- a/build/docs.js +++ b/build/docs.js @@ -1,5 +1,3 @@ -var packageDef = require('../package.json'); - function buildDocs() { console.log('Building Leaflet documentation with Leafdoc ...'); @@ -27,7 +25,7 @@ function buildDocs() { doc.addFile('build/docs-misc.leafdoc', false); var out = doc.outputStr(); - var path = 'dist/reference-' + packageDef.version + '.html'; + var path = 'docs/reference.html'; var fs = require('fs'); diff --git a/build/leafdoc-templates/html.hbs b/build/leafdoc-templates/html.hbs index a6f35ef65eb..74c51a7c873 100644 --- a/build/leafdoc-templates/html.hbs +++ b/build/leafdoc-templates/html.hbs @@ -1,153 +1,128 @@ - - - - {{ title }} - +--- +layout: v2 +title: Documentation +bodyclass: api-page +--- - - - - - - - - - -
+

Leaflet API reference

- +

This reference reflects Leaflet {{site.latest_leaflet_version}}. Check this list if you are using a different version of Leaflet.

-

Leaflet API reference

-
- -
-

UI Layers

- -

Raster Layers

- -

Vector Layers

- -
-
-

Other Layers

- -

Basic Types

- -

Controls

- -
-
- - - - - - -

Utility

- -

DOM Utility

- -
-
-

Base Classes

- - -

Misc

- -
+
+ - - {{{ body }}} - - - +
+

UI Layers

+ +

Raster Layers

+ +

Vector Layers

+
+
+

Other Layers

+ +

Basic Types

+ +

Controls

+ +
+
+

Utility

+ +

DOM Utility

+ +
+
+

Base Classes

+ - - +

Misc

+ +
+
- +{{{ body }}} diff --git a/build/publish.sh b/build/publish.sh deleted file mode 100755 index 31b9876c453..00000000000 --- a/build/publish.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -npm update - -VERSION=$(node --eval "console.log(require('./package.json').version);") - -npm test || exit 1 - -echo "Ready to publish Leaflet version $VERSION." -echo "Has the version number been bumped?" -read -n1 -r -p "Press Ctrl+C to cancel, or any other key to continue." key - -git checkout -b build - -export NODE_ENV=release - -npm run-script build - -echo "Creating git tag v$VERSION..." - -git add dist/leaflet-src.js dist/leaflet.js dist/leaflet-src.esm.js dist/leaflet-src.js.map dist/leaflet.js.map dist/leaflet-src.esm.js.map -f - -git commit -m "v$VERSION" - -git tag v$VERSION -f -git push --tags -f - -echo "Uploading to NPM..." - -npm publish - -git checkout master -git branch -D build - -echo "All done." -echo "Remember to run 'npm run-script integrity' and then commit the changes to the master branch, in order to update the website." diff --git a/build/rollup-config.js b/build/rollup-config.js index 79a8594057f..ea7258feb48 100644 --- a/build/rollup-config.js +++ b/build/rollup-config.js @@ -1,4 +1,4 @@ -// Config file for running Rollup in "normal" mode (non-watch) +// Config file for running Rollup import rollupGitVersion from 'rollup-plugin-git-version'; import json from '@rollup/plugin-json'; @@ -7,33 +7,41 @@ import pkg from '../package.json'; import {createBanner} from './banner'; const release = process.env.NODE_ENV === 'release'; +const watch = process.argv.indexOf('-w') > -1 || process.argv.indexOf('--watch') > -1; // Skip the git branch+rev in the banner when doing a release build const version = release ? pkg.version : `${pkg.version}+${gitRev.branch()}.${gitRev.short()}`; const banner = createBanner(version); const outro = `var oldL = window.L; -exports.noConflict = function() { +leaflet.noConflict = function() { window.L = oldL; return this; } - // Always export us to window global (see #2364) -window.L = exports;`; +window.L = leaflet;`; /** @type {import('rollup').RollupOptions} */ -export default { +const config = { input: 'src/Leaflet.js', output: [ { file: pkg.main, format: 'umd', - name: 'L', + name: 'leaflet', banner: banner, outro: outro, sourcemap: true, freeze: false, esModule: false - }, + } + ], + plugins: [ + release ? json() : rollupGitVersion() + ] +}; + +if (!watch) { + config.output.push( { file: 'dist/leaflet-src.esm.js', format: 'es', @@ -41,8 +49,6 @@ export default { sourcemap: true, freeze: false } - ], - plugins: [ - release ? json() : rollupGitVersion() - ] -}; + ); +} +export default config; diff --git a/build/rollup-watch-config.js b/build/rollup-watch-config.js deleted file mode 100644 index 2e3a765576a..00000000000 --- a/build/rollup-watch-config.js +++ /dev/null @@ -1,27 +0,0 @@ -// Config file for running Rollup in "watch" mode -// This adds a sanity check to help ourselves to run 'rollup -w' as needed. - -import rollupGitVersion from 'rollup-plugin-git-version'; -import gitRev from 'git-rev-sync'; -import pkg from '../package.json'; -import {createBanner} from './banner'; - -const version = `${pkg.version}+${gitRev.branch()}.${gitRev.short()}`; -const banner = createBanner(version); - -/** @type {import('rollup').RollupOptions} */ -export default { - input: 'src/Leaflet.js', - output: { - file: 'dist/leaflet-src.js', - format: 'umd', - name: 'L', - banner: banner, - sourcemap: true, - freeze: false, - esModule: false - }, - plugins: [ - rollupGitVersion() - ] -}; diff --git a/debug/hacks/jitter.html b/debug/hacks/jitter.html index 14858f8160b..29cd01a0083 100644 --- a/debug/hacks/jitter.html +++ b/debug/hacks/jitter.html @@ -8,7 +8,7 @@ - + diff --git a/debug/leaflet-include.js b/debug/leaflet-include.js deleted file mode 120000 index 23dfb1d9bd2..00000000000 --- a/debug/leaflet-include.js +++ /dev/null @@ -1 +0,0 @@ -../dist/leaflet-src.js \ No newline at end of file diff --git a/debug/map/canvas.html b/debug/map/canvas.html index 9234b356c19..ccca55407b3 100644 --- a/debug/map/canvas.html +++ b/debug/map/canvas.html @@ -7,7 +7,7 @@ - + diff --git a/debug/map/control-layers.html b/debug/map/control-layers.html index 32b87b03f98..25dafef018b 100644 --- a/debug/map/control-layers.html +++ b/debug/map/control-layers.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/map/controls.html b/debug/map/controls.html index be9488897f8..24906ed5194 100644 --- a/debug/map/controls.html +++ b/debug/map/controls.html @@ -7,7 +7,7 @@ - + diff --git a/debug/map/geolocation.html b/debug/map/geolocation.html index e54d3474425..774710e4312 100644 --- a/debug/map/geolocation.html +++ b/debug/map/geolocation.html @@ -8,7 +8,7 @@ - + diff --git a/debug/map/grid.html b/debug/map/grid.html index 11f4b6005cd..3757ea7ddcd 100644 --- a/debug/map/grid.html +++ b/debug/map/grid.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/image-overlay.html b/debug/map/image-overlay.html index 13790b5089a..bf1cb1a8ab3 100644 --- a/debug/map/image-overlay.html +++ b/debug/map/image-overlay.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/layer_remove_add.html b/debug/map/layer_remove_add.html index 3fd81328497..dcbc7120a8e 100644 --- a/debug/map/layer_remove_add.html +++ b/debug/map/layer_remove_add.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/map-mobile.html b/debug/map/map-mobile.html index fa9ec287894..5ce5c93cdb1 100644 --- a/debug/map/map-mobile.html +++ b/debug/map/map-mobile.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/map-popup.html b/debug/map/map-popup.html index a0cf98d9c78..e3cb98371c9 100644 --- a/debug/map/map-popup.html +++ b/debug/map/map-popup.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/map-scaled.html b/debug/map/map-scaled.html index 8b88ff7b977..a99809f1dfe 100644 --- a/debug/map/map-scaled.html +++ b/debug/map/map-scaled.html @@ -28,7 +28,7 @@ } - + diff --git a/debug/map/map.html b/debug/map/map.html index 489fb13dfef..1687eaa02ab 100644 --- a/debug/map/map.html +++ b/debug/map/map.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/marker-autopan.html b/debug/map/marker-autopan.html index 6bad94391fe..c708cdd43a0 100644 --- a/debug/map/marker-autopan.html +++ b/debug/map/marker-autopan.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/markers.html b/debug/map/markers.html index 0730f3ea973..3a696f3acce 100644 --- a/debug/map/markers.html +++ b/debug/map/markers.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/max-bounds-bouncy.html b/debug/map/max-bounds-bouncy.html index bd6d866ae88..f8b1849eafb 100644 --- a/debug/map/max-bounds-bouncy.html +++ b/debug/map/max-bounds-bouncy.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/max-bounds-infinite.html b/debug/map/max-bounds-infinite.html index e7c460b783a..02cbba4b53e 100644 --- a/debug/map/max-bounds-infinite.html +++ b/debug/map/max-bounds-infinite.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/max-bounds.html b/debug/map/max-bounds.html index 5e4bf9ccff8..4801af14189 100644 --- a/debug/map/max-bounds.html +++ b/debug/map/max-bounds.html @@ -9,7 +9,7 @@ - + diff --git a/debug/map/opacity.html b/debug/map/opacity.html index a83a1530f8f..738623dc92b 100644 --- a/debug/map/opacity.html +++ b/debug/map/opacity.html @@ -9,7 +9,7 @@ - + - +
diff --git a/debug/map/tile-opacity.html b/debug/map/tile-opacity.html index 5ddf63642c0..31036136d9e 100644 --- a/debug/map/tile-opacity.html +++ b/debug/map/tile-opacity.html @@ -7,7 +7,7 @@ - + diff --git a/debug/map/tooltip.html b/debug/map/tooltip.html index 2cd73ec3aac..de686193fb5 100644 --- a/debug/map/tooltip.html +++ b/debug/map/tooltip.html @@ -7,7 +7,7 @@ - + - + diff --git a/debug/tests/add_remove_layers.html b/debug/tests/add_remove_layers.html index 3b61b184582..02e8db3e89d 100644 --- a/debug/tests/add_remove_layers.html +++ b/debug/tests/add_remove_layers.html @@ -9,7 +9,7 @@ - +
diff --git a/debug/tests/bringtoback.html b/debug/tests/bringtoback.html index e6460255a27..af1d8ea99fb 100644 --- a/debug/tests/bringtoback.html +++ b/debug/tests/bringtoback.html @@ -8,7 +8,7 @@ - + diff --git a/debug/tests/canvasloop.html b/debug/tests/canvasloop.html index 997f8ff07a6..6e3027dcb69 100644 --- a/debug/tests/canvasloop.html +++ b/debug/tests/canvasloop.html @@ -4,7 +4,7 @@ - + diff --git a/debug/tests/click_on_canvas.html b/debug/tests/click_on_canvas.html index d4e02de03d3..a72ef887fb6 100644 --- a/debug/tests/click_on_canvas.html +++ b/debug/tests/click_on_canvas.html @@ -9,7 +9,7 @@ - +
diff --git a/debug/tests/custom-panes.html b/debug/tests/custom-panes.html index 0a6fd08618b..ef993fa12f1 100644 --- a/debug/tests/custom-panes.html +++ b/debug/tests/custom-panes.html @@ -2,15 +2,15 @@ Leaflet debug page - + - + - + - - - + + + - + @@ -63,7 +63,7 @@ },1); } } - + var polygon = (new L.Polygon([ [39, 8.40], [39.10, 8.50], @@ -73,7 +73,7 @@ .on('mouseout',update('exit1')) .on('click',update('click1')) .bindPopup('Triangle 1'); - + var polygon2 = (new L.Polygon([ [39.03, 8.30], [39.10, 8.40], @@ -84,11 +84,11 @@ .on('click',update('click2')) .bindPopup('Triangle 2'); - + var marker = new L.Marker(latlng, {draggable: true}) .bindPopup('Marker');; map.addLayer(marker); - + // map.on('mousemove', function (e) { // marker.setLatLng(e.latlng); @@ -97,7 +97,7 @@ .on('mousemove',update('move3')) .on('mouseout',update('exit3')) .on('click',update('click3')); - + // We should be able to move marker around in a fluid way, // plus going over the polygon with no issue. diff --git a/debug/tests/opacity.html b/debug/tests/opacity.html index 6747d9d2e01..6098a57eab1 100644 --- a/debug/tests/opacity.html +++ b/debug/tests/opacity.html @@ -14,7 +14,7 @@ } - + diff --git a/debug/tests/popup_offset.html b/debug/tests/popup_offset.html index a101853d7b4..83ff95616e0 100644 --- a/debug/tests/popup_offset.html +++ b/debug/tests/popup_offset.html @@ -9,7 +9,7 @@ - + diff --git a/debug/tests/popupcontextmenuclicks.html b/debug/tests/popupcontextmenuclicks.html index 8080f9e1e4d..1251065d401 100644 --- a/debug/tests/popupcontextmenuclicks.html +++ b/debug/tests/popupcontextmenuclicks.html @@ -9,7 +9,7 @@ - + diff --git a/debug/tests/remove_while_dragging.html b/debug/tests/remove_while_dragging.html index 6539738e3c7..5726c782e01 100644 --- a/debug/tests/remove_while_dragging.html +++ b/debug/tests/remove_while_dragging.html @@ -7,7 +7,7 @@ - + diff --git a/debug/tests/removetilewhilepan.html b/debug/tests/removetilewhilepan.html index 8475b0fff6e..0b9bd1c27b2 100644 --- a/debug/tests/removetilewhilepan.html +++ b/debug/tests/removetilewhilepan.html @@ -8,7 +8,7 @@ - + diff --git a/debug/tests/reuse_popups.html b/debug/tests/reuse_popups.html index f1bafbfad54..5feddb99b7d 100644 --- a/debug/tests/reuse_popups.html +++ b/debug/tests/reuse_popups.html @@ -6,7 +6,7 @@ - +
diff --git a/debug/tests/rtl.html b/debug/tests/rtl.html index 2344856cf62..81605a233d6 100644 --- a/debug/tests/rtl.html +++ b/debug/tests/rtl.html @@ -9,7 +9,7 @@ - + diff --git a/debug/tests/set_icon_reuse_dom.html b/debug/tests/set_icon_reuse_dom.html index e4bb7d489c6..f5985f66f3c 100644 --- a/debug/tests/set_icon_reuse_dom.html +++ b/debug/tests/set_icon_reuse_dom.html @@ -5,7 +5,7 @@ - +
diff --git a/debug/tests/svg_clicks.html b/debug/tests/svg_clicks.html index 9056d75e7b9..871b9807d9b 100644 --- a/debug/tests/svg_clicks.html +++ b/debug/tests/svg_clicks.html @@ -8,7 +8,7 @@ - + diff --git a/debug/tests/tile-bounds.html b/debug/tests/tile-bounds.html index c5e6b757d1a..57408906f9b 100644 --- a/debug/tests/tile-bounds.html +++ b/debug/tests/tile-bounds.html @@ -9,7 +9,7 @@ - + diff --git a/debug/tests/touch-shake.html b/debug/tests/touch-shake.html index 7ecdf14d444..1588f1781d1 100644 --- a/debug/tests/touch-shake.html +++ b/debug/tests/touch-shake.html @@ -11,7 +11,7 @@ - + diff --git a/debug/tests/touch-zoom-bounce.html b/debug/tests/touch-zoom-bounce.html index e5486062eea..d3c818b4b60 100644 --- a/debug/tests/touch-zoom-bounce.html +++ b/debug/tests/touch-zoom-bounce.html @@ -11,7 +11,7 @@ - + diff --git a/debug/vector/bounds-extend.html b/debug/vector/bounds-extend.html index 611460fcf01..c3cd3b84257 100644 --- a/debug/vector/bounds-extend.html +++ b/debug/vector/bounds-extend.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/vector/feature-group-bounds.html b/debug/vector/feature-group-bounds.html index de2bc24d617..82947fde4b3 100644 --- a/debug/vector/feature-group-bounds.html +++ b/debug/vector/feature-group-bounds.html @@ -7,7 +7,7 @@ - + diff --git a/debug/vector/geojson.html b/debug/vector/geojson.html index b13733c83bc..54cb3e041c7 100644 --- a/debug/vector/geojson.html +++ b/debug/vector/geojson.html @@ -40,7 +40,7 @@ } - + diff --git a/debug/vector/inherit-dashArray.html b/debug/vector/inherit-dashArray.html index 01d0019e8b6..853ccd98a64 100644 --- a/debug/vector/inherit-dashArray.html +++ b/debug/vector/inherit-dashArray.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/vector/moving-canvas.html b/debug/vector/moving-canvas.html index ca4728a86b4..3e7ab7424c1 100644 --- a/debug/vector/moving-canvas.html +++ b/debug/vector/moving-canvas.html @@ -9,7 +9,7 @@ - + diff --git a/debug/vector/rectangle.html b/debug/vector/rectangle.html index 2d73b0c44d7..2e97b683297 100644 --- a/debug/vector/rectangle.html +++ b/debug/vector/rectangle.html @@ -7,7 +7,7 @@ - + diff --git a/debug/vector/touchzoomemu.html b/debug/vector/touchzoomemu.html index 6402f6b2d1e..f7a8d7f4702 100644 --- a/debug/vector/touchzoomemu.html +++ b/debug/vector/touchzoomemu.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/vector/vector-bounds.html b/debug/vector/vector-bounds.html index 3984a6944e3..1504ef44d8a 100644 --- a/debug/vector/vector-bounds.html +++ b/debug/vector/vector-bounds.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/vector/vector-canvas.html b/debug/vector/vector-canvas.html index 16e1be79a51..aa92675abc1 100644 --- a/debug/vector/vector-canvas.html +++ b/debug/vector/vector-canvas.html @@ -7,7 +7,7 @@ - +
diff --git a/debug/vector/vector-mobile.html b/debug/vector/vector-mobile.html index 66385d4583c..5c059f21ce5 100644 --- a/debug/vector/vector-mobile.html +++ b/debug/vector/vector-mobile.html @@ -9,7 +9,7 @@ - +
diff --git a/debug/vector/vector-simple.html b/debug/vector/vector-simple.html index 6bb4280f287..ff6589482dd 100644 --- a/debug/vector/vector-simple.html +++ b/debug/vector/vector-simple.html @@ -9,14 +9,14 @@ - +
+
diff --git a/debug/vector/vector2.html b/debug/vector/vector2.html index 2050f2a2a81..3c19dc497ce 100644 --- a/debug/vector/vector2.html +++ b/debug/vector/vector2.html @@ -6,7 +6,7 @@ - +
diff --git a/dist/leaflet.css b/dist/leaflet.css index 601476fe6dc..01dd2379f9b 100644 --- a/dist/leaflet.css +++ b/dist/leaflet.css @@ -45,7 +45,10 @@ } /* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ /* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ -.leaflet-container .leaflet-overlay-pane svg, +.leaflet-container .leaflet-overlay-pane svg { + max-width: none !important; + max-height: none !important; + } .leaflet-container .leaflet-marker-pane img, .leaflet-container .leaflet-shadow-pane img, .leaflet-container .leaflet-tile-pane img, @@ -53,6 +56,8 @@ .leaflet-container .leaflet-tile { max-width: none !important; max-height: none !important; + width: auto; + padding: 0; } .leaflet-container.leaflet-touch-zoom { @@ -166,9 +171,6 @@ /* zoom and fade animations */ -.leaflet-fade-anim .leaflet-tile { - will-change: opacity; - } .leaflet-fade-anim .leaflet-popup { opacity: 0; -webkit-transition: opacity 0.2s linear; @@ -183,9 +185,7 @@ -ms-transform-origin: 0 0; transform-origin: 0 0; } -.leaflet-zoom-anim .leaflet-zoom-animated { - will-change: transform; - } + .leaflet-zoom-anim .leaflet-zoom-animated { -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); @@ -256,9 +256,6 @@ svg.leaflet-image-layer.leaflet-interactive path { .leaflet-container a { color: #0078A8; } -.leaflet-container a.leaflet-active { - outline: 2px solid orange; - } .leaflet-zoom-box { border: 2px dotted #38f; background: rgba(255,255,255,0.5); @@ -268,6 +265,7 @@ svg.leaflet-image-layer.leaflet-interactive path { /* general typography */ .leaflet-container { font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; + font: 0.75rem/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } @@ -393,7 +391,7 @@ svg.leaflet-image-layer.leaflet-interactive path { } /* Default icon URLs */ -.leaflet-default-icon-path { +.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */ background-image: url(images/marker-icon.png); } @@ -419,6 +417,7 @@ svg.leaflet-image-layer.leaflet-interactive path { .leaflet-container .leaflet-control-attribution, .leaflet-container .leaflet-control-scale { font-size: 11px; + font-size: 0.69rem; } .leaflet-left .leaflet-control-scale { margin-left: 5px; @@ -432,6 +431,7 @@ svg.leaflet-image-layer.leaflet-interactive path { line-height: 1.1; padding: 2px 5px 1px; font-size: 11px; + font-size: 0.69rem; white-space: nowrap; overflow: hidden; -moz-box-sizing: border-box; @@ -485,6 +485,7 @@ svg.leaflet-image-layer.leaflet-interactive path { height: 20px; position: absolute; left: 50%; + margin-top: -1px; margin-left: -20px; overflow: hidden; pointer-events: none; @@ -495,6 +496,7 @@ svg.leaflet-image-layer.leaflet-interactive path { padding: 1px; margin: -10px auto 0; + pointer-events: auto; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); @@ -517,13 +519,12 @@ svg.leaflet-image-layer.leaflet-interactive path { width: 18px; height: 14px; font: 16px/14px Tahoma, Verdana, sans-serif; - color: #c3c3c3; + color: #757575; text-decoration: none; - font-weight: bold; background: transparent; } .leaflet-container a.leaflet-popup-close-button:hover { - color: #999; + color: #585858; } .leaflet-popup-scrolled { overflow: auto; @@ -541,9 +542,6 @@ svg.leaflet-image-layer.leaflet-interactive path { -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); } -.leaflet-oldie .leaflet-popup-tip-container { - margin-top: -1px; - } .leaflet-oldie .leaflet-control-zoom, .leaflet-oldie .leaflet-control-layers, @@ -578,7 +576,7 @@ svg.leaflet-image-layer.leaflet-interactive path { pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,0.4); } -.leaflet-tooltip.leaflet-clickable { +.leaflet-tooltip.leaflet-interactive { cursor: pointer; pointer-events: auto; } @@ -638,3 +636,13 @@ svg.leaflet-image-layer.leaflet-interactive path { margin-left: -12px; border-right-color: #fff; } + +/* Printing */ + +@media print { + /* Prevent printers from removing background-images of controls. */ + .leaflet-control { + -webkit-print-color-adjust: exact; + color-adjust: exact; + } + } diff --git a/docs/_config.yml b/docs/_config.yml index ab028944851..ecacd84705f 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -6,7 +6,6 @@ kramdown: entity_output: as_input latest_leaflet_version: 1.7.1 -latest_leaflet_reference: 1.7.1 # Integrity hashes for both leaflet.js and leaflet-src.js # These will be shown in the downloads page @@ -14,3 +13,8 @@ latest_leaflet_reference: 1.7.1 integrity_hash_css: "sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" integrity_hash_source: "sha512-I5Hd7FcJ9rZkH7uD01G3AjsuzFy3gqz7HIJvzFZGFt2mrCS4Piw9bYZvCgUE0aiJuiZFYIJIwpbNnDIM6ohTrg==" integrity_hash_uglified: "sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" + + +collections: + plugins: + output: false diff --git a/docs/_includes/plugin_category_table.html b/docs/_includes/plugin_category_table.html new file mode 100644 index 00000000000..974928cdd23 --- /dev/null +++ b/docs/_includes/plugin_category_table.html @@ -0,0 +1,22 @@ +{% assign filteredplugins = site.plugins | where: "category", include.category %} + +
Enter Move Exit Click
Triangle 1:
+{% for plugin in filteredplugins %} + + + + + + +{% endfor %} +
PluginDescriptionDemoMaintainer
{{ plugin.name }}{{ plugin.content }} + {% if plugin.demo %} + Demo + {% endif %} + + {% if plugin.category %} + {{ plugin.author }} + {% else %} + {{ plugin.author }} + {% endif %} +
diff --git a/docs/_layouts/v2.html b/docs/_layouts/v2.html index 989957f6d1c..930166a8c10 100644 --- a/docs/_layouts/v2.html +++ b/docs/_layouts/v2.html @@ -1,5 +1,5 @@ - + {% capture title %}{% if page.title %}{{ page.title }} - {% elsif post.title %}{{ post.title }} - {% endif %}{% endcapture %} @@ -11,7 +11,7 @@ - + @@ -58,71 +58,76 @@ -

Leaflet

-

an open-source JavaScript library
for mobile-friendly interactive maps

- - - -
- - -{{ content }} - - - -
- -
+--- ## Tile & image layers @@ -97,738 +105,38 @@ The following plugins allow loading different maps and provide functionality to Ready-to-go basemaps, with little or no configuration at all. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- leaflet-providers - - Contains configurations for various free tile providers — OSM, OpenCycleMap, Stamen, Esri, etc. - - leaflet-extras members -
- Leaflet.KoreanTmsProviders - - Contains configurations for various (South) Korean tile providers — Daum, Naver, VWorld, etc. - - Seong Choi -
- Leaflet.ChineseTmsProviders - - Contains configurations for various Chinese tile providers — TianDiTu, MapABC, GaoDe, etc. - - Tao Huang -
- Esri Leaflet - - A set of tools for using ArcGIS services with Leaflet. Support for map services, feature layers, ArcGIS Online tiles and more. - - Patrick Arlt -
- Leaflet.GIBS - - NASA EOSDIS GIBS imagery integration. The plugin provides 96 daily updated layers with satellite imagery and science parameters. Demo. - - Alexander Parshin -
- L.TileLayer.Kartverket - - Provides easy setup of the tile layers from Kartverket (The Norwegian Mapping Authority) - - Kultur og naturreise / Atle Frenvik Sveen -
- Leaflet.Spain.WMS - - Provides easy setup for several Web Map Services (WMS) layers for Spain (PNOA, IGN base, Catastro, etc), from Spanish mapping agencies. - - Patricio Soriano -
- PolarMap.js - - JavaScript library for displaying tiles from ArcticWebMap, a free tile provider with OSM data in multiple Arctic polar projections. Includes lower-level API for deeper integration with other Leaflet plugins. - - GeoSensorWeb Lab -
- Bing Maps Layer - - Add Bing Maps tiles to your Leaflet Map. Requires Leaflet v1.0.0.beta.2 or later. - - Gregor MacLennan -
- L.TileLayer.HERE - - Displays map tiles from HERE maps (demo). - - Iván Sánchez -
- L.GridLayer.GoogleMutant - - Displays Google maps (with minimal artifacts thanks to a DOM mutation observer technique) (demo). - - Iván Sánchez -
- L.MapkitMutant - - Displays Apple's MapkitJS basemaps. - - Iván Sánchez -
- SuperMap Leaflet - - SuperMap Leaflet is a Leaflet plugins for working with SuperMap service types. - Support for SuperMap services, tiles and more. - - SuperMap -
- Leaflet.TileLayer.Mierune - - Displays tiles from Mierune map. (Demo) - - Mierune -
- Leaflet.TileLayer.Swiss - - Displays national maps of Switzerland using map tiles from Swisstopo. - Demo. - - Roman Karavia -
- Leaflet.TileLayer.HERE - - Displays tiles from HERE maps. - - Wanderson Souza -
- +{% include plugin_category_table.html category="basemap-providers" %} ### Basemap formats Plugins for loading basemaps or GIS raster layers in common (albeit non-default) formats. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- leaflet.TileLayer.WMTS - Add WMTS (IGN) layering for leaflet. - - Alexandre Melard -
- azgs-leaflet - - A set of small plugins for Leaflet, including WFS-GeoJSON layer with filtering, a hover control for GeoJSON, and an Esri tile layer. - - AZGS -
- leaflet.wms - - Enhanced WMS support for Leaflet, including single-tile/untiled layers, shared WMS sources, and layer identify via GetFeatureInfo. - - S. Andrew Sheppard
(HEI Geo) -
- L.TileLayer.WMTS - - A simple WMTS Tile Layer plugin for Leaflet. - - Alexandru Calin -
- Leaflet.NonTiledLayer.WCS - - Display raster data from Web Coverage Services. Rasters can be styled and queried in the client. See the demo. - - Stuart Matthews -
- Leaflet.bpg - - TileLayer with .bpg image format decoding. - - Andrzej Zaborowski -
- TileLayer.GeoJSON - - A TileLayer for GeoJSON tiles. - - Glen Robertson -
- leaflet-tilejson - - Adds support for the TileJSON specification to Leaflet. - - Per Liedman, Kartena -
- cartodb-leaflet - - Official CartoDB plugin for Leaflet. - - Vizzuality -
- Leaflet-2gis - - Adds support for 2GIS tile layer - - Eugene Mikhalev -
- Leaflet GeoJSON Encoded - - Extends the L.GeoJSON layer using Google polyline encoding algorithm, allowing an optimized data transfer. - - Geobricks -
- Leaflet.TileLayer.MBTiles - - Loads .mbtiles tilesets. - - Iván Sánchez -
- Leaflet.CanvasLayer.Field - - Loads and styles raster files (geotiff & asciigrid formats). - It includes a ScalarField layer (for DTM, temperature...) and - VectorFieldAnim (an animated layer for wind, currents...). See the examples - - Víctor Velarde -
- leaflet-geotiff - - Display raster data from geoTIFF files as images or direction arrows. Rasters can be styled and queried in the client. An optional clipping mask can be applied, e.g. to restrict DEMs to land areas. See the demo. - - Stuart Matthews -
- Leaflet.projwmts - - Adding WMTS services (GUGiK Poland). - (demo). - - Geoportal Poland -
- +{% include plugin_category_table.html category="basemap-formats" %} ### Non-map base layers Sometimes you don't want to load a map, just big custom images. **Really** big ones. - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- TileLayer.Zoomify - - A TileLayer for Zoomify images. - - Bjørn Sandvik -
- TileLayer.DeepZoom - - A TileLayer for DeepZoom images. - - Al Farisi, - Indokreatif Teknologi -
- TileLayer.Gigapan - - A TileLayer for Gigapan images. - - Dan Sherman -
- Leaflet.TileLayer.IIP - Add support for IIPImage layers in Leaflet. - - Emmanuel Bertin -
- Leaflet-IIIF - - A IIIF (International Image Interoperability Framework) viewer for Leaflet. See the demo. - - Jack Reed -
- leaflet-fractal - - Renders some fractals (Mandelbrot set, Julia set and some others) using 2D canvas (demo). - - Alexander Parshin -
- leaflet-rastercoords - - Renders large tiled images generated with - gdal2tiles-leaflet. - Image raster coordinates can be used to set markers, etc. - (demo). - - Commenthol -
- - +{% include plugin_category_table.html category="non-map-base-layers" %} ### Tile/image display The following plugins change the way that tile or image layers are displayed in the map. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- TileLayer.BoundaryCanvas - - Allows you to draw tile layers with arbitrary polygonal boundary. HTML5 Canvas is used for rendering. - - Alexander Parshin -
- TileLayer.Grayscale - - A regular TileLayer with grayscale makeover. - - Ilya Zverev -
- Leaflet.ImageTransform - Add support of image overlays with arbitrary perspective transformation. - - Alexander Parshin, - Sergey Alekseev -
- Leaflet.OpacityControls - - Simple Leaflet controls to adjust the opacity of a map layer. - - Jared Dominguez -
- Leaflet.DistortableImage - - Enable users to scale, rotate, and distort images on Leaflet maps. - - Public Lab -
- Leaflet.DistortableVideo - - Enable users to scale, rotate, and distort videos on Leaflet maps. (demo). - - Roni Karilkar -
- Leaflet.ImageOverlay.Rotate - - Displays rotated, scaled and skewed (but not rubbersheeted) ImageOverlays, given three control points. (demo). - - Iván Sánchez Ortega -
- Leaflet.ImageOverlay.Arrugator - - Displays reprojected ImageOverlays, given four control points and a proj4js projection function. (demo). - - Iván Sánchez Ortega -
- Leaflet.TileLayer.ColorFilter - - A simple and lightweight Leaflet plugin to apply CSS filters on map tiles (demo). - - Cláudio Kawakani -
- Leaflet.TileLayer.Mask - - A TileLayer with mask effect (demo) - - Yuzo Matsuzawa -
- Leaflet.TileLayer.PixelFilter - - A TileLayer which can filter and replace pixels by RGB code. -
- demo 1demo 2 -
- GreenInfo Network -
- Leaflet.Control.SideBySide - - A Leaflet control to add a split screen to compare two map overlays (demo). - - Digital Democracy -
- Leaflet.TileLayer.GL - - Applies custom WebGL shaders to each tile in a tilelayer (demo). - - Iván Sánchez -
- Leaflet.TileLayer.ColorPicker - - A Leaflet TileLayer with getColor(latLng). Demos: color picker, elevation picker with mapbox terrain-RGB - - Yuzo Matsuzawa -
- Leaflet.TileLayer.Colorizr - - A Leaflet TileLayer which can modify colors by RGBA code. Demos: coming soon. - - Hinrich Riedel -
- Leaflet.UTFGrid - - Provides UTF-8 Grid support for Leaflet >= 1.0. Includes basic mouseover support plus ability to highlight feature from UTFGrid on hover (demo). - - Brendan Ward -
- Leaflet.Control.Opacity - - Make multiple tile layers transparent. (demo) - - Yasunori Kirimoto -
- Leaflet.TileLayer.GLColorScale - - TileLayer that uses WebGL to colorize floating-point pixels according to a specified color scale (demo). - - David Schneider -
- Leaflet.Control.DetailLevel - - Display tiles at higher-than-retina (hdpi) resolutions, by real-time modification of the zoomOffset. Useful for mapping sources which drastically change map style between different zoom levels. Increasing the zoomOffset by too much does slow down the browser, as the number of displayed tiles grows exponentially with the zoomOffset. (demo). - - Wessel Valkenburg -
- Leaflet.Multispectral - - Provides multispectral channel manipulation and processing tools (such as NDVI or other remote sensing methods) for Leaflet image layers using pure client-side JavaScript. It uses `image-sequencer` via an ImageOverlay `filter()` function. (demo). - - Public Lab -
- Leaflet.TileLayer.GLOperations - - WebGL TileLayer: Colorize floating-point pixels, mouse event handlers for pixel values, hillshading, contours, - transitions, filter and do calculations on multiple layers. - (Demo). - - Thorbjørn Horgen -
- - +{% include plugin_category_table.html category="tile-image-display" %} ### Tile Load The following plugins change the way that tile layers are loaded into the map. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.MultiTileLayer - - Allows to compose a TileLayer from several tile sources. Each source is active only on a defined set of zoomlevels. - - Mattias Bengtsson -
- Leaflet.FunctionalTileLayer - - Allows you to define tile layer URLs using a function. Even works with asynchronous sources, using promises. - - Ishmael Smyrnow -
- TileLayer.Cordova - - For use with Cordova/Phonegap, adds tile caching onto local device storage, switching between offline and online mode. - - Greg Allensworth -
- TileLayer.PouchDBCached - - Allows all Leaflet TileLayers to cache into PouchDB for offline use. - - Iván Sánchez Ortega, - MazeMap -
- Leaflet.loading - - A simple control that adds a loading indicator as tiles and other data are loaded. - - Eric Brelsford -
- Leaflet.EdgeBuffer - - Buffer tiles beyond the edge of the viewport, for Leaflet 1.0. Demo. - - Alex Paterson -
- Leaflet.TileLayer.Fallback - - Replaces missing Tiles (HTTP 404 Not Found Error) by scaled up equivalent Tiles from lower zooms. - - ghybs -
- Leaflet.FeatureGroup.LoadEvents - - `FeatureGroup` that supports the `"loading"` and `"load"` events (for v0.7.*). - - G. Lathoud, Outdooractive. -
- Leaflet.GridLayer.FadeOut - - Fades out grid layers and tilelayers when they are removed, making basemap changes smoother (for 1.0.0). Demo. - - Iván Sánchez -
- leaflet-offline - - Allows the use of offline tiles in a customizable way while falling back to the normal TileLayer when necessary. Demo. - - Roberto Soares -
- leaflet.offline - - Allow tiles to be stored in an database for offline access. Original plugin.Demo. - - Allart Kooiman -
- - +{% include plugin_category_table.html category="tile-load" %} ### Vector tiles Plugins to display [vector tiles](https://github.com/mapbox/vector-tile-spec). - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.MapboxVectorTile - - A Leaflet Plugin that renders Mapbox Vector Tiles on canvas. See demo. Compatible with Leaflet 0.7.x only. - - SpatialDev -
- Hoverboard - - Render vector tiles on canvas with leaflet (geojson, topojson, and protobuf). See demo. Compatible with Leaflet 0.7.x only. - - Tristan Davies -
- geojson-vt - - Efficient library for slicing GeoJSON data into vector tiles on the fly. - - Mapbox -
- Leaflet.VectorGrid - - Display gridded vector data (GeoJSON or TopoJSON sliced with geojson-vt, or protobuf vector tiles) in Leaflet 1.0.0. See demos. Not compatible with 0.7.x. - - Iván Sánchez -
- Leaflet.VectorTileLayer - - A Leaflet layer for displaying vector tiles. Very similar to Leaflet.VectorGrid except for styling: a single style can be specified for all layers while VectorGrid requires knowing layer names in advance. For Leaflet 1.0.0. - - Joachim Kuebart -
+{% include plugin_category_table.html category="vector-tiles" %} ## Overlay data @@ -844,413 +152,19 @@ The following plugins provide new ways of loading overlay data (GIS vector data) Load your own data from various GIS formats. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- leaflet-kml - - Loads & displays KML - - Windyx -
- leaflet-omnivore - - Loads & converts CSV, KML, GPX, TopoJSON, WKT formats for Leaflet. - - Mapbox -
- Leaflet.FileLayer - - Loads files (GeoJSON, GPX, KML) into the map using the HTML5 FileReader API (i.e. locally without server). - - Mathieu Leplatre -
- Leaflet.geoCSV - - Leaflet plugin for loading a CSV file as geoJSON layer. - - Iván Eixarch -
- Leaflet.Shapefile - - Put a shapefile onto your map as a layer. - - Calvin Metcalf -
- Leaflet.FileGDB - - Put an ESRI File GeoDatabase onto your map as a layer. - - Calvin Metcalf -
- Leaflet.encoded - - Use encoded polylines in Leaflet. - - Jieter -
- Leaflet GPX - - GPX layer, targeted at sporting activities by providing access to information such as distance, moving time, pace, elevation, heart rate, etc. - - Maxime Petazzoni -
- Wicket - - A modest library for translating between Well-Known Text (WKT) and Leaflet geometry objects (e.g. between L.marker() instances and "POINT()" strings). - - K. Arthur Endsley -
- qgis2web - - A QGIS plugin to make webmaps without coding. - - Tom Chadwin -
- Leaflet-WFST - - WFS client layer with transaction support - - Flexberry -
- Leaflet-BetterScale - - A new, more GIS-like scalebar with alternating black/white bars. - - Dan Brown -
- Leaflet-GeoPackage - - Load GeoPackage Tile and Feature Layers. - - Daniel Barela, - NGA -
- Leaflet-CsvTiles - - Load points from tiled csv files, using the amazing PapaParse library. Demo. - - Gherardo Varando -
- - +{% include plugin_category_table.html category="overlay-data-formats" %} ### Dynamic/custom data loading Load dynamic data which is updated in the map, or load GIS vector data in non-standard ways. - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet Realtime - - Put realtime data on a Leaflet map: live tracking GPS units, sensor data or just about anything. - - Per Liedman -
- Leaflet Ajax - - Add GeoJSON data via ajax or jsonp. - - Calvin Metcalf -
- Leaflet.Liveupdate - - Periodically ('live') update something on a map (Demo) - - Martijn Grendelman -
- Leaflet.Pouch - - Use PouchDB to sync CouchDB data to local storage (indexedDB), to just add couchDB data or as just a less confusing implementation of indexedDB. - - Calvin Metcalf -
- Leaflet.Indoor - - Create indoor maps. - - Christopher Baines -
- Leaflet uGeoJSON - - Add an auto updating GeoJSON data Layer via ajax post requests. - - Benjamin VADANT -
- Leaflet.mytrack - Track my way on a map and download it. Demo - - DJ -
- - - -### Synthetic overlays - -These plugins create useful overlays from scratch, no loading required. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.Graticule - - Draws a grid of latitude and longitude lines. - - Bjørn Sandvik -
- Leaflet.SimpleGraticule - - Draws a grid lines for L.CRS.Simple coordinate system. - - Andrew Blakey -
- L.OS.Graticule - - Overlays UK Ordinance Survey (OS) 1km grid squares and labels. - - Jon Shutt -
- Leaflet.MetricGrid - - A general purpose Metric Grid overlay for Leaflet with ready defined UTM, British and Irish Grids. - - Bill Chadwick -
- Leaflet.Terminator - Overlay day and night regions on a map. - - Jörg Dietrich -
- Leaflet.Sun - Get sunset or sunrise at map click. Demo - - DJ -
- Leaflet.timezones - Overlay timezones on a Leaflet Earth map. Demo - - DJ -
- leaflet.latlng-graticule - - Create a Canvas as ImageOverlay to draw the Lat/Lon Graticule, and show the grid tick label at the edges of the map.Demo. - - CloudyBay -
- Leaflet.EdgeScaleBar - - Creates scale bars along top and right edge of a map in the Web Mercator projection..Demo. - - Dražen Tutić, Ana Kuveždić Divjak -
- Leaflet.Maidenhead - - An implementation of the Maidenhead Locator System grid ((demo)). - - Iván Sánchez Ortega -
- - +{% include plugin_category_table.html category="dynamic-custom-data-loading" %} ### Data providers Load overlay data from third-party-services. See also [basemap providers](#basemap-providers) and [plugin collections](#collections). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet Vector Layers - - Allows to easily create vector layers from a number of geo web services, such as ArcGIS Server, Arc2Earth, GeoIQ, CartoDB and GIS Cloud. - - Jason Sanford -
- Leaflet Overpass Layer - - Easily include data from the overpass api. - - Guillaume AMAT -
- Leaflet.dbpediaLayer - - A layer with Points of interest from Wikipedia - loaded via ajax from DBpedia's SPARQL endpoint. - - Kr1 -
- Leaflet-Wikipedia - - A leaflet plugin to display Wikipedia API entries on a map layer. - - Matthew Barker -
- Windy-Leaflet-plugin - - Displays animated weather map on your page using Windy's free API. - - Windy.com -
- Leaflet.GeographPhotos - - Display Geographical-Photos from Geograph Britain and Ireland in an interactive overlay, using their API. - - Barry Hunter -
- leaflet-radar - - Animated satellite weather radar overlays for Leaflet. - - rwev -
- leaflet-environmental-layers - - - Collection of different environmental map layers in an easy to use Leaflet library Demo. - - Public Lab -
- Leaflet.Rainviewer - - - Plugin for RainViewer radar data API Demo. - - Marcin Wasilewski -
- +{% include plugin_category_table.html category="data-providers" %} ## Overlay display @@ -1268,1109 +182,31 @@ The following plugins provide new ways of displaying overlay data information. These plugins provide new markers or news ways of converting abstract data into images in your screen. Leaflet users versed in GIS also know these as symbolizers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.RoughCanvas - - Leaflet.RoughCanvas renders hand-drawn, sketch style vector map (polyline, polygon, geojson). - - haoming -
- Leaflet.ellipse - - Leaflet.ellipse place ellipses on map by specifying center point, semi-major axis, - semi-minor axis, and tilt degrees from west. - - JD Fergason -
- Leaflet.label - - Adds text labels to map markers and vector layers. - - Jacob Toye -
- Leaflet-semicircle - - Adds functionality to L.Circle to draw semicircles. - - Jieter -
- Leaflet.PolylineDecorator - - Allows you to draw patterns (like dashes, arrows or evenly spaced Markers) along Polylines or coordinate paths. - - Benjamin Becquet -
- Leaflet-arrowheads - - Allows user to quickly draw arrowheads on polylines for vector visualization. - - Slutske22 -
- Leaflet.Sprite - - Use sprite based icons in your markers. - - Calvin Metcalf -
- Leaflet.TextPath - - Allows you to draw text along Polylines. - - Mathieu Leplatre -
- Leaflet-SVGIcon - - A simple and customizable SVG icon with no external dependencies. Also included is a convenience Marker class and two example subclasses. Customizable demo with example subclasses - - Ilya Atkin -
- Leaflet.BeautifyMarkers - - Lightweight plugin that adds colorful iconic markers without image and gives full control of style to end user (i.e. Unlimited colors and CSS styling). - - Muhammad Arslan Sajid -
- Leaflet.Awesome-Markers - - Colorful, iconic & retina-proof markers based on the Font Awesome icons/Twitter Bootstrap icons - - Lennard Voogdt -
- Leaflet.Extra-Markers - - Shameless copy of Awesome-Markers with more shapes, colors and semantic-ui support - - Cory Silva -
- Leaflet.MakiMarkers - Create markers using Maki Icons from MapBox. - - James Seppi -
- Leaflet.Icon.Glyph - - Use icon font glyphs in your markers (from Font Awesome, Material Design Icons, Glyphicons, - Metro UI icons, Elusive, and other icon fonts). (demo) - - Iván Sánchez Ortega -
- Leaflet.LineExtremities - - Show symbols at the extremities of polylines, using SVG markers. - - Frédéric Bonifas -
- Leaflet.VectorMarkers - - Vector SVG markers for Leaflet, with an option for Font Awesome/Twitter Bootstrap icons. - - Mathias Schneider -
- Leaflet.SvgShapeMarkers - - Adds support for additional SVG marker types such as triangles, diamonds and squares. - - Rowan Winsemius -
- Leaflet.pattern - - Add support for pattern fills on Paths. - - Tyler Eastman -
- Leaflet.BoatMarker - - A boat marker using HTML Canvas for displaying yachts and sailboats with heading and optional wind information. Demo. - - Thomas Brüggemann -
- leaflet-usermarker - - Plugin for plotting a marker representing a user - or multiple users - on a map, - with support for drawing an accuracy circle. Can be seen in action on - Longitude.me. - - Jonatan Heyman -
- Leaflet.geojsonCSS - - Geojson CSS implementation for Leaflet. - - Alexander Burtsev -
- leaflet-simplestyle - - Extends L.geoJSON to support the simple style spec. - - Rowan Winsemius -
- OSM Buildings - - Amazing JS library for visualizing 3D OSM building geometry on top of Leaflet. - - Jan Marsch -
- Leaflet.EdgeMarker - - Plugin to indicate the existence of Features outside of the current view. - - Gerald Pape -
- Leaflet.orientedMarker - - Allows to manage orientation of markers dynamically. - - Gismartwaredev -
- leaflet-icon-pulse - - Renders pulsing icon using CSS3. It can be used for location marker. - - mapshakers/ - Filip Zavadil -
- leaflet-mapkey-icon - - Set of cartographic font icons based on mapkeyicons. - - mapshakers/ - Filip Zavadil -
- Leaflet.Photo - - Plugin to show geotagged photos on a Leaflet map. Demo. - - Bjørn Sandvik -
- Leaflet.curve - - A Leaflet plugin for drawing Bézier curves and other complex shapes. Demo. - - elfalem -
- Leaflet.bezier - - Draws a Bézier line between two points with an animated flight object. - - Supun Praneeth -
- Leaflet.Arc - - This plugin adds L.Polyline.Arc function which wraps arc.js functionality for creation of Great Cirlce arcs. - - Alexey Gusev -
- leaflet-choropleth - - Extends L.geoJson to add a choropleth visualization (color scale based on value). Demo. - - Tim Wisniewski -
- Leaflet.Canvas-Markers - - Displays markers on canvas instead of DOM. - - Evgeniy Voynov -
- leaflet-tracksymbol - - This marker provides a tracksymbol with orientation, velocity-vector and configurable shape. - - Tim Leerhoff -
- leaflet-ais-tracksymbol - - AIS Extension for leaflet-tracksymbol It displays AIS Contacts on the Map. - - Johannes Rudolph -
- leaflet-ais-tracksymbol-search - - Adds a Search Box for your Leaflet Map and Your [leaflet-ais-trackymbol](https://github.com/PowerPan/leaflet-ais-tracksymbol) - - Johannes Rudolph -
- leaflet.TravelNotes - - Editable markers and routing engine for leaflet. The routing engine have plugins for Mapbox, GraphHopper and OSRM and can be used for car, bike or pedestrian route. Demo. - - Christian Guyette -
- Leaflet.Marker.Stack - - A pure Leaflet implementation of CartoDB's "stacked chips" symbolizer. Demo. - - Iván Sánchez -
- leaflet-polygon.fillPattern - - Extend the Polygon Object to fill SVG Path element with an image pattern.Demo. - - CloudyBay -
- Leaflet Polyline Offset - - Adds to L.Polyline the ability to be shifted with a relative pixel offset, without modifying its actual LatLngs. The offset value can be either negative or positive, for left- or right-side offset, and remains constant across zoom levels (basic demo). - - Benjamin Becquet -
- leaflet-labeled-circle - - Special type of SVG marker with a label inside and draggable around the anchor point (demo). - - Alexander Milevski -
- Leaflet.ParallaxMarker - - Add markers that moves with a parallax-effect relative to the map when panning (demos / examples). - - Dag Jomar Mersland -
- leaflet-distance-markers - - Allows displaying markers along a route (L.Polyline) at equivalent distances (eg. one per mile) (demo). - - Doroszlai, Attila -
- leaflet-corridor - - Renders a polyline with width fixed in meters, not in pixels; adjusts width depending on zoom level (demo). - - Mikhail Shilkov -
- Leaflet.LabelTextCollision - - Displays labels on paths (polylines, polygons, circles) avoiding label collision. (demo). - - Kenta Hakoishi -
- Leaflet.streetlabels - - A Leaflet plugin to show labels following the paths of polylines. An extension of yakitoritabetai Leaflet.LabelTextCollision (demo). - - Triede TI -
- Leaflet.Viewpoint - - Displays circleMarker with multiple directions. - Useful to show photos taken from one point. (demo). - - Grigory Golikov -
- Leaflet.magicMarker - - Adding magical animation effect to a marker while loading.(Demo). - - Sylvenas -
- Leaflet.Marker.Highlight - - Adding highlight performance for L.marker.(Demo). - - Brandon Xiang -
- Leaflet.GeotagPhoto - - Plugin for photo geotagging, with two modes: camera and crosshair (Demo). - - Bert Spaan -
- Leaflet.GLMarkers - - Display thousands of markers with custom WebGL shaders, optionally animated. (demo) - - Iván Sánchez Ortega -
- Leaflet.River - - Draw lines with different width (like rivers) on a map. - Useful when you want to show how rivers 'flow' on the map (demo). - - Grigory Golikov -
- Leaflet.SpeechBubble - - Popup a speech bubble with the arrow that follow points, layer, markers ... - (demo). - - Sylvain BRISSY -
- Leaflet Swoopy - - A plugin for creating customizable swoopy arrow annotations. - - webkid -
- leaflet-polycolor - - Color each polyline segment. (demo) - - Olivier Gasc -
- leaflet-marker-direction - - display the path and the direction of the marker. (demo) - - Jack Zou -
- Leaflet Rotated Marker - - Enables rotation of marker icons in Leaflet. (Demo) - - Benjamin Becquet -
- Leaflet Truesize - - A plugin for creating projection aware draggable polygons and polylines. - - webkid -
- Leaflet.RepeatedMarkers - - Displays markers when wrapping around the globe, once every 360 degrees of longitude (demo). - - Iván Sánchez -
- Leaflet.Geodesic - - Draw geodesic lines and circles. A geodesic line is the shortest path between two given points on the earth surface. It uses Vincenty's formulae for highest precision and distance calculation. Written in Typescript and available via CDN. Demo - - Henry Thasler -
- Leaflet.greatCircle - - A wrapper class for the Leaflet.js Polygon object that draws true "great circles" (showing true geodesic, spherical paths) that wrap around the Earth (demo). - - Alex Wellerstein -
- Leaflet.CustomLayer - - A Leaflet plugin L.CustomLayer - fully custom Layer. - - Derek Li -
- Leaflet.ArrowCircle - - A Marker extension to display circles with directional arrows. - - R.A. Porter -
- L.Donut - - Extension of L.Circle which allows to define a outer and inner radius. Demo - - Falke-Design -
- - +{% include plugin_category_table.html category="markers-renderers" %} ### Overlay animations These plugins animate markers or some geometries. See also [geometries with time or elevation](#geometryinteraction-time). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.AnimatedMarker - - Animate a marker along a polyline. - - Aaron Ogle -
- Leaflet.BounceMarker - - Make a marker bounce when you add it to a map. - - Maxime Hadjinlian -
- Leaflet.SmoothMarkerBouncing - - Smooth animation of marker bouncing for Leaflet. - - Alexei KLENIN -
- Leaflet.MovingMarker - - Allow to move markers along a polyline with custom durations. - - Ewoken -
- Leaflet.TransitionedIcon - - Transition in/out markers with CSS3 transitions. It supports jitter - for staggering markers into view to prevent visual overload. See the demo. - - Brian Reavis -
- Leaflet.Polyline.SnakeAnim - - Animates (poly)lines into existence, as if they were being slowly drawn from start to end. - - Iván Sánchez Ortega, - MazeMap -
- Leaflet.Path.DashFlow - - Animates the dashArray of lines and circles, creating a basic flow effect. (Demo. - - Iván Sánchez Ortega -
- Leaflet.AntPath - - Leaflet.AntPath put a flux animation (like ants walking) into a Polyline. - (demo) - - Rubens Pinheiro -
- Leaflet.Marker.SlideTo - - Smoothly move (slide) markers to a new location. (demo) - - Iván Sánchez Ortega, - MazeMap -
- leaflet.motion - - Adds simple motion to your polyline with marker in a head on line (demo) - - Igor Vladyka, -
- Leaflet.Rain - - Customizable WebGL rain animation for Leaflet. Useful for weather maps. (demo) - - Grigory Golikov -
- Leaflet.Snow - - Customizable WebGL snow animation for Leaflet. Useful for weather maps. (demo) - - Grigory Golikov -
- leaflet-point-animator - - Animate a large number of GeoJSON points. (demo) - - danwild, onaci -
- leaflet-temporal-geojson - - Flexible animation of GeoJSON features. (demo) - - danwild, onaci -
- - +{% include plugin_category_table.html category="overlay-animations" %} ### Clustering/Decluttering When you are displaying a lot of data, these plugins will make your map look cleaner. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.markercluster - - Beautiful, sophisticated, high performance marker clustering solution with smooth animations and lots of great features. Recommended! - - Dave Leaver -
- Leaflet.LayerGroup.Collision - - Provides collision detection for groups of markers. Unlike clustering, this takes into account the shape & size of the markers. - - Iván Sánchez Ortega, - MazeMap -
- Overlapping Marker Spiderfier - - Deals with overlapping markers in a Google Earth-inspired way by gracefully springing them apart on click. - - George MacKerron -
- PruneCluster - - Fast and realtime marker clustering library. - - Antoine Pultier -
- Leaflet.Deflate - - Deflates lines and polygons to a marker when their screen size becomes too small in lower zoom levels. - - Oliver Roick -
- Leaflet.GridCluster - - Create grid-based clusters in realtime. - - Andreas Kiefer -
- q-cluster - - Quick point clustering library with D3 categorization. - - Nicholas Hallahan -
- Leaflet.ConditionalLayer - - A FeatureGroup that does not show any more than a certain amount of markers visible in the viewport. (Demo) - - EPP -
- Leaflet.FeatureGroup.SubGroup - - A simple plugin to create Feature Groups that add their child layers into a parent group. Typical usage is to switch them through L.Control.Layers to dynamically add/remove groups of markers from Leaflet.markercluster. Demo. - - ghybs -
- leaflet-tooltip-layout - - A plugin to avoid tooltips overlapping and make it easier to find out the relationship between each tooltip and marker. Demo. - - Zijing Peng -
+{% include plugin_category_table.html category="clustering-decluttering" %} ### Heatmaps These plugins create heatmaps and heatmap-like visualizations from vector data. - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- MaskCanvas - - Canvas layer that can be used to visualize coverage. - - Dominik Moritz -
- HeatCanvas - - Simple heatmap api based on HTML5 canvas. - - Sun Ning -
- heatmap.js - - JavaScript Library for HTML5 canvas based heatmaps. - - Its Leaflet layer implementation supports large datasets because it is tile based and uses a quadtree index to store the data. - - Patrick Wied -
- Leaflet divHeatmap - - Lightweight and versatile heatmap layer based on CSS3 and divIcons - - - Daniele Piccone -
- WebGL Heatmap - - High performance Javascript heatmap plugin using WebGL. - - - Benjamin J DeLong -
- Leaflet.heat - - A tiny, simple and fast Leaflet heatmap plugin. Uses simpleheat under the hood, additionally clustering points into a grid for performance. (Demo) - - - Vladimir Agafonkin -
- Leaflet-Solr-Heatmap - - A Leaflet plugin for rendering heatmaps and clusters from Solr's Heatmap Faceting. High performance for millions of points or polygons. - - Jack Reed / - Steve McDonald -
- +{% include plugin_category_table.html category="heatmaps" %} ### DataViz Powerful multi-purpose libraries for data visualization. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- geogrid.js - - Displays data aggregated by the ISEA3H discrete global grid system. The data can, e.g., be delivered by using Measures REST (a framework to deliver data aggregated by the grid) or geogrid (a library for handling the grid in case that you want to aggregate data manually). - - F.-B. Mocnik,
GIScience Research Group,
Heidelberg University
-
- RaphaelLayer - - Allows you to use Raphael as a layer on a Leaflet map for advanced animations and visualizations. - - Dynamic Methods -
- Leaflet Data Visualization Framework - - New markers, layers, and utility classes for easy thematic mapping and data visualization. - - Scott Fairgrieve -
- Leaflet.D3SvgOverlay - - SVG overlay class for using with D3 library. Supports zoom animation and scaling without need to redraw the layer. - - Kirill Zhuravlev -
- mapbox-gl-leaflet - - Binding from Mapbox GL JS to the Leaflet API - - Tom MacWright -
- leaflet-echarts - - A plugin for Leaflet to load echarts map and make big data visualization easier. - - wandergis -
- jquery-storymap - - A jQuery plugin to display several map locations as the user scrolls through paragraphs. - - Atle Frenvik Sveen -
- Leaflet for R - - Allows using Leaflet from within R programs, a programming language popular for statistical analysis and data mining. - - RStudio team -
- leaflet.migrationLayer - - leaflet.migrationLayer is used to show migration data such as population, flight, vehicle, traffic and so on. Data visualization on map.demo - - Sylvenas -
- Leaflet.Quadtree - - Leaflet.Quadtree is used to retrieve visible data inside given bounds - - ibesora -
- Leaflet.Canvas-Flowmap-Layer - - A LeafletJS custom map layer for mapping the flow of objects, ideas, people, etc. with Bezier curves rendered on the HTML canvas. - - Jacob Wasilkowski, - Sarah Bell -
- Leaflet.PixiOverlay - - A Leaflet overlay class for drawing and animating with Pixi.js. (demo) - - Manuel Baclet -
- leaflet-velocity - - Visualise velocity layers with leaflet. - Demo here. - - Dan Wild -
- leaflet-partition - - Divide the area into parts in different ways such as voronoi(triangulation) and hexagonal tiling. - Basic demo - - locknono -
- +{% include plugin_category_table.html category="dataviz" %} ## Interaction with geometries/features @@ -2386,552 +222,25 @@ The following plugins enable users to interact with overlay data: edit geometrie Allows users to create, draw, edit and/or delete points, lines and polygons. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet-Geoman - - Geometry Management for Leaflet 1.0 and higher. Draw, Edit, Cut, Drag and Snap Layers like Markers, Circles, Rectangles, Polylines, Polygons, LayerGroups, geoJSON, MultiPolygons, MultiLineStrings. Supports holes in polygons, snapping, canvas mode and more. (Demo) - - Sumit Kumar -
- Leaflet.FreeDraw - - Zoopla inspired freehand polygon creation using Leaflet.js and D3. - - Wildhoney -
- Leaflet.plotter - - leaflet-plotter allows you to create routes using a leaflet powered map. You can click on the mid-points to create a new, draggable point. - - Nathan Mahdavi -
- Leaflet.Editable.Polyline - Editable polylines: move existing points, add new points and split polylines. - - Tomo Krajina -
- Leaflet.draw - - Enables drawing features like polylines, polygons, rectangles, circles and markers through a very nice user-friendly interface with icons and hints. Recommended! - - Jacob Toye -
- Leaflet.EditableHandlers - - A set of plugins that includes circle editing, measuring tool, and label for polygon sides. - - Kartena -
- Leaflet.StyleEditor - - Enables editing the styles of features (lines, polygons, etc) and markers with a GUI. - - Dennis Wilhelm -
- Leaflet.SimpleMarkers - - A light-weight Leaflet plugin for adding and deleting markers. - - Jared Dominguez -
- Leaflet.Editable - - Lightweight fully customisable and controllable drawing/editing plugin. - - Yohan Boniface -
- Leaflet.Path.Drag - - Drag handler and interaction for polygons and polylines (Demo) - - Alexander Milevski -
- Leaflet.Path.Transform - - Scale & rotate handler and interaction for polygons and polylines (Demo) - - Alexander Milevski -
- Leaflet.Snap - - Enables snapping of draggable markers to polylines and other layers. - - Mathieu Leplatre -
- Leaflet.Clipper - - Allows Union, Difference, Xor, and Intersection operations on two polygons. (Demo) - - will Farrell -
- Leaflet.MapPaint - - Bitmap painting plugin designed for touch devices. - - Antoine Pultier -
- Leaflet.Storage - - Create/update/delete Map, Marker, Polygon, Polyline... and expose them for backend storage with an API. - - Yohan Boniface -
- Leaflet.Pather - - L.Pather is a freehand polyline creator that simplifies the polyline for mutability. Requires D3 support. - - Wildhoney -
- Leaflet.Illustrate - - Extension for Leaflet.draw enabling users to type annotations directly on maps. - - Justin Manley -
- Leaflet.Pin - - Enable attaching of markers to other layers during draw or edit features with Leaflet.Draw. - - Konrad Klimczak -
- L.Control.PaintPolygon - - Draw yours polygons with a circle brush like Paint[brush]. Includes turf.js dependencies. - - Thibault Coupin -
- Leaflet-Craft - - Extends Leaflet.FreeDraw and gives extended features like Undo-Redo, deleting markers,dynamic area calculation of polygons ,various hooks/events and in-build control bars, etc. - - Sagarpreet Chadha -
- Leaflet.SegmentEdit - - An extension to Leaflet.draw to allow editing large polylines one chunk at the time. - - Lemaf -
- +{% include plugin_category_table.html category="edit-geometries" %} ### Time & elevation Most data is two-dimensional (latitude and longitude), but some data has more dimensions (altitude and/or time). The following plugins help users navigate these extra dimensions. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet Topography - - A set of tools for calculating and visualizing topographic data (elevation, slope, aspect) at lightning speed. Based on Mapbox RGB Encoded DEM tiles. - - Seth Lutske -
- Leaflet.timelineSlider - - Leaflet plugin that creates a customizable timeline slider with user designed functionality. Original implementation of timeline at https://codepen.io/trevanhetzel/pen/rOVrGK. - - Sol Vitkin -
- Leaflet.TimeDimension - - Add time dimension capabilities on a Leaflet map. Demos - - ICTS SOCIB -
- Leaflet Time-Slider - - The Leaflet Time-Slider enables you to dynamically add and remove Markers on a map by using a JQuery UI slider - - Dennis Wilhelm -
- LeafletPlayback - - Play back time-stamped GPS Tracks synchronized to a clock. - - Nicholas Hallahan -
- Leaflet.timeline - - Display arbitrary GeoJSON on a map with a timeline slider and play button. - - Jonathan Skeate -
- Leaflet.Elevation - - A Leaflet plugin to view interactive height profiles of GeoJSON lines using d3. - - Felix Bache -
- Leaflet.Heightgraph - - Inspired by Leaflet.Elevation this Leaflet plugin allows you to view interactive height profiles stored as GeoJSON featuring the handy ability to visualize arbitrary segments (e.g. surface types or steepness categories) with customized colors stored as properties within the GeoJSON itself. - - Robin Boldt -
- Leaflet.hotline - - A Leaflet plugin for drawing gradients along polylines. - - iosphere -
- leaflet.TrackPlayBack - - A leaflet track-playback plugin, can display and dynamically play tracks. Demo. - - linghuam -
- Leaflet Timeline Control - - Unopinionated timeline control that helps you display time series data. Demo. - - Michal Zimmermann -
- - - +{% include plugin_category_table.html category="time-elevation" %} ### Search & popups Plugins that search for overlays and enhance how to display information about them. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- leaflet-fusesearch - - A control that provides a panel to search features in a GeoJSON layer using the lightweight fuzzy search Fuse.js - - Antoine Riche -
- Leaflet Search - - A control for search Markers/Features location by custom property in LayerGroup/GeoJSON. Support AJAX/JSONP, Autocompletion and 3rd party service - - Stefano Cudini -
- leaflet-custom-searchbox - - A google map style search box which includes a side panel slider control. - - A.D -
- Leaflet.Rrose - - A Leaflet Plugin for Edge Cases. For use when you want popups on mouseover, not click, and - you need popup tips to reorient as you get close to the edges of your map. - - Eric Theise -
- Leaflet.utfgrid - - Provides a utfgrid interaction handler for leaflet a very small footprint. - - Dave Leaver -
- Leaflet.RevealOSM - - Very simple but extendable Leaflet plugin to display OSM POIs data on map click. - - Yohan Boniface -
- Leaflet Underneath - - Find interesting features near a location using Mapbox Vector Tiles data, to add - interactive functionality to a tile layer with speed and limited bandwidth. - - Per Liedman -
- Leaflet.GeoJSONAutocomplete - - Leaflet Autocomplete For Remote Searching with GeoJSON Services. - - Yunus Emre Özkaya -
- L.tagFilterButton - - LeafLet marker filtering by tags - - Mehmet Aydemir -
- Leaflet-gplaces-autocomplete - - Add google places search into map - - Michal Haták -
- leaflet-responsive-popup - - Removes the need to move the map to be able to see the content of the popup. - - YaFred -
- leaflet-popup-modifier - - Allows user to edit the contents of a popup, or use the popup to remove its source marker. - - Slutske22 -
- - +{% include plugin_category_table.html category="search-popups" %} ### Area/overlay selection These plugins help users select either overlays or areas in the map. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.AreaSelect - - A fixed positioned, resizable rectangle for selecting an area on the map. - - Jonatan Heyman -
- leaflet-locationfilter - - A draggable/resizable rectangle for selecting an area on the map. - - Robert Kajic -
- L.Control.LineStringSelect - - Fast LineString(polyline) partial selection tool: select a stretch between two points in a complex path. Demo - - Alexander Milevski -
- Leaflet.FeatureSelect - Use a configurable centerpoint marker to select any geometry type from a GeoJSON layer. - - Aaron Ogle -
- Leaflet GeoJSON Selector - - Leaflet Control for selection from GeoJSON feature in an interactive list and map (Demo). - - Stefano Cudini -
- Leaflet.CheapLayerAt - - Allows querying which layer is under a screen coordinate (Demo). - - Iván Sánchez Ortega, - MazeMap -
- Leaflet.SelectAreaFeature - - Selecting feature layers on a map by drawing an area. - - Sandro Pibia -
- Leaflet-Shades - - A draggable and resizable rectangle for selecting an area on a map and creating a gray overlay in unselected areas (Demo) - - Mandy Kong -
- leaflet-lasso - - Lasso selection plugin (Demo) - - Jan Zak -
- Leaflet-Select-Polygons - - Leaflet-Select-Polygons allows the selection of several polygons and also adjusts the base map view (demo) - - Erick S Escalante Olano -
- +{% include plugin_category_table.html category="area-overlay-selection" %} ## Map interaction @@ -2954,1162 +263,56 @@ New ways to interact with the map itself. The following plugins enhance or extend `L.Control.Layers`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.AutoLayers - - Automatically pull layers from multiple mapservers and organize/search them with user controlled overlay zIndex management. - - Alex Ebadirad -
- Leaflet.SelectLayers - - a Leaflet plugin which adds new control to switch between different layers on the map. New control replaces L.Control.Layers radio button panel with select tag. - - vogdb -
- Leaflet.StyledLayerControl - - A Leaflet plugin that implements the management and control of layers by organization into categories or groups. - - Davi Custodio -
- Leaflet.GroupedLayerControl - - Leaflet layer control with support for grouping overlays together. - - Ishmael Smyrnow -
- Leaflet Control Order Layers - - Adds the ability to change overlay order in the layers control. - - Michael Salgado -
- Leaflet Categorized Layers - - Leaflet Control Layers extended for groups of categorized layers - - Robbie Trencheny -
- Leaflet Panel Layers - - Leaflet Control Layers extended for group of layers and icons legend - - Stefano Cudini -
- Leaflet.UniformControl - - Leaflet layer control with stylable checkboxes and radio buttons. - - Chris Calip -
- Leaflet-IconLayers - - Leaflet control that displays base layers as small icons (demo). - - Alexander Zverev -
- Leaflet.LayerTreePlugin - - Leaflet control allows to switch layers on and off, display them in a tree-like way (demo). - - Alexander Arakelyan -
- Leaflet.Basemaps - - A basemap chooser with a preview image from the tile stack. - Example - - Brendan Ward -
- Leaflet.Control.Layers.Tree - - L.Control.Layers extension that supports a Tree structure, both for base and overlay layers. Simple and highly configurable. See demos - - Javier Jimenez Shaw -
- Leaflet.ActiveLayers - - Adds new L.Control.ActiveLayers with functionality to get currently active layers on the map. - - vogdb -
- Leaflet.Control.Appearance - - Extend of Control.Layers, can control Appearances of Layers - color, opacity and able to remove a overlay layer. Example - - Kanahiro Iguchi -
+{% include plugin_category_table.html category="layer-switching-controls" %} ### Interactive pan/zoom Change the way the user can interactively move around the map. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.Pancontrol - - A simple panning control. - - Kartena -
- Leaflet.BoxZoom - - A visible, clickable control to perform a box zoom. - - Greg Allensworth -
- L.Control.ZoomBar - - An extended version of Leaflet's native Zoom control with Home and Zoom-to-Area buttons. Demo - - Elijah Robison -
- Leaflet.zoomslider - - A zoom slider control. - - Kartena -
- Leaflet.zoominfo - - A zoom control which displays the current zoom level. - - Flávio Carmo -
- Leaflet.BorderPan - - A Leaflet plugin to pan by clicking on map borders. - - Sebastián Lara -
- Leaflet GameController - - Interaction handler providing support for gamepads. - - Antoine Pultier -
- Leaflet.twofingerZoom - - Interaction handler for touch devices enabling zooming out with a two finger tap. - - Adam Ratcliffe -
- Leaflet.ZoomBox - - A lightweight zoom box control: draw a box around the area you want to zoom to. Demo - - Brendan Ward -
- Leaflet LimitZoom - - Plugins to limit available zoom levels to a given list, either by - restricting zooming or by interpolating tiles. - - Ilya Zverev -
- Leaflet.DoubleRightClickZoom - - Interaction handler enabling zooming out with double right click. - - Mike O'Toole -
- Leaflet.ZoomLabel - - A simple zoom label control. - - Masashi Takeshita -
- Leaflet.ZoomPanel - - A Zoom Control Panel Of Leaflet. Demo - - Shuhua Huang -
- - +{% include plugin_category_table.html category="interactive-pan-zoom" %} ### Bookmarked pan/zoom Change the way the user is moved around the map, by jumping to predefined/stored places. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.viewcenter - - A simple control that adds a button to change view and zoom to predefined values in options. - - Dariusz Pawlak -
- leaflet-zoom-min - - Adds a button to the zoom control that allows you to zoom to the map minimum zoom level in a single click. - - Alan Shaw -
- Leaflet Navigation Toolbar - - Leaflet control for simple back, forward and home navigation. - - David C -
- Leaflet Locationlist - - A control to jump between predefined locations and zooms. - - Ivan Ignatyev -
- Leaflet.defaultextent - - A control that returns to the original start extent of the map. Similar to the HomeButton widget. - - Alex Nguyen -
- Leaflet.Bookmarks - - Control for adding and navigating between user-created bookmarks on the map. - - Alexander Milevski -
- Leaflet.ShowAll - - A control that can show a predefined extent while saving the current one so it can be jumped back to. - - Mor Yariv -
- Leaflet.zoomhome - - Zoom control with a home button for resetting the view (Demo) - - Florian Brucker -
- Leaflet-History - - Track history of map movements and zoom locations similar to a browser. - - Chris Scott -
- Leaflet.RestoreView - - Stores and restores map view using localStorage. - - Mathieu Leplatre -
- leaflet-hash - - Plugin for persisting map state and browsing history through the URL hash. - - Michael Lawrence Evans -
- leaflet-view-meta - - Plugin control that displays and persists map view meta-data, center and boundary coordinates to URL for precise sharing and view reconstruction. - - rwev -
- - +{% include plugin_category_table.html category="bookmarked-pan-zoom" %} ### Fullscreen controls Allows display of the map in full-screen mode. - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.fullscreen - - A fullscreen button control by Mapbox - - Mapbox -
- leaflet.fullscreen - - Another fullscreen button control but for modern browsers, using HTML5 Fullscreen API. - - Bruno B -
- leaflet.zoomfs - - A fullscreen button control. - - Eli Dupuis -
- - +{% include plugin_category_table.html category="fullscreen-controls" %} ### Minimaps & synced maps Display two maps at once. One of them might be a different size and zoom level, usable as a minimap to aid with navigation. - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.Sync - - Synchronized view of two maps. - - Bjørn Sandvik -
- Leaflet.MiniMap - - A small minimap showing the map at a different scale to aid navigation. - - Robert Nordan -
- Leaflet.MagnifyingGlass - - Allows you to display a small portion of the map at another zoom level, either at a fixed position or linked to the mouse movement, for a magnifying glass effect. - - Benjamin Becquet -
- Leaflet.layerscontrol-minimap - - Extends the default Leaflet layers control with synced minimaps. - - Jieter -
- Leaflet.GlobeMiniMap - - Simple minimap control that places a 3D Globe in the corner of your map, centered on the same location as the main map (demo). - - Chris Whong -
- leaflet-clonelayer - - Clone Leaflet layers to allow reuse across different maps in the same runtime. - - Jieter -
- - - - - +{% include plugin_category_table.html category="minimaps-synced-maps" %} ### Measurement Allow the user to measure distances or areas. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.PolylineMeasure - - Measure great-circle distances of simple lines as well as of complex polylines. (Demo 1), (Demo 2), (Demo 3) - - PPete -
- Leaflet.MeasureControl - - A simple tool to measure distances on maps (*relies on Leaflet.Draw*). - - Makina Corpus -
- Leaflet.MeasureAreaControl - - Control for measuring element's area. - - Ondrej Zvara -
- leaflet-measure - - Coordinate, linear, and area measure control for Leaflet maps - - LJA GIS -
- leaflet-graphicscale - - Animated graphic scale control (demo). - - Erik Escoffier -
- Leaflet.ScaleFactor - - Display a Scale Factor (e.g. 1:50,000) for Leaflet maps (Demo) - - Marc Chasse -
- Leaflet.nauticscale - - Display a Nauticscale on Leaflet maps - - Johannes Rudolph -
- Leaflet Measure Path - - Show measurements on paths; polylines, polygons and circles currently supported (demo) - - Per Liedman / Prominent Edge -
- Leaflet.LinearMeasurement - - Leaflet Linear Measurement plugin that creates polylines with incremental measures along the path. (demo) - - New Light Technologies -
- leaflet-ruler - - A simple leaflet plugin to measure true bearing and distance between clicked points. (Demo) - - Goker Tanrisever -
- leaflet-reticle - - Leaflet control adding a centering reticle consisting of independently calculated latitude and longitude scales. - - rwev -
- - - - - - - +{% include plugin_category_table.html category="measurement" %} ### Mouse coordinates Show the geographical coordinates under the mouse cursor in different ways. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.MousePosition - - A simple MousePosition control that displays geographic coordinates of the mouse pointer, as it is moved about the map - - Ardhi Lukianto -
- Leaflet.Coordinates - - A simple Leaflet plugin viewing the mouse LatLng-coordinates. Also views a marker with coordinate popup on userinput. - - Felix Bache -
- Leaflet Coordinates Control - - Captures mouseclick and displays its coordinates with easy way to copy them. - - Michal Zimmermann -
- Leaflet Copy Coordinates Control - - Works with Leaflet to capture mouseclicks on a map and display the associated coordinates with an easy way to copy them. (Derived from original work by zimmicz. Forked mainly to provide npm functionality.) - - Chaim Krause -
- Leaflet.NACCoordinates - - Displays NAC coordinate of the mouse pointer on mouse move (Demo) - - Mahmood Dehghan -
- Leaflet.mouseCoordinates - - Displays the Mouse Coordinate in a Box. - Multiple Formats Are Possible -
    -
  • GPS
  • -
  • UTM
  • -
  • UTMREF / MGRS
  • -
  • QTH
  • -
-
- Johannes Rudolph -
- Leaflet Location Picker - - Simple location picker with mini Leaflet map (Demo) - - Stefano Cudini -
- Leaflet.MapCenterCoord - - A Leaflet control to display the coordinates of the map center, especially useful on touch/mobile devices. (Doc & demos) - - Xisco Guaita -
- Leaflet.Mapcodes - - Displays the Mapcode of the mouse pointer on mouse move (Demo) - - Martin Atukunda -
- - - - - - - - +{% include plugin_category_table.html category="mouse-coordinates" %} ### Events These plugins extend Leaflet event handling. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.GestureHandling - - Brings the basic functionality of Google Maps Gesture Handling into Leaflet. Prevents users from getting trapped on the map when scrolling a long page. - Demo - - Andy Marquis -
- L.Sleep - - Avoid unwanted scroll capturing. - Demo - - atstp -
- Leaflet.OverIntent - - Adds a new event ``mouseintent``, that differs from ``mouseover`` since it reflects user - intentions to aim a particular layer. - - Mathieu Leplatre -
- Leaflet.AlmostOver - - Trigger mouse events when cursor is "almost" over a layer. - - Mathieu Leplatre -
- Leaflet-active-area - - This plugin allows you to use a smaller portion of the map as an active area. - All positioning methods (setView, fitBounds, setZoom) will be applied on this portion instead of the all map. - - Mappy -
- Leaflet.ControlledBounds - - Inspired by Leaflet-active-area, automatically detects the largest area of the map not covered by any map controls and applies setView, fitBounds, setZoom, getBounds to that area. - - Iván Sánchez Ortega, - MazeMap -
- singleclick - - Extend L.Map to fire a singleclick event (demo). Compatible with Leaflet 0.7.x only. - - Guillaume Lathoud -
- singleclick - - Extend L.Evented to fire a singleclick event (demo). Compatible with Leaflet 1.0.0-beta1 and greater only. - - Iván Sánchez Ortega, - MazeMap -
- Leaflet.VisualClick - - Adds visual feedback when user clicks/taps the map (demo). - Useful when further action is delayed by server requests, or implementation of Leaflet.singleclick. - Or just because it looks cool :) - Only tested with Leaflet 1.0.0-beta1. - - Dag Jomar Mersland, - Iván Sánchez Ortega, - MazeMap -
- Leaflet Touch Helper - - Makes it easy to touch vector overlays with thick fingers on a small display by adding a transparent, larger touch surface - - Per Liedman / Prominent Edge -
- Leaflet.ClickTolerance - - This plugin allows you to increase the click tolerance of canvas powered layers, making it possible to increase the clickable area of vector layers beyond their visible extent. Useful when your features are difficult to click otherwise. - - Geoloep -
- L.DraggableEnhancer - - Modify the default L.Draggable handler (responsible for map panning, ...) to make it work properly if one of the map container's parents has predefined handlers like "event.stopPropagation()' attached to a "mousemove" event for example. - - Vincent Dechandon -
- L.Spotlight - - Dynamically highlight features near the mouse cursor with a customizable shape - - Isaac Boates -
- - +{% include plugin_category_table.html category="events" %} ### User interface Buttons, sliders, toolbars, sidebars, and panels. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.Control.Custom - - Fully customizable Leaflet control panel with HTML element. - Demo - - Yiğit Yüce -
- L.EasyButton - - In one line, add a Font Awesome control button with attached click events. - Demo - - atstp -
- Leaflet.contextmenu - - A context menu for Leaflet. - - Adam Ratcliffe -
- Leaflet.CountrySelect - - Control with menu of all countries, and an event listener that returns - the selected country as a GeoJSON feature (demo) - - Anika Halota -
- Leaflet.GeojsonLayerSwitcher - - Allows to navigate between GeoJSON layers, select some, and return selection. - - Easy-Mountain -
- leaflet-sidebar-v2 - - A responsive, tabbed sidebar with HTML & JS API. - Compatible with old (0.7) and current leaflet. - - Norwin Roosen -
- leaflet-sidebar - - A responsive sidebar plugin. - - Tobias Bieniek -
- sidebar-v2 - - Another responsive sidebar plugin. This time with tabs! - - Tobias Bieniek -
- Leaflet.Messagebox - - Display a temporary text message on a map (Demo) - - Martijn Grendelman -
- Leaflet.TileLegend - - Create illustrated and interactive legends for your background layers. - - Yohan Boniface -
- Leaflet.toolbar - - Flexible, extensible toolbars for Leaflet maps. View an example here. - - Justin Manley -
- L.Credits - - A simple, attractive, interactive control to put your logo and link in the corner of your map. - - Greg Allensworth -
- Leaflet.Spin - - Shows a nice spinner on the map using Spin.js, - for asynchronous data load, like with Leaflet Ajax. - - Mathieu Leplatre -
- Leaflet Weather - - A Leaflet plugin for adding a weather widget to the map using OpenWeatherMap API (Demo). - - Osk -
- Leaflet ResizableControl - - A Leaflet plugin to add a resizable and scrollable control to the map (Demo). - - David Albrecht -
- Leaflet.Slider - - Adds a <input type="range"> slider that calls a function every time its input is changed (Demo) - - EPP -
- leaflet-control-window - - Creates modal/modeless, draggable, responsive, customisable window in your map. - - mapshakers/ - Filip Zavadil -
- Leaflet.CoordinatedImagePreview - - Displays coordinated images in map bounds. - - Yunus Emre Özkaya -
- Leaflet.SlideMenu - - A simple slide menu for Leaflet. - - Masashi Takeshita -
- Leaflet.Dialog - - A simple resizable, movable, customizable dialog box. (Demo) - - NBT Solutions -
- Leaflet.BootstrapZoom - - Overrides default zoom control buttons with Twitter Bootstrap styled ones - - Alexey Gusev -
- Leaflet.CondensedAttribution - - An attribution plugin that makes long attributes visible on hover - - Motion Intelligence GmbH -
- Leaflet.HtmlLegend - - A simple Leaflet plugin for creating legends using HTML elements. Demo. - - Kaveh Karimi -
- leaflet-blurred-location - - A Leaflet-based interface for selecting a "blurred" or low-resolution location, to preserve privacy. Demo. - - Public Lab -
- Leaflet.Control.Resizer - - Control to resize your map on the right or bottom side. See demo - - Javier Jimenez Shaw -
- leaflet-blurred-location-display - - - Cleverly dispays "blurred" locations using color-coded heatmap and color-coded markers while fetching data from remote API Demo. - - Public Lab -
- Leaflet.Legend - - - Display legend symbols and toggle overlays(Demo). - - JJ Jin -
- - +{% include plugin_category_table.html category="user-interface" %} ### Print/export @@ -4120,418 +323,34 @@ Print or export your map. - Get a PNG from a Leaflet map and export it in PDF https://github.com/chrissom/leaflet-pdf --> - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.print - - Implements the Mapfish print protocol allowing a Leaflet map to be printed using either the Mapfish or GeoServer print module. - - Adam Ratcliffe -
- Leaflet-image - - Export images out of Leaflet maps without a server component, by using Canvas and CORS. - - Tom MacWright -
- Leaflet-easyPrint - - A simple plugin which adds an icon to print your Leaflet map. - - Rowan Winsemius -
- leaflet.browser.print - - Allows users to print full page map directly from the browser. - - Igor Vladyka -
- Leaflet.BigImage - - Allows users to download an image with a scaled-up version of the visible map. - - Vasyl Pasichnyk (Oswald) -
- - +{% include plugin_category_table.html category="print-export" %} ### Geolocation Plugins that extend Leaflet's geolocation capabilities. - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- L.LocationShare - - Allow users to send and receive a marker with a message. - Demo - - atstp -
- Leaflet.Locate - - A customizable locate control. - - Dominik Moritz -
- Leaflet Control Compass - - A leaflet control plugin to build a simple rotating compass - - Stefano Cudini -
- Leaflet.AccuratePosition - - Leaflet.AccuratePosition aims to provide a desired device location accuracy. - - Michael Schmidt-Voigt -
- - - +{% include plugin_category_table.html category="geolocation" %} ## Miscellaneous - - ### Geoprocessing The following plugins perform several sorts of geoprocessing (mathematical and topological operations on points, lines and polygons). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Proj4Leaflet - - Proj4js integration plugin, allowing you to use all kinds of weird projections in Leaflet. - - Kartena -
- arc.js - - A JS library for drawing great circle routes that can be used with Leaflet. - - Dane Springmeyer -
- Leaflet-pip - - Simple point in polygon calculation using point-in-polygon. - - Tom MacWright -
- Leaflet.GeometryUtil - - A collection of utilities for Leaflet geometries (linear referencing, etc.) - - Benjamin Becquet, Mathieu Leplatre -
- Greiner-Hormann - - Greiner-Hormann algorithm for polygon clipping and binary operations, adapted for use with Leaflet. - - Alexander Milevski -
- Leaflet.buffer - - Enables buffering of shapes drawn with Leaflet.draw. - - Jonathan Skeate -
- Leaflet.LayerIndex - - An efficient spatial index for features and layers, using RTree.js. - - Mathieu Leplatre -
- leaflet-spatial-prefix-tree - - Leaflet plugin for visualizing spatial prefix trees, quadtree and geohash. See demo - - Mapzen -
- Leaflet.UTM - - A simple way to convert L.LatLng into UTM (WGS84) and vice versa. UTM string format easily configurable. It does not depend on any other plugin or 3rd party. See demo - - Javier Jimenez Shaw -
- Leaflet.Antimeridian - - A plugin to allow polygons and polylines to naturally draw across the Antimeridian (or the International Date Line) instead of always wrapping across the Greenwich meridian. (Demo) - - Brianna Landon -
- - +{% include plugin_category_table.html category="geoprocessing" %} ### Routing The following plugins use external services to calculate driving or walking routes. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet Routing Machine - - Control for route search with via points, displaying itinerary and alternative routes. Uses - OSRM by default, but also supports - GraphHopper, - Mapbox Directions API and more. - - Per Liedman -
- Leaflet.Routing - - Leaflet controller and interface for routing paths between waypoints using any user provided routing service. - - Norwegian Trekking Association -
- Route360° - - Route360° visualizes the area which is reachable from a set of starting points in a given time and gives detailed routing information (walk, bike, car and public transportation) to targets. - - Motion Intelligence GmbH -
- Leaflet RouteBoxer - - This is a Leaflet implementation of the RouteBoxer Class from Google. The Leaflet RouteBoxer class generates a set of L.LatLngBounds objects that are guaranteed to cover every point within a specified distance of a path. - - Stephan Georg -
- Leaflet.Routing.Amap - - Control for route search using AMap(高德地图) as a backend. Supports the Chinese BD09 and GCJ02 coordinate systems, colourful lines, and turn-by-turn popups. - - Jack Good -
- Leaflet TripGo routing - - The TripGo mobility platform lets you create apps providing seamless and personalised door-to-door trips using any public, private or commercial mode of transport. - TripGo Leaflet's plugin motivation is to provide an easy way to include its functionality in an external platform. - - SkedGo -
- leaflet.TravelNotes - - Editable markers and routing engine for leaflet. The routing engine have plugins for Mapbox, GraphHopper and OSRM and can be used for car, bike or pedestrian route. Demo. - - Christian Guyette -
- Leaflet.Reachability - - Show areas of reachability based on time or distance for different modes of travel using the openrouteservice isochrones API. - - Trafford Data Lab -
- - - +{% include plugin_category_table.html category="routing" %} ### Geocoding External services that transform an address or the name of a place into latitude and longitude (or vice versa). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet GeoSearch - - Small geocoding plugin that brings address searching/lookup (aka geosearching) to Leaflet.
- Comes with support for Google, OpenStreetMap Nominatim, Bing, Esri and Nokia. Easily extensible. -
- Stephan Meijer -
- Leaflet Control OSM Geocoder - - A simple geocoder that uses OpenstreetMap Nominatim to locate places by address. - - Karsten Hinz -
- Leaflet Control Bing Geocoder - - A simple geocoder control that uses Bing to locate places. - - Samuel Piquet -
- Leaflet Control Geocoder - - A clean and extensible control for both geocoding and reverse geocoding. Builtin support for - Nominatim, Bing, MapQuest, Mapbox, What3Words, Google and Photon. Easy to extend to other providers. - - Per Liedman -
- Leaflet GeoIP Locator - - A simple plugin that allows finding the approximate location of IP addresses and map centering on said location. - - Jakub Dostal -
- Esri Leaflet Geocoder - - A geocoding control with suggestions powered by the ArcGIS Online geocoder. - - Patrick Arlt -
- Leaflet.OpenCage.Search - - A search plugin plugin that uses OpenCage's geocoding API. - - The OpenCage team -
- Leaflet.Geonames - - A lightweight geocoding control powered by GeoNames. Demo - - Brendan Ward -
- Pelias Leaflet Plugin - - A geocoding control using Geocode Earth or any hosted service powered by the Pelias Geocoder API. Demo - - Lou Huang -
- Leaflet LocationIQ Geocoder - - A plugin that adds the ability to search (geocode) a Leaflet-powered map using LocationIQ. - - LocationIQ -
- L.Highlight - - A plugin that adds the ability to quick highlighting streets and areas using Nominatim. - - Maciej Kowalski -
- - +{% include plugin_category_table.html category="geocoding" %} ### Plugin collections @@ -4539,37 +358,7 @@ Sets of plugins that span several categories. Plugin developers: please keep future plugins in individual repositories. - - - - - - - - - - -
PluginDescriptionMaintainer
- Plugins by Pavel Shramov - - A set of plugins for: GPX, KML, TOPOJSON layers; Bing tile layer; Yandex layers (implemented with their APIs), and permalink control. - - Pavel Shramov, Bruno B -
- Spectrum4Leaflet - - Tools for using Spectrum Spatial Server services with leaflet. This plugin supports: map service, tile service, feature service. It has layers, legend and feature controls. - - SVoyt, ESTI MAP -
- MapBBCode-related leaflet plugins - - Seven plugins for various features, independent of the MapBBCode library. - From circular and popup icons to buttons, layer switcher, better search and attribution. - - Ilya Zverev -
- +{% include plugin_category_table.html category="plugin-collections" %} ## Integration @@ -4578,391 +367,13 @@ Plugin developers: please keep future plugins in individual repositories. Ease your development integrating Leaflet into a development framework or automating some of the javascript/CSS work for complex applications. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- leaflet-defaulticon-compatibility - - Retrieve all Leaflet Default Icon options from CSS, in particular all icon images URL's, to improve compatibility with bundlers and frameworks that modify URL's in CSS. In particular for webpack (with style-, css-, file- and url-loader's), Rails Asset Pipeline and Django pipeline. Should solve all use cases linked to issue Leaflet/Leaflet #4968. Demo with webpack (and without this plugin). - - ghybs -
- Leaflet Yeoman Generator - - Yeoman generator that scaffolds out a basic Leaflet map application. - - Moritz Klack -
- react-leaflet - - React components for Leaflet maps. - - Paul Le Cam -
- Leaflet.CSS - - Add the main Leaflet CSS files (or any css) from within JavaScript, be gone conditional comments. - - Calvin Metcalf -
- Leaflet LayerConfig - - Provide a json file or service response with a configuration of layers and markers to automatically set up a Leaflet client. - - Alexander Nossum -
- Leaflet.i18n - - Internationalization for Leaflet plugins. - - Yohan Boniface -
- Leaflet ZoomLevel CSS Class - - Add zoom level css class to map element for easy style updates based on zoom levels - - Dag Jomar Mersland -
- famous-map - - Integrate Leaflet in applications made with the famo.us web framework. - - Hein Rutjes -
- ngx-leaflet - - Leaflet components and extensions for Angular.io. - - Asymmetrik, Ltd. -
- Angular Leaflet directive - - Integrate Leaflet in applications made with the AngularJS web framework. - - David Rubert -
- Tiny Leaflet Directive - - Tiny LeafletJS map directive for your AngularJS apps. - - Martin Tesař -
- Leaflet Popup Angular - - Use AngularJS in your Leaflet popups. Extends the built-in L.popup. - - Grant Harris -
- Leaflet Control Angular - - Insert and use Angularized HTML code in your Leaflet map as a Leaflet control. - - Grant Harris -
- YAGA leaflet-ng2 - - Granular integration into Angular2/4. demo . - - YAGA Development Team -
- <leaflet-map> - - Integrate Leaflet in applications made with the Polymer >= 1.0 web component framework. - - Hendrik Brummermann, - Prateek Saxena -
- Leaflet map component - - Integrate Leaflet in applications made with the Polymer 0.5 web framework. - - Prateek Saxena -
- Leaflet.jsf - - Comprehensive Java Server Faces(JSF) Component/Wrapper for Leaflet. - - Terra SI LLC. - M.Çağrı Tepebaşılı -
- JSF2Leaf - - A JavaServer Faces wrapper for Leaflet. - - Leonardo Ciocari -
- ember-leaflet - - Easy and declarative mapping for Ember.js using Leaflet. - - Miguel Andrade -
- meteor-leaflet - - Provides a Meteor package to quickly build real-time cross-platform map apps. - - Bevan Hunt -
- L.Control.BootstrapModal - - Trigger a Bootstrap modal using an on-map control. - - Greg Allensworth -
- L.Control.jQueryDialog - - Trigger a jQuery UI dialog/modal using an on-map control. - - Greg Allensworth -
- V-Leaflet - - Use Leaflet as a component for the Vaadin Java/HTML framework. - - Matti Tahvonen -
- gwty-leaflet - - A Java/GWT JsInterop wrapper for Leaflet. It allows using Leaflet in Java the same way as from a javascript script. - - Zakaria Amine -
- Leaflet Map Builder - - It populates a leaflet map from a configuration object, can also creates zoom, layers, attribution and draw controls. demo . - - Gherardo Varando -
- Vue2Leaflet - - Vue2Leaflet is a JavaScript library for the Vue.js framework that wraps Leaflet, making it easy to create reactive maps. - - Mickaël KoRiGaN -
- leaflet-rails gem - - This gem provides the leaflet.js map display library for your Rails 5 application. leaflet-rails on RubyGems - - Akshay Joshi -
- +{% include plugin_category_table.html category="frameworks-build-systems" %} ### 3rd party integration The following plugins integrate Leaflet into third party services or websites. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PluginDescriptionMaintainer
- Leaflet.EditInOSM - - Add a control with links to open the current map view on main OSM editors. - - Yohan Boniface -
- Maps Marker Pro - - A WordPress plugin that enables users to pin, organize and share their favorite places and tracks through their WordPress powered site. - - Robert Harm -
- WordPress Leaflet Map - - Interactive and flexible shortcode to create multiple maps in posts and pages, - and to add multiple markers on those maps. - - Benjamin J DeLong -
- Maptiks - - Analytics platform for web maps. Track map activities, layer load times, marker clicks, and more! - - Sparkgeo -
- Leaflet for Drupal - - A Drupal (7.x and 8.x) module to integrate Leaflet maps in your Drupal site. Contains a field formatter to show a map for fields containing geospatial data, Views integration to plot data on a map, and a lightweight and easy to use API. Currently used by over 10.000 sites. - - Marzee Labs, and more maintainers listed at drupal.org -
- Leaflet Easymap - - Include a map in your HTML page without one line of programming. A data-driven Javascript module. - - Klaus Stein -
- WP MapIt - - Easy to use, WordPress Map plugin based on Open Street Map and Leaflet with custom markers images, descriptions and links. - - Chandni Patel -
- Map Block Leaflet - - A Block for the New WordPress Block Editor based on Leaflet, it allow add and custom maps from a visual interface. - - Jesús Olazagoitia -
- ABP Usermap MyBB - - A plugin for MyBB creating a map of users based on Open Street Map and Leaflet, with customisable popup and markers - - CrazyCat -
- Leaflet Extensions for Joomla! (3.x) - -
    -
  • - Agosm:
    - Joomla Module not only for showing Markers on a OpenStreetMap Map.
    - Gibhub
    - Joomla Extension Directory
    -
  • -
  • - Aggpxtrack:
    - Joomla Custom Field for dispaying a GPX Track on a Map - you can choose an OpenStreetMap or GoogleMaps. With much options. For example: One option is an elevation profil.
    - Gibhub
    - Joomla Extension Directory
    -
  • -
  • - Agosmmapwithmarker:
    - Custom field for show a map with a marker in frond end - always the right card for the content. You can enter the address in backend.
    - Gibhub
    - Joomla Extension Directory
    -
  • -
-
- Astrid Günther -
- Leaflet.Facebook - - Simple plugin for adding Facebook like button as a control. - - Marcin Wasilewski -
- WP-Trip-Summary - - A WordPress trip summary plugin to help travel bloggers manage and display structured information about their train rides and biking or hiking trips. - - Alexandru Boia -
+{% include plugin_category_table.html category="3rd-party-integration" %} @@ -4972,4 +383,4 @@ Leaflet keeps it simple. If you can think of a feature that is not required by a There are no hard requirements on how to create your own plugin, but all developers are encouraged to read the recommendations in the [plugin guide](https://github.com/Leaflet/Leaflet/blob/master/PLUGIN-GUIDE.md). -Once your plugin is ready, you can submit it to this list: just send a pull request with the addition to [/docs/plugins.md](https://github.com/Leaflet/Leaflet/blob/master/docs/plugins.md) to our GitHub repository. +Once your plugin is ready, you can submit it: just send a pull request with a new plugin file in [/docs/_plugins/](https://github.com/Leaflet/Leaflet/tree/master/docs/_plugins)to our GitHub repository. diff --git a/docs/reference-1.0.3.html b/docs/reference-1.0.3.html index 61fdbdc7952..1c55d2f6f50 100644 --- a/docs/reference-1.0.3.html +++ b/docs/reference-1.0.3.html @@ -19773,9 +19773,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.1.0.html b/docs/reference-1.1.0.html index 384839396c4..cf857fa9c28 100644 --- a/docs/reference-1.1.0.html +++ b/docs/reference-1.1.0.html @@ -19903,9 +19903,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.2.0.html b/docs/reference-1.2.0.html index fa0fa819e03..7ec20f69480 100644 --- a/docs/reference-1.2.0.html +++ b/docs/reference-1.2.0.html @@ -19918,9 +19918,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.3.4.html b/docs/reference-1.3.4.html index a4f7dff66b1..7d08ea80e26 100644 --- a/docs/reference-1.3.4.html +++ b/docs/reference-1.3.4.html @@ -20120,9 +20120,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.4.0.html b/docs/reference-1.4.0.html index 3a4fd2afca7..38a69092a02 100644 --- a/docs/reference-1.4.0.html +++ b/docs/reference-1.4.0.html @@ -20133,9 +20133,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.6.0.html b/docs/reference-1.6.0.html index dfe9b74eb8a..1fa18a9b9f8 100644 --- a/docs/reference-1.6.0.html +++ b/docs/reference-1.6.0.html @@ -21025,9 +21025,9 @@

Methods

- listens(<String> type) + listens(<String> type, <Boolean> propagate?) Boolean -

Returns true if a particular event type has any listeners attached to it.

+

Returns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.

diff --git a/docs/reference-1.7.1.html b/docs/reference-1.7.1.html index 26ebd1128d1..87fbc08f2ba 100644 --- a/docs/reference-1.7.1.html +++ b/docs/reference-1.7.1.html @@ -1,25067 +1,4 @@ --- -layout: v2 -title: Documentation -bodyclass: api-page +layout: redirected +redirect_to: reference.html --- - -

This reference reflects Leaflet 1.7.1. Check this list if you are using a different version of Leaflet.

- -

Leaflet API reference

-
- -
-

UI Layers

- -

Raster Layers

- -

Vector Layers

- -
-
-

Other Layers

- -

Basic Types

- -

Controls

- -
-
- - - - - - -

Utility

- -

DOM Utility

- -
-
-

Base Classes

- - -

Misc

- -
-
- -

Map

The central class of the API — it is used to create a map on a page and manipulate it.

- -
-

Usage example

- -
- - - - - -
// initialize the map on the "map" div with a given center and zoom
-var map = L.map('map', {
-	center: [51.505, -0.09],
-	zoom: 13
-});
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - -
FactoryDescription
L.map(<String> id, <Map options> options?)Instantiates a map object given the DOM ID of a <div> element -and optionally an object literal with Map options.
L.map(<HTMLElement> el, <Map options> options?)Instantiates a map object given an instance of a <div> HTML element -and optionally an object literal with Map options.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
preferCanvasBooleanfalseWhether Paths should be rendered on a Canvas renderer. -By default, all Paths are rendered in a SVG renderer.
- -
- -

Control options

- - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionControlBooleantrueWhether a attribution control is added to the map by default.
zoomControlBooleantrueWhether a zoom control is added to the map by default.
- -
- -

Interaction Options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
closePopupOnClickBooleantrueSet it to false if you don't want popups to close when user clicks the map.
zoomSnapNumber1Forces the map's zoom level to always be a multiple of this, particularly -right after a fitBounds() or a pinch-zoom. -By default, the zoom level snaps to the nearest integer; lower values -(e.g. 0.5 or 0.1) allow for greater granularity. A value of 0 -means the zoom level will not be snapped after fitBounds or a pinch-zoom.
zoomDeltaNumber1Controls how much the map's zoom level will change after a -zoomIn(), zoomOut(), pressing + -or - on the keyboard, or using the zoom controls. -Values smaller than 1 (e.g. 0.5) allow for greater granularity.
trackResizeBooleantrueWhether the map automatically handles browser window resize to update itself.
boxZoomBooleantrueWhether the map can be zoomed to a rectangular area specified by -dragging the mouse while pressing the shift key.
doubleClickZoomBoolean|StringtrueWhether the map can be zoomed in by double clicking on it and -zoomed out by double clicking while holding shift. If passed -'center', double-click zoom will zoom to the center of the -view regardless of where the mouse was.
draggingBooleantrueWhether the map be draggable with mouse/touch or not.
- -
- -

Map State Options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
crsCRSL.CRS.EPSG3857The Coordinate Reference System to use. Don't change this if you're not -sure what it means.
centerLatLngundefinedInitial geographic center of the map
zoomNumberundefinedInitial map zoom level
minZoomNumber*Minimum zoom level of the map. -If not specified and at least one GridLayer or TileLayer is in the map, -the lowest of their minZoom options will be used instead.
maxZoomNumber*Maximum zoom level of the map. -If not specified and at least one GridLayer or TileLayer is in the map, -the highest of their maxZoom options will be used instead.
layersLayer[][]Array of layers that will be added to the map initially
maxBoundsLatLngBoundsnullWhen this option is set, the map restricts the view to the given -geographical bounds, bouncing the user back if the user tries to pan -outside the view. To set the restriction dynamically, use -setMaxBounds method.
rendererRenderer*The default method for drawing vector layers on the map. L.SVG -or L.Canvas by default depending on browser support.
- -
- -

Animation Options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
zoomAnimationBooleantrueWhether the map zoom animation is enabled. By default it's enabled -in all browsers that support CSS3 Transitions except Android.
zoomAnimationThresholdNumber4Won't animate zoom if the zoom difference exceeds this value.
fadeAnimationBooleantrueWhether the tile fade animation is enabled. By default it's enabled -in all browsers that support CSS3 Transitions except Android.
markerZoomAnimationBooleantrueWhether markers animate their zoom with the zoom animation, if disabled -they will disappear for the length of the animation. By default it's -enabled in all browsers that support CSS3 Transitions except Android.
transform3DLimitNumber2^23Defines the maximum size of a CSS translation transform. The default -value should not be changed unless a web browser positions layers in -the wrong place after doing a large panBy.
- -
- -

Panning Inertia Options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
inertiaBoolean*If enabled, panning of the map will have an inertia effect where -the map builds momentum while dragging and continues moving in -the same direction for some time. Feels especially nice on touch -devices. Enabled by default unless running on old Android devices.
inertiaDecelerationNumber3000The rate with which the inertial movement slows down, in pixels/second².
inertiaMaxSpeedNumberInfinityMax speed of the inertial movement, in pixels/second.
easeLinearityNumber0.2
worldCopyJumpBooleanfalseWith this option enabled, the map tracks when you pan to another "copy" -of the world and seamlessly jumps to the original one so that all overlays -like markers and vector layers are still visible.
maxBoundsViscosityNumber0.0If maxBounds is set, this option will control how solid the bounds -are when dragging the map around. The default value of 0.0 allows the -user to drag outside the bounds at normal speed, higher values will -slow down map dragging outside bounds, and 1.0 makes the bounds fully -solid, preventing the user from dragging outside the bounds.
- -
- -

Keyboard Navigation Options

- - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
keyboardBooleantrueMakes the map focusable and allows users to navigate the map with keyboard -arrows and +/- keys.
keyboardPanDeltaNumber80Amount of pixels to pan when pressing an arrow key.
- -
- -

Mouse wheel options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
scrollWheelZoomBoolean|StringtrueWhether the map can be zoomed by using the mouse wheel. If passed 'center', -it will zoom to the center of the view regardless of where the mouse was.
wheelDebounceTimeNumber40Limits the rate at which a wheel can fire (in milliseconds). By default -user can't zoom via wheel more often than once per 40 ms.
wheelPxPerZoomLevelNumber60How many scroll pixels (as reported by L.DomEvent.getWheelDelta) -mean a change of one full zoom level. Smaller values will make wheel-zooming -faster (and vice versa).
- -
- -

Touch interaction options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
tapBooleantrueEnables mobile hacks for supporting instant taps (fixing 200ms click -delay on iOS/Android) and touch holds (fired as contextmenu events).
tapToleranceNumber15The max number of pixels a user can shift his finger during touch -for it to be considered a valid tap.
touchZoomBoolean|String*Whether the map can be zoomed by touch-dragging with two fingers. If -passed 'center', it will zoom to the center of the view regardless of -where the touch events (fingers) were. Enabled for touch-capable web -browsers except for old Androids.
bounceAtZoomLimitsBooleantrueSet it to false if you don't want the map to zoom beyond min/max zoom -and then bounce back when pinch-zooming.
- -
- - -
-

Events

- -
- -

Layer events

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
baselayerchangeLayersControlEventFired when the base layer is changed through the layers control.
overlayaddLayersControlEventFired when an overlay is selected through the layers control.
overlayremoveLayersControlEventFired when an overlay is deselected through the layers control.
layeraddLayerEventFired when a new layer is added to the map.
layerremoveLayerEventFired when some layer is removed from the map
- -
- -

Map state change events

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
zoomlevelschangeEventFired when the number of zoomlevels on the map is changed due -to adding or removing a layer.
resizeResizeEventFired when the map is resized.
unloadEventFired when the map is destroyed with remove method.
viewresetEventFired when the map needs to redraw its content (this usually happens -on map zoom or load). Very useful for creating custom overlays.
loadEventFired when the map is initialized (when its center and zoom are set -for the first time).
zoomstartEventFired when the map zoom is about to change (e.g. before zoom animation).
movestartEventFired when the view of the map starts changing (e.g. user starts dragging the map).
zoomEventFired repeatedly during any change in zoom level, including zoom -and fly animations.
moveEventFired repeatedly during any movement of the map, including pan and -fly animations.
zoomendEventFired when the map zoom has changed, after any animations.
moveendEventFired when the center of the map stops changing (e.g. user stopped dragging the map or when a non-centered zoom ends).
- -
- -

Popup events

- - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup is opened in the map
popupclosePopupEventFired when a popup in the map is closed
autopanstartEventFired when the map starts autopanning when opening a popup.
- -
- -

Tooltip events

- - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip is opened in the map.
tooltipcloseTooltipEventFired when a tooltip in the map is closed.
- -
- -

Location events

- - - - - - - - - - - - - - - - - - - -
EventDataDescription
locationerrorErrorEventFired when geolocation (using the locate method) failed.
locationfoundLocationEventFired when geolocation (using the locate method) -went successfully.
- -
- -

Interaction events

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the map.
dblclickMouseEventFired when the user double-clicks (or double-taps) the map.
mousedownMouseEventFired when the user pushes the mouse button on the map.
mouseupMouseEventFired when the user releases the mouse button on the map.
mouseoverMouseEventFired when the mouse enters the map.
mouseoutMouseEventFired when the mouse leaves the map.
mousemoveMouseEventFired while the mouse moves over the map.
contextmenuMouseEventFired when the user pushes the right mouse button on the map, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
keypressKeyboardEventFired when the user presses a key from the keyboard that produces a character value while the map is focused.
keydownKeyboardEventFired when the user presses a key from the keyboard while the map is focused. Unlike the keypress event, -the keydown event is fired for keys that produce a character value and for keys -that do not produce a character value.
keyupKeyboardEventFired when the user releases a key from the keyboard while the map is focused.
preclickMouseEventFired before mouse click on the map (sometimes useful when you -want something to happen on click before any existing click -handlers start running).
- -
- -

Other Events

- - - - - - - - - - - - - - -
EventDataDescription
zoomanimZoomAnimEventFired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
getRenderer(<Path> layer)Renderer

Returns the instance of Renderer that should be used to render the given -Path. It will ensure that the renderer options of the map and paths -are respected, and that the renderers do exist on the map.

-
- -
- -

Methods for Layers and Controls

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addControl(<Control> control)this

Adds the given control to the map

-
removeControl(<Control> control)this

Removes the given control from the map

-
addLayer(<Layer> layer)this

Adds the given layer to the map

-
removeLayer(<Layer> layer)this

Removes the given layer from the map.

-
hasLayer(<Layer> layer)Boolean

Returns true if the given layer is currently added to the map

-
eachLayer(<Function> fn, <Object> context?)this

Iterates over the layers of the map, optionally specifying context of the iterator function.

-
map.eachLayer(function(layer){
-    layer.bindPopup('Hello');
-});
-
-
openPopup(<Popup> popup)this

Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).

-
openPopup(<String|HTMLElement> content, <LatLng> latlng, <Popup options> options?)this

Creates a popup with the specified content and options and opens it in the given point on a map.

-
closePopup(<Popup> popup?)this

Closes the popup previously opened with openPopup (or the given one).

-
openTooltip(<Tooltip> tooltip)this

Opens the specified tooltip.

-
openTooltip(<String|HTMLElement> content, <LatLng> latlng, <Tooltip options> options?)this

Creates a tooltip with the specified content and options and open it.

-
closeTooltip(<Tooltip> tooltip?)this

Closes the tooltip given as parameter.

-
- -
- -

Methods for modifying map state

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setView(<LatLng> center, <Number> zoom, <Zoom/pan options> options?)this

Sets the view of the map (geographical center and zoom) with the given -animation options.

-
setZoom(<Number> zoom, <Zoom/pan options> options?)this

Sets the zoom of the map.

-
zoomIn(<Number> delta?, <Zoom options> options?)this

Increases the zoom of the map by delta (zoomDelta by default).

-
zoomOut(<Number> delta?, <Zoom options> options?)this

Decreases the zoom of the map by delta (zoomDelta by default).

-
setZoomAround(<LatLng> latlng, <Number> zoom, <Zoom options> options)this

Zooms the map while keeping a specified geographical point on the map -stationary (e.g. used internally for scroll zoom and double-click zoom).

-
setZoomAround(<Point> offset, <Number> zoom, <Zoom options> options)this

Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.

-
fitBounds(<LatLngBounds> bounds, <fitBounds options> options?)this

Sets a map view that contains the given geographical bounds with the -maximum zoom level possible.

-
fitWorld(<fitBounds options> options?)this

Sets a map view that mostly contains the whole world with the maximum -zoom level possible.

-
panTo(<LatLng> latlng, <Pan options> options?)this

Pans the map to a given center.

-
panBy(<Point> offset, <Pan options> options?)this

Pans the map by a given number of pixels (animated).

-
flyTo(<LatLng> latlng, <Number> zoom?, <Zoom/pan options> options?)this

Sets the view of the map (geographical center and zoom) performing a smooth -pan-zoom animation.

-
flyToBounds(<LatLngBounds> bounds, <fitBounds options> options?)this

Sets the view of the map with a smooth animation like flyTo, -but takes a bounds parameter like fitBounds.

-
setMaxBounds(<LatLngBounds> bounds)this

Restricts the map view to the given bounds (see the maxBounds option).

-
setMinZoom(<Number> zoom)this

Sets the lower limit for the available zoom levels (see the minZoom option).

-
setMaxZoom(<Number> zoom)this

Sets the upper limit for the available zoom levels (see the maxZoom option).

-
panInsideBounds(<LatLngBounds> bounds, <Pan options> options?)this

Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.

-
panInside(<LatLng> latlng, <options> options?)this

Pans the map the minimum amount to make the latlng visible. Use -padding, paddingTopLeft and paddingTopRight options to fit -the display to more restricted bounds, like fitBounds. -If latlng is already within the (optionally padded) display bounds, -the map will not be panned.

-
invalidateSize(<Zoom/pan options> options)this

Checks if the map container size changed and updates the map if so — -call it after you've changed the map size dynamically, also animating -pan by default. If options.pan is false, panning will not occur. -If options.debounceMoveend is true, it will delay moveend event so -that it doesn't happen often even if the method is called many -times in a row.

-
invalidateSize(<Boolean> animate)this

Checks if the map container size changed and updates the map if so — -call it after you've changed the map size dynamically, also animating -pan by default.

-
stop()this

Stops the currently running panTo or flyTo animation, if any.

-
- -
- -

Geolocation methods

- - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
locate(<Locate options> options?)this

Tries to locate the user using the Geolocation API, firing a locationfound -event with location data on success or a locationerror event on failure, -and optionally sets the map view to the user's location with respect to -detection accuracy (or to the world view if geolocation failed). -Note that, if your page doesn't use HTTPS, this method will fail in -modern browsers (Chrome 50 and newer) -See Locate options for more details.

-
stopLocate()this

Stops watching location previously initiated by map.locate({watch: true}) -and aborts resetting the map view if map.locate was called with -{setView: true}.

-
- -
- -

Other Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addHandler(<String> name, <Function> HandlerClass)this

Adds a new Handler to the map, given its name and constructor function.

-
remove()this

Destroys the map and clears all related event listeners.

-
createPane(<String> name, <HTMLElement> container?)HTMLElement

Creates a new map pane with the given name if it doesn't exist already, -then returns it. The pane is created as a child of container, or -as a child of the main map pane if not set.

-
getPane(<String|HTMLElement> pane)HTMLElement

Returns a map pane, given its name or its HTML element (its identity).

-
getPanes()Object

Returns a plain object containing the names of all panes as keys and -the panes as values.

-
getContainer()HTMLElement

Returns the HTML element that contains the map.

-
whenReady(<Function> fn, <Object> context?)this

Runs the given function fn when the map gets initialized with -a view (center and zoom) and at least one layer, or immediately -if it's already initialized, optionally passing a function context.

-
- -
- -

Methods for Getting Map State

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getCenter()LatLng

Returns the geographical center of the map view

-
getZoom()Number

Returns the current zoom level of the map view

-
getBounds()LatLngBounds

Returns the geographical bounds visible in the current map view

-
getMinZoom()Number

Returns the minimum zoom level of the map (if set in the minZoom option of the map or of any layers), or 0 by default.

-
getMaxZoom()Number

Returns the maximum zoom level of the map (if set in the maxZoom option of the map or of any layers).

-
getBoundsZoom(<LatLngBounds> bounds, <Boolean> inside?, <Point> padding?)Number

Returns the maximum zoom level on which the given bounds fit to the map -view in its entirety. If inside (optional) is set to true, the method -instead returns the minimum zoom level on which the map view fits into -the given bounds in its entirety.

-
getSize()Point

Returns the current size of the map container (in pixels).

-
getPixelBounds()Bounds

Returns the bounds of the current map view in projected pixel -coordinates (sometimes useful in layer and overlay implementations).

-
getPixelOrigin()Point

Returns the projected pixel coordinates of the top left point of -the map layer (useful in custom layer and overlay implementations).

-
getPixelWorldBounds(<Number> zoom?)Bounds

Returns the world's bounds in pixel coordinates for zoom level zoom. -If zoom is omitted, the map's current zoom level is used.

-
- -
- -

Conversion Methods

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getZoomScale(<Number> toZoom, <Number> fromZoom)Number

Returns the scale factor to be applied to a map transition from zoom level -fromZoom to toZoom. Used internally to help with zoom animations.

-
getScaleZoom(<Number> scale, <Number> fromZoom)Number

Returns the zoom level that the map would end up at, if it is at fromZoom -level and everything is scaled by a factor of scale. Inverse of -getZoomScale.

-
project(<LatLng> latlng, <Number> zoom)Point

Projects a geographical coordinate LatLng according to the projection -of the map's CRS, then scales it according to zoom and the CRS's -Transformation. The result is pixel coordinate relative to -the CRS origin.

-
unproject(<Point> point, <Number> zoom)LatLng

Inverse of project.

-
layerPointToLatLng(<Point> point)LatLng

Given a pixel coordinate relative to the origin pixel, -returns the corresponding geographical coordinate (for the current zoom level).

-
latLngToLayerPoint(<LatLng> latlng)Point

Given a geographical coordinate, returns the corresponding pixel coordinate -relative to the origin pixel.

-
wrapLatLng(<LatLng> latlng)LatLng

Returns a LatLng where lat and lng has been wrapped according to the -map's CRS's wrapLat and wrapLng properties, if they are outside the -CRS's bounds. -By default this means longitude is wrapped around the dateline so its -value is between -180 and +180 degrees.

-
wrapLatLngBounds(<LatLngBounds> bounds)LatLngBounds

Returns a LatLngBounds with the same size as the given one, ensuring that -its center is within the CRS's bounds. -By default this means the center longitude is wrapped around the dateline so its -value is between -180 and +180 degrees, and the majority of the bounds -overlaps the CRS's bounds.

-
distance(<LatLng> latlng1, <LatLng> latlng2)Number

Returns the distance between two geographical coordinates according to -the map's CRS. By default this measures distance in meters.

-
containerPointToLayerPoint(<Point> point)Point

Given a pixel coordinate relative to the map container, returns the corresponding -pixel coordinate relative to the origin pixel.

-
layerPointToContainerPoint(<Point> point)Point

Given a pixel coordinate relative to the origin pixel, -returns the corresponding pixel coordinate relative to the map container.

-
containerPointToLatLng(<Point> point)LatLng

Given a pixel coordinate relative to the map container, returns -the corresponding geographical coordinate (for the current zoom level).

-
latLngToContainerPoint(<LatLng> latlng)Point

Given a geographical coordinate, returns the corresponding pixel coordinate -relative to the map container.

-
mouseEventToContainerPoint(<MouseEvent> ev)Point

Given a MouseEvent object, returns the pixel coordinate relative to the -map container where the event took place.

-
mouseEventToLayerPoint(<MouseEvent> ev)Point

Given a MouseEvent object, returns the pixel coordinate relative to -the origin pixel where the event took place.

-
mouseEventToLatLng(<MouseEvent> ev)LatLng

Given a MouseEvent object, returns geographical coordinate where the -event took place.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -
-

Properties

- -
- -

Controls

- - - - - - - - - - - - - - -
PropertyTypeDescription
zoomControlControl.ZoomThe default zoom control (only available if the -zoomControl option was true when creating the map).
- -
- -

Handlers

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
boxZoomHandlerBox (shift-drag with mouse) zoom handler.
doubleClickZoomHandlerDouble click zoom handler.
draggingHandlerMap dragging handler (by both mouse and touch).
keyboardHandlerKeyboard navigation handler.
scrollWheelZoomHandlerScroll wheel zoom handler.
tapHandlerMobile touch hacks (quick tap and touch hold) handler.
touchZoomHandlerTouch zoom handler.
- -
- - -
-

Map panes

- -
- - - -
Panes are DOM elements used to control the ordering of layers on the map. You -can access panes with map.getPane or -map.getPanes methods. New panes can be created with the -map.createPane method. -

Every map has the following default panes that differ only in zIndex.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaneTypeZ-indexDescription
mapPaneHTMLElement'auto'Pane that contains all other map panes
tilePaneHTMLElement200Pane for GridLayers and TileLayers
overlayPaneHTMLElement400Pane for overlay shadows (e.g. Marker shadows)
shadowPaneHTMLElement500Pane for vectors (Paths, like Polylines and Polygons), ImageOverlays and VideoOverlays
markerPaneHTMLElement600Pane for Icons of Markers
tooltipPaneHTMLElement650Pane for Tooltips.
popupPaneHTMLElement700Pane for Popups.
- -
- - -
- -
-

Locate options

- -
- - - -
Some of the geolocation methods for Map take in an options parameter. This -is a plain javascript object with the following optional components:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
watchBooleanfalseIf true, starts continuous watching of location changes (instead of detecting it -once) using W3C watchPosition method. You can later stop watching using -map.stopLocate() method.
setViewBooleanfalseIf true, automatically sets the map view to the user location with respect to -detection accuracy, or to world view if geolocation failed.
maxZoomNumberInfinityThe maximum zoom for automatic view setting when using setView option.
timeoutNumber10000Number of milliseconds to wait for a response from geolocation before firing a -locationerror event.
maximumAgeNumber0Maximum age of detected location. If less than this amount of milliseconds -passed since last geolocation response, locate will return a cached location.
enableHighAccuracyBooleanfalseEnables high accuracy, see description in the W3C spec.
- -
- - -
- -
-

Zoom options

- -
- - - -
Some of the Map methods which modify the zoom level take in an options -parameter. This is a plain javascript object with the following optional -components:
- - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the -current view. If true, the map will attempt animating zoom disregarding where -zoom origin is. Setting false will make it always reset the view completely -without animation.
- -
- - -
- -
-

Pan options

- -
- - - -
Some of the Map methods which modify the center of the map take in an options -parameter. This is a plain javascript object with the following optional -components:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
animateBooleanIf true, panning will always be animated if possible. If false, it will -not animate panning, either resetting the map view if panning more than a -screen away, or just setting a new offset for the map pane (except for panBy -which always does the latter).
durationNumber0.25Duration of animated panning, in seconds.
easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the -Cubic Bezier curve). 1.0 means linear animation, -and the smaller this number, the more bowed the curve.
noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for -panning inertia).
- -
- - -
- -
-

Zoom/pan options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the -current view. If true, the map will attempt animating zoom disregarding where -zoom origin is. Setting false will make it always reset the view completely -without animation.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
durationNumber0.25Duration of animated panning, in seconds.
easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the -Cubic Bezier curve). 1.0 means linear animation, -and the smaller this number, the more bowed the curve.
noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for -panning inertia).
- -
-
-
- -
- -
-

FitBounds options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paddingTopLeftPoint[0, 0]Sets the amount of padding in the top left corner of a map container that -shouldn't be accounted for when setting the view to fit bounds. Useful if you -have some control overlays on the map like a sidebar and you don't want them -to obscure objects you're zooming to.
paddingBottomRightPoint[0, 0]The same for the bottom right corner of the map.
paddingPoint[0, 0]Equivalent of setting both top left and bottom right padding to the same value.
maxZoomNumbernullThe maximum possible zoom to use.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the -current view. If true, the map will attempt animating zoom disregarding where -zoom origin is. Setting false will make it always reset the view completely -without animation.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
durationNumber0.25Duration of animated panning, in seconds.
easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the -Cubic Bezier curve). 1.0 means linear animation, -and the smaller this number, the more bowed the curve.
noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for -panning inertia).
- -
-
-
- -

Marker

L.Marker is used to display clickable/draggable icons on the map. Extends Layer.

- -
-

Usage example

- -
- - - - - -
L.marker([50.5, 30.5]).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.marker(<LatLng> latlng, <Marker options> options?)Instantiates a Marker object given a geographical point and optionally an options object.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
iconIcon*Icon instance to use for rendering the marker. -See Icon documentation for details on how to customize the marker icon. -If not specified, a common instance of L.Icon.Default is used.
keyboardBooleantrueWhether the marker can be tabbed to with a keyboard and clicked by pressing enter.
titleString''Text for the browser tooltip that appear on marker hover (no tooltip by default).
altString''Text for the alt attribute of the icon image (useful for accessibility).
zIndexOffsetNumber0By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively).
opacityNumber1.0The opacity of the marker.
riseOnHoverBooleanfalseIf true, the marker will get on top of others when you hover the mouse over it.
riseOffsetNumber250The z-index offset used for the riseOnHover feature.
paneString'markerPane'Map pane where the markers icon will be added.
shadowPaneString'shadowPane'Map pane where the markers shadow will be added.
bubblingMouseEventsBooleanfalseWhen true, a mouse event on this marker will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
- -
- -

Draggable marker options

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
draggableBooleanfalseWhether the marker is draggable with mouse/touch or not.
autoPanBooleanfalseWhether to pan the map when dragging this marker near its edge or not.
autoPanPaddingPointPoint(50, 50)Distance (in pixels to the left/right and to the top/bottom) of the -map edge to start panning the map.
autoPanSpeedNumber10Number of pixels the map should pan by.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - -
EventDataDescription
moveEventFired when the marker is moved via setLatLng or by dragging. Old and new coordinates are included in event arguments as oldLatLng, latlng.
- -
- -

Dragging events

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
dragstartEventFired when the user starts dragging the marker.
movestartEventFired when the marker starts moving (because of dragging).
dragEventFired repeatedly while the user drags the marker.
dragendDragEndEventFired when the user stops dragging the marker.
moveendEventFired when the marker stops moving (because of dragging).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - -
In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getLatLng()LatLng

Returns the current geographical position of the marker.

-
setLatLng(<LatLng> latlng)this

Changes the marker position to the given point.

-
setZIndexOffset(<Number> offset)this

Changes the zIndex offset of the marker.

-
getIcon()Icon

Returns the current icon used by the marker

-
setIcon(<Icon> icon)this

Changes the marker icon.

-
setOpacity(<Number> opacity)this

Changes the opacity of the marker.

-
- -
- -

Other methods

- - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the marker (as a GeoJSON Point Feature).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -
-

Properties

- -
- -

Interaction handlers

- -
Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see Handler methods). Example: -
marker.dragging.disable();
-
- - - - - - - - - - - - - -
PropertyTypeDescription
draggingHandlerMarker dragging handler (by both mouse and touch). Only valid when the marker is on the map (Otherwise set marker.options.draggable).
- -
- - -

Used to open popups in certain places of the map. Use Map.openPopup to -open popups while making sure that only one popup is open at one time -(recommended for usability), or use Map.addLayer to open as many as you want.

- -
- - -
- - - - - -

If you want to just bind a popup to marker click and then open it, it's really easy:

-
marker.bindPopup(popupContent).openPopup();
-
-

Path overlays like polylines also have a bindPopup method. -Here's a more complicated way to open a popup on a map:

-
var popup = L.popup()
-	.setLatLng(latlng)
-	.setContent('<p>Hello world!<br />This is a nice popup.</p>')
-	.openOn(map);
-
- - - -
- - -
- - -
- - - - - - - - - - - - - - -
FactoryDescription
- -
- - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
- -
-
-
- -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
- -
-
-
- -

Tooltip

Used to display small texts on top of map layers.

- -
-

Usage example

- -
- - - - - -
marker.bindTooltip("my tooltip text").openTooltip();
-
-

Note about tooltip offset. Leaflet takes two options in consideration -for computing tooltip offsetting:

-
    -
  • the offset Tooltip option: it defaults to [0, 0], and it's specific to one tooltip. -Add a positive x offset to move the tooltip to the right, and a positive y offset to -move it to the bottom. Negatives will move to the left and top.
  • -
  • the tooltipAnchor Icon option: this will only be considered for Marker. You -should adapt this value if you use a custom icon.
  • -
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.tooltip(<Tooltip options> options?, <Layer> source?)Instantiates a Tooltip object given an optional options object that describes its appearance and location and an optional source object that is used to tag the tooltip with a reference to the Layer to which it refers.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'tooltipPane'Map pane where the tooltip will be added.
offsetPointPoint(0, 0)Optional offset of the tooltip position.
directionString'auto'Direction where to open the tooltip. Possible values are: right, left, -top, bottom, center, auto. -auto will dynamically switch between right and left according to the tooltip -position on the map.
permanentBooleanfalseWhether to open the tooltip permanently or only on mouseover.
stickyBooleanfalseIf true, the tooltip will follow the mouse instead of being fixed at the feature center.
interactiveBooleanfalseIf true, the tooltip will listen to the feature events.
opacityNumber0.9Tooltip container opacity.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
classNameString''A custom CSS class name to assign to the popup.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

TileLayer

Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under Layer. Extends GridLayer.

- -
-

Usage example

- -
- - - - - -
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
-
- - - -
- -

URL template

- - - -

A string of the following form:

-
'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
-
-

{s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates. {r} can be used to add "@2x" to the URL to load retina tiles.

-

You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

-
L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});
-
- - - -
- - -
-

Creation

- -
- -

Extension methods

- - - - - - - - - - - - -
FactoryDescription
L.tilelayer(<String> urlTemplate, <TileLayer options> options?)Instantiates a tile layer object given a URL template and optionally an options object.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
maxZoomNumber18The maximum zoom level up to which this layer will be displayed (inclusive).
subdomainsString|String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the tiles. -If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. -Refer to CORS Settings for valid String values.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
updateWhenIdleBoolean(depends)Load new tiles only when panning ends. -true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. -false otherwise in order to display new tiles during panning, since it is easy to pan outside the -keepBuffer option in desktop browsers.
updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
zIndexNumber1The explicit zIndex of the tile layer.
boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels higher than maxNativeZoom will be loaded -from maxNativeZoom level and auto-scaled.
minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels lower than minNativeZoom will be loaded -from minNativeZoom level and auto-scaled.
noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the -GridLayer will only be displayed once at low zoom levels. Has no -effect when the map CRS doesn't wrap around. Can be used -in combination with bounds to prevent requesting -tiles outside the CRS limits.
paneString'tilePane'Map pane where the grid layer will be added.
classNameString''A custom class name to assign to the tile layer. Empty by default.
keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
loadingEventFired when the grid layer starts loading tiles.
tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
tileloadstartTileEventFired when a tile is requested and starts loading.
tileerrorTileErrorEventFired when there is an error loading a tile.
tileloadTileEventFired when a tile loads.
loadEventFired when the grid layer loaded all visible tiles.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setUrl(<String> url, <Boolean> noRedraw?)this

Updates the layer's URL template and redraws it (unless noRedraw is set to true). -If the URL does not change, the layer will not be redrawn unless -the noRedraw parameter is set to false.

-
createTile(<Object> coords, <Function> done?)HTMLElement

Called only internally, overrides GridLayer's createTile() -to return an <img> HTML element with the appropriate image URL given coords. The done -callback is called when the tile has been loaded.

-
- -
- -

Extension methods

- -
Layers extending TileLayer might reimplement the following method.
- - - - - - - - - - - - - -
MethodReturnsDescription
getTileUrl(<Object> coords)String

Called only internally, returns the URL for a tile given its coordinates. -Classes extending TileLayer can override this function to provide custom tile URL naming schemes.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bringToFront()this

Brings the tile layer to the top of all tile layers.

-
bringToBack()this

Brings the tile layer to the bottom of all tile layers.

-
getContainer()HTMLElement

Returns the HTML element that contains the tiles for this layer.

-
setOpacity(<Number> opacity)this

Changes the opacity of the grid layer.

-
setZIndex(<Number> zIndex)this

Changes the zIndex of the grid layer.

-
isLoading()Boolean

Returns true if any tile in the grid layer has not finished loading.

-
redraw()this

Causes the layer to clear all the tiles and request them again.

-
getTileSize()Point

Normalizes the tileSize option into a point. Used by the createTile() method.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

TileLayer.WMS

Used to display WMS services as tile layers on the map. Extends TileLayer.

- -
-

Usage example

- -
- - - - - -
var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
-	layers: 'nexrad-n0r-900913',
-	format: 'image/png',
-	transparent: true,
-	attribution: "Weather data © 2012 IEM Nexrad"
-});
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.tileLayer.wms(<String> baseUrl, <TileLayer.WMS options> options)Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
- -
- - -
-

Options

- -
- - - -
If any custom options not documented here are used, they will be sent to the -WMS server as extra parameters in each request URL. This can be useful for -non-standard vendor WMS parameters.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
layersString''(required) Comma-separated list of WMS layers to show.
stylesString''Comma-separated list of WMS styles.
formatString'image/jpeg'WMS image format (use 'image/png' for layers with transparency).
transparentBooleanfalseIf true, the WMS service will return images with transparency.
versionString'1.1.1'Version of the WMS service to use
crsCRSnullCoordinate Reference System to use for the WMS requests, defaults to -map CRS. Don't change this if you're not sure what it means.
uppercaseBooleanfalseIf true, WMS request parameter keys will be uppercase.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
maxZoomNumber18The maximum zoom level up to which this layer will be displayed (inclusive).
subdomainsString|String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the tiles. -If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. -Refer to CORS Settings for valid String values.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
updateWhenIdleBoolean(depends)Load new tiles only when panning ends. -true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. -false otherwise in order to display new tiles during panning, since it is easy to pan outside the -keepBuffer option in desktop browsers.
updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
zIndexNumber1The explicit zIndex of the tile layer.
boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels higher than maxNativeZoom will be loaded -from maxNativeZoom level and auto-scaled.
minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels lower than minNativeZoom will be loaded -from minNativeZoom level and auto-scaled.
noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the -GridLayer will only be displayed once at low zoom levels. Has no -effect when the map CRS doesn't wrap around. Can be used -in combination with bounds to prevent requesting -tiles outside the CRS limits.
paneString'tilePane'Map pane where the grid layer will be added.
classNameString''A custom class name to assign to the tile layer. Empty by default.
keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
loadingEventFired when the grid layer starts loading tiles.
tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
tileloadstartTileEventFired when a tile is requested and starts loading.
tileerrorTileErrorEventFired when there is an error loading a tile.
tileloadTileEventFired when a tile loads.
loadEventFired when the grid layer loaded all visible tiles.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
setParams(<Object> params, <Boolean> noRedraw?)this

Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setUrl(<String> url, <Boolean> noRedraw?)this

Updates the layer's URL template and redraws it (unless noRedraw is set to true). -If the URL does not change, the layer will not be redrawn unless -the noRedraw parameter is set to false.

-
createTile(<Object> coords, <Function> done?)HTMLElement

Called only internally, overrides GridLayer's createTile() -to return an <img> HTML element with the appropriate image URL given coords. The done -callback is called when the tile has been loaded.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bringToFront()this

Brings the tile layer to the top of all tile layers.

-
bringToBack()this

Brings the tile layer to the bottom of all tile layers.

-
getContainer()HTMLElement

Returns the HTML element that contains the tiles for this layer.

-
setOpacity(<Number> opacity)this

Changes the opacity of the grid layer.

-
setZIndex(<Number> zIndex)this

Changes the zIndex of the grid layer.

-
isLoading()Boolean

Returns true if any tile in the grid layer has not finished loading.

-
redraw()this

Causes the layer to clear all the tiles and request them again.

-
getTileSize()Point

Normalizes the tileSize option into a point. Used by the createTile() method.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

ImageOverlay

Used to load and display a single image over specific bounds of the map. Extends Layer.

- -
-

Usage example

- -
- - - - - -
var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
-	imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
-L.imageOverlay(imageUrl, imageBounds).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.imageOverlay(<String> imageUrl, <LatLngBounds> bounds, <ImageOverlay options> options?)Instantiates an image overlay object given the URL of the image and the -geographical bounds it is tied to.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
opacityNumber1.0The opacity of the image overlay.
altString''Text for the alt attribute of the image (useful for accessibility).
interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. -If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. -Refer to CORS Settings for valid String values.
errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
zIndexNumber1The explicit zIndex of the overlay layer.
classNameString''A custom class name to assign to the image. Empty by default.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
loadEventFired when the ImageOverlay layer has loaded its image
errorEventFired when the ImageOverlay layer fails to load its image
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setOpacity(<Number> opacity)this

Sets the opacity of the overlay.

-
bringToFront()this

Brings the layer to the top of all overlays.

-
bringToBack()this

Brings the layer to the bottom of all overlays.

-
setUrl(<String> url)this

Changes the URL of the image.

-
setBounds(<LatLngBounds> bounds)this

Update the bounds that this ImageOverlay covers

-
setZIndex(<Number> value)this

Changes the zIndex of the image overlay.

-
getBounds()LatLngBounds

Get the bounds that this ImageOverlay covers

-
getElement()HTMLElement

Returns the instance of HTMLImageElement -used by this overlay.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

VideoOverlay

Used to load and display a video player over specific bounds of the map. Extends ImageOverlay.

-

A video overlay uses the <video> -HTML5 element.

- -
-

Usage example

- -
- - - - - -
var videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
-	videoBounds = [[ 32, -130], [ 13, -100]];
-L.videoOverlay(videoUrl, videoBounds ).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.videoOverlay(<String|Array|HTMLVideoElement> video, <LatLngBounds> bounds, <VideoOverlay options> options?)Instantiates an image overlay object given the URL of the video (or array of URLs, or even a video element) and the -geographical bounds it is tied to.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
autoplayBooleantrueWhether the video starts playing automatically when loaded.
loopBooleantrueWhether the video will loop back to the beginning when played.
keepAspectRatioBooleantrueWhether the video will save aspect ratio after the projection. -Relevant for supported browsers. See browser compatibility
mutedBooleanfalseWhether the video starts on mute when loaded.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
opacityNumber1.0The opacity of the image overlay.
altString''Text for the alt attribute of the image (useful for accessibility).
interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. -If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. -Refer to CORS Settings for valid String values.
errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
zIndexNumber1The explicit zIndex of the overlay layer.
classNameString''A custom class name to assign to the image. Empty by default.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - -
EventDataDescription
loadEventFired when the video has finished loading the first frame
- -
- - -
- -
-
- - - - - - - - - - - - - - - - -
EventDataDescription
errorEventFired when the ImageOverlay layer fails to load its image
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
getElement()HTMLVideoElement

Returns the instance of HTMLVideoElement -used by this overlay.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setOpacity(<Number> opacity)this

Sets the opacity of the overlay.

-
bringToFront()this

Brings the layer to the top of all overlays.

-
bringToBack()this

Brings the layer to the bottom of all overlays.

-
setUrl(<String> url)this

Changes the URL of the image.

-
setBounds(<LatLngBounds> bounds)this

Update the bounds that this ImageOverlay covers

-
setZIndex(<Number> value)this

Changes the zIndex of the image overlay.

-
getBounds()LatLngBounds

Get the bounds that this ImageOverlay covers

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

SVGOverlay

Used to load, display and provide DOM access to an SVG file over specific bounds of the map. Extends ImageOverlay.

-

An SVG overlay uses the <svg> element.

- -
-

Usage example

- -
- - - - - -
var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
-svgElement.setAttribute('xmlns', "http://www.w3.org/2000/svg");
-svgElement.setAttribute('viewBox', "0 0 200 200");
-svgElement.innerHTML = '<rect width="200" height="200"/><rect x="75" y="23" width="50" height="50" style="fill:red"/><rect x="75" y="123" width="50" height="50" style="fill:#0013ff"/>';
-var svgElementBounds = [ [ 32, -130 ], [ 13, -100 ] ];
-L.svgOverlay(svgElement, svgElementBounds).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.svgOverlay(<String|SVGElement> svg, <LatLngBounds> bounds, <SVGOverlay options> options?)Instantiates an image overlay object given an SVG element and the geographical bounds it is tied to. -A viewBox attribute is required on the SVG element to zoom in and out properly.
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
opacityNumber1.0The opacity of the image overlay.
altString''Text for the alt attribute of the image (useful for accessibility).
interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. -If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. -Refer to CORS Settings for valid String values.
errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
zIndexNumber1The explicit zIndex of the overlay layer.
classNameString''A custom class name to assign to the image. Empty by default.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
loadEventFired when the ImageOverlay layer has loaded its image
errorEventFired when the ImageOverlay layer fails to load its image
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
getElement()SVGElement

Returns the instance of SVGElement -used by this overlay.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setOpacity(<Number> opacity)this

Sets the opacity of the overlay.

-
bringToFront()this

Brings the layer to the top of all overlays.

-
bringToBack()this

Brings the layer to the bottom of all overlays.

-
setUrl(<String> url)this

Changes the URL of the image.

-
setBounds(<LatLngBounds> bounds)this

Update the bounds that this ImageOverlay covers

-
setZIndex(<Number> value)this

Changes the zIndex of the image overlay.

-
getBounds()LatLngBounds

Get the bounds that this ImageOverlay covers

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Path

An abstract class that contains options and constants shared between vector -overlays (Polygon, Polyline, Circle). Do not use it directly. Extends Layer.

- -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Polyline

A class for drawing polyline overlays on a map. Extends Path.

- -
-

Usage example

- -
- - - - - -
// create a red polyline from an array of LatLng points
-var latlngs = [
-	[45.51, -122.68],
-	[37.77, -122.43],
-	[34.04, -118.2]
-];
-
-var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
-
-// zoom the map to the polyline
-map.fitBounds(polyline.getBounds());
-
-

You can also pass a multi-dimensional array to represent a MultiPolyline shape:

-
// create a red polyline from an array of arrays of LatLng points
-var latlngs = [
-	[[45.51, -122.68],
-	 [37.77, -122.43],
-	 [34.04, -118.2]],
-	[[40.78, -73.91],
-	 [41.83, -87.62],
-	 [32.76, -96.72]]
-];
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.polyline(<LatLng[]> latlngs, <Polyline options> options?)Instantiates a polyline object given an array of geographical points and -optionally an options object. You can create a Polyline object with -multiple separate lines (MultiPolyline) by passing an array of arrays -of geographic points.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means -better performance and smoother look, and less means more accurate representation.
noClipBooleanfalseDisable polyline clipping.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the polyline (as a GeoJSON LineString or MultiLineString Feature).

-
getLatLngs()LatLng[]

Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

-
setLatLngs(<LatLng[]> latlngs)this

Replaces all the points in the polyline with the given array of geographical points.

-
isEmpty()Boolean

Returns true if the Polyline has no LatLngs.

-
closestLayerPoint(<Point> p)Point

Returns the point closest to p on the Polyline.

-
getCenter()LatLng

Returns the center (centroid) of the polyline.

-
getBounds()LatLngBounds

Returns the LatLngBounds of the path.

-
addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

Adds a given point to the polyline. By default, adds to the first ring of -the polyline in case of a multi-polyline, but can be overridden by passing -a specific ring as a LatLng array (that you can earlier access with getLatLngs).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Polygon

A class for drawing polygon overlays on a map. Extends Polyline.

-

Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

- -
-

Usage example

- -
- - - - - -
// create a red polygon from an array of LatLng points
-var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];
-
-var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
-
-// zoom the map to the polygon
-map.fitBounds(polygon.getBounds());
-
-

You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:

-
var latlngs = [
-  [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
-  [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
-];
-
-

Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.

-
var latlngs = [
-  [ // first polygon
-    [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
-    [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
-  ],
-  [ // second polygon
-    [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]
-  ]
-];
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.polygon(<LatLng[]> latlngs, <Polyline options> options?)
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means -better performance and smoother look, and less means more accurate representation.
noClipBooleanfalseDisable polyline clipping.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getLatLngs()LatLng[]

Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

-
setLatLngs(<LatLng[]> latlngs)this

Replaces all the points in the polyline with the given array of geographical points.

-
isEmpty()Boolean

Returns true if the Polyline has no LatLngs.

-
closestLayerPoint(<Point> p)Point

Returns the point closest to p on the Polyline.

-
getCenter()LatLng

Returns the center (centroid) of the polyline.

-
getBounds()LatLngBounds

Returns the LatLngBounds of the path.

-
addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

Adds a given point to the polyline. By default, adds to the first ring of -the polyline in case of a multi-polyline, but can be overridden by passing -a specific ring as a LatLng array (that you can earlier access with getLatLngs).

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Rectangle

A class for drawing rectangle overlays on a map. Extends Polygon.

- -
-

Usage example

- -
- - - - - -
// define rectangle geographical bounds
-var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
-
-// create an orange rectangle
-L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
-
-// zoom the map to the rectangle bounds
-map.fitBounds(bounds);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.rectangle(<LatLngBounds> latLngBounds, <Polyline options> options?)
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means -better performance and smoother look, and less means more accurate representation.
noClipBooleanfalseDisable polyline clipping.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
setBounds(<LatLngBounds> latLngBounds)this

Redraws the rectangle with the passed bounds.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getLatLngs()LatLng[]

Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

-
setLatLngs(<LatLng[]> latlngs)this

Replaces all the points in the polyline with the given array of geographical points.

-
isEmpty()Boolean

Returns true if the Polyline has no LatLngs.

-
closestLayerPoint(<Point> p)Point

Returns the point closest to p on the Polyline.

-
getCenter()LatLng

Returns the center (centroid) of the polyline.

-
getBounds()LatLngBounds

Returns the LatLngBounds of the path.

-
addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

Adds a given point to the polyline. By default, adds to the first ring of -the polyline in case of a multi-polyline, but can be overridden by passing -a specific ring as a LatLng array (that you can earlier access with getLatLngs).

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Circle

A class for drawing circle overlays on a map. Extends CircleMarker.

-

It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion).

- -
-

Usage example

- -
- - - - - -
L.circle([50.5, 30.5], {radius: 200}).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - -
FactoryDescription
L.circle(<LatLng> latlng, <Circle options> options?)Instantiates a circle object given a geographical point, and an options object -which contains the circle radius.
L.circle(<LatLng> latlng, <Number> radius, <Circle options> options?)Obsolete way of instantiating a circle, for compatibility with 0.7.x code. -Do not use in new applications or plugins.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
radiusNumberRadius of the circle, in meters.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - -
EventDataDescription
moveEventFired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setRadius(<Number> radius)this

Sets the radius of a circle. Units are in meters.

-
getRadius()Number

Returns the current radius of a circle. Units are in meters.

-
getBounds()LatLngBounds

Returns the LatLngBounds of the path.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

-
setLatLng(<LatLng> latLng)this

Sets the position of a circle marker to a new location.

-
getLatLng()LatLng

Returns the current geographical position of the circle marker

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

CircleMarker

A circle of a fixed size with radius specified in pixels. Extends Path.

- -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.circleMarker(<LatLng> latlng, <CircleMarker options> options?)Instantiates a circle marker object given a geographical point, and an optional options object.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
radiusNumber10Radius of the circle marker, in pixels
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
colorString'#3388ff'Stroke color
weightNumber3Stroke width in pixels
opacityNumber1.0Stroke opacity
lineCapString'round'A string that defines shape to be used at the end of the stroke.
lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
fillColorString*Fill color. Defaults to the value of the color option
fillOpacityNumber0.2Fill opacity.
fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
rendererRendererUse this specific instance of Renderer for this path. Takes -precedence over the map's default renderer.
classNameStringnullCustom class name set on an element. Only for SVG renderer.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - -
EventDataDescription
moveEventFired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

-
setLatLng(<LatLng> latLng)this

Sets the position of a circle marker to a new location.

-
getLatLng()LatLng

Returns the current geographical position of the circle marker

-
setRadius(<Number> radius)this

Sets the radius of a circle marker. Units are in pixels.

-
getRadius()Number

Returns the current radius of the circle

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
redraw()this

Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

-
setStyle(<Path options> style)this

Changes the appearance of a Path based on the options in the Path options object.

-
bringToFront()this

Brings the layer to the top of all path layers.

-
bringToBack()this

Brings the layer to the bottom of all path layers.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

SVG

VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility -with old versions of Internet Explorer.

-

Allows vector layers to be displayed with SVG. -Inherits Renderer.

-

Due to technical limitations, SVG is not -available in all web browsers, notably Android 2.x and 3.x.

-

Although SVG is not available on IE7 and IE8, these browsers support -VML -(a now deprecated technology), and the SVG renderer will fall back to VML in -this case.

- -
-

Usage example

- -
- - - - - -

Use SVG by default for all paths in the map:

-
var map = L.map('map', {
-	renderer: L.svg()
-});
-
-

Use a SVG renderer with extra padding for specific vector geometries:

-
var map = L.map('map');
-var myRenderer = L.svg({ padding: 0.5 });
-var line = L.polyline( coordinates, { renderer: myRenderer } );
-var circle = L.circle( center, { renderer: myRenderer } );
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.svg(<Renderer options> options?)Creates a SVG renderer with the given options.
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paddingNumber0.1How much to extend the clip area around the map view (relative to its size) -e.g. 0.1 would be 10% of map view in each direction
toleranceNumber0How much to extend click tolerance round a path/object on the map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - -
EventDataDescription
updateEventFired when the renderer updates its bounds, center and zoom, for example when -its map has moved
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -
-

Functions

- -
- - - -
There are several static functions which can be called without instantiating L.SVG:
- - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
create(<String> name)SVGElementReturns a instance of SVGElement, -corresponding to the class name passed. For example, using 'line' will return -an instance of SVGLineElement.
pointsToPath(<Point[]> rings, <Boolean> closed)StringGenerates a SVG path string for multiple rings, with each ring turning -into "M..L..L.." instructions
- -
- - -

Canvas

Allows vector layers to be displayed with <canvas>. -Inherits Renderer.

-

Due to technical limitations, Canvas is not -available in all web browsers, notably IE8, and overlapping geometries might -not display properly in some edge cases.

- -
-

Usage example

- -
- - - - - -

Use Canvas by default for all paths in the map:

-
var map = L.map('map', {
-	renderer: L.canvas()
-});
-
-

Use a Canvas renderer with extra padding for specific vector geometries:

-
var map = L.map('map');
-var myRenderer = L.canvas({ padding: 0.5 });
-var line = L.polyline( coordinates, { renderer: myRenderer } );
-var circle = L.circle( center, { renderer: myRenderer } );
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.canvas(<Renderer options> options?)Creates a Canvas renderer with the given options.
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paddingNumber0.1How much to extend the clip area around the map view (relative to its size) -e.g. 0.1 would be 10% of map view in each direction
toleranceNumber0How much to extend click tolerance round a path/object on the map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - -
EventDataDescription
updateEventFired when the renderer updates its bounds, center and zoom, for example when -its map has moved
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

LayerGroup

Used to group several layers and handle them as one. If you add it to the map, -any layers added or removed from the group will be added/removed on the map as -well. Extends Layer.

- -
-

Usage example

- -
- - - - - -
L.layerGroup([marker1, marker2])
-	.addLayer(polyline)
-	.addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.layerGroup(<Layer[]> layers?, <Object> options?)Create a layer group, optionally given an initial set of layers and an options object.
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

-
addLayer(<Layer> layer)this

Adds the given layer to the group.

-
removeLayer(<Layer> layer)this

Removes the given layer from the group.

-
removeLayer(<Number> id)this

Removes the layer with the given internal ID from the group.

-
hasLayer(<Layer> layer)Boolean

Returns true if the given layer is currently added to the group.

-
hasLayer(<Number> id)Boolean

Returns true if the given internal ID is currently added to the group.

-
clearLayers()this

Removes all the layers from the group.

-
invoke(<String> methodName, )this

Calls methodName on every layer contained in this group, passing any -additional parameters. Has no effect if the layers contained do not -implement methodName.

-
eachLayer(<Function> fn, <Object> context?)this

Iterates over the layers of the group, optionally specifying context of the iterator function.

-
group.eachLayer(function (layer) {
-	layer.bindPopup('Hello');
-});
-
-
getLayer(<Number> id)Layer

Returns the layer with the given internal ID.

-
getLayers()Layer[]

Returns an array of all the layers added to the group.

-
setZIndex(<Number> zIndex)this

Calls setZIndex on every layer contained in this group, passing the z-index.

-
getLayerId(<Layer> layer)Number

Returns the internal ID for a layer

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

FeatureGroup

Extended LayerGroup that makes it easier to do the same thing to all its member layers:

- - -
-

Usage example

- -
- - - - - -
L.featureGroup([marker1, marker2, polyline])
-	.bindPopup('Hello world!')
-	.on('click', function() { alert('Clicked on a member of the group!'); })
-	.addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.featureGroup(<Layer[]> layers?, <Object> options?)Create a feature group, optionally given an initial set of layers and an options object.
- -
- - -
-

Options

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
layeraddLayerEventFired when a layer is added to this FeatureGroup
layerremoveLayerEventFired when a layer is removed from this FeatureGroup
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setStyle(<Path options> style)this

Sets the given path options to each layer of the group that has a setStyle method.

-
bringToFront()this

Brings the layer group to the top of all other layers

-
bringToBack()this

Brings the layer group to the back of all other layers

-
getBounds()LatLngBounds

Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

-
addLayer(<Layer> layer)this

Adds the given layer to the group.

-
removeLayer(<Layer> layer)this

Removes the given layer from the group.

-
removeLayer(<Number> id)this

Removes the layer with the given internal ID from the group.

-
hasLayer(<Layer> layer)Boolean

Returns true if the given layer is currently added to the group.

-
hasLayer(<Number> id)Boolean

Returns true if the given internal ID is currently added to the group.

-
clearLayers()this

Removes all the layers from the group.

-
invoke(<String> methodName, )this

Calls methodName on every layer contained in this group, passing any -additional parameters. Has no effect if the layers contained do not -implement methodName.

-
eachLayer(<Function> fn, <Object> context?)this

Iterates over the layers of the group, optionally specifying context of the iterator function.

-
group.eachLayer(function (layer) {
-	layer.bindPopup('Hello');
-});
-
-
getLayer(<Number> id)Layer

Returns the layer with the given internal ID.

-
getLayers()Layer[]

Returns an array of all the layers added to the group.

-
setZIndex(<Number> zIndex)this

Calls setZIndex on every layer contained in this group, passing the z-index.

-
getLayerId(<Layer> layer)Number

Returns the internal ID for a layer

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

GeoJSON

Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse -GeoJSON data and display it on the map. Extends FeatureGroup.

- -
-

Usage example

- -
- - - - - -
L.geoJSON(data, {
-	style: function (feature) {
-		return {color: feature.properties.color};
-	}
-}).bindPopup(function (layer) {
-	return layer.feature.properties.description;
-}).addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.geoJSON(<Object> geojson?, <GeoJSON options> options?)Creates a GeoJSON layer. Optionally accepts an object in -GeoJSON format to display on the map -(you can alternatively add it later with addData method) and an options object.
- -
- - -
-

Options

- -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
pointToLayerFunction*A Function defining how GeoJSON points spawn Leaflet layers. It is internally -called when data is added, passing the GeoJSON point feature and its LatLng. -The default is to spawn a default Marker: -
function(geoJsonPoint, latlng) {
-	return L.marker(latlng);
-}
-
styleFunction*A Function defining the Path options for styling GeoJSON lines and polygons, -called internally when data is added. -The default value is to not override any defaults: -
function (geoJsonFeature) {
-	return {}
-}
-
onEachFeatureFunction*A Function that will be called once for each created Feature, after it has -been created and styled. Useful for attaching events and popups to features. -The default is to do nothing with the newly created layers: -
function (feature, layer) {}
-
filterFunction*A Function that will be used to decide whether to include a feature or not. -The default is to include all features: -
function (geoJsonFeature) {
-	return true;
-}
-
-

Note: dynamically changing the filter option will have effect only on newly -added data. It will not re-evaluate already included features.

coordsToLatLngFunction*A Function that will be used for converting GeoJSON coordinates to LatLngs. -The default is the coordsToLatLng static method.
markersInheritOptionsBooleanfalseWhether default Markers for "Point" type Features inherit from group options.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
layeraddLayerEventFired when a layer is added to this FeatureGroup
layerremoveLayerEventFired when a layer is removed from this FeatureGroup
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addData(data)this

Adds a GeoJSON object to the layer.

-
resetStyle(layer?)this

Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. -If layer is omitted, the style of all features in the current layer is reset.

-
setStyle(style)this

Changes styles of GeoJSON vector layers with the given style function.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bringToFront()this

Brings the layer group to the top of all other layers

-
bringToBack()this

Brings the layer group to the back of all other layers

-
getBounds()LatLngBounds

Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
toGeoJSON(<Number> precision?)Object

precision is the number of decimal places for coordinates. -The default value is 6 places. -Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

-
addLayer(<Layer> layer)this

Adds the given layer to the group.

-
removeLayer(<Layer> layer)this

Removes the given layer from the group.

-
removeLayer(<Number> id)this

Removes the layer with the given internal ID from the group.

-
hasLayer(<Layer> layer)Boolean

Returns true if the given layer is currently added to the group.

-
hasLayer(<Number> id)Boolean

Returns true if the given internal ID is currently added to the group.

-
clearLayers()this

Removes all the layers from the group.

-
invoke(<String> methodName, )this

Calls methodName on every layer contained in this group, passing any -additional parameters. Has no effect if the layers contained do not -implement methodName.

-
eachLayer(<Function> fn, <Object> context?)this

Iterates over the layers of the group, optionally specifying context of the iterator function.

-
group.eachLayer(function (layer) {
-	layer.bindPopup('Hello');
-});
-
-
getLayer(<Number> id)Layer

Returns the layer with the given internal ID.

-
getLayers()Layer[]

Returns an array of all the layers added to the group.

-
setZIndex(<Number> zIndex)this

Calls setZIndex on every layer contained in this group, passing the z-index.

-
getLayerId(<Layer> layer)Number

Returns the internal ID for a layer

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -
-

Functions

- -
- - - -
There are several static functions which can be called without instantiating L.GeoJSON:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
geometryToLayer(<Object> featureData, <GeoJSON options> options?)LayerCreates a Layer from a given GeoJSON feature. Can use a custom -pointToLayer and/or coordsToLatLng -functions if provided as options.
coordsToLatLng(<Array> coords)LatLngCreates a LatLng object from an array of 2 numbers (longitude, latitude) -or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
coordsToLatLngs(<Array> coords, <Number> levelsDeep?, <Function> coordsToLatLng?)ArrayCreates a multidimensional array of LatLngs from a GeoJSON coordinates array. -levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). -Can use a custom coordsToLatLng function.
latLngToCoords(<LatLng> latlng, <Number> precision?)ArrayReverse of coordsToLatLng
latLngsToCoords(<Array> latlngs, <Number> levelsDeep?, <Boolean> closed?)ArrayReverse of coordsToLatLngs -closed determines whether the first point should be appended to the end of the array to close the feature, only used when levelsDeep is 0. False by default.
asFeature(<Object> geojson)ObjectNormalize GeoJSON geometries/features into GeoJSON features.
- -
- - -

GridLayer

Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces TileLayer.Canvas. -GridLayer can be extended to create a tiled grid of HTML elements like <canvas>, <img> or <div>. GridLayer will handle creating and animating these DOM elements for you.

- -
-

Usage example

- -
- -

Synchronous usage

- - - -

To create a custom layer, extend GridLayer and implement the createTile() method, which will be passed a Point object with the x, y, and z (zoom level) coordinates to draw your tile.

-
var CanvasLayer = L.GridLayer.extend({
-    createTile: function(coords){
-        // create a <canvas> element for drawing
-        var tile = L.DomUtil.create('canvas', 'leaflet-tile');
-
-        // setup tile width and height according to the options
-        var size = this.getTileSize();
-        tile.width = size.x;
-        tile.height = size.y;
-
-        // get a canvas context and draw something on it using coords.x, coords.y and coords.z
-        var ctx = tile.getContext('2d');
-
-        // return the tile so it can be rendered on screen
-        return tile;
-    }
-});
-
- - - -
- -

Asynchronous usage

- - - -

Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the done() callback.

-
var CanvasLayer = L.GridLayer.extend({
-    createTile: function(coords, done){
-        var error;
-
-        // create a <canvas> element for drawing
-        var tile = L.DomUtil.create('canvas', 'leaflet-tile');
-
-        // setup tile width and height according to the options
-        var size = this.getTileSize();
-        tile.width = size.x;
-        tile.height = size.y;
-
-        // draw something asynchronously and pass the tile to the done() callback
-        setTimeout(function() {
-            done(error, tile);
-        }, 1000);
-
-        return tile;
-    }
-});
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.gridLayer(<GridLayer options> options?)Creates a new instance of GridLayer with the supplied options.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
updateWhenIdleBoolean(depends)Load new tiles only when panning ends. -true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. -false otherwise in order to display new tiles during panning, since it is easy to pan outside the -keepBuffer option in desktop browsers.
updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
zIndexNumber1The explicit zIndex of the tile layer.
boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
maxZoomNumberundefinedThe maximum zoom level up to which this layer will be displayed (inclusive).
maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels higher than maxNativeZoom will be loaded -from maxNativeZoom level and auto-scaled.
minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, -the tiles on all zoom levels lower than minNativeZoom will be loaded -from minNativeZoom level and auto-scaled.
noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the -GridLayer will only be displayed once at low zoom levels. Has no -effect when the map CRS doesn't wrap around. Can be used -in combination with bounds to prevent requesting -tiles outside the CRS limits.
paneString'tilePane'Map pane where the grid layer will be added.
classNameString''A custom class name to assign to the tile layer. Empty by default.
keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
loadingEventFired when the grid layer starts loading tiles.
tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
tileloadstartTileEventFired when a tile is requested and starts loading.
tileerrorTileErrorEventFired when there is an error loading a tile.
tileloadTileEventFired when a tile loads.
loadEventFired when the grid layer loaded all visible tiles.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bringToFront()this

Brings the tile layer to the top of all tile layers.

-
bringToBack()this

Brings the tile layer to the bottom of all tile layers.

-
getContainer()HTMLElement

Returns the HTML element that contains the tiles for this layer.

-
setOpacity(<Number> opacity)this

Changes the opacity of the grid layer.

-
setZIndex(<Number> zIndex)this

Changes the zIndex of the grid layer.

-
isLoading()Boolean

Returns true if any tile in the grid layer has not finished loading.

-
redraw()this

Causes the layer to clear all the tiles and request them again.

-
getTileSize()Point

Normalizes the tileSize option into a point. Used by the createTile() method.

-
- -
- -

Extension methods

- -
Layers extending GridLayer shall reimplement the following method.
- - - - - - - - - - - - - -
MethodReturnsDescription
createTile(<Object> coords, <Function> done?)HTMLElement

Called only internally, must be overridden by classes extending GridLayer. -Returns the HTMLElement corresponding to the given coords. If the done callback -is specified, it must be called when the tile has finished loading and drawing.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

LatLng

Represents a geographical point with a certain latitude and longitude.

- -
-

Usage example

- -
- - - - - -
var latlng = L.latLng(50.5, 30.5);
-
-

All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:

-
map.panTo([50, 30]);
-map.panTo({lon: 30, lat: 50});
-map.panTo({lat: 50, lng: 30});
-map.panTo(L.latLng(50, 30));
-
-

Note that LatLng does not inherit from Leaflet's Class object, -which means new classes can't inherit from it, and new methods -can't be added to it with the include function.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - - - - - -
FactoryDescription
L.latLng(<Number> latitude, <Number> longitude, <Number> altitude?)Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).
L.latLng(<Array> coords)Expects an array of the form [Number, Number] or [Number, Number, Number] instead.
L.latLng(<Object> coords)Expects an plain object of the form {lat: Number, lng: Number} or {lat: Number, lng: Number, alt: Number} instead.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
equals(<LatLng> otherLatLng, <Number> maxMargin?)Boolean

Returns true if the given LatLng point is at the same position (within a small margin of error). The margin of error can be overridden by setting maxMargin to a small number.

-
toString()String

Returns a string representation of the point (for debugging purposes).

-
distanceTo(<LatLng> otherLatLng)Number

Returns the distance (in meters) to the given LatLng calculated using the Spherical Law of Cosines.

-
wrap()LatLng

Returns a new LatLng object with the longitude wrapped so it's always between -180 and +180 degrees.

-
toBounds(<Number> sizeInMeters)LatLngBounds

Returns a new LatLngBounds object in which each boundary is sizeInMeters/2 meters apart from the LatLng.

-
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
latNumberLatitude in degrees
lngNumberLongitude in degrees
altNumberAltitude in meters (optional)
- -
- - -

LatLngBounds

Represents a rectangular geographical area on a map.

- -
-

Usage example

- -
- - - - - -
var corner1 = L.latLng(40.712, -74.227),
-corner2 = L.latLng(40.774, -74.125),
-bounds = L.latLngBounds(corner1, corner2);
-
-

All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

-
map.fitBounds([
-	[40.712, -74.227],
-	[40.774, -74.125]
-]);
-
-

Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners outside the [-180, 180] degrees longitude range.

-

Note that LatLngBounds does not inherit from Leaflet's Class object, -which means new classes can't inherit from it, and new methods -can't be added to it with the include function.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - -
FactoryDescription
L.latLngBounds(<LatLng> corner1, <LatLng> corner2)Creates a LatLngBounds object by defining two diagonally opposite corners of the rectangle.
L.latLngBounds(<LatLng[]> latlngs)Creates a LatLngBounds object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with fitBounds.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
extend(<LatLng> latlng)this

Extend the bounds to contain the given point

-
extend(<LatLngBounds> otherBounds)this

Extend the bounds to contain the given bounds

-
pad(<Number> bufferRatio)LatLngBounds

Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. -For example, a ratio of 0.5 extends the bounds by 50% in each direction. -Negative values will retract the bounds.

-
getCenter()LatLng

Returns the center point of the bounds.

-
getSouthWest()LatLng

Returns the south-west point of the bounds.

-
getNorthEast()LatLng

Returns the north-east point of the bounds.

-
getNorthWest()LatLng

Returns the north-west point of the bounds.

-
getSouthEast()LatLng

Returns the south-east point of the bounds.

-
getWest()Number

Returns the west longitude of the bounds

-
getSouth()Number

Returns the south latitude of the bounds

-
getEast()Number

Returns the east longitude of the bounds

-
getNorth()Number

Returns the north latitude of the bounds

-
contains(<LatLngBounds> otherBounds)Boolean

Returns true if the rectangle contains the given one.

-
contains(<LatLng> latlng)Boolean

Returns true if the rectangle contains the given point.

-
intersects(<LatLngBounds> otherBounds)Boolean

Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.

-
overlaps(<LatLngBounds> otherBounds)Boolean

Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.

-
toBBoxString()String

Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.

-
equals(<LatLngBounds> otherBounds, <Number> maxMargin?)Boolean

Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting maxMargin to a small number.

-
isValid()Boolean

Returns true if the bounds are properly initialized.

-
- -
- - -

Point

Represents a point with x and y coordinates in pixels.

- -
-

Usage example

- -
- - - - - -
var point = L.point(200, 300);
-
-

All Leaflet methods and options that accept Point objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:

-
map.panBy([200, 300]);
-map.panBy(L.point(200, 300));
-
-

Note that Point does not inherit from Leaflet's Class object, -which means new classes can't inherit from it, and new methods -can't be added to it with the include function.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - - - - - -
FactoryDescription
L.point(<Number> x, <Number> y, <Boolean> round?)Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values.
L.point(<Number[]> coords)Expects an array of the form [x, y] instead.
L.point(<Object> coords)Expects a plain object of the form {x: Number, y: Number} instead.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
clone()Point

Returns a copy of the current point.

-
add(<Point> otherPoint)Point

Returns the result of addition of the current and the given points.

-
subtract(<Point> otherPoint)Point

Returns the result of subtraction of the given point from the current.

-
divideBy(<Number> num)Point

Returns the result of division of the current point by the given number.

-
multiplyBy(<Number> num)Point

Returns the result of multiplication of the current point by the given number.

-
scaleBy(<Point> scale)Point

Multiply each coordinate of the current point by each coordinate of -scale. In linear algebra terms, multiply the point by the -scaling matrix -defined by scale.

-
unscaleBy(<Point> scale)Point

Inverse of scaleBy. Divide each coordinate of the current point by -each coordinate of scale.

-
round()Point

Returns a copy of the current point with rounded coordinates.

-
floor()Point

Returns a copy of the current point with floored coordinates (rounded down).

-
ceil()Point

Returns a copy of the current point with ceiled coordinates (rounded up).

-
trunc()Point

Returns a copy of the current point with truncated coordinates (rounded towards zero).

-
distanceTo(<Point> otherPoint)Number

Returns the cartesian distance between the current and the given points.

-
equals(<Point> otherPoint)Boolean

Returns true if the given point has the same coordinates.

-
contains(<Point> otherPoint)Boolean

Returns true if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).

-
toString()String

Returns a string representation of the point for debugging purposes.

-
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
xNumberThe x coordinate of the point
yNumberThe y coordinate of the point
- -
- - -

Bounds

Represents a rectangular area in pixel coordinates.

- -
-

Usage example

- -
- - - - - -
var p1 = L.point(10, 10),
-p2 = L.point(40, 60),
-bounds = L.bounds(p1, p2);
-
-

All Leaflet methods that accept Bounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

-
otherBounds.intersects([[10, 10], [40, 60]]);
-
-

Note that Bounds does not inherit from Leaflet's Class object, -which means new classes can't inherit from it, and new methods -can't be added to it with the include function.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - -
FactoryDescription
L.bounds(<Point> corner1, <Point> corner2)Creates a Bounds object from two corners coordinate pairs.
L.bounds(<Point[]> points)Creates a Bounds object from the given array of points.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
extend(<Point> point)this

Extends the bounds to contain the given point.

-
getCenter(<Boolean> round?)Point

Returns the center point of the bounds.

-
getBottomLeft()Point

Returns the bottom-left point of the bounds.

-
getTopRight()Point

Returns the top-right point of the bounds.

-
getTopLeft()Point

Returns the top-left point of the bounds (i.e. this.min).

-
getBottomRight()Point

Returns the bottom-right point of the bounds (i.e. this.max).

-
getSize()Point

Returns the size of the given bounds

-
contains(<Bounds> otherBounds)Boolean

Returns true if the rectangle contains the given one.

-
contains(<Point> point)Boolean

Returns true if the rectangle contains the given point.

-
intersects(<Bounds> otherBounds)Boolean

Returns true if the rectangle intersects the given bounds. Two bounds -intersect if they have at least one point in common.

-
overlaps(<Bounds> otherBounds)Boolean

Returns true if the rectangle overlaps the given bounds. Two bounds -overlap if their intersection is an area.

-
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
minPointThe top left corner of the rectangle.
maxPointThe bottom right corner of the rectangle.
- -
- - -

Icon

Represents an icon to provide when creating a marker.

- -
-

Usage example

- -
- - - - - -
var myIcon = L.icon({
-    iconUrl: 'my-icon.png',
-    iconSize: [38, 95],
-    iconAnchor: [22, 94],
-    popupAnchor: [-3, -76],
-    shadowUrl: 'my-icon-shadow.png',
-    shadowSize: [68, 95],
-    shadowAnchor: [22, 94]
-});
-
-L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
-
-

L.Icon.Default extends L.Icon and is the blue icon Leaflet uses for markers by default.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.icon(<Icon options> options)Creates an icon instance with the given options.
- -
- - -
-

Options

- -
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
iconUrlStringnull(required) The URL to the icon image (absolute or relative to your script path).
iconRetinaUrlStringnullThe URL to a retina sized version of the icon image (absolute or relative to your -script path). Used for Retina screen devices.
iconSizePointnullSize of the icon image in pixels.
iconAnchorPointnullThe coordinates of the "tip" of the icon (relative to its top left corner). The icon -will be aligned so that this point is at the marker's geographical location. Centered -by default if size is specified, also can be set in CSS with negative margins.
popupAnchorPoint[0, 0]The coordinates of the point from which popups will "open", relative to the icon anchor.
tooltipAnchorPoint[0, 0]The coordinates of the point from which tooltips will "open", relative to the icon anchor.
shadowUrlStringnullThe URL to the icon shadow image. If not specified, no shadow image will be created.
shadowRetinaUrlStringnull
shadowSizePointnullSize of the shadow image in pixels.
shadowAnchorPointnullThe coordinates of the "tip" of the shadow (relative to its top left corner) (the same -as iconAnchor if not specified).
classNameString''A custom class name to assign to both icon and shadow images. Empty by default.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
createIcon(<HTMLElement> oldIcon?)HTMLElement

Called internally when the icon has to be shown, returns a <img> HTML element -styled according to the options.

-
createShadow(<HTMLElement> oldIcon?)HTMLElement

As createIcon, but for the shadow beneath it.

-
- -
- - -
- -
-

Icon.Default

- -
- - - -
A trivial subclass of Icon, represents the icon to use in Markers when -no icon is specified. Points to the blue marker image distributed with Leaflet -releases. -

In order to customize the default icon, just change the properties of L.Icon.Default.prototype.options -(which is a set of Icon options).

-

If you want to completely replace the default icon, override the -L.Marker.prototype.options.icon with your own icon instead.

- - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
imagePathStringIcon.Default will try to auto-detect the location of the -blue icon images. If you are placing these images in a non-standard -way, set this option to point to the right path.
- -
- - -

DivIcon

Represents a lightweight icon for markers that uses a simple <div> -element instead of an image. Inherits from Icon but ignores the iconUrl and shadow options.

- -
-

Usage example

- -
- - - - - -
var myIcon = L.divIcon({className: 'my-div-icon'});
-// you can set .my-div-icon styles in CSS
-
-L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
-
-

By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow.

- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.divIcon(<DivIcon options> options)Creates a DivIcon instance with the given options.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
htmlString|HTMLElement''Custom HTML code to put inside the div element, empty by default. Alternatively, -an instance of HTMLElement.
bgPosPoint[0, 0]Optional relative position of the background, in pixels
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
iconUrlStringnull(required) The URL to the icon image (absolute or relative to your script path).
iconRetinaUrlStringnullThe URL to a retina sized version of the icon image (absolute or relative to your -script path). Used for Retina screen devices.
iconSizePointnullSize of the icon image in pixels.
iconAnchorPointnullThe coordinates of the "tip" of the icon (relative to its top left corner). The icon -will be aligned so that this point is at the marker's geographical location. Centered -by default if size is specified, also can be set in CSS with negative margins.
popupAnchorPoint[0, 0]The coordinates of the point from which popups will "open", relative to the icon anchor.
tooltipAnchorPoint[0, 0]The coordinates of the point from which tooltips will "open", relative to the icon anchor.
shadowUrlStringnullThe URL to the icon shadow image. If not specified, no shadow image will be created.
shadowRetinaUrlStringnull
shadowSizePointnullSize of the shadow image in pixels.
shadowAnchorPointnullThe coordinates of the "tip" of the shadow (relative to its top left corner) (the same -as iconAnchor if not specified).
classNameString''A custom class name to assign to both icon and shadow images. Empty by default.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
createIcon(<HTMLElement> oldIcon?)HTMLElement

Called internally when the icon has to be shown, returns a <img> HTML element -styled according to the options.

-
createShadow(<HTMLElement> oldIcon?)HTMLElement

As createIcon, but for the shadow beneath it.

-
- -
-
-
- -

Control.Zoom

A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

- -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.control.zoom(<Control.Zoom options> options)Creates a zoom control
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
zoomInTextString'+'The text set on the 'zoom in' button.
zoomInTitleString'Zoom in'The title set on the 'zoom in' button.
zoomOutTextString'&#x2212' -The text set on the 'zoom out' button.
zoomOutTitleString'Zoom out'The title set on the 'zoom out' button.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', -'topright', 'bottomleft' or 'bottomright'
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getPosition()string

Returns the position of the control.

-
setPosition(<string> position)this

Sets the position of the control.

-
getContainer()HTMLElement

Returns the HTMLElement that contains the control.

-
addTo(<Map> map)this

Adds the control to the given map.

-
remove()this

Removes the control from the map it is currently active on.

-
- -
-
-
- -

Control.Attribution

The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with the getAttribution method automatically. Extends Control.

- -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.control.attribution(<Control.Attribution options> options)Creates an attribution control.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
prefixString'Leaflet'The HTML text shown before the attributions. Pass false to disable.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', -'topright', 'bottomleft' or 'bottomright'
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
setPrefix(<String> prefix)this

Sets the text before the attributions.

-
addAttribution(<String> text)this

Adds an attribution text (e.g. 'Vector data &copy; Mapbox').

-
removeAttribution(<String> text)this

Removes an attribution text.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getPosition()string

Returns the position of the control.

-
setPosition(<string> position)this

Sets the position of the control.

-
getContainer()HTMLElement

Returns the HTMLElement that contains the control.

-
addTo(<Map> map)this

Adds the control to the given map.

-
remove()this

Removes the control from the map it is currently active on.

-
- -
-
-
- -

Control.Layers

The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the detailed example). Extends Control.

- -
-

Usage example

- -
- - - - - -
var baseLayers = {
-	"Mapbox": mapbox,
-	"OpenStreetMap": osm
-};
-
-var overlays = {
-	"Marker": marker,
-	"Roads": roadsLayer
-};
-
-L.control.layers(baseLayers, overlays).addTo(map);
-
-

The baseLayers and overlays parameters are object literals with layer names as keys and Layer objects as values:

-
{
-    "<someName1>": layer1,
-    "<someName2>": layer2
-}
-
-

The layer names can contain HTML, which allows you to add additional styling to the items:

-
{"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>": myLayer}
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.control.layers(<Object> baselayers?, <Object> overlays?, <Control.Layers options> options?)Creates a layers control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
collapsedBooleantrueIf true, the control will be collapsed into an icon and expanded on mouse hover or touch.
autoZIndexBooleantrueIf true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.
hideSingleBaseBooleanfalseIf true, the base layers in the control will be hidden when there is only one.
sortLayersBooleanfalseWhether to sort the layers. When false, layers will keep the order -in which they were added to the control.
sortFunctionFunction*A compare function -that will be used for sorting the layers, when sortLayers is true. -The function receives both the L.Layer instances and their names, as in -sortFunction(layerA, layerB, nameA, nameB). -By default, it sorts layers alphabetically by their name.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', -'topright', 'bottomleft' or 'bottomright'
- -
-
-
- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addBaseLayer(<Layer> layer, <String> name)this

Adds a base layer (radio button entry) with the given name to the control.

-
addOverlay(<Layer> layer, <String> name)this

Adds an overlay (checkbox entry) with the given name to the control.

-
removeLayer(<Layer> layer)this

Remove the given layer from the control.

-
expand()this

Expand the control container if collapsed.

-
collapse()this

Collapse the control container if expanded.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getPosition()string

Returns the position of the control.

-
setPosition(<string> position)this

Sets the position of the control.

-
getContainer()HTMLElement

Returns the HTMLElement that contains the control.

-
addTo(<Map> map)this

Adds the control to the given map.

-
remove()this

Removes the control from the map it is currently active on.

-
- -
-
-
- -

Control.Scale

A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends Control.

- -
-

Usage example

- -
- - - - - -
L.control.scale().addTo(map);
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - -
FactoryDescription
L.control.scale(<Control.Scale options> options?)Creates an scale control with the given options.
- -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
maxWidthNumber100Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
metricBooleanTrueWhether to show the metric scale line (m/km).
imperialBooleanTrueWhether to show the imperial scale line (mi/ft).
updateWhenIdleBooleanfalseIf true, the control is updated on moveend, otherwise it's always up-to-date (updated on move).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', -'topright', 'bottomleft' or 'bottomright'
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getPosition()string

Returns the position of the control.

-
setPosition(<string> position)this

Sets the position of the control.

-
getContainer()HTMLElement

Returns the HTMLElement that contains the control.

-
addTo(<Map> map)this

Adds the control to the given map.

-
remove()this

Removes the control from the map it is currently active on.

-
- -
-
-
- -

Browser

A namespace with static properties for browser/feature detection used by Leaflet internally.

- -
-

Usage example

- -
- - - - - -
if (L.Browser.ielt9) {
-  alert('Upgrade your browser, dude!');
-}
-
- - - -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
ieBooleantrue for all Internet Explorer versions (not Edge).
ielt9Booleantrue for Internet Explorer versions less than 9.
edgeBooleantrue for the Edge web browser.
webkitBooleantrue for webkit-based browsers like Chrome and Safari (including mobile versions).
androidBooleantrue for any browser running on an Android platform.
android23Booleantrue for browsers running on Android 2 or Android 3.
androidStockBooleantrue for the Android stock browser (i.e. not Chrome)
operaBooleantrue for the Opera browser
chromeBooleantrue for the Chrome browser.
geckoBooleantrue for gecko-based browsers like Firefox.
safariBooleantrue for the Safari browser.
opera12Booleantrue for the Opera browser supporting CSS transforms (version 12 or later).
winBooleantrue when the browser is running in a Windows platform
ie3dBooleantrue for all Internet Explorer versions supporting CSS transforms.
webkit3dBooleantrue for webkit-based browsers supporting CSS transforms.
gecko3dBooleantrue for gecko-based browsers supporting CSS transforms.
any3dBooleantrue for all browsers supporting CSS transforms.
mobileBooleantrue for all browsers running in a mobile device.
mobileWebkitBooleantrue for all webkit-based browsers in a mobile device.
mobileWebkit3dBooleantrue for all webkit-based browsers in a mobile device supporting CSS transforms.
msPointerBooleantrue for browsers implementing the Microsoft touch events model (notably IE10).
pointerBooleantrue for all browsers supporting pointer events.
touchBooleantrue for all browsers supporting touch events. -This does not necessarily mean that the browser is running in a computer with -a touchscreen, it only means that the browser is capable of understanding -touch events.
mobileOperaBooleantrue for the Opera browser in a mobile device.
mobileGeckoBooleantrue for gecko-based browsers running in a mobile device.
retinaBooleantrue for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%.
passiveEventsBooleantrue for browsers that support passive events.
canvasBooleantrue when the browser supports <canvas>.
svgBooleantrue when the browser supports SVG.
vmlBooleantrue if the browser supports VML.
- -
- - -

Util

Various utility functions, used by Leaflet internally.

- -
-

Functions

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
extend(<Object> dest, <Object> src?)ObjectMerges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut.
create(<Object> proto, <Object> properties?)ObjectCompatibility polyfill for Object.create
bind(<Function> fn, )FunctionReturns a new function bound to the arguments passed, like Function.prototype.bind. -Has a L.bind() shortcut.
stamp(<Object> obj)NumberReturns the unique ID of an object, assigning it one if it doesn't have it.
throttle(<Function> fn, <Number> time, <Object> context)FunctionReturns a function which executes function fn with the given scope context -(so that the this keyword refers to context inside fn's code). The function -fn will be called no more than one time per given amount of time. The arguments -received by the bound function will be any arguments passed when binding the -function, followed by any arguments passed when invoking the bound function. -Has an L.throttle shortcut.
wrapNum(<Number> num, <Number[]> range, <Boolean> includeMax?)NumberReturns the number num modulo range in such a way so it lies within -range[0] and range[1]. The returned value will be always smaller than -range[1] unless includeMax is set to true.
falseFn()FunctionReturns a function which always returns false.
formatNum(<Number> num, <Number> digits?)NumberReturns the number num rounded to digits decimals, or to 6 decimals by default.
trim(<String> str)StringCompatibility polyfill for String.prototype.trim
splitWords(<String> str)String[]Trims and splits the string on whitespace and returns the array of parts.
setOptions(<Object> obj, <Object> options)ObjectMerges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut.
getParamString(<Object> obj, <String> existingUrl?, <Boolean> uppercase?)StringConverts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} -translates to '?a=foo&b=bar'. If existingUrl is set, the parameters will -be appended at the end. If uppercase is true, the parameter names will -be uppercased (e.g. '?A=foo&B=bar')
template(<String> str, <Object> data)StringSimple templating facility, accepts a template string of the form 'Hello {a}, {b}' -and a data object like {a: 'foo', b: 'bar'}, returns evaluated string -('Hello foo, bar'). You can also specify functions instead of strings for -data values — they will be evaluated passing data as an argument.
isArray(obj)BooleanCompatibility polyfill for Array.isArray
indexOf(<Array> array, <Object> el)NumberCompatibility polyfill for Array.prototype.indexOf
requestAnimFrame(<Function> fn, <Object> context?, <Boolean> immediate?)NumberSchedules fn to be executed when the browser repaints. fn is bound to -context if given. When immediate is set, fn is called immediately if -the browser doesn't have native support for -window.requestAnimationFrame, -otherwise it's delayed. Returns a request ID that can be used to cancel the request.
cancelAnimFrame(<Number> id)undefinedCancels a previous requestAnimFrame. See also window.cancelAnimationFrame.
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
lastIdNumberLast unique ID used by stamp()
emptyImageUrlStringData URI string containing a base64-encoded empty GIF image. -Used as a hack to free memory from unused images on WebKit-powered -mobile devices (by setting image src to this string).
- -
- - -

Transformation

Represents an affine transformation: a set of coefficients a, b, c, d -for transforming a point of a form (x, y) into (a*x + b, c*y + d) and doing -the reverse. Used by Leaflet in its projections code.

- -
-

Usage example

- -
- - - - - -
var transformation = L.transformation(2, 5, -1, 10),
-	p = L.point(1, 2),
-	p2 = transformation.transform(p), //  L.point(7, 8)
-	p3 = transformation.untransform(p2); //  L.point(1, 2)
-
- - - -
- - -
-

Creation

- -
- - - - - - - - - - - - - - - - - - -
FactoryDescription
L.transformation(<Number> a, <Number> b, <Number> c, <Number> d)Instantiates a Transformation object with the given coefficients.
L.transformation(<Array> coefficients)Expects an coefficients array of the form -[a: Number, b: Number, c: Number, d: Number].
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
transform(<Point> point, <Number> scale?)Point

Returns a transformed point, optionally multiplied by the given scale. -Only accepts actual L.Point instances, not arrays.

-
untransform(<Point> point, <Number> scale?)Point

Returns the reverse transformation of the given point, optionally divided -by the given scale. Only accepts actual L.Point instances, not arrays.

-
- -
- - -

LineUtil

Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast.

- -
-

Functions

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
simplify(<Point[]> points, <Number> tolerance)Point[]Dramatically reduces the number of points in a polyline while retaining -its shape and returns a new array of simplified points, using the -Douglas-Peucker algorithm. -Used for a huge performance boost when processing/displaying Leaflet polylines for -each zoom level and also reducing visual noise. tolerance affects the amount of -simplification (lesser value means higher quality but slower and with more points). -Also released as a separated micro-library Simplify.js.
pointToSegmentDistance(<Point> p, <Point> p1, <Point> p2)NumberReturns the distance between point p and segment p1 to p2.
closestPointOnSegment(<Point> p, <Point> p1, <Point> p2)NumberReturns the closest point from a point p on a segment p1 to p2.
clipSegment(<Point> a, <Point> b, <Bounds> bounds, <Boolean> useLastCode?, <Boolean> round?)Point[]|BooleanClips the segment a to b by rectangular bounds with the -Cohen-Sutherland algorithm -(modifying the segment points directly!). Used by Leaflet to only show polyline -points that are on the screen or near, increasing performance.
isFlat(<LatLng[]> latlngs)BooleanReturns true if latlngs is a flat array, false is nested.
- -
- - -

PolyUtil

Various utility functions for polygon geometries.

- -
-

Functions

- -
- - - - - - - - - - - - - - - - -
FunctionReturnsDescription
clipPolygon(<Point[]> points, <Bounds> bounds, <Boolean> round?)Point[]Clips the polygon geometry defined by the given points by the given bounds (using the Sutherland-Hodgman algorithm). -Used by Leaflet to only show polygon points that are on the screen or near, increasing -performance. Note that polygon points needs different algorithm for clipping -than polyline, so there's a separate method for it.
- -
- - -

DomEvent

Utility functions to work with the DOM events, used by Leaflet internally.

- -
-

Functions

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
on(<HTMLElement> el, <String> types, <Function> fn, <Object> context?)thisAdds a listener function (fn) to a particular DOM event type of the -element el. You can optionally specify the context of the listener -(object the this keyword will point to). You can also pass several -space-separated types (e.g. 'click dblclick').
on(<HTMLElement> el, <Object> eventMap, <Object> context?)thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
off(<HTMLElement> el, <String> types, <Function> fn, <Object> context?)thisRemoves a previously added listener function. -Note that if you passed a custom context to on, you must pass the same -context to off in order to remove the listener.
off(<HTMLElement> el, <Object> eventMap, <Object> context?)thisRemoves a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
stopPropagation(<DOMEvent> ev)thisStop the given event from propagation to parent elements. Used inside the listener functions: -
L.DomEvent.on(div, 'click', function (ev) {
-	L.DomEvent.stopPropagation(ev);
-});
-
disableScrollPropagation(<HTMLElement> el)thisAdds stopPropagation to the element's 'wheel' events (plus browser variants).
disableClickPropagation(<HTMLElement> el)thisAdds stopPropagation to the element's 'click', 'doubleclick', -'mousedown' and 'touchstart' events (plus browser variants).
preventDefault(<DOMEvent> ev)thisPrevents the default action of the DOM Event ev from happening (such as -following a link in the href of the a element, or doing a POST request -with page reload when a <form> is submitted). -Use it inside listener functions.
stop(<DOMEvent> ev)thisDoes stopPropagation and preventDefault at the same time.
getMousePosition(<DOMEvent> ev, <HTMLElement> container?)PointGets normalized mouse position from a DOM event relative to the -container (border excluded) or to the whole page if not specified.
getWheelDelta(<DOMEvent> ev)NumberGets normalized wheel delta from a wheel DOM event, in vertical -pixels scrolled (negative if scrolling down). -Events from pointing devices without precise scrolling are mapped to -a best guess of 60 pixels.
addListener()thisAlias to L.DomEvent.on
removeListener()thisAlias to L.DomEvent.off
- -
- - -

DomUtil

Utility functions to work with the DOM -tree, used by Leaflet internally.

-

Most functions expecting or returning a HTMLElement also work for -SVG elements. The only difference is that classes refer to CSS classes -in HTML and SVG classes in SVG.

- -
-

Functions

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
get(<String|HTMLElement> id)HTMLElementReturns an element given its DOM id, or returns the element itself -if it was passed directly.
getStyle(<HTMLElement> el, <String> styleAttrib)StringReturns the value for a certain style attribute on an element, -including computed values or values set through CSS.
create(<String> tagName, <String> className?, <HTMLElement> container?)HTMLElementCreates an HTML element with tagName, sets its class to className, and optionally appends it to container element.
remove(<HTMLElement> el)Removes el from its parent element
empty(<HTMLElement> el)Removes all of el's children elements from el
toFront(<HTMLElement> el)Makes el the last child of its parent, so it renders in front of the other children.
toBack(<HTMLElement> el)Makes el the first child of its parent, so it renders behind the other children.
hasClass(<HTMLElement> el, <String> name)BooleanReturns true if the element's class attribute contains name.
addClass(<HTMLElement> el, <String> name)Adds name to the element's class attribute.
removeClass(<HTMLElement> el, <String> name)Removes name from the element's class attribute.
setClass(<HTMLElement> el, <String> name)Sets the element's class.
getClass(<HTMLElement> el)StringReturns the element's class.
setOpacity(<HTMLElement> el, <Number> opacity)Set the opacity of an element (including old IE support). -opacity must be a number from 0 to 1.
testProp(<String[]> props)String|falseGoes through the array of style names and returns the first name -that is a valid style name for an element. If no such name is found, -it returns false. Useful for vendor-prefixed styles like transform.
setTransform(<HTMLElement> el, <Point> offset, <Number> scale?)Resets the 3D CSS transform of el so it is translated by offset pixels -and optionally scaled by scale. Does not have an effect if the -browser doesn't support 3D CSS transforms.
setPosition(<HTMLElement> el, <Point> position)Sets the position of el to coordinates specified by position, -using CSS translate or top/left positioning depending on the browser -(used by Leaflet internally to position its layers).
getPosition(<HTMLElement> el)PointReturns the coordinates of an element previously positioned with setPosition.
disableTextSelection()Prevents the user from generating selectstart DOM events, usually generated -when the user drags the mouse through a page with text. Used internally -by Leaflet to override the behaviour of any click-and-drag interaction on -the map. Affects drag interactions on the whole document.
enableTextSelection()Cancels the effects of a previous L.DomUtil.disableTextSelection.
disableImageDrag()As L.DomUtil.disableTextSelection, but -for dragstart DOM events, usually generated when the user drags an image.
enableImageDrag()Cancels the effects of a previous L.DomUtil.disableImageDrag.
preventOutline(<HTMLElement> el)Makes the outline -of the element el invisible. Used internally by Leaflet to prevent -focusable elements from displaying an outline when the user performs a -drag interaction on them.
restoreOutline()Cancels the effects of a previous L.DomUtil.preventOutline.
getSizedParentNode(<HTMLElement> el)HTMLElementFinds the closest parent node which size (width and height) is not null.
getScale(<HTMLElement> el)ObjectComputes the CSS scale currently applied on the element. -Returns an object with x and y members as horizontal and vertical scales respectively, -and boundingClientRect as the result of getBoundingClientRect().
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
TRANSFORMStringVendor-prefixed transform style name (e.g. 'webkitTransform' for WebKit).
TRANSITIONStringVendor-prefixed transition style name.
TRANSITION_ENDStringVendor-prefixed transitionend event name.
- -
- - -

PosAnimation

Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.

- -
-

Usage example

- -
- - - - - -
var fx = new L.PosAnimation();
-fx.run(el, [300, 500], 0.5);
-
- - - -
- - -
-

Constructor

- -
- - - - - - - - - - - - - - -
ConstructorDescription
L.PosAnimation()Creates a PosAnimation object.
- - -
- - -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
startEventFired when the animation starts
stepEventFired continuously during the animation.
endEventFired when the animation ends.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
run(<HTMLElement> el, <Point> newPos, <Number> duration?, <Number> easeLinearity?)

Run an animation of a given element to a new position, optionally setting -duration in seconds (0.25 by default) and easing linearity factor (3rd -argument of the cubic bezier curve, -0.5 by default).

-
stop()

Stops the animation (if currently running).

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Draggable

A class for making DOM elements draggable (including touch support). -Used internally for map and marker dragging. Only works for elements -that were positioned with L.DomUtil.setPosition.

- -
-

Usage example

- -
- - - - - -
var draggable = new L.Draggable(elementToDrag);
-draggable.enable();
-
- - - -
- - -
-

Constructor

- -
- - - - - - - - - - - - - - -
ConstructorDescription
L.Draggable(<HTMLElement> el, <HTMLElement> dragHandle?, <Boolean> preventOutline?, <Draggable options> options?)Creates a Draggable object for moving el when you start dragging the dragHandle element (equals el itself by default).
- - -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
clickToleranceNumber3The max number of pixels a user can shift the mouse pointer during a click -for it to be considered a valid click (as opposed to a mouse drag).
- -
- - -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
downEventFired when a drag is about to start.
dragstartEventFired when a drag starts
predragEventFired continuously during dragging before each corresponding -update of the element's position.
dragEventFired continuously during dragging.
dragendDragEndEventFired when the drag ends.
- -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
enable()

Enables the dragging ability

-
disable()

Disables the dragging ability

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Class

L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

-

In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

- -
-

Usage example

- -
- - - - - -
var MyClass = L.Class.extend({
-initialize: function (greeter) {
-	this.greeter = greeter;
-	// class constructor
-},
-
-greet: function (name) {
-	alert(this.greeter + ', ' + name)
-	}
-});
-
-// create instance of MyClass, passing "Hello" to the constructor
-var a = new MyClass("Hello");
-
-// call greet method, alerting "Hello, World"
-a.greet("World");
-
- - - -
- -

Class Factories

- - - -

You may have noticed that Leaflet objects are created without using -the new keyword. This is achieved by complementing each class with a -lowercase factory method:

-
new L.Map('map'); // becomes:
-L.map('map');
-
-

The factories are implemented very easily, and you can do this for your own classes:

-
L.map = function (id, options) {
-    return new L.Map(id, options);
-};
-
- - - -
- -

Inheritance

- - - -

You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

-
var MyChildClass = MyClass.extend({
-    // ... new properties and methods
-});
-
-

This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

-
var a = new MyChildClass();
-a instanceof MyChildClass; // true
-a instanceof MyClass; // true
-
-

You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

-
var MyChildClass = MyClass.extend({
-    initialize: function () {
-        MyClass.prototype.initialize.call(this, "Yo");
-    },
-
-    greet: function (name) {
-        MyClass.prototype.greet.call(this, 'bro ' + name + '!');
-    }
-});
-
-var a = new MyChildClass();
-a.greet('Jason'); // alerts "Yo, bro Jason!"
-
- - - -
- -

Options

- - - -

options is a special property that unlike other objects that you pass -to extend will be merged with the parent one instead of overriding it -completely, which makes managing configuration of objects and default -values convenient:

-
var MyClass = L.Class.extend({
-    options: {
-        myOption1: 'foo',
-        myOption2: 'bar'
-    }
-});
-
-var MyChildClass = MyClass.extend({
-    options: {
-        myOption1: 'baz',
-        myOption3: 5
-    }
-});
-
-var a = new MyChildClass();
-a.options.myOption1; // 'baz'
-a.options.myOption2; // 'bar'
-a.options.myOption3; // 5
-
-

There's also L.Util.setOptions, a method for -conveniently merging options passed to constructor with the defaults -defines in the class:

-
var MyClass = L.Class.extend({
-    options: {
-        foo: 'bar',
-        bla: 5
-    },
-
-    initialize: function (options) {
-        L.Util.setOptions(this, options);
-        ...
-    }
-});
-
-var a = new MyClass({bla: 10});
-a.options; // {foo: 'bar', bla: 10}
-
-

Note that the options object allows any keys, not just -the options defined by the class and its base classes. -This means you can use the options object to store -application specific information, as long as you avoid -keys that are already used by the class in question.

- - - -
- -

Includes

- - - -

includes is a special class property that merges all specified objects into the class (such objects are called mixins).

-
 var MyMixin = {
-    foo: function () { ... },
-    bar: 5
-};
-
-var MyClass = L.Class.extend({
-    includes: MyMixin
-});
-
-var a = new MyClass();
-a.foo();
-
-

You can also do such includes in runtime with the include method:

-
MyClass.include(MyMixin);
-
-

statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

-
var MyClass = L.Class.extend({
-    statics: {
-        FOO: 'bar',
-        BLA: 5
-    }
-});
-
-MyClass.FOO; // 'bar'
-
- - - -
- -

Constructor hooks

- - - -

If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

-
MyClass.addInitHook(function () {
-    // ... do something in constructor additionally
-    // e.g. add event listeners, set custom properties etc.
-});
-
-

You can also use the following shortcut when you just need to make one additional method call:

-
MyClass.addInitHook('methodName', arg1, arg2, …);
-
- - - -
- - -
-

Functions

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FunctionReturnsDescription
extend(<Object> props)FunctionExtends the current class given the properties to be included. -Returns a Javascript function that is a class constructor (to be called with new).
include(<Object> properties)thisIncludes a mixin into the current class.
mergeOptions(<Object> options)thisMerges options into the defaults of the class.
addInitHook(<Function> fn)thisAdds a constructor hook to the class.
- -
- - -

Evented

A set of methods shared between event-powered classes (like Map and Marker). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire 'click' event).

- -
-

Usage example

- -
- - - - - -
map.on('click', function(e) {
-	alert(e.latlng);
-} );
-
-

Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:

-
function onClick(e) { ... }
-
-map.on('click', onClick);
-map.off('click', onClick);
-
- - - -
- - -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
- - -

Layer

A set of methods from the Layer base class that all Leaflet layers use. -Inherits all methods, options and events from L.Evented.

- -
-

Usage example

- -
- - - - - -
var layer = L.marker(latlng).addTo(map);
-layer.addTo(map);
-layer.remove();
-
- - - -
- - -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
- - -
-

Events

- -
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
- -

Popup events

- - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
- -

Tooltip events

- - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
- - -
-

Methods

- -
- - - -
Classes extending L.Layer will inherit the following methods:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
- -

Extension methods

- -
Every layer should extend from L.Layer and (re-)implement the following methods.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
onAdd(<Map> map)this

Should contain code that creates DOM elements for the layer, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).

-
onRemove(<Map> map)this

Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).

-
getEvents()Object

This optional method should return an object like { viewreset: this._reset } for addEventListener. The event handlers in this object will be automatically added and removed from the map with your layer.

-
getAttribution()String

This optional method should return a string containing HTML to be shown on the Attribution control whenever the layer is visible.

-
beforeAdd(<Map> map)this

Optional method. Called on map.addLayer(layer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only.

-
- -
- -

Popup methods

- -
All layers share a set of methods convenient for binding popups to it. -
var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map);
-layer.openPopup();
-layer.closePopup();
-
-

Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
- -

Tooltip methods

- -
All layers share a set of methods convenient for binding tooltips to it. -
var layer = L.Polygon(latlngs).bindTooltip('Hi There!').addTo(map);
-layer.openTooltip();
-layer.closeTooltip();
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Interactive layer

Some Layers can be made interactive - when the user interacts -with such a layer, mouse events like click and mouseover can be handled. -Use the event handling methods to handle these events.

- -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map -(unless L.DomEvent.stopPropagation is used).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- -

Mouse events

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
mousedownMouseEventFired when the user pushes the mouse button on the layer.
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
mouseoverMouseEventFired when the mouse enters the layer.
mouseoutMouseEventFired when the mouse leaves the layer.
contextmenuMouseEventFired when the user right-clicks on the layer, prevents -default browser context menu from showing if there are listeners on -this event. Also fired on mobile when the user holds a single touch -for a second (also called long press).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Control

L.Control is a base class for implementing map controls. Handles positioning. -All other controls extend from this class.

- -
-

Options

- -
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', -'topright', 'bottomleft' or 'bottomright'
- -
- - -
-

Methods

- -
- - - -
Classes extending L.Control will inherit the following methods:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
getPosition()string

Returns the position of the control.

-
setPosition(<string> position)this

Sets the position of the control.

-
getContainer()HTMLElement

Returns the HTMLElement that contains the control.

-
addTo(<Map> map)this

Adds the control to the given map.

-
remove()this

Removes the control from the map it is currently active on.

-
- -
- -

Extension methods

- -
Every control should extend from L.Control and (re-)implement the following methods.
- - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
onAdd(<Map> map)HTMLElement

Should return the container DOM element for the control and add listeners on relevant map events. Called on control.addTo(map).

-
onRemove(<Map> map)

Optional method. Should contain all clean up code that removes the listeners previously added in onAdd. Called on control.remove().

-
- -
- - -

Handler

Abstract class for map interaction handlers

- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
enable()this

Enables the handler

-
disable()this

Disables the handler

-
enabled()Boolean

Returns true if the handler is enabled

-
- -
- -

Extension methods

- -
Classes inheriting from Handler must implement the two following methods:
- - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addHooks()

Called when the handler is enabled, should add event hooks.

-
removeHooks()

Called when the handler is disabled, should remove the event hooks added previously.

-
- -
- - -
-

Functions

- -
- -

There is static function which can be called without instantiating L.Handler:

- - - - - - - - - - - - - - -
FunctionReturnsDescription
addTo(<Map> map, <String> name)thisAdds a new Handler to the given map with the given name.
- -
- - -

Projection

An object with methods for projecting geographical coordinates of the world onto -a flat surface (and back). See Map projection.

- -
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
project(<LatLng> latlng)Point

Projects geographical coordinates into a 2D point. -Only accepts actual L.LatLng instances, not arrays.

-
unproject(<Point> point)LatLng

The inverse of project. Projects a 2D point into a geographical location. -Only accepts actual L.Point instances, not arrays.

-

Note that the projection instances do not inherit from Leaflet's Class object, -and can't be instantiated. Also, new classes can't inherit from them, -and methods can't be added to them with the include function.

-
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
boundsBoundsThe bounds (specified in CRS units) where the projection is valid
- -
- - -
-

Defined projections

- -
- - - -
Leaflet comes with a set of already defined Projections out of the box:
- - - - - - - - - - - - - - - - - - - -
ProjectionDescription
L.Projection.LonLatEquirectangular, or Plate Carree projection — the most simple projection, -mostly used by GIS enthusiasts. Directly maps x as longitude, and y as -latitude. Also suitable for flat worlds, e.g. game maps. Used by the -EPSG:4326 and Simple CRS.
L.Projection.MercatorElliptical Mercator projection — more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS.
L.Projection.SphericalMercatorSpherical Mercator projection — the most common projection for online maps, -used by almost all free and commercial tile providers. Assumes that Earth is -a sphere. Used by the EPSG:3857 CRS.
- -
- - -

CRS

-
-

Methods

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
latLngToPoint(<LatLng> latlng, <Number> zoom)Point

Projects geographical coordinates into pixel coordinates for a given zoom.

-
pointToLatLng(<Point> point, <Number> zoom)LatLng

The inverse of latLngToPoint. Projects pixel coordinates on a given -zoom into geographical coordinates.

-
project(<LatLng> latlng)Point

Projects geographical coordinates into coordinates in units accepted for -this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).

-
unproject(<Point> point)LatLng

Given a projected coordinate returns the corresponding LatLng. -The inverse of project.

-
scale(<Number> zoom)Number

Returns the scale used when transforming projected coordinates into -pixel coordinates for a particular zoom. For example, it returns -256 * 2^zoom for Mercator-based CRS.

-
zoom(<Number> scale)Number

Inverse of scale(), returns the zoom level corresponding to a scale -factor of scale.

-
getProjectedBounds(<Number> zoom)Bounds

Returns the projection's bounds scaled and transformed for the provided zoom.

-
distance(<LatLng> latlng1, <LatLng> latlng2)Number

Returns the distance between two geographical coordinates.

-
wrapLatLng(<LatLng> latlng)LatLng

Returns a LatLng where lat and lng has been wrapped according to the -CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.

-
wrapLatLngBounds(<LatLngBounds> bounds)LatLngBounds

Returns a LatLngBounds with the same size as the given one, ensuring -that its center is within the CRS's bounds. -Only accepts actual L.LatLngBounds instances, not arrays.

-
- -
- - -
-

Properties

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
codeStringStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857')
wrapLngNumber[]An array of two numbers defining whether the longitude (horizontal) coordinate -axis wraps around a given range and how. Defaults to [-180, 180] in most -geographical CRSs. If undefined, the longitude axis does not wrap around.
wrapLatNumber[]Like wrapLng, but for the latitude (vertical) axis.
infiniteBooleanIf true, the coordinate space will be unbounded (infinite in both axes)
- -
- - -
-

Defined CRSs

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CRSDescription
L.CRS.EPSG3395Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
L.CRS.EPSG3857The most common CRS for online maps, used by almost all free and commercial -tile providers. Uses Spherical Mercator projection. Set in by default in -Map's crs option.
L.CRS.EPSG4326A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. -

Leaflet 1.0.x complies with the TMS coordinate scheme for EPSG:4326, -which is a breaking change from 0.7.x behaviour. If you are using a TileLayer -with this CRS, ensure that there are two 256x256 pixel tiles covering the -whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90), -or (-180,-90) for TileLayers with the tms option set.

L.CRS.EarthServes as the base for CRS that are global such that they cover the earth. -Can only be used as the base for other CRS and cannot be used directly, -since it does not have a code, projection or transformation. distance() returns -meters.
L.CRS.SimpleA simple CRS that maps longitude and latitude into x and y directly. -May be used for maps of flat surfaces (e.g. game maps). Note that the y -axis should still be inverted (going from bottom to top). distance() returns -simple euclidean distance.
L.CRS.BaseObject that defines coordinate reference systems for projecting -geographical points into pixel (screen) coordinates and back (and to -coordinates in other units for WMS services). See -spatial reference system. -

Leaflet defines the most usual CRSs by default. If you want to use a -CRS not defined by default, take a look at the -Proj4Leaflet plugin.

-

Note that the CRS instances do not inherit from Leaflet's Class object, -and can't be instantiated. Also, new classes can't inherit from them, -and methods can't be added to them with the include function.

- -
- - -

Renderer

Base class for vector renderer implementations (SVG, Canvas). Handles the -DOM container of the renderer, its bounds, and its zoom animation.

-

A Renderer works as an implicit layer group for all Paths - the renderer -itself can be added or removed to the map. All paths use a renderer, which can -be implicit (the map will decide the type of renderer and use it automatically) -or explicit (using the renderer option of the path).

-

Do not use this class directly, use SVG and Canvas instead.

- -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paddingNumber0.1How much to extend the clip area around the map view (relative to its size) -e.g. 0.1 would be 10% of map view in each direction
toleranceNumber0How much to extend click tolerance round a path/object on the map
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- -
- - - - - - - - - - - - - - - - -
EventDataDescription
updateEventFired when the renderer updates its bounds, center and zoom, for example when -its map has moved
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Event objects

Whenever a class inheriting from Evented fires an event, a listener function -will be called with an event argument, which is a plain object containing -information about the event. For example:

-
map.on('click', function(ev) {
-    alert(ev.latlng); // ev is an event object (MouseEvent in this case)
-});
-
-

The information available depends on the event type:

- - - -
-

Event

- -
- - - -
The base event object. All other event objects contain these properties too.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
- - -
- -
-

KeyboardEvent

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
originalEventDOMEventThe original DOM KeyboardEvent that triggered this Leaflet event.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

MouseEvent

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
latlngLatLngThe geographical point where the mouse event occurred.
layerPointPointPixel coordinates of the point where the mouse event occurred relative to the map layer.
containerPointPointPixel coordinates of the point where the mouse event occurred relative to the map сontainer.
originalEventDOMEventThe original DOM MouseEvent or DOM TouchEvent that triggered this Leaflet event.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

LocationEvent

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
latlngLatLngDetected geographical location of the user.
boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
accuracyNumberAccuracy of location in meters.
altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
altitudeAccuracyNumberAccuracy of altitude in meters.
headingNumberThe direction of travel in degrees counting clockwise from true North.
speedNumberCurrent velocity in meters per second.
timestampNumberThe time when the position was acquired.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

ErrorEvent

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
messageStringError message.
codeNumberError code (if applicable).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

LayerEvent

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
layerLayerThe layer that was added or removed.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
- -
-
-
- -
- -
-

LayersControlEvent

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
layerLayerThe layer that was added or removed.
nameStringThe name of the layer that was added or removed.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
- -
-
-
- -
- -
-

TileEvent

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
tileHTMLElementThe tile element (image).
coordsPointPoint object with the tile's x, y, and z (zoom level) coordinates.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

TileErrorEvent

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
tileHTMLElementThe tile element (image).
coordsPointPoint object with the tile's x, y, and z (zoom level) coordinates.
error*Error passed to the tile's done() callback.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

ResizeEvent

- -
- - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
oldSizePointThe old size before resize event.
newSizePointThe new size after the resize event.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

GeoJSONEvent

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
layerLayerThe layer for the GeoJSON feature that is being added to the map.
propertiesObjectGeoJSON properties of the feature.
geometryTypeStringGeoJSON geometry type of the feature.
idStringGeoJSON ID of the feature (if present).
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
- -
-
-
- -
- -
-

PopupEvent

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
popupPopupThe popup that was opened or closed.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

TooltipEvent

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
tooltipTooltipThe tooltip that was opened or closed.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

DragEndEvent

- -
- - - - - - - - - - - - - - - - -
PropertyTypeDescription
distanceNumberThe distance in pixels the draggable element was moved by.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -
- -
-

ZoomAnimEvent

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
centerLatLngThe current center of the map
zoomNumberThe current zoom level of the map
noUpdateBooleanWhether layers should update their contents due to this event
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyTypeDescription
typeStringThe event type (e.g. 'click').
targetObjectThe object that fired the event. For propagated events, the last object in -the propagation chain that fired the event.
sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will -be the same as the target.
propagatedFromObjectFor propagated events, the last object that propagated the event to its -event parent.
layerObjectDeprecated. The same as propagatedFrom.
- -
-
-
- -

DivOverlay

Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins.

- -
-

Options

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
offsetPointPoint(0, 7)The offset of the popup position. Useful to control the anchor -of the popup when opening it on some overlays.
classNameString''A custom CSS class name to assign to the popup.
paneString'popupPane'Map pane where the popup will be added.
- -
- - -
- -
-
- - - - - - - - - - - - - - - - - - -
OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
- -
-
-
- -
-

Events

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
addEventFired after the layer is added to a map
removeEventFired after the layer is removed from a map
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
popupclosePopupEventFired when a popup bound to this layer is closed
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - -
EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
- -
-
-
- -
-

Methods

- - - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
addTo(<Map|LayerGroup> map)this

Adds the layer to the given map or layer group.

-
remove()this

Removes the layer from the map it is currently active on.

-
removeFrom(<Map> map)this

Removes the layer from the given map

-
removeFrom(<LayerGroup> group)this

Removes the layer from the given LayerGroup

-
getPane(<String> name?)HTMLElement

Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

-
getAttribution()String

Used by the attribution control, returns the attribution option.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

Binds a popup to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindPopup()this

Removes the popup previously bound with bindPopup.

-
openPopup(<LatLng> latlng?)this

Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

-
closePopup()this

Closes the popup bound to this layer if it is open.

-
togglePopup()this

Opens or closes the popup bound to this layer depending on its current state.

-
isPopupOpen()boolean

Returns true if the popup bound to this layer is currently open.

-
setPopupContent(<String|HTMLElement|Popup> content)this

Sets the content of the popup bound to this layer.

-
getPopup()Popup

Returns the popup bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

Binds a tooltip to the layer with the passed content and sets up the -necessary event listeners. If a Function is passed it will receive -the layer as the first argument and should return a String or HTMLElement.

-
unbindTooltip()this

Removes the tooltip previously bound with bindTooltip.

-
openTooltip(<LatLng> latlng?)this

Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

-
closeTooltip()this

Closes the tooltip bound to this layer if it is open.

-
toggleTooltip()this

Opens or closes the tooltip bound to this layer depending on its current state.

-
isTooltipOpen()boolean

Returns true if the tooltip bound to this layer is currently open.

-
setTooltipContent(<String|HTMLElement|Tooltip> content)this

Sets the content of the tooltip bound to this layer.

-
getTooltip()Tooltip

Returns the tooltip bound to this layer.

-
- -
-
-
- -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)this

Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

-
on(<Object> eventMap)this

Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

-
off(<String> type, <Function> fn?, <Object> context?)this

Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

-
off(<Object> eventMap)this

Removes a set of type/listener pairs.

-
off()this

Removes all listeners to all events on the object. This includes implicitly attached events.

-
fire(<String> type, <Object> data?, <Boolean> propagate?)this

Fires an event of the specified type. You can optionally provide an data -object — the first argument of the listener function will contain its -properties. The event can optionally be propagated to event parents.

-
listens(<String> type)Boolean

Returns true if a particular event type has any listeners attached to it.

-
once()this

Behaves as on(…), except the listener will only get fired once and then removed.

-
addEventParent(<Evented> obj)this

Adds an event parent - an Evented that will receive propagated events

-
removeEventParent(<Evented> obj)this

Removes an event parent, so it will stop receiving propagated events

-
addEventListener()this

Alias to on(…)

-
removeEventListener()this

Alias to off(…)

-
clearAllEventListeners()this

Alias to off()

-
addOneTimeEventListener()this

Alias to once(…)

-
fireEvent()this

Alias to fire(…)

-
hasEventListeners()Boolean

Alias to listens(…)

-
- -
-
-
- -

Global Switches

Global switches are created for rare cases and generally make -Leaflet to not detect a particular browser feature even if it's -there. You need to set the switch as a global variable to true -before including Leaflet on the page, like this:

-
<script>L_NO_TOUCH = true;</script>
-<script src="leaflet.js"></script>
-
- - - - - - - - - - - - - - - - - -
SwitchDescription
L_NO_TOUCHForces Leaflet to not use touch events even if it detects them.
L_DISABLE_3DForces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning (which may cause glitches in some rare environments) even if they're supported.
- -

noConflict

This method restores the L global variable to the original value -it had before Leaflet inclusion, and returns the real Leaflet -namespace so you can put it elsewhere, like this:

-
<script src='libs/l.js'>
-<!-- L points to some other library -->
-
-<script src='leaflet.js'>
-<!-- you include Leaflet, it replaces the L variable to Leaflet namespace -->
-
-<script>
-var Leaflet = L.noConflict();
-// now L points to that other library again, and you can use Leaflet.Map etc.
-</script>
-
- -

version

A constant that represents the Leaflet version in use.

-
L.version; // contains "1.0.0" (or whatever version is currently in use)
-
diff --git a/docs/reference-versions.html b/docs/reference-versions.html index 84046c56544..a99a7833adc 100644 --- a/docs/reference-versions.html +++ b/docs/reference-versions.html @@ -17,5 +17,5 @@

Available API References

  • API reference for 1.4.0
  • API reference for 1.5.1
  • API reference for 1.6.0 -
  • API reference for 1.7.1 +
  • API reference for 1.7.1

    diff --git a/docs/reference.html b/docs/reference.html index 24751ea59b2..b83b5efce2c 100644 --- a/docs/reference.html +++ b/docs/reference.html @@ -1,4 +1,25068 @@ --- -layout: redirected -redirect_to: reference-1.7.1.html +layout: v2 +title: Documentation +bodyclass: api-page --- + +

    Leaflet API reference

    + +

    This reference reflects Leaflet 1.7.1. Check this list if you are using a different version of Leaflet.

    + +
    + +
    +

    UI Layers

    + +

    Raster Layers

    + +

    Vector Layers

    + +
    +
    +

    Other Layers

    + +

    Basic Types

    + +

    Controls

    + +
    +
    + + + + + + +

    Utility

    + +

    DOM Utility

    + +
    +
    +

    Base Classes

    + + +

    Misc

    + +
    +
    + +

    Map

    The central class of the API — it is used to create a map on a page and manipulate it.

    + +
    +

    Usage example

    + +
    + + + + + +
    // initialize the map on the "map" div with a given center and zoom
    +var map = L.map('map', {
    +	center: [51.505, -0.09],
    +	zoom: 13
    +});
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.map(<String> id, <Map options> options?)Instantiates a map object given the DOM ID of a <div> element +and optionally an object literal with Map options.
    L.map(<HTMLElement> el, <Map options> options?)Instantiates a map object given an instance of a <div> HTML element +and optionally an object literal with Map options.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    preferCanvasBooleanfalseWhether Paths should be rendered on a Canvas renderer. +By default, all Paths are rendered in a SVG renderer.
    + +
    + +

    Control options

    + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionControlBooleantrueWhether a attribution control is added to the map by default.
    zoomControlBooleantrueWhether a zoom control is added to the map by default.
    + +
    + +

    Interaction Options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    closePopupOnClickBooleantrueSet it to false if you don't want popups to close when user clicks the map.
    zoomSnapNumber1Forces the map's zoom level to always be a multiple of this, particularly +right after a fitBounds() or a pinch-zoom. +By default, the zoom level snaps to the nearest integer; lower values +(e.g. 0.5 or 0.1) allow for greater granularity. A value of 0 +means the zoom level will not be snapped after fitBounds or a pinch-zoom.
    zoomDeltaNumber1Controls how much the map's zoom level will change after a +zoomIn(), zoomOut(), pressing + +or - on the keyboard, or using the zoom controls. +Values smaller than 1 (e.g. 0.5) allow for greater granularity.
    trackResizeBooleantrueWhether the map automatically handles browser window resize to update itself.
    boxZoomBooleantrueWhether the map can be zoomed to a rectangular area specified by +dragging the mouse while pressing the shift key.
    doubleClickZoomBoolean|StringtrueWhether the map can be zoomed in by double clicking on it and +zoomed out by double clicking while holding shift. If passed +'center', double-click zoom will zoom to the center of the +view regardless of where the mouse was.
    draggingBooleantrueWhether the map be draggable with mouse/touch or not.
    + +
    + +

    Map State Options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    crsCRSL.CRS.EPSG3857The Coordinate Reference System to use. Don't change this if you're not +sure what it means.
    centerLatLngundefinedInitial geographic center of the map
    zoomNumberundefinedInitial map zoom level
    minZoomNumber*Minimum zoom level of the map. +If not specified and at least one GridLayer or TileLayer is in the map, +the lowest of their minZoom options will be used instead.
    maxZoomNumber*Maximum zoom level of the map. +If not specified and at least one GridLayer or TileLayer is in the map, +the highest of their maxZoom options will be used instead.
    layersLayer[][]Array of layers that will be added to the map initially
    maxBoundsLatLngBoundsnullWhen this option is set, the map restricts the view to the given +geographical bounds, bouncing the user back if the user tries to pan +outside the view. To set the restriction dynamically, use +setMaxBounds method.
    rendererRenderer*The default method for drawing vector layers on the map. L.SVG +or L.Canvas by default depending on browser support.
    + +
    + +

    Animation Options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    zoomAnimationBooleantrueWhether the map zoom animation is enabled. By default it's enabled +in all browsers that support CSS3 Transitions except Android.
    zoomAnimationThresholdNumber4Won't animate zoom if the zoom difference exceeds this value.
    fadeAnimationBooleantrueWhether the tile fade animation is enabled. By default it's enabled +in all browsers that support CSS3 Transitions except Android.
    markerZoomAnimationBooleantrueWhether markers animate their zoom with the zoom animation, if disabled +they will disappear for the length of the animation. By default it's +enabled in all browsers that support CSS3 Transitions except Android.
    transform3DLimitNumber2^23Defines the maximum size of a CSS translation transform. The default +value should not be changed unless a web browser positions layers in +the wrong place after doing a large panBy.
    + +
    + +

    Panning Inertia Options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    inertiaBoolean*If enabled, panning of the map will have an inertia effect where +the map builds momentum while dragging and continues moving in +the same direction for some time. Feels especially nice on touch +devices. Enabled by default unless running on old Android devices.
    inertiaDecelerationNumber3000The rate with which the inertial movement slows down, in pixels/second².
    inertiaMaxSpeedNumberInfinityMax speed of the inertial movement, in pixels/second.
    easeLinearityNumber0.2
    worldCopyJumpBooleanfalseWith this option enabled, the map tracks when you pan to another "copy" +of the world and seamlessly jumps to the original one so that all overlays +like markers and vector layers are still visible.
    maxBoundsViscosityNumber0.0If maxBounds is set, this option will control how solid the bounds +are when dragging the map around. The default value of 0.0 allows the +user to drag outside the bounds at normal speed, higher values will +slow down map dragging outside bounds, and 1.0 makes the bounds fully +solid, preventing the user from dragging outside the bounds.
    + +
    + +

    Keyboard Navigation Options

    + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    keyboardBooleantrueMakes the map focusable and allows users to navigate the map with keyboard +arrows and +/- keys.
    keyboardPanDeltaNumber80Amount of pixels to pan when pressing an arrow key.
    + +
    + +

    Mouse wheel options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    scrollWheelZoomBoolean|StringtrueWhether the map can be zoomed by using the mouse wheel. If passed 'center', +it will zoom to the center of the view regardless of where the mouse was.
    wheelDebounceTimeNumber40Limits the rate at which a wheel can fire (in milliseconds). By default +user can't zoom via wheel more often than once per 40 ms.
    wheelPxPerZoomLevelNumber60How many scroll pixels (as reported by L.DomEvent.getWheelDelta) +mean a change of one full zoom level. Smaller values will make wheel-zooming +faster (and vice versa).
    + +
    + +

    Touch interaction options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    tapBooleantrueEnables mobile hacks for supporting instant taps (fixing 200ms click +delay on iOS/Android) and touch holds (fired as contextmenu events).
    tapToleranceNumber15The max number of pixels a user can shift his finger during touch +for it to be considered a valid tap.
    touchZoomBoolean|String*Whether the map can be zoomed by touch-dragging with two fingers. If +passed 'center', it will zoom to the center of the view regardless of +where the touch events (fingers) were. Enabled for touch-capable web +browsers except for old Androids.
    bounceAtZoomLimitsBooleantrueSet it to false if you don't want the map to zoom beyond min/max zoom +and then bounce back when pinch-zooming.
    + +
    + + +
    +

    Events

    + +
    + +

    Layer events

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    baselayerchangeLayersControlEventFired when the base layer is changed through the layers control.
    overlayaddLayersControlEventFired when an overlay is selected through the layers control.
    overlayremoveLayersControlEventFired when an overlay is deselected through the layers control.
    layeraddLayerEventFired when a new layer is added to the map.
    layerremoveLayerEventFired when some layer is removed from the map
    + +
    + +

    Map state change events

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    zoomlevelschangeEventFired when the number of zoomlevels on the map is changed due +to adding or removing a layer.
    resizeResizeEventFired when the map is resized.
    unloadEventFired when the map is destroyed with remove method.
    viewresetEventFired when the map needs to redraw its content (this usually happens +on map zoom or load). Very useful for creating custom overlays.
    loadEventFired when the map is initialized (when its center and zoom are set +for the first time).
    zoomstartEventFired when the map zoom is about to change (e.g. before zoom animation).
    movestartEventFired when the view of the map starts changing (e.g. user starts dragging the map).
    zoomEventFired repeatedly during any change in zoom level, including zoom +and fly animations.
    moveEventFired repeatedly during any movement of the map, including pan and +fly animations.
    zoomendEventFired when the map zoom has changed, after any animations.
    moveendEventFired when the center of the map stops changing (e.g. user stopped dragging the map or when a non-centered zoom ends).
    + +
    + +

    Popup events

    + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup is opened in the map
    popupclosePopupEventFired when a popup in the map is closed
    autopanstartEventFired when the map starts autopanning when opening a popup.
    + +
    + +

    Tooltip events

    + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip is opened in the map.
    tooltipcloseTooltipEventFired when a tooltip in the map is closed.
    + +
    + +

    Location events

    + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    locationerrorErrorEventFired when geolocation (using the locate method) failed.
    locationfoundLocationEventFired when geolocation (using the locate method) +went successfully.
    + +
    + +

    Interaction events

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the map.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the map.
    mousedownMouseEventFired when the user pushes the mouse button on the map.
    mouseupMouseEventFired when the user releases the mouse button on the map.
    mouseoverMouseEventFired when the mouse enters the map.
    mouseoutMouseEventFired when the mouse leaves the map.
    mousemoveMouseEventFired while the mouse moves over the map.
    contextmenuMouseEventFired when the user pushes the right mouse button on the map, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    keypressKeyboardEventFired when the user presses a key from the keyboard that produces a character value while the map is focused.
    keydownKeyboardEventFired when the user presses a key from the keyboard while the map is focused. Unlike the keypress event, +the keydown event is fired for keys that produce a character value and for keys +that do not produce a character value.
    keyupKeyboardEventFired when the user releases a key from the keyboard while the map is focused.
    preclickMouseEventFired before mouse click on the map (sometimes useful when you +want something to happen on click before any existing click +handlers start running).
    + +
    + +

    Other Events

    + + + + + + + + + + + + + + +
    EventDataDescription
    zoomanimZoomAnimEventFired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getRenderer(<Path> layer)Renderer

    Returns the instance of Renderer that should be used to render the given +Path. It will ensure that the renderer options of the map and paths +are respected, and that the renderers do exist on the map.

    +
    + +
    + +

    Methods for Layers and Controls

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addControl(<Control> control)this

    Adds the given control to the map

    +
    removeControl(<Control> control)this

    Removes the given control from the map

    +
    addLayer(<Layer> layer)this

    Adds the given layer to the map

    +
    removeLayer(<Layer> layer)this

    Removes the given layer from the map.

    +
    hasLayer(<Layer> layer)Boolean

    Returns true if the given layer is currently added to the map

    +
    eachLayer(<Function> fn, <Object> context?)this

    Iterates over the layers of the map, optionally specifying context of the iterator function.

    +
    map.eachLayer(function(layer){
    +    layer.bindPopup('Hello');
    +});
    +
    +
    openPopup(<Popup> popup)this

    Opens the specified popup while closing the previously opened (to make sure only one is opened at one time for usability).

    +
    openPopup(<String|HTMLElement> content, <LatLng> latlng, <Popup options> options?)this

    Creates a popup with the specified content and options and opens it in the given point on a map.

    +
    closePopup(<Popup> popup?)this

    Closes the popup previously opened with openPopup (or the given one).

    +
    openTooltip(<Tooltip> tooltip)this

    Opens the specified tooltip.

    +
    openTooltip(<String|HTMLElement> content, <LatLng> latlng, <Tooltip options> options?)this

    Creates a tooltip with the specified content and options and open it.

    +
    closeTooltip(<Tooltip> tooltip?)this

    Closes the tooltip given as parameter.

    +
    + +
    + +

    Methods for modifying map state

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setView(<LatLng> center, <Number> zoom, <Zoom/pan options> options?)this

    Sets the view of the map (geographical center and zoom) with the given +animation options.

    +
    setZoom(<Number> zoom, <Zoom/pan options> options?)this

    Sets the zoom of the map.

    +
    zoomIn(<Number> delta?, <Zoom options> options?)this

    Increases the zoom of the map by delta (zoomDelta by default).

    +
    zoomOut(<Number> delta?, <Zoom options> options?)this

    Decreases the zoom of the map by delta (zoomDelta by default).

    +
    setZoomAround(<LatLng> latlng, <Number> zoom, <Zoom options> options)this

    Zooms the map while keeping a specified geographical point on the map +stationary (e.g. used internally for scroll zoom and double-click zoom).

    +
    setZoomAround(<Point> offset, <Number> zoom, <Zoom options> options)this

    Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary.

    +
    fitBounds(<LatLngBounds> bounds, <fitBounds options> options?)this

    Sets a map view that contains the given geographical bounds with the +maximum zoom level possible.

    +
    fitWorld(<fitBounds options> options?)this

    Sets a map view that mostly contains the whole world with the maximum +zoom level possible.

    +
    panTo(<LatLng> latlng, <Pan options> options?)this

    Pans the map to a given center.

    +
    panBy(<Point> offset, <Pan options> options?)this

    Pans the map by a given number of pixels (animated).

    +
    flyTo(<LatLng> latlng, <Number> zoom?, <Zoom/pan options> options?)this

    Sets the view of the map (geographical center and zoom) performing a smooth +pan-zoom animation.

    +
    flyToBounds(<LatLngBounds> bounds, <fitBounds options> options?)this

    Sets the view of the map with a smooth animation like flyTo, +but takes a bounds parameter like fitBounds.

    +
    setMaxBounds(<LatLngBounds> bounds)this

    Restricts the map view to the given bounds (see the maxBounds option).

    +
    setMinZoom(<Number> zoom)this

    Sets the lower limit for the available zoom levels (see the minZoom option).

    +
    setMaxZoom(<Number> zoom)this

    Sets the upper limit for the available zoom levels (see the maxZoom option).

    +
    panInsideBounds(<LatLngBounds> bounds, <Pan options> options?)this

    Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any.

    +
    panInside(<LatLng> latlng, <options> options?)this

    Pans the map the minimum amount to make the latlng visible. Use +padding, paddingTopLeft and paddingTopRight options to fit +the display to more restricted bounds, like fitBounds. +If latlng is already within the (optionally padded) display bounds, +the map will not be panned.

    +
    invalidateSize(<Zoom/pan options> options)this

    Checks if the map container size changed and updates the map if so — +call it after you've changed the map size dynamically, also animating +pan by default. If options.pan is false, panning will not occur. +If options.debounceMoveend is true, it will delay moveend event so +that it doesn't happen often even if the method is called many +times in a row.

    +
    invalidateSize(<Boolean> animate)this

    Checks if the map container size changed and updates the map if so — +call it after you've changed the map size dynamically, also animating +pan by default.

    +
    stop()this

    Stops the currently running panTo or flyTo animation, if any.

    +
    + +
    + +

    Geolocation methods

    + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    locate(<Locate options> options?)this

    Tries to locate the user using the Geolocation API, firing a locationfound +event with location data on success or a locationerror event on failure, +and optionally sets the map view to the user's location with respect to +detection accuracy (or to the world view if geolocation failed). +Note that, if your page doesn't use HTTPS, this method will fail in +modern browsers (Chrome 50 and newer) +See Locate options for more details.

    +
    stopLocate()this

    Stops watching location previously initiated by map.locate({watch: true}) +and aborts resetting the map view if map.locate was called with +{setView: true}.

    +
    + +
    + +

    Other Methods

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addHandler(<String> name, <Function> HandlerClass)this

    Adds a new Handler to the map, given its name and constructor function.

    +
    remove()this

    Destroys the map and clears all related event listeners.

    +
    createPane(<String> name, <HTMLElement> container?)HTMLElement

    Creates a new map pane with the given name if it doesn't exist already, +then returns it. The pane is created as a child of container, or +as a child of the main map pane if not set.

    +
    getPane(<String|HTMLElement> pane)HTMLElement

    Returns a map pane, given its name or its HTML element (its identity).

    +
    getPanes()Object

    Returns a plain object containing the names of all panes as keys and +the panes as values.

    +
    getContainer()HTMLElement

    Returns the HTML element that contains the map.

    +
    whenReady(<Function> fn, <Object> context?)this

    Runs the given function fn when the map gets initialized with +a view (center and zoom) and at least one layer, or immediately +if it's already initialized, optionally passing a function context.

    +
    + +
    + +

    Methods for Getting Map State

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getCenter()LatLng

    Returns the geographical center of the map view

    +
    getZoom()Number

    Returns the current zoom level of the map view

    +
    getBounds()LatLngBounds

    Returns the geographical bounds visible in the current map view

    +
    getMinZoom()Number

    Returns the minimum zoom level of the map (if set in the minZoom option of the map or of any layers), or 0 by default.

    +
    getMaxZoom()Number

    Returns the maximum zoom level of the map (if set in the maxZoom option of the map or of any layers).

    +
    getBoundsZoom(<LatLngBounds> bounds, <Boolean> inside?, <Point> padding?)Number

    Returns the maximum zoom level on which the given bounds fit to the map +view in its entirety. If inside (optional) is set to true, the method +instead returns the minimum zoom level on which the map view fits into +the given bounds in its entirety.

    +
    getSize()Point

    Returns the current size of the map container (in pixels).

    +
    getPixelBounds()Bounds

    Returns the bounds of the current map view in projected pixel +coordinates (sometimes useful in layer and overlay implementations).

    +
    getPixelOrigin()Point

    Returns the projected pixel coordinates of the top left point of +the map layer (useful in custom layer and overlay implementations).

    +
    getPixelWorldBounds(<Number> zoom?)Bounds

    Returns the world's bounds in pixel coordinates for zoom level zoom. +If zoom is omitted, the map's current zoom level is used.

    +
    + +
    + +

    Conversion Methods

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getZoomScale(<Number> toZoom, <Number> fromZoom)Number

    Returns the scale factor to be applied to a map transition from zoom level +fromZoom to toZoom. Used internally to help with zoom animations.

    +
    getScaleZoom(<Number> scale, <Number> fromZoom)Number

    Returns the zoom level that the map would end up at, if it is at fromZoom +level and everything is scaled by a factor of scale. Inverse of +getZoomScale.

    +
    project(<LatLng> latlng, <Number> zoom)Point

    Projects a geographical coordinate LatLng according to the projection +of the map's CRS, then scales it according to zoom and the CRS's +Transformation. The result is pixel coordinate relative to +the CRS origin.

    +
    unproject(<Point> point, <Number> zoom)LatLng

    Inverse of project.

    +
    layerPointToLatLng(<Point> point)LatLng

    Given a pixel coordinate relative to the origin pixel, +returns the corresponding geographical coordinate (for the current zoom level).

    +
    latLngToLayerPoint(<LatLng> latlng)Point

    Given a geographical coordinate, returns the corresponding pixel coordinate +relative to the origin pixel.

    +
    wrapLatLng(<LatLng> latlng)LatLng

    Returns a LatLng where lat and lng has been wrapped according to the +map's CRS's wrapLat and wrapLng properties, if they are outside the +CRS's bounds. +By default this means longitude is wrapped around the dateline so its +value is between -180 and +180 degrees.

    +
    wrapLatLngBounds(<LatLngBounds> bounds)LatLngBounds

    Returns a LatLngBounds with the same size as the given one, ensuring that +its center is within the CRS's bounds. +By default this means the center longitude is wrapped around the dateline so its +value is between -180 and +180 degrees, and the majority of the bounds +overlaps the CRS's bounds.

    +
    distance(<LatLng> latlng1, <LatLng> latlng2)Number

    Returns the distance between two geographical coordinates according to +the map's CRS. By default this measures distance in meters.

    +
    containerPointToLayerPoint(<Point> point)Point

    Given a pixel coordinate relative to the map container, returns the corresponding +pixel coordinate relative to the origin pixel.

    +
    layerPointToContainerPoint(<Point> point)Point

    Given a pixel coordinate relative to the origin pixel, +returns the corresponding pixel coordinate relative to the map container.

    +
    containerPointToLatLng(<Point> point)LatLng

    Given a pixel coordinate relative to the map container, returns +the corresponding geographical coordinate (for the current zoom level).

    +
    latLngToContainerPoint(<LatLng> latlng)Point

    Given a geographical coordinate, returns the corresponding pixel coordinate +relative to the map container.

    +
    mouseEventToContainerPoint(<MouseEvent> ev)Point

    Given a MouseEvent object, returns the pixel coordinate relative to the +map container where the event took place.

    +
    mouseEventToLayerPoint(<MouseEvent> ev)Point

    Given a MouseEvent object, returns the pixel coordinate relative to +the origin pixel where the event took place.

    +
    mouseEventToLatLng(<MouseEvent> ev)LatLng

    Given a MouseEvent object, returns geographical coordinate where the +event took place.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +
    +

    Properties

    + +
    + +

    Controls

    + + + + + + + + + + + + + + +
    PropertyTypeDescription
    zoomControlControl.ZoomThe default zoom control (only available if the +zoomControl option was true when creating the map).
    + +
    + +

    Handlers

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    boxZoomHandlerBox (shift-drag with mouse) zoom handler.
    doubleClickZoomHandlerDouble click zoom handler.
    draggingHandlerMap dragging handler (by both mouse and touch).
    keyboardHandlerKeyboard navigation handler.
    scrollWheelZoomHandlerScroll wheel zoom handler.
    tapHandlerMobile touch hacks (quick tap and touch hold) handler.
    touchZoomHandlerTouch zoom handler.
    + +
    + + +
    +

    Map panes

    + +
    + + + +
    Panes are DOM elements used to control the ordering of layers on the map. You +can access panes with map.getPane or +map.getPanes methods. New panes can be created with the +map.createPane method. +

    Every map has the following default panes that differ only in zIndex.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PaneTypeZ-indexDescription
    mapPaneHTMLElement'auto'Pane that contains all other map panes
    tilePaneHTMLElement200Pane for GridLayers and TileLayers
    overlayPaneHTMLElement400Pane for overlay shadows (e.g. Marker shadows)
    shadowPaneHTMLElement500Pane for vectors (Paths, like Polylines and Polygons), ImageOverlays and VideoOverlays
    markerPaneHTMLElement600Pane for Icons of Markers
    tooltipPaneHTMLElement650Pane for Tooltips.
    popupPaneHTMLElement700Pane for Popups.
    + +
    + + +
    + +
    +

    Locate options

    + +
    + + + +
    Some of the geolocation methods for Map take in an options parameter. This +is a plain javascript object with the following optional components:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    watchBooleanfalseIf true, starts continuous watching of location changes (instead of detecting it +once) using W3C watchPosition method. You can later stop watching using +map.stopLocate() method.
    setViewBooleanfalseIf true, automatically sets the map view to the user location with respect to +detection accuracy, or to world view if geolocation failed.
    maxZoomNumberInfinityThe maximum zoom for automatic view setting when using setView option.
    timeoutNumber10000Number of milliseconds to wait for a response from geolocation before firing a +locationerror event.
    maximumAgeNumber0Maximum age of detected location. If less than this amount of milliseconds +passed since last geolocation response, locate will return a cached location.
    enableHighAccuracyBooleanfalseEnables high accuracy, see description in the W3C spec.
    + +
    + + +
    + +
    +

    Zoom options

    + +
    + + + +
    Some of the Map methods which modify the zoom level take in an options +parameter. This is a plain javascript object with the following optional +components:
    + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the +current view. If true, the map will attempt animating zoom disregarding where +zoom origin is. Setting false will make it always reset the view completely +without animation.
    + +
    + + +
    + +
    +

    Pan options

    + +
    + + + +
    Some of the Map methods which modify the center of the map take in an options +parameter. This is a plain javascript object with the following optional +components:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    animateBooleanIf true, panning will always be animated if possible. If false, it will +not animate panning, either resetting the map view if panning more than a +screen away, or just setting a new offset for the map pane (except for panBy +which always does the latter).
    durationNumber0.25Duration of animated panning, in seconds.
    easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the +Cubic Bezier curve). 1.0 means linear animation, +and the smaller this number, the more bowed the curve.
    noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for +panning inertia).
    + +
    + + +
    + +
    +

    Zoom/pan options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the +current view. If true, the map will attempt animating zoom disregarding where +zoom origin is. Setting false will make it always reset the view completely +without animation.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    durationNumber0.25Duration of animated panning, in seconds.
    easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the +Cubic Bezier curve). 1.0 means linear animation, +and the smaller this number, the more bowed the curve.
    noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for +panning inertia).
    + +
    +
    +
    + +
    + +
    +

    FitBounds options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paddingTopLeftPoint[0, 0]Sets the amount of padding in the top left corner of a map container that +shouldn't be accounted for when setting the view to fit bounds. Useful if you +have some control overlays on the map like a sidebar and you don't want them +to obscure objects you're zooming to.
    paddingBottomRightPoint[0, 0]The same for the bottom right corner of the map.
    paddingPoint[0, 0]Equivalent of setting both top left and bottom right padding to the same value.
    maxZoomNumbernullThe maximum possible zoom to use.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    animateBooleanIf not specified, zoom animation will happen if the zoom origin is inside the +current view. If true, the map will attempt animating zoom disregarding where +zoom origin is. Setting false will make it always reset the view completely +without animation.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    durationNumber0.25Duration of animated panning, in seconds.
    easeLinearityNumber0.25The curvature factor of panning animation easing (third parameter of the +Cubic Bezier curve). 1.0 means linear animation, +and the smaller this number, the more bowed the curve.
    noMoveStartBooleanfalseIf true, panning won't fire movestart event on start (used internally for +panning inertia).
    + +
    +
    +
    + +

    Marker

    L.Marker is used to display clickable/draggable icons on the map. Extends Layer.

    + +
    +

    Usage example

    + +
    + + + + + +
    L.marker([50.5, 30.5]).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.marker(<LatLng> latlng, <Marker options> options?)Instantiates a Marker object given a geographical point and optionally an options object.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    iconIcon*Icon instance to use for rendering the marker. +See Icon documentation for details on how to customize the marker icon. +If not specified, a common instance of L.Icon.Default is used.
    keyboardBooleantrueWhether the marker can be tabbed to with a keyboard and clicked by pressing enter.
    titleString''Text for the browser tooltip that appear on marker hover (no tooltip by default).
    altString''Text for the alt attribute of the icon image (useful for accessibility).
    zIndexOffsetNumber0By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively).
    opacityNumber1.0The opacity of the marker.
    riseOnHoverBooleanfalseIf true, the marker will get on top of others when you hover the mouse over it.
    riseOffsetNumber250The z-index offset used for the riseOnHover feature.
    paneString'markerPane'Map pane where the markers icon will be added.
    shadowPaneString'shadowPane'Map pane where the markers shadow will be added.
    bubblingMouseEventsBooleanfalseWhen true, a mouse event on this marker will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    + +
    + +

    Draggable marker options

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    draggableBooleanfalseWhether the marker is draggable with mouse/touch or not.
    autoPanBooleanfalseWhether to pan the map when dragging this marker near its edge or not.
    autoPanPaddingPointPoint(50, 50)Distance (in pixels to the left/right and to the top/bottom) of the +map edge to start panning the map.
    autoPanSpeedNumber10Number of pixels the map should pan by.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    moveEventFired when the marker is moved via setLatLng or by dragging. Old and new coordinates are included in event arguments as oldLatLng, latlng.
    + +
    + +

    Dragging events

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    dragstartEventFired when the user starts dragging the marker.
    movestartEventFired when the marker starts moving (because of dragging).
    dragEventFired repeatedly while the user drags the marker.
    dragendDragEndEventFired when the user stops dragging the marker.
    moveendEventFired when the marker stops moving (because of dragging).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + +
    In addition to shared layer methods like addTo() and remove() and popup methods like bindPopup() you can also use the following methods:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getLatLng()LatLng

    Returns the current geographical position of the marker.

    +
    setLatLng(<LatLng> latlng)this

    Changes the marker position to the given point.

    +
    setZIndexOffset(<Number> offset)this

    Changes the zIndex offset of the marker.

    +
    getIcon()Icon

    Returns the current icon used by the marker

    +
    setIcon(<Icon> icon)this

    Changes the marker icon.

    +
    setOpacity(<Number> opacity)this

    Changes the opacity of the marker.

    +
    + +
    + +

    Other methods

    + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the marker (as a GeoJSON Point Feature).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +
    +

    Properties

    + +
    + +

    Interaction handlers

    + +
    Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see Handler methods). Example: +
    marker.dragging.disable();
    +
    + + + + + + + + + + + + + +
    PropertyTypeDescription
    draggingHandlerMarker dragging handler (by both mouse and touch). Only valid when the marker is on the map (Otherwise set marker.options.draggable).
    + +
    + + +

    Used to open popups in certain places of the map. Use Map.openPopup to +open popups while making sure that only one popup is open at one time +(recommended for usability), or use Map.addLayer to open as many as you want.

    + +
    + + +
    + + + + + +

    If you want to just bind a popup to marker click and then open it, it's really easy:

    +
    marker.bindPopup(popupContent).openPopup();
    +
    +

    Path overlays like polylines also have a bindPopup method. +Here's a more complicated way to open a popup on a map:

    +
    var popup = L.popup()
    +	.setLatLng(latlng)
    +	.setContent('<p>Hello world!<br />This is a nice popup.</p>')
    +	.openOn(map);
    +
    + + + +
    + + +
    + + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    + +
    + + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    + +
    +
    +
    + +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    + +
    +
    +
    + +

    Tooltip

    Used to display small texts on top of map layers.

    + +
    +

    Usage example

    + +
    + + + + + +
    marker.bindTooltip("my tooltip text").openTooltip();
    +
    +

    Note about tooltip offset. Leaflet takes two options in consideration +for computing tooltip offsetting:

    +
      +
    • the offset Tooltip option: it defaults to [0, 0], and it's specific to one tooltip. +Add a positive x offset to move the tooltip to the right, and a positive y offset to +move it to the bottom. Negatives will move to the left and top.
    • +
    • the tooltipAnchor Icon option: this will only be considered for Marker. You +should adapt this value if you use a custom icon.
    • +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.tooltip(<Tooltip options> options?, <Layer> source?)Instantiates a Tooltip object given an optional options object that describes its appearance and location and an optional source object that is used to tag the tooltip with a reference to the Layer to which it refers.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'tooltipPane'Map pane where the tooltip will be added.
    offsetPointPoint(0, 0)Optional offset of the tooltip position.
    directionString'auto'Direction where to open the tooltip. Possible values are: right, left, +top, bottom, center, auto. +auto will dynamically switch between right and left according to the tooltip +position on the map.
    permanentBooleanfalseWhether to open the tooltip permanently or only on mouseover.
    stickyBooleanfalseIf true, the tooltip will follow the mouse instead of being fixed at the feature center.
    interactiveBooleanfalseIf true, the tooltip will listen to the feature events.
    opacityNumber0.9Tooltip container opacity.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    classNameString''A custom CSS class name to assign to the popup.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    TileLayer

    Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under Layer. Extends GridLayer.

    + +
    +

    Usage example

    + +
    + + + + + +
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
    +
    + + + +
    + +

    URL template

    + + + +

    A string of the following form:

    +
    'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png'
    +
    +

    {s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; a, b or c by default, can be omitted), {z} — zoom level, {x} and {y} — tile coordinates. {r} can be used to add "@2x" to the URL to load retina tiles.

    +

    You can use custom keys in the template, which will be evaluated from TileLayer options, like this:

    +
    L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});
    +
    + + + +
    + + +
    +

    Creation

    + +
    + +

    Extension methods

    + + + + + + + + + + + + +
    FactoryDescription
    L.tilelayer(<String> urlTemplate, <TileLayer options> options?)Instantiates a tile layer object given a URL template and optionally an options object.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
    maxZoomNumber18The maximum zoom level up to which this layer will be displayed (inclusive).
    subdomainsString|String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
    errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
    zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
    tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
    zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
    detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
    crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the tiles. +If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. +Refer to CORS Settings for valid String values.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
    opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
    updateWhenIdleBoolean(depends)Load new tiles only when panning ends. +true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. +false otherwise in order to display new tiles during panning, since it is easy to pan outside the +keepBuffer option in desktop browsers.
    updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
    updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
    zIndexNumber1The explicit zIndex of the tile layer.
    boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
    maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels higher than maxNativeZoom will be loaded +from maxNativeZoom level and auto-scaled.
    minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels lower than minNativeZoom will be loaded +from minNativeZoom level and auto-scaled.
    noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the +GridLayer will only be displayed once at low zoom levels. Has no +effect when the map CRS doesn't wrap around. Can be used +in combination with bounds to prevent requesting +tiles outside the CRS limits.
    paneString'tilePane'Map pane where the grid layer will be added.
    classNameString''A custom class name to assign to the tile layer. Empty by default.
    keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadingEventFired when the grid layer starts loading tiles.
    tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
    tileloadstartTileEventFired when a tile is requested and starts loading.
    tileerrorTileErrorEventFired when there is an error loading a tile.
    tileloadTileEventFired when a tile loads.
    loadEventFired when the grid layer loaded all visible tiles.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setUrl(<String> url, <Boolean> noRedraw?)this

    Updates the layer's URL template and redraws it (unless noRedraw is set to true). +If the URL does not change, the layer will not be redrawn unless +the noRedraw parameter is set to false.

    +
    createTile(<Object> coords, <Function> done?)HTMLElement

    Called only internally, overrides GridLayer's createTile() +to return an <img> HTML element with the appropriate image URL given coords. The done +callback is called when the tile has been loaded.

    +
    + +
    + +

    Extension methods

    + +
    Layers extending TileLayer might reimplement the following method.
    + + + + + + + + + + + + + +
    MethodReturnsDescription
    getTileUrl(<Object> coords)String

    Called only internally, returns the URL for a tile given its coordinates. +Classes extending TileLayer can override this function to provide custom tile URL naming schemes.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bringToFront()this

    Brings the tile layer to the top of all tile layers.

    +
    bringToBack()this

    Brings the tile layer to the bottom of all tile layers.

    +
    getContainer()HTMLElement

    Returns the HTML element that contains the tiles for this layer.

    +
    setOpacity(<Number> opacity)this

    Changes the opacity of the grid layer.

    +
    setZIndex(<Number> zIndex)this

    Changes the zIndex of the grid layer.

    +
    isLoading()Boolean

    Returns true if any tile in the grid layer has not finished loading.

    +
    redraw()this

    Causes the layer to clear all the tiles and request them again.

    +
    getTileSize()Point

    Normalizes the tileSize option into a point. Used by the createTile() method.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    TileLayer.WMS

    Used to display WMS services as tile layers on the map. Extends TileLayer.

    + +
    +

    Usage example

    + +
    + + + + + +
    var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
    +	layers: 'nexrad-n0r-900913',
    +	format: 'image/png',
    +	transparent: true,
    +	attribution: "Weather data © 2012 IEM Nexrad"
    +});
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.tileLayer.wms(<String> baseUrl, <TileLayer.WMS options> options)Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
    + +
    + + +
    +

    Options

    + +
    + + + +
    If any custom options not documented here are used, they will be sent to the +WMS server as extra parameters in each request URL. This can be useful for +non-standard vendor WMS parameters.
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    layersString''(required) Comma-separated list of WMS layers to show.
    stylesString''Comma-separated list of WMS styles.
    formatString'image/jpeg'WMS image format (use 'image/png' for layers with transparency).
    transparentBooleanfalseIf true, the WMS service will return images with transparency.
    versionString'1.1.1'Version of the WMS service to use
    crsCRSnullCoordinate Reference System to use for the WMS requests, defaults to +map CRS. Don't change this if you're not sure what it means.
    uppercaseBooleanfalseIf true, WMS request parameter keys will be uppercase.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
    maxZoomNumber18The maximum zoom level up to which this layer will be displayed (inclusive).
    subdomainsString|String[]'abc'Subdomains of the tile service. Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings.
    errorTileUrlString''URL to the tile image to show in place of the tile that failed to load.
    zoomOffsetNumber0The zoom number used in tile URLs will be offset with this value.
    tmsBooleanfalseIf true, inverses Y axis numbering for tiles (turn this on for TMS services).
    zoomReverseBooleanfalseIf set to true, the zoom number used in tile URLs will be reversed (maxZoom - zoom instead of zoom)
    detectRetinaBooleanfalseIf true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
    crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the tiles. +If a String is provided, all tiles will have their crossOrigin attribute set to the String provided. This is needed if you want to access tile pixel data. +Refer to CORS Settings for valid String values.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
    opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
    updateWhenIdleBoolean(depends)Load new tiles only when panning ends. +true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. +false otherwise in order to display new tiles during panning, since it is easy to pan outside the +keepBuffer option in desktop browsers.
    updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
    updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
    zIndexNumber1The explicit zIndex of the tile layer.
    boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
    maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels higher than maxNativeZoom will be loaded +from maxNativeZoom level and auto-scaled.
    minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels lower than minNativeZoom will be loaded +from minNativeZoom level and auto-scaled.
    noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the +GridLayer will only be displayed once at low zoom levels. Has no +effect when the map CRS doesn't wrap around. Can be used +in combination with bounds to prevent requesting +tiles outside the CRS limits.
    paneString'tilePane'Map pane where the grid layer will be added.
    classNameString''A custom class name to assign to the tile layer. Empty by default.
    keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadingEventFired when the grid layer starts loading tiles.
    tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
    tileloadstartTileEventFired when a tile is requested and starts loading.
    tileerrorTileErrorEventFired when there is an error loading a tile.
    tileloadTileEventFired when a tile loads.
    loadEventFired when the grid layer loaded all visible tiles.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setParams(<Object> params, <Boolean> noRedraw?)this

    Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setUrl(<String> url, <Boolean> noRedraw?)this

    Updates the layer's URL template and redraws it (unless noRedraw is set to true). +If the URL does not change, the layer will not be redrawn unless +the noRedraw parameter is set to false.

    +
    createTile(<Object> coords, <Function> done?)HTMLElement

    Called only internally, overrides GridLayer's createTile() +to return an <img> HTML element with the appropriate image URL given coords. The done +callback is called when the tile has been loaded.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bringToFront()this

    Brings the tile layer to the top of all tile layers.

    +
    bringToBack()this

    Brings the tile layer to the bottom of all tile layers.

    +
    getContainer()HTMLElement

    Returns the HTML element that contains the tiles for this layer.

    +
    setOpacity(<Number> opacity)this

    Changes the opacity of the grid layer.

    +
    setZIndex(<Number> zIndex)this

    Changes the zIndex of the grid layer.

    +
    isLoading()Boolean

    Returns true if any tile in the grid layer has not finished loading.

    +
    redraw()this

    Causes the layer to clear all the tiles and request them again.

    +
    getTileSize()Point

    Normalizes the tileSize option into a point. Used by the createTile() method.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    ImageOverlay

    Used to load and display a single image over specific bounds of the map. Extends Layer.

    + +
    +

    Usage example

    + +
    + + + + + +
    var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
    +	imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
    +L.imageOverlay(imageUrl, imageBounds).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.imageOverlay(<String> imageUrl, <LatLngBounds> bounds, <ImageOverlay options> options?)Instantiates an image overlay object given the URL of the image and the +geographical bounds it is tied to.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    opacityNumber1.0The opacity of the image overlay.
    altString''Text for the alt attribute of the image (useful for accessibility).
    interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
    crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. +If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. +Refer to CORS Settings for valid String values.
    errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
    zIndexNumber1The explicit zIndex of the overlay layer.
    classNameString''A custom class name to assign to the image. Empty by default.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadEventFired when the ImageOverlay layer has loaded its image
    errorEventFired when the ImageOverlay layer fails to load its image
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setOpacity(<Number> opacity)this

    Sets the opacity of the overlay.

    +
    bringToFront()this

    Brings the layer to the top of all overlays.

    +
    bringToBack()this

    Brings the layer to the bottom of all overlays.

    +
    setUrl(<String> url)this

    Changes the URL of the image.

    +
    setBounds(<LatLngBounds> bounds)this

    Update the bounds that this ImageOverlay covers

    +
    setZIndex(<Number> value)this

    Changes the zIndex of the image overlay.

    +
    getBounds()LatLngBounds

    Get the bounds that this ImageOverlay covers

    +
    getElement()HTMLElement

    Returns the instance of HTMLImageElement +used by this overlay.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    VideoOverlay

    Used to load and display a video player over specific bounds of the map. Extends ImageOverlay.

    +

    A video overlay uses the <video> +HTML5 element.

    + +
    +

    Usage example

    + +
    + + + + + +
    var videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
    +	videoBounds = [[ 32, -130], [ 13, -100]];
    +L.videoOverlay(videoUrl, videoBounds ).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.videoOverlay(<String|Array|HTMLVideoElement> video, <LatLngBounds> bounds, <VideoOverlay options> options?)Instantiates an image overlay object given the URL of the video (or array of URLs, or even a video element) and the +geographical bounds it is tied to.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    autoplayBooleantrueWhether the video starts playing automatically when loaded.
    loopBooleantrueWhether the video will loop back to the beginning when played.
    keepAspectRatioBooleantrueWhether the video will save aspect ratio after the projection. +Relevant for supported browsers. See browser compatibility
    mutedBooleanfalseWhether the video starts on mute when loaded.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    opacityNumber1.0The opacity of the image overlay.
    altString''Text for the alt attribute of the image (useful for accessibility).
    interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
    crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. +If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. +Refer to CORS Settings for valid String values.
    errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
    zIndexNumber1The explicit zIndex of the overlay layer.
    classNameString''A custom class name to assign to the image. Empty by default.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadEventFired when the video has finished loading the first frame
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    errorEventFired when the ImageOverlay layer fails to load its image
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getElement()HTMLVideoElement

    Returns the instance of HTMLVideoElement +used by this overlay.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setOpacity(<Number> opacity)this

    Sets the opacity of the overlay.

    +
    bringToFront()this

    Brings the layer to the top of all overlays.

    +
    bringToBack()this

    Brings the layer to the bottom of all overlays.

    +
    setUrl(<String> url)this

    Changes the URL of the image.

    +
    setBounds(<LatLngBounds> bounds)this

    Update the bounds that this ImageOverlay covers

    +
    setZIndex(<Number> value)this

    Changes the zIndex of the image overlay.

    +
    getBounds()LatLngBounds

    Get the bounds that this ImageOverlay covers

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    SVGOverlay

    Used to load, display and provide DOM access to an SVG file over specific bounds of the map. Extends ImageOverlay.

    +

    An SVG overlay uses the <svg> element.

    + +
    +

    Usage example

    + +
    + + + + + +
    var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
    +svgElement.setAttribute('xmlns', "http://www.w3.org/2000/svg");
    +svgElement.setAttribute('viewBox', "0 0 200 200");
    +svgElement.innerHTML = '<rect width="200" height="200"/><rect x="75" y="23" width="50" height="50" style="fill:red"/><rect x="75" y="123" width="50" height="50" style="fill:#0013ff"/>';
    +var svgElementBounds = [ [ 32, -130 ], [ 13, -100 ] ];
    +L.svgOverlay(svgElement, svgElementBounds).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.svgOverlay(<String|SVGElement> svg, <LatLngBounds> bounds, <SVGOverlay options> options?)Instantiates an image overlay object given an SVG element and the geographical bounds it is tied to. +A viewBox attribute is required on the SVG element to zoom in and out properly.
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    opacityNumber1.0The opacity of the image overlay.
    altString''Text for the alt attribute of the image (useful for accessibility).
    interactiveBooleanfalseIf true, the image overlay will emit mouse events when clicked or hovered.
    crossOriginBoolean|StringfalseWhether the crossOrigin attribute will be added to the image. +If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. +Refer to CORS Settings for valid String values.
    errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
    zIndexNumber1The explicit zIndex of the overlay layer.
    classNameString''A custom class name to assign to the image. Empty by default.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadEventFired when the ImageOverlay layer has loaded its image
    errorEventFired when the ImageOverlay layer fails to load its image
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getElement()SVGElement

    Returns the instance of SVGElement +used by this overlay.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setOpacity(<Number> opacity)this

    Sets the opacity of the overlay.

    +
    bringToFront()this

    Brings the layer to the top of all overlays.

    +
    bringToBack()this

    Brings the layer to the bottom of all overlays.

    +
    setUrl(<String> url)this

    Changes the URL of the image.

    +
    setBounds(<LatLngBounds> bounds)this

    Update the bounds that this ImageOverlay covers

    +
    setZIndex(<Number> value)this

    Changes the zIndex of the image overlay.

    +
    getBounds()LatLngBounds

    Get the bounds that this ImageOverlay covers

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Path

    An abstract class that contains options and constants shared between vector +overlays (Polygon, Polyline, Circle). Do not use it directly. Extends Layer.

    + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Polyline

    A class for drawing polyline overlays on a map. Extends Path.

    + +
    +

    Usage example

    + +
    + + + + + +
    // create a red polyline from an array of LatLng points
    +var latlngs = [
    +	[45.51, -122.68],
    +	[37.77, -122.43],
    +	[34.04, -118.2]
    +];
    +
    +var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
    +
    +// zoom the map to the polyline
    +map.fitBounds(polyline.getBounds());
    +
    +

    You can also pass a multi-dimensional array to represent a MultiPolyline shape:

    +
    // create a red polyline from an array of arrays of LatLng points
    +var latlngs = [
    +	[[45.51, -122.68],
    +	 [37.77, -122.43],
    +	 [34.04, -118.2]],
    +	[[40.78, -73.91],
    +	 [41.83, -87.62],
    +	 [32.76, -96.72]]
    +];
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.polyline(<LatLng[]> latlngs, <Polyline options> options?)Instantiates a polyline object given an array of geographical points and +optionally an options object. You can create a Polyline object with +multiple separate lines (MultiPolyline) by passing an array of arrays +of geographic points.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means +better performance and smoother look, and less means more accurate representation.
    noClipBooleanfalseDisable polyline clipping.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the polyline (as a GeoJSON LineString or MultiLineString Feature).

    +
    getLatLngs()LatLng[]

    Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

    +
    setLatLngs(<LatLng[]> latlngs)this

    Replaces all the points in the polyline with the given array of geographical points.

    +
    isEmpty()Boolean

    Returns true if the Polyline has no LatLngs.

    +
    closestLayerPoint(<Point> p)Point

    Returns the point closest to p on the Polyline.

    +
    getCenter()LatLng

    Returns the center (centroid) of the polyline.

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the path.

    +
    addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

    Adds a given point to the polyline. By default, adds to the first ring of +the polyline in case of a multi-polyline, but can be overridden by passing +a specific ring as a LatLng array (that you can earlier access with getLatLngs).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Polygon

    A class for drawing polygon overlays on a map. Extends Polyline.

    +

    Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points.

    + +
    +

    Usage example

    + +
    + + + + + +
    // create a red polygon from an array of LatLng points
    +var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]];
    +
    +var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map);
    +
    +// zoom the map to the polygon
    +map.fitBounds(polygon.getBounds());
    +
    +

    You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape:

    +
    var latlngs = [
    +  [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
    +  [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
    +];
    +
    +

    Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape.

    +
    var latlngs = [
    +  [ // first polygon
    +    [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring
    +    [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole
    +  ],
    +  [ // second polygon
    +    [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]]
    +  ]
    +];
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.polygon(<LatLng[]> latlngs, <Polyline options> options?)
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means +better performance and smoother look, and less means more accurate representation.
    noClipBooleanfalseDisable polyline clipping.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getLatLngs()LatLng[]

    Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

    +
    setLatLngs(<LatLng[]> latlngs)this

    Replaces all the points in the polyline with the given array of geographical points.

    +
    isEmpty()Boolean

    Returns true if the Polyline has no LatLngs.

    +
    closestLayerPoint(<Point> p)Point

    Returns the point closest to p on the Polyline.

    +
    getCenter()LatLng

    Returns the center (centroid) of the polyline.

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the path.

    +
    addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

    Adds a given point to the polyline. By default, adds to the first ring of +the polyline in case of a multi-polyline, but can be overridden by passing +a specific ring as a LatLng array (that you can earlier access with getLatLngs).

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Rectangle

    A class for drawing rectangle overlays on a map. Extends Polygon.

    + +
    +

    Usage example

    + +
    + + + + + +
    // define rectangle geographical bounds
    +var bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
    +
    +// create an orange rectangle
    +L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
    +
    +// zoom the map to the rectangle bounds
    +map.fitBounds(bounds);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.rectangle(<LatLngBounds> latLngBounds, <Polyline options> options?)
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    smoothFactorNumber1.0How much to simplify the polyline on each zoom level. More means +better performance and smoother look, and less means more accurate representation.
    noClipBooleanfalseDisable polyline clipping.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setBounds(<LatLngBounds> latLngBounds)this

    Redraws the rectangle with the passed bounds.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the polygon (as a GeoJSON Polygon or MultiPolygon Feature).

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getLatLngs()LatLng[]

    Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.

    +
    setLatLngs(<LatLng[]> latlngs)this

    Replaces all the points in the polyline with the given array of geographical points.

    +
    isEmpty()Boolean

    Returns true if the Polyline has no LatLngs.

    +
    closestLayerPoint(<Point> p)Point

    Returns the point closest to p on the Polyline.

    +
    getCenter()LatLng

    Returns the center (centroid) of the polyline.

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the path.

    +
    addLatLng(<LatLng> latlng, <LatLng[]> latlngs?)this

    Adds a given point to the polyline. By default, adds to the first ring of +the polyline in case of a multi-polyline, but can be overridden by passing +a specific ring as a LatLng array (that you can earlier access with getLatLngs).

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Circle

    A class for drawing circle overlays on a map. Extends CircleMarker.

    +

    It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion).

    + +
    +

    Usage example

    + +
    + + + + + +
    L.circle([50.5, 30.5], {radius: 200}).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.circle(<LatLng> latlng, <Circle options> options?)Instantiates a circle object given a geographical point, and an options object +which contains the circle radius.
    L.circle(<LatLng> latlng, <Number> radius, <Circle options> options?)Obsolete way of instantiating a circle, for compatibility with 0.7.x code. +Do not use in new applications or plugins.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    radiusNumberRadius of the circle, in meters.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    moveEventFired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setRadius(<Number> radius)this

    Sets the radius of a circle. Units are in meters.

    +
    getRadius()Number

    Returns the current radius of a circle. Units are in meters.

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the path.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

    +
    setLatLng(<LatLng> latLng)this

    Sets the position of a circle marker to a new location.

    +
    getLatLng()LatLng

    Returns the current geographical position of the circle marker

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    CircleMarker

    A circle of a fixed size with radius specified in pixels. Extends Path.

    + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.circleMarker(<LatLng> latlng, <CircleMarker options> options?)Instantiates a circle marker object given a geographical point, and an optional options object.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    radiusNumber10Radius of the circle marker, in pixels
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    strokeBooleantrueWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.
    colorString'#3388ff'Stroke color
    weightNumber3Stroke width in pixels
    opacityNumber1.0Stroke opacity
    lineCapString'round'A string that defines shape to be used at the end of the stroke.
    lineJoinString'round'A string that defines shape to be used at the corners of the stroke.
    dashArrayStringnullA string that defines the stroke dash pattern. Doesn't work on Canvas-powered layers in some old browsers.
    dashOffsetStringnullA string that defines the distance into the dash pattern to start the dash. Doesn't work on Canvas-powered layers in some old browsers.
    fillBooleandependsWhether to fill the path with color. Set it to false to disable filling on polygons or circles.
    fillColorString*Fill color. Defaults to the value of the color option
    fillOpacityNumber0.2Fill opacity.
    fillRuleString'evenodd'A string that defines how the inside of a shape is determined.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this path will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    rendererRendererUse this specific instance of Renderer for this path. Takes +precedence over the map's default renderer.
    classNameStringnullCustom class name set on an element. Only for SVG renderer.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    moveEventFired when the marker is moved via setLatLng. Old and new coordinates are included in event arguments as oldLatLng, latlng.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the circle marker (as a GeoJSON Point Feature).

    +
    setLatLng(<LatLng> latLng)this

    Sets the position of a circle marker to a new location.

    +
    getLatLng()LatLng

    Returns the current geographical position of the circle marker

    +
    setRadius(<Number> radius)this

    Sets the radius of a circle marker. Units are in pixels.

    +
    getRadius()Number

    Returns the current radius of the circle

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    redraw()this

    Redraws the layer. Sometimes useful after you changed the coordinates that the path uses.

    +
    setStyle(<Path options> style)this

    Changes the appearance of a Path based on the options in the Path options object.

    +
    bringToFront()this

    Brings the layer to the top of all path layers.

    +
    bringToBack()this

    Brings the layer to the bottom of all path layers.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    SVG

    VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility +with old versions of Internet Explorer.

    +

    Allows vector layers to be displayed with SVG. +Inherits Renderer.

    +

    Due to technical limitations, SVG is not +available in all web browsers, notably Android 2.x and 3.x.

    +

    Although SVG is not available on IE7 and IE8, these browsers support +VML +(a now deprecated technology), and the SVG renderer will fall back to VML in +this case.

    + +
    +

    Usage example

    + +
    + + + + + +

    Use SVG by default for all paths in the map:

    +
    var map = L.map('map', {
    +	renderer: L.svg()
    +});
    +
    +

    Use a SVG renderer with extra padding for specific vector geometries:

    +
    var map = L.map('map');
    +var myRenderer = L.svg({ padding: 0.5 });
    +var line = L.polyline( coordinates, { renderer: myRenderer } );
    +var circle = L.circle( center, { renderer: myRenderer } );
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.svg(<Renderer options> options?)Creates a SVG renderer with the given options.
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paddingNumber0.1How much to extend the clip area around the map view (relative to its size) +e.g. 0.1 would be 10% of map view in each direction
    toleranceNumber0How much to extend click tolerance round a path/object on the map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    updateEventFired when the renderer updates its bounds, center and zoom, for example when +its map has moved
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +
    +

    Functions

    + +
    + + + +
    There are several static functions which can be called without instantiating L.SVG:
    + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    create(<String> name)SVGElementReturns a instance of SVGElement, +corresponding to the class name passed. For example, using 'line' will return +an instance of SVGLineElement.
    pointsToPath(<Point[]> rings, <Boolean> closed)StringGenerates a SVG path string for multiple rings, with each ring turning +into "M..L..L.." instructions
    + +
    + + +

    Canvas

    Allows vector layers to be displayed with <canvas>. +Inherits Renderer.

    +

    Due to technical limitations, Canvas is not +available in all web browsers, notably IE8, and overlapping geometries might +not display properly in some edge cases.

    + +
    +

    Usage example

    + +
    + + + + + +

    Use Canvas by default for all paths in the map:

    +
    var map = L.map('map', {
    +	renderer: L.canvas()
    +});
    +
    +

    Use a Canvas renderer with extra padding for specific vector geometries:

    +
    var map = L.map('map');
    +var myRenderer = L.canvas({ padding: 0.5 });
    +var line = L.polyline( coordinates, { renderer: myRenderer } );
    +var circle = L.circle( center, { renderer: myRenderer } );
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.canvas(<Renderer options> options?)Creates a Canvas renderer with the given options.
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paddingNumber0.1How much to extend the clip area around the map view (relative to its size) +e.g. 0.1 would be 10% of map view in each direction
    toleranceNumber0How much to extend click tolerance round a path/object on the map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    updateEventFired when the renderer updates its bounds, center and zoom, for example when +its map has moved
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    LayerGroup

    Used to group several layers and handle them as one. If you add it to the map, +any layers added or removed from the group will be added/removed on the map as +well. Extends Layer.

    + +
    +

    Usage example

    + +
    + + + + + +
    L.layerGroup([marker1, marker2])
    +	.addLayer(polyline)
    +	.addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.layerGroup(<Layer[]> layers?, <Object> options?)Create a layer group, optionally given an initial set of layers and an options object.
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

    +
    addLayer(<Layer> layer)this

    Adds the given layer to the group.

    +
    removeLayer(<Layer> layer)this

    Removes the given layer from the group.

    +
    removeLayer(<Number> id)this

    Removes the layer with the given internal ID from the group.

    +
    hasLayer(<Layer> layer)Boolean

    Returns true if the given layer is currently added to the group.

    +
    hasLayer(<Number> id)Boolean

    Returns true if the given internal ID is currently added to the group.

    +
    clearLayers()this

    Removes all the layers from the group.

    +
    invoke(<String> methodName, )this

    Calls methodName on every layer contained in this group, passing any +additional parameters. Has no effect if the layers contained do not +implement methodName.

    +
    eachLayer(<Function> fn, <Object> context?)this

    Iterates over the layers of the group, optionally specifying context of the iterator function.

    +
    group.eachLayer(function (layer) {
    +	layer.bindPopup('Hello');
    +});
    +
    +
    getLayer(<Number> id)Layer

    Returns the layer with the given internal ID.

    +
    getLayers()Layer[]

    Returns an array of all the layers added to the group.

    +
    setZIndex(<Number> zIndex)this

    Calls setZIndex on every layer contained in this group, passing the z-index.

    +
    getLayerId(<Layer> layer)Number

    Returns the internal ID for a layer

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    FeatureGroup

    Extended LayerGroup that makes it easier to do the same thing to all its member layers:

    + + +
    +

    Usage example

    + +
    + + + + + +
    L.featureGroup([marker1, marker2, polyline])
    +	.bindPopup('Hello world!')
    +	.on('click', function() { alert('Clicked on a member of the group!'); })
    +	.addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.featureGroup(<Layer[]> layers?, <Object> options?)Create a feature group, optionally given an initial set of layers and an options object.
    + +
    + + +
    +

    Options

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    layeraddLayerEventFired when a layer is added to this FeatureGroup
    layerremoveLayerEventFired when a layer is removed from this FeatureGroup
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setStyle(<Path options> style)this

    Sets the given path options to each layer of the group that has a setStyle method.

    +
    bringToFront()this

    Brings the layer group to the top of all other layers

    +
    bringToBack()this

    Brings the layer group to the back of all other layers

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

    +
    addLayer(<Layer> layer)this

    Adds the given layer to the group.

    +
    removeLayer(<Layer> layer)this

    Removes the given layer from the group.

    +
    removeLayer(<Number> id)this

    Removes the layer with the given internal ID from the group.

    +
    hasLayer(<Layer> layer)Boolean

    Returns true if the given layer is currently added to the group.

    +
    hasLayer(<Number> id)Boolean

    Returns true if the given internal ID is currently added to the group.

    +
    clearLayers()this

    Removes all the layers from the group.

    +
    invoke(<String> methodName, )this

    Calls methodName on every layer contained in this group, passing any +additional parameters. Has no effect if the layers contained do not +implement methodName.

    +
    eachLayer(<Function> fn, <Object> context?)this

    Iterates over the layers of the group, optionally specifying context of the iterator function.

    +
    group.eachLayer(function (layer) {
    +	layer.bindPopup('Hello');
    +});
    +
    +
    getLayer(<Number> id)Layer

    Returns the layer with the given internal ID.

    +
    getLayers()Layer[]

    Returns an array of all the layers added to the group.

    +
    setZIndex(<Number> zIndex)this

    Calls setZIndex on every layer contained in this group, passing the z-index.

    +
    getLayerId(<Layer> layer)Number

    Returns the internal ID for a layer

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    GeoJSON

    Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse +GeoJSON data and display it on the map. Extends FeatureGroup.

    + +
    +

    Usage example

    + +
    + + + + + +
    L.geoJSON(data, {
    +	style: function (feature) {
    +		return {color: feature.properties.color};
    +	}
    +}).bindPopup(function (layer) {
    +	return layer.feature.properties.description;
    +}).addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.geoJSON(<Object> geojson?, <GeoJSON options> options?)Creates a GeoJSON layer. Optionally accepts an object in +GeoJSON format to display on the map +(you can alternatively add it later with addData method) and an options object.
    + +
    + + +
    +

    Options

    + +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    pointToLayerFunction*A Function defining how GeoJSON points spawn Leaflet layers. It is internally +called when data is added, passing the GeoJSON point feature and its LatLng. +The default is to spawn a default Marker: +
    function(geoJsonPoint, latlng) {
    +	return L.marker(latlng);
    +}
    +
    styleFunction*A Function defining the Path options for styling GeoJSON lines and polygons, +called internally when data is added. +The default value is to not override any defaults: +
    function (geoJsonFeature) {
    +	return {}
    +}
    +
    onEachFeatureFunction*A Function that will be called once for each created Feature, after it has +been created and styled. Useful for attaching events and popups to features. +The default is to do nothing with the newly created layers: +
    function (feature, layer) {}
    +
    filterFunction*A Function that will be used to decide whether to include a feature or not. +The default is to include all features: +
    function (geoJsonFeature) {
    +	return true;
    +}
    +
    +

    Note: dynamically changing the filter option will have effect only on newly +added data. It will not re-evaluate already included features.

    coordsToLatLngFunction*A Function that will be used for converting GeoJSON coordinates to LatLngs. +The default is the coordsToLatLng static method.
    markersInheritOptionsBooleanfalseWhether default Markers for "Point" type Features inherit from group options.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    layeraddLayerEventFired when a layer is added to this FeatureGroup
    layerremoveLayerEventFired when a layer is removed from this FeatureGroup
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addData(data)this

    Adds a GeoJSON object to the layer.

    +
    resetStyle(layer?)this

    Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. +If layer is omitted, the style of all features in the current layer is reset.

    +
    setStyle(style)this

    Changes styles of GeoJSON vector layers with the given style function.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bringToFront()this

    Brings the layer group to the top of all other layers

    +
    bringToBack()this

    Brings the layer group to the back of all other layers

    +
    getBounds()LatLngBounds

    Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children).

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    toGeoJSON(<Number> precision?)Object

    precision is the number of decimal places for coordinates. +The default value is 6 places. +Returns a GeoJSON representation of the layer group (as a GeoJSON FeatureCollection, GeometryCollection, or MultiPoint).

    +
    addLayer(<Layer> layer)this

    Adds the given layer to the group.

    +
    removeLayer(<Layer> layer)this

    Removes the given layer from the group.

    +
    removeLayer(<Number> id)this

    Removes the layer with the given internal ID from the group.

    +
    hasLayer(<Layer> layer)Boolean

    Returns true if the given layer is currently added to the group.

    +
    hasLayer(<Number> id)Boolean

    Returns true if the given internal ID is currently added to the group.

    +
    clearLayers()this

    Removes all the layers from the group.

    +
    invoke(<String> methodName, )this

    Calls methodName on every layer contained in this group, passing any +additional parameters. Has no effect if the layers contained do not +implement methodName.

    +
    eachLayer(<Function> fn, <Object> context?)this

    Iterates over the layers of the group, optionally specifying context of the iterator function.

    +
    group.eachLayer(function (layer) {
    +	layer.bindPopup('Hello');
    +});
    +
    +
    getLayer(<Number> id)Layer

    Returns the layer with the given internal ID.

    +
    getLayers()Layer[]

    Returns an array of all the layers added to the group.

    +
    setZIndex(<Number> zIndex)this

    Calls setZIndex on every layer contained in this group, passing the z-index.

    +
    getLayerId(<Layer> layer)Number

    Returns the internal ID for a layer

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +
    +

    Functions

    + +
    + + + +
    There are several static functions which can be called without instantiating L.GeoJSON:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    geometryToLayer(<Object> featureData, <GeoJSON options> options?)LayerCreates a Layer from a given GeoJSON feature. Can use a custom +pointToLayer and/or coordsToLatLng +functions if provided as options.
    coordsToLatLng(<Array> coords)LatLngCreates a LatLng object from an array of 2 numbers (longitude, latitude) +or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
    coordsToLatLngs(<Array> coords, <Number> levelsDeep?, <Function> coordsToLatLng?)ArrayCreates a multidimensional array of LatLngs from a GeoJSON coordinates array. +levelsDeep specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). +Can use a custom coordsToLatLng function.
    latLngToCoords(<LatLng> latlng, <Number> precision?)ArrayReverse of coordsToLatLng
    latLngsToCoords(<Array> latlngs, <Number> levelsDeep?, <Boolean> closed?)ArrayReverse of coordsToLatLngs +closed determines whether the first point should be appended to the end of the array to close the feature, only used when levelsDeep is 0. False by default.
    asFeature(<Object> geojson)ObjectNormalize GeoJSON geometries/features into GeoJSON features.
    + +
    + + +

    GridLayer

    Generic class for handling a tiled grid of HTML elements. This is the base class for all tile layers and replaces TileLayer.Canvas. +GridLayer can be extended to create a tiled grid of HTML elements like <canvas>, <img> or <div>. GridLayer will handle creating and animating these DOM elements for you.

    + +
    +

    Usage example

    + +
    + +

    Synchronous usage

    + + + +

    To create a custom layer, extend GridLayer and implement the createTile() method, which will be passed a Point object with the x, y, and z (zoom level) coordinates to draw your tile.

    +
    var CanvasLayer = L.GridLayer.extend({
    +    createTile: function(coords){
    +        // create a <canvas> element for drawing
    +        var tile = L.DomUtil.create('canvas', 'leaflet-tile');
    +
    +        // setup tile width and height according to the options
    +        var size = this.getTileSize();
    +        tile.width = size.x;
    +        tile.height = size.y;
    +
    +        // get a canvas context and draw something on it using coords.x, coords.y and coords.z
    +        var ctx = tile.getContext('2d');
    +
    +        // return the tile so it can be rendered on screen
    +        return tile;
    +    }
    +});
    +
    + + + +
    + +

    Asynchronous usage

    + + + +

    Tile creation can also be asynchronous, this is useful when using a third-party drawing library. Once the tile is finished drawing it can be passed to the done() callback.

    +
    var CanvasLayer = L.GridLayer.extend({
    +    createTile: function(coords, done){
    +        var error;
    +
    +        // create a <canvas> element for drawing
    +        var tile = L.DomUtil.create('canvas', 'leaflet-tile');
    +
    +        // setup tile width and height according to the options
    +        var size = this.getTileSize();
    +        tile.width = size.x;
    +        tile.height = size.y;
    +
    +        // draw something asynchronously and pass the tile to the done() callback
    +        setTimeout(function() {
    +            done(error, tile);
    +        }, 1000);
    +
    +        return tile;
    +    }
    +});
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.gridLayer(<GridLayer options> options?)Creates a new instance of GridLayer with the supplied options.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    tileSizeNumber|Point256Width and height of tiles in the grid. Use a number if width and height are equal, or L.point(width, height) otherwise.
    opacityNumber1.0Opacity of the tiles. Can be used in the createTile() function.
    updateWhenIdleBoolean(depends)Load new tiles only when panning ends. +true by default on mobile browsers, in order to avoid too many requests and keep smooth navigation. +false otherwise in order to display new tiles during panning, since it is easy to pan outside the +keepBuffer option in desktop browsers.
    updateWhenZoomingBooleantrueBy default, a smooth zoom animation (during a touch zoom or a flyTo()) will update grid layers every integer zoom level. Setting this option to false will update the grid layer only when the smooth animation ends.
    updateIntervalNumber200Tiles will not update more than once every updateInterval milliseconds when panning.
    zIndexNumber1The explicit zIndex of the tile layer.
    boundsLatLngBoundsundefinedIf set, tiles will only be loaded inside the set LatLngBounds.
    minZoomNumber0The minimum zoom level down to which this layer will be displayed (inclusive).
    maxZoomNumberundefinedThe maximum zoom level up to which this layer will be displayed (inclusive).
    maxNativeZoomNumberundefinedMaximum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels higher than maxNativeZoom will be loaded +from maxNativeZoom level and auto-scaled.
    minNativeZoomNumberundefinedMinimum zoom number the tile source has available. If it is specified, +the tiles on all zoom levels lower than minNativeZoom will be loaded +from minNativeZoom level and auto-scaled.
    noWrapBooleanfalseWhether the layer is wrapped around the antimeridian. If true, the +GridLayer will only be displayed once at low zoom levels. Has no +effect when the map CRS doesn't wrap around. Can be used +in combination with bounds to prevent requesting +tiles outside the CRS limits.
    paneString'tilePane'Map pane where the grid layer will be added.
    classNameString''A custom class name to assign to the tile layer. Empty by default.
    keepBufferNumber2When panning the map, keep this many rows and columns of tiles before unloading them.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    loadingEventFired when the grid layer starts loading tiles.
    tileunloadTileEventFired when a tile is removed (e.g. when a tile goes off the screen).
    tileloadstartTileEventFired when a tile is requested and starts loading.
    tileerrorTileErrorEventFired when there is an error loading a tile.
    tileloadTileEventFired when a tile loads.
    loadEventFired when the grid layer loaded all visible tiles.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bringToFront()this

    Brings the tile layer to the top of all tile layers.

    +
    bringToBack()this

    Brings the tile layer to the bottom of all tile layers.

    +
    getContainer()HTMLElement

    Returns the HTML element that contains the tiles for this layer.

    +
    setOpacity(<Number> opacity)this

    Changes the opacity of the grid layer.

    +
    setZIndex(<Number> zIndex)this

    Changes the zIndex of the grid layer.

    +
    isLoading()Boolean

    Returns true if any tile in the grid layer has not finished loading.

    +
    redraw()this

    Causes the layer to clear all the tiles and request them again.

    +
    getTileSize()Point

    Normalizes the tileSize option into a point. Used by the createTile() method.

    +
    + +
    + +

    Extension methods

    + +
    Layers extending GridLayer shall reimplement the following method.
    + + + + + + + + + + + + + +
    MethodReturnsDescription
    createTile(<Object> coords, <Function> done?)HTMLElement

    Called only internally, must be overridden by classes extending GridLayer. +Returns the HTMLElement corresponding to the given coords. If the done callback +is specified, it must be called when the tile has finished loading and drawing.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    LatLng

    Represents a geographical point with a certain latitude and longitude.

    + +
    +

    Usage example

    + +
    + + + + + +
    var latlng = L.latLng(50.5, 30.5);
    +
    +

    All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:

    +
    map.panTo([50, 30]);
    +map.panTo({lon: 30, lat: 50});
    +map.panTo({lat: 50, lng: 30});
    +map.panTo(L.latLng(50, 30));
    +
    +

    Note that LatLng does not inherit from Leaflet's Class object, +which means new classes can't inherit from it, and new methods +can't be added to it with the include function.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.latLng(<Number> latitude, <Number> longitude, <Number> altitude?)Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).
    L.latLng(<Array> coords)Expects an array of the form [Number, Number] or [Number, Number, Number] instead.
    L.latLng(<Object> coords)Expects an plain object of the form {lat: Number, lng: Number} or {lat: Number, lng: Number, alt: Number} instead.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    equals(<LatLng> otherLatLng, <Number> maxMargin?)Boolean

    Returns true if the given LatLng point is at the same position (within a small margin of error). The margin of error can be overridden by setting maxMargin to a small number.

    +
    toString()String

    Returns a string representation of the point (for debugging purposes).

    +
    distanceTo(<LatLng> otherLatLng)Number

    Returns the distance (in meters) to the given LatLng calculated using the Spherical Law of Cosines.

    +
    wrap()LatLng

    Returns a new LatLng object with the longitude wrapped so it's always between -180 and +180 degrees.

    +
    toBounds(<Number> sizeInMeters)LatLngBounds

    Returns a new LatLngBounds object in which each boundary is sizeInMeters/2 meters apart from the LatLng.

    +
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    latNumberLatitude in degrees
    lngNumberLongitude in degrees
    altNumberAltitude in meters (optional)
    + +
    + + +

    LatLngBounds

    Represents a rectangular geographical area on a map.

    + +
    +

    Usage example

    + +
    + + + + + +
    var corner1 = L.latLng(40.712, -74.227),
    +corner2 = L.latLng(40.774, -74.125),
    +bounds = L.latLngBounds(corner1, corner2);
    +
    +

    All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

    +
    map.fitBounds([
    +	[40.712, -74.227],
    +	[40.774, -74.125]
    +]);
    +
    +

    Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners outside the [-180, 180] degrees longitude range.

    +

    Note that LatLngBounds does not inherit from Leaflet's Class object, +which means new classes can't inherit from it, and new methods +can't be added to it with the include function.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.latLngBounds(<LatLng> corner1, <LatLng> corner2)Creates a LatLngBounds object by defining two diagonally opposite corners of the rectangle.
    L.latLngBounds(<LatLng[]> latlngs)Creates a LatLngBounds object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with fitBounds.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    extend(<LatLng> latlng)this

    Extend the bounds to contain the given point

    +
    extend(<LatLngBounds> otherBounds)this

    Extend the bounds to contain the given bounds

    +
    pad(<Number> bufferRatio)LatLngBounds

    Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. +For example, a ratio of 0.5 extends the bounds by 50% in each direction. +Negative values will retract the bounds.

    +
    getCenter()LatLng

    Returns the center point of the bounds.

    +
    getSouthWest()LatLng

    Returns the south-west point of the bounds.

    +
    getNorthEast()LatLng

    Returns the north-east point of the bounds.

    +
    getNorthWest()LatLng

    Returns the north-west point of the bounds.

    +
    getSouthEast()LatLng

    Returns the south-east point of the bounds.

    +
    getWest()Number

    Returns the west longitude of the bounds

    +
    getSouth()Number

    Returns the south latitude of the bounds

    +
    getEast()Number

    Returns the east longitude of the bounds

    +
    getNorth()Number

    Returns the north latitude of the bounds

    +
    contains(<LatLngBounds> otherBounds)Boolean

    Returns true if the rectangle contains the given one.

    +
    contains(<LatLng> latlng)Boolean

    Returns true if the rectangle contains the given point.

    +
    intersects(<LatLngBounds> otherBounds)Boolean

    Returns true if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.

    +
    overlaps(<LatLngBounds> otherBounds)Boolean

    Returns true if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.

    +
    toBBoxString()String

    Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.

    +
    equals(<LatLngBounds> otherBounds, <Number> maxMargin?)Boolean

    Returns true if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting maxMargin to a small number.

    +
    isValid()Boolean

    Returns true if the bounds are properly initialized.

    +
    + +
    + + +

    Point

    Represents a point with x and y coordinates in pixels.

    + +
    +

    Usage example

    + +
    + + + + + +
    var point = L.point(200, 300);
    +
    +

    All Leaflet methods and options that accept Point objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:

    +
    map.panBy([200, 300]);
    +map.panBy(L.point(200, 300));
    +
    +

    Note that Point does not inherit from Leaflet's Class object, +which means new classes can't inherit from it, and new methods +can't be added to it with the include function.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.point(<Number> x, <Number> y, <Boolean> round?)Creates a Point object with the given x and y coordinates. If optional round is set to true, rounds the x and y values.
    L.point(<Number[]> coords)Expects an array of the form [x, y] instead.
    L.point(<Object> coords)Expects a plain object of the form {x: Number, y: Number} instead.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    clone()Point

    Returns a copy of the current point.

    +
    add(<Point> otherPoint)Point

    Returns the result of addition of the current and the given points.

    +
    subtract(<Point> otherPoint)Point

    Returns the result of subtraction of the given point from the current.

    +
    divideBy(<Number> num)Point

    Returns the result of division of the current point by the given number.

    +
    multiplyBy(<Number> num)Point

    Returns the result of multiplication of the current point by the given number.

    +
    scaleBy(<Point> scale)Point

    Multiply each coordinate of the current point by each coordinate of +scale. In linear algebra terms, multiply the point by the +scaling matrix +defined by scale.

    +
    unscaleBy(<Point> scale)Point

    Inverse of scaleBy. Divide each coordinate of the current point by +each coordinate of scale.

    +
    round()Point

    Returns a copy of the current point with rounded coordinates.

    +
    floor()Point

    Returns a copy of the current point with floored coordinates (rounded down).

    +
    ceil()Point

    Returns a copy of the current point with ceiled coordinates (rounded up).

    +
    trunc()Point

    Returns a copy of the current point with truncated coordinates (rounded towards zero).

    +
    distanceTo(<Point> otherPoint)Number

    Returns the cartesian distance between the current and the given points.

    +
    equals(<Point> otherPoint)Boolean

    Returns true if the given point has the same coordinates.

    +
    contains(<Point> otherPoint)Boolean

    Returns true if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).

    +
    toString()String

    Returns a string representation of the point for debugging purposes.

    +
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    xNumberThe x coordinate of the point
    yNumberThe y coordinate of the point
    + +
    + + +

    Bounds

    Represents a rectangular area in pixel coordinates.

    + +
    +

    Usage example

    + +
    + + + + + +
    var p1 = L.point(10, 10),
    +p2 = L.point(40, 60),
    +bounds = L.bounds(p1, p2);
    +
    +

    All Leaflet methods that accept Bounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:

    +
    otherBounds.intersects([[10, 10], [40, 60]]);
    +
    +

    Note that Bounds does not inherit from Leaflet's Class object, +which means new classes can't inherit from it, and new methods +can't be added to it with the include function.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.bounds(<Point> corner1, <Point> corner2)Creates a Bounds object from two corners coordinate pairs.
    L.bounds(<Point[]> points)Creates a Bounds object from the given array of points.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    extend(<Point> point)this

    Extends the bounds to contain the given point.

    +
    getCenter(<Boolean> round?)Point

    Returns the center point of the bounds.

    +
    getBottomLeft()Point

    Returns the bottom-left point of the bounds.

    +
    getTopRight()Point

    Returns the top-right point of the bounds.

    +
    getTopLeft()Point

    Returns the top-left point of the bounds (i.e. this.min).

    +
    getBottomRight()Point

    Returns the bottom-right point of the bounds (i.e. this.max).

    +
    getSize()Point

    Returns the size of the given bounds

    +
    contains(<Bounds> otherBounds)Boolean

    Returns true if the rectangle contains the given one.

    +
    contains(<Point> point)Boolean

    Returns true if the rectangle contains the given point.

    +
    intersects(<Bounds> otherBounds)Boolean

    Returns true if the rectangle intersects the given bounds. Two bounds +intersect if they have at least one point in common.

    +
    overlaps(<Bounds> otherBounds)Boolean

    Returns true if the rectangle overlaps the given bounds. Two bounds +overlap if their intersection is an area.

    +
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    minPointThe top left corner of the rectangle.
    maxPointThe bottom right corner of the rectangle.
    + +
    + + +

    Icon

    Represents an icon to provide when creating a marker.

    + +
    +

    Usage example

    + +
    + + + + + +
    var myIcon = L.icon({
    +    iconUrl: 'my-icon.png',
    +    iconSize: [38, 95],
    +    iconAnchor: [22, 94],
    +    popupAnchor: [-3, -76],
    +    shadowUrl: 'my-icon-shadow.png',
    +    shadowSize: [68, 95],
    +    shadowAnchor: [22, 94]
    +});
    +
    +L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
    +
    +

    L.Icon.Default extends L.Icon and is the blue icon Leaflet uses for markers by default.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.icon(<Icon options> options)Creates an icon instance with the given options.
    + +
    + + +
    +

    Options

    + +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    iconUrlStringnull(required) The URL to the icon image (absolute or relative to your script path).
    iconRetinaUrlStringnullThe URL to a retina sized version of the icon image (absolute or relative to your +script path). Used for Retina screen devices.
    iconSizePointnullSize of the icon image in pixels.
    iconAnchorPointnullThe coordinates of the "tip" of the icon (relative to its top left corner). The icon +will be aligned so that this point is at the marker's geographical location. Centered +by default if size is specified, also can be set in CSS with negative margins.
    popupAnchorPoint[0, 0]The coordinates of the point from which popups will "open", relative to the icon anchor.
    tooltipAnchorPoint[0, 0]The coordinates of the point from which tooltips will "open", relative to the icon anchor.
    shadowUrlStringnullThe URL to the icon shadow image. If not specified, no shadow image will be created.
    shadowRetinaUrlStringnull
    shadowSizePointnullSize of the shadow image in pixels.
    shadowAnchorPointnullThe coordinates of the "tip" of the shadow (relative to its top left corner) (the same +as iconAnchor if not specified).
    classNameString''A custom class name to assign to both icon and shadow images. Empty by default.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    createIcon(<HTMLElement> oldIcon?)HTMLElement

    Called internally when the icon has to be shown, returns a <img> HTML element +styled according to the options.

    +
    createShadow(<HTMLElement> oldIcon?)HTMLElement

    As createIcon, but for the shadow beneath it.

    +
    + +
    + + +
    + +
    +

    Icon.Default

    + +
    + + + +
    A trivial subclass of Icon, represents the icon to use in Markers when +no icon is specified. Points to the blue marker image distributed with Leaflet +releases. +

    In order to customize the default icon, just change the properties of L.Icon.Default.prototype.options +(which is a set of Icon options).

    +

    If you want to completely replace the default icon, override the +L.Marker.prototype.options.icon with your own icon instead.

    + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    imagePathStringIcon.Default will try to auto-detect the location of the +blue icon images. If you are placing these images in a non-standard +way, set this option to point to the right path.
    + +
    + + +

    DivIcon

    Represents a lightweight icon for markers that uses a simple <div> +element instead of an image. Inherits from Icon but ignores the iconUrl and shadow options.

    + +
    +

    Usage example

    + +
    + + + + + +
    var myIcon = L.divIcon({className: 'my-div-icon'});
    +// you can set .my-div-icon styles in CSS
    +
    +L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
    +
    +

    By default, it has a 'leaflet-div-icon' CSS class and is styled as a little white square with a shadow.

    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.divIcon(<DivIcon options> options)Creates a DivIcon instance with the given options.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    htmlString|HTMLElement''Custom HTML code to put inside the div element, empty by default. Alternatively, +an instance of HTMLElement.
    bgPosPoint[0, 0]Optional relative position of the background, in pixels
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    iconUrlStringnull(required) The URL to the icon image (absolute or relative to your script path).
    iconRetinaUrlStringnullThe URL to a retina sized version of the icon image (absolute or relative to your +script path). Used for Retina screen devices.
    iconSizePointnullSize of the icon image in pixels.
    iconAnchorPointnullThe coordinates of the "tip" of the icon (relative to its top left corner). The icon +will be aligned so that this point is at the marker's geographical location. Centered +by default if size is specified, also can be set in CSS with negative margins.
    popupAnchorPoint[0, 0]The coordinates of the point from which popups will "open", relative to the icon anchor.
    tooltipAnchorPoint[0, 0]The coordinates of the point from which tooltips will "open", relative to the icon anchor.
    shadowUrlStringnullThe URL to the icon shadow image. If not specified, no shadow image will be created.
    shadowRetinaUrlStringnull
    shadowSizePointnullSize of the shadow image in pixels.
    shadowAnchorPointnullThe coordinates of the "tip" of the shadow (relative to its top left corner) (the same +as iconAnchor if not specified).
    classNameString''A custom class name to assign to both icon and shadow images. Empty by default.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    createIcon(<HTMLElement> oldIcon?)HTMLElement

    Called internally when the icon has to be shown, returns a <img> HTML element +styled according to the options.

    +
    createShadow(<HTMLElement> oldIcon?)HTMLElement

    As createIcon, but for the shadow beneath it.

    +
    + +
    +
    +
    + +

    Control.Zoom

    A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its zoomControl option to false. Extends Control.

    + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.control.zoom(<Control.Zoom options> options)Creates a zoom control
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    zoomInTextString'+'The text set on the 'zoom in' button.
    zoomInTitleString'Zoom in'The title set on the 'zoom in' button.
    zoomOutTextString'&#x2212' +The text set on the 'zoom out' button.
    zoomOutTitleString'Zoom out'The title set on the 'zoom out' button.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', +'topright', 'bottomleft' or 'bottomright'
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getPosition()string

    Returns the position of the control.

    +
    setPosition(<string> position)this

    Sets the position of the control.

    +
    getContainer()HTMLElement

    Returns the HTMLElement that contains the control.

    +
    addTo(<Map> map)this

    Adds the control to the given map.

    +
    remove()this

    Removes the control from the map it is currently active on.

    +
    + +
    +
    +
    + +

    Control.Attribution

    The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its attributionControl option to false, and it fetches attribution texts from layers with the getAttribution method automatically. Extends Control.

    + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.control.attribution(<Control.Attribution options> options)Creates an attribution control.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    prefixString'Leaflet'The HTML text shown before the attributions. Pass false to disable.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', +'topright', 'bottomleft' or 'bottomright'
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    setPrefix(<String> prefix)this

    Sets the text before the attributions.

    +
    addAttribution(<String> text)this

    Adds an attribution text (e.g. 'Vector data &copy; Mapbox').

    +
    removeAttribution(<String> text)this

    Removes an attribution text.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getPosition()string

    Returns the position of the control.

    +
    setPosition(<string> position)this

    Sets the position of the control.

    +
    getContainer()HTMLElement

    Returns the HTMLElement that contains the control.

    +
    addTo(<Map> map)this

    Adds the control to the given map.

    +
    remove()this

    Removes the control from the map it is currently active on.

    +
    + +
    +
    +
    + +

    Control.Layers

    The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the detailed example). Extends Control.

    + +
    +

    Usage example

    + +
    + + + + + +
    var baseLayers = {
    +	"Mapbox": mapbox,
    +	"OpenStreetMap": osm
    +};
    +
    +var overlays = {
    +	"Marker": marker,
    +	"Roads": roadsLayer
    +};
    +
    +L.control.layers(baseLayers, overlays).addTo(map);
    +
    +

    The baseLayers and overlays parameters are object literals with layer names as keys and Layer objects as values:

    +
    {
    +    "<someName1>": layer1,
    +    "<someName2>": layer2
    +}
    +
    +

    The layer names can contain HTML, which allows you to add additional styling to the items:

    +
    {"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>": myLayer}
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.control.layers(<Object> baselayers?, <Object> overlays?, <Control.Layers options> options?)Creates a layers control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    collapsedBooleantrueIf true, the control will be collapsed into an icon and expanded on mouse hover or touch.
    autoZIndexBooleantrueIf true, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off.
    hideSingleBaseBooleanfalseIf true, the base layers in the control will be hidden when there is only one.
    sortLayersBooleanfalseWhether to sort the layers. When false, layers will keep the order +in which they were added to the control.
    sortFunctionFunction*A compare function +that will be used for sorting the layers, when sortLayers is true. +The function receives both the L.Layer instances and their names, as in +sortFunction(layerA, layerB, nameA, nameB). +By default, it sorts layers alphabetically by their name.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', +'topright', 'bottomleft' or 'bottomright'
    + +
    +
    +
    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addBaseLayer(<Layer> layer, <String> name)this

    Adds a base layer (radio button entry) with the given name to the control.

    +
    addOverlay(<Layer> layer, <String> name)this

    Adds an overlay (checkbox entry) with the given name to the control.

    +
    removeLayer(<Layer> layer)this

    Remove the given layer from the control.

    +
    expand()this

    Expand the control container if collapsed.

    +
    collapse()this

    Collapse the control container if expanded.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getPosition()string

    Returns the position of the control.

    +
    setPosition(<string> position)this

    Sets the position of the control.

    +
    getContainer()HTMLElement

    Returns the HTMLElement that contains the control.

    +
    addTo(<Map> map)this

    Adds the control to the given map.

    +
    remove()this

    Removes the control from the map it is currently active on.

    +
    + +
    +
    +
    + +

    Control.Scale

    A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends Control.

    + +
    +

    Usage example

    + +
    + + + + + +
    L.control.scale().addTo(map);
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + +
    FactoryDescription
    L.control.scale(<Control.Scale options> options?)Creates an scale control with the given options.
    + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    maxWidthNumber100Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500).
    metricBooleanTrueWhether to show the metric scale line (m/km).
    imperialBooleanTrueWhether to show the imperial scale line (mi/ft).
    updateWhenIdleBooleanfalseIf true, the control is updated on moveend, otherwise it's always up-to-date (updated on move).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', +'topright', 'bottomleft' or 'bottomright'
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getPosition()string

    Returns the position of the control.

    +
    setPosition(<string> position)this

    Sets the position of the control.

    +
    getContainer()HTMLElement

    Returns the HTMLElement that contains the control.

    +
    addTo(<Map> map)this

    Adds the control to the given map.

    +
    remove()this

    Removes the control from the map it is currently active on.

    +
    + +
    +
    +
    + +

    Browser

    A namespace with static properties for browser/feature detection used by Leaflet internally.

    + +
    +

    Usage example

    + +
    + + + + + +
    if (L.Browser.ielt9) {
    +  alert('Upgrade your browser, dude!');
    +}
    +
    + + + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    ieBooleantrue for all Internet Explorer versions (not Edge).
    ielt9Booleantrue for Internet Explorer versions less than 9.
    edgeBooleantrue for the Edge web browser.
    webkitBooleantrue for webkit-based browsers like Chrome and Safari (including mobile versions).
    androidBooleantrue for any browser running on an Android platform.
    android23Booleantrue for browsers running on Android 2 or Android 3.
    androidStockBooleantrue for the Android stock browser (i.e. not Chrome)
    operaBooleantrue for the Opera browser
    chromeBooleantrue for the Chrome browser.
    geckoBooleantrue for gecko-based browsers like Firefox.
    safariBooleantrue for the Safari browser.
    opera12Booleantrue for the Opera browser supporting CSS transforms (version 12 or later).
    winBooleantrue when the browser is running in a Windows platform
    ie3dBooleantrue for all Internet Explorer versions supporting CSS transforms.
    webkit3dBooleantrue for webkit-based browsers supporting CSS transforms.
    gecko3dBooleantrue for gecko-based browsers supporting CSS transforms.
    any3dBooleantrue for all browsers supporting CSS transforms.
    mobileBooleantrue for all browsers running in a mobile device.
    mobileWebkitBooleantrue for all webkit-based browsers in a mobile device.
    mobileWebkit3dBooleantrue for all webkit-based browsers in a mobile device supporting CSS transforms.
    msPointerBooleantrue for browsers implementing the Microsoft touch events model (notably IE10).
    pointerBooleantrue for all browsers supporting pointer events.
    touchBooleantrue for all browsers supporting touch events. +This does not necessarily mean that the browser is running in a computer with +a touchscreen, it only means that the browser is capable of understanding +touch events.
    mobileOperaBooleantrue for the Opera browser in a mobile device.
    mobileGeckoBooleantrue for gecko-based browsers running in a mobile device.
    retinaBooleantrue for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%.
    passiveEventsBooleantrue for browsers that support passive events.
    canvasBooleantrue when the browser supports <canvas>.
    svgBooleantrue when the browser supports SVG.
    vmlBooleantrue if the browser supports VML.
    + +
    + + +

    Util

    Various utility functions, used by Leaflet internally.

    + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    extend(<Object> dest, <Object> src?)ObjectMerges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut.
    create(<Object> proto, <Object> properties?)ObjectCompatibility polyfill for Object.create
    bind(<Function> fn, )FunctionReturns a new function bound to the arguments passed, like Function.prototype.bind. +Has a L.bind() shortcut.
    stamp(<Object> obj)NumberReturns the unique ID of an object, assigning it one if it doesn't have it.
    throttle(<Function> fn, <Number> time, <Object> context)FunctionReturns a function which executes function fn with the given scope context +(so that the this keyword refers to context inside fn's code). The function +fn will be called no more than one time per given amount of time. The arguments +received by the bound function will be any arguments passed when binding the +function, followed by any arguments passed when invoking the bound function. +Has an L.throttle shortcut.
    wrapNum(<Number> num, <Number[]> range, <Boolean> includeMax?)NumberReturns the number num modulo range in such a way so it lies within +range[0] and range[1]. The returned value will be always smaller than +range[1] unless includeMax is set to true.
    falseFn()FunctionReturns a function which always returns false.
    formatNum(<Number> num, <Number> digits?)NumberReturns the number num rounded to digits decimals, or to 6 decimals by default.
    trim(<String> str)StringCompatibility polyfill for String.prototype.trim
    splitWords(<String> str)String[]Trims and splits the string on whitespace and returns the array of parts.
    setOptions(<Object> obj, <Object> options)ObjectMerges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut.
    getParamString(<Object> obj, <String> existingUrl?, <Boolean> uppercase?)StringConverts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} +translates to '?a=foo&b=bar'. If existingUrl is set, the parameters will +be appended at the end. If uppercase is true, the parameter names will +be uppercased (e.g. '?A=foo&B=bar')
    template(<String> str, <Object> data)StringSimple templating facility, accepts a template string of the form 'Hello {a}, {b}' +and a data object like {a: 'foo', b: 'bar'}, returns evaluated string +('Hello foo, bar'). You can also specify functions instead of strings for +data values — they will be evaluated passing data as an argument.
    isArray(obj)BooleanCompatibility polyfill for Array.isArray
    indexOf(<Array> array, <Object> el)NumberCompatibility polyfill for Array.prototype.indexOf
    requestAnimFrame(<Function> fn, <Object> context?, <Boolean> immediate?)NumberSchedules fn to be executed when the browser repaints. fn is bound to +context if given. When immediate is set, fn is called immediately if +the browser doesn't have native support for +window.requestAnimationFrame, +otherwise it's delayed. Returns a request ID that can be used to cancel the request.
    cancelAnimFrame(<Number> id)undefinedCancels a previous requestAnimFrame. See also window.cancelAnimationFrame.
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    lastIdNumberLast unique ID used by stamp()
    emptyImageUrlStringData URI string containing a base64-encoded empty GIF image. +Used as a hack to free memory from unused images on WebKit-powered +mobile devices (by setting image src to this string).
    + +
    + + +

    Transformation

    Represents an affine transformation: a set of coefficients a, b, c, d +for transforming a point of a form (x, y) into (a*x + b, c*y + d) and doing +the reverse. Used by Leaflet in its projections code.

    + +
    +

    Usage example

    + +
    + + + + + +
    var transformation = L.transformation(2, 5, -1, 10),
    +	p = L.point(1, 2),
    +	p2 = transformation.transform(p), //  L.point(7, 8)
    +	p3 = transformation.untransform(p2); //  L.point(1, 2)
    +
    + + + +
    + + +
    +

    Creation

    + +
    + + + + + + + + + + + + + + + + + + +
    FactoryDescription
    L.transformation(<Number> a, <Number> b, <Number> c, <Number> d)Instantiates a Transformation object with the given coefficients.
    L.transformation(<Array> coefficients)Expects an coefficients array of the form +[a: Number, b: Number, c: Number, d: Number].
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    transform(<Point> point, <Number> scale?)Point

    Returns a transformed point, optionally multiplied by the given scale. +Only accepts actual L.Point instances, not arrays.

    +
    untransform(<Point> point, <Number> scale?)Point

    Returns the reverse transformation of the given point, optionally divided +by the given scale. Only accepts actual L.Point instances, not arrays.

    +
    + +
    + + +

    LineUtil

    Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast.

    + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    simplify(<Point[]> points, <Number> tolerance)Point[]Dramatically reduces the number of points in a polyline while retaining +its shape and returns a new array of simplified points, using the +Douglas-Peucker algorithm. +Used for a huge performance boost when processing/displaying Leaflet polylines for +each zoom level and also reducing visual noise. tolerance affects the amount of +simplification (lesser value means higher quality but slower and with more points). +Also released as a separated micro-library Simplify.js.
    pointToSegmentDistance(<Point> p, <Point> p1, <Point> p2)NumberReturns the distance between point p and segment p1 to p2.
    closestPointOnSegment(<Point> p, <Point> p1, <Point> p2)NumberReturns the closest point from a point p on a segment p1 to p2.
    clipSegment(<Point> a, <Point> b, <Bounds> bounds, <Boolean> useLastCode?, <Boolean> round?)Point[]|BooleanClips the segment a to b by rectangular bounds with the +Cohen-Sutherland algorithm +(modifying the segment points directly!). Used by Leaflet to only show polyline +points that are on the screen or near, increasing performance.
    isFlat(<LatLng[]> latlngs)BooleanReturns true if latlngs is a flat array, false is nested.
    + +
    + + +

    PolyUtil

    Various utility functions for polygon geometries.

    + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    clipPolygon(<Point[]> points, <Bounds> bounds, <Boolean> round?)Point[]Clips the polygon geometry defined by the given points by the given bounds (using the Sutherland-Hodgman algorithm). +Used by Leaflet to only show polygon points that are on the screen or near, increasing +performance. Note that polygon points needs different algorithm for clipping +than polyline, so there's a separate method for it.
    + +
    + + +

    DomEvent

    Utility functions to work with the DOM events, used by Leaflet internally.

    + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    on(<HTMLElement> el, <String> types, <Function> fn, <Object> context?)thisAdds a listener function (fn) to a particular DOM event type of the +element el. You can optionally specify the context of the listener +(object the this keyword will point to). You can also pass several +space-separated types (e.g. 'click dblclick').
    on(<HTMLElement> el, <Object> eventMap, <Object> context?)thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
    off(<HTMLElement> el, <String> types, <Function> fn, <Object> context?)thisRemoves a previously added listener function. +Note that if you passed a custom context to on, you must pass the same +context to off in order to remove the listener.
    off(<HTMLElement> el, <Object> eventMap, <Object> context?)thisRemoves a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
    stopPropagation(<DOMEvent> ev)thisStop the given event from propagation to parent elements. Used inside the listener functions: +
    L.DomEvent.on(div, 'click', function (ev) {
    +	L.DomEvent.stopPropagation(ev);
    +});
    +
    disableScrollPropagation(<HTMLElement> el)thisAdds stopPropagation to the element's 'wheel' events (plus browser variants).
    disableClickPropagation(<HTMLElement> el)thisAdds stopPropagation to the element's 'click', 'doubleclick', +'mousedown' and 'touchstart' events (plus browser variants).
    preventDefault(<DOMEvent> ev)thisPrevents the default action of the DOM Event ev from happening (such as +following a link in the href of the a element, or doing a POST request +with page reload when a <form> is submitted). +Use it inside listener functions.
    stop(<DOMEvent> ev)thisDoes stopPropagation and preventDefault at the same time.
    getMousePosition(<DOMEvent> ev, <HTMLElement> container?)PointGets normalized mouse position from a DOM event relative to the +container (border excluded) or to the whole page if not specified.
    getWheelDelta(<DOMEvent> ev)NumberGets normalized wheel delta from a wheel DOM event, in vertical +pixels scrolled (negative if scrolling down). +Events from pointing devices without precise scrolling are mapped to +a best guess of 60 pixels.
    addListener()thisAlias to L.DomEvent.on
    removeListener()thisAlias to L.DomEvent.off
    + +
    + + +

    DomUtil

    Utility functions to work with the DOM +tree, used by Leaflet internally.

    +

    Most functions expecting or returning a HTMLElement also work for +SVG elements. The only difference is that classes refer to CSS classes +in HTML and SVG classes in SVG.

    + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    get(<String|HTMLElement> id)HTMLElementReturns an element given its DOM id, or returns the element itself +if it was passed directly.
    getStyle(<HTMLElement> el, <String> styleAttrib)StringReturns the value for a certain style attribute on an element, +including computed values or values set through CSS.
    create(<String> tagName, <String> className?, <HTMLElement> container?)HTMLElementCreates an HTML element with tagName, sets its class to className, and optionally appends it to container element.
    remove(<HTMLElement> el)Removes el from its parent element
    empty(<HTMLElement> el)Removes all of el's children elements from el
    toFront(<HTMLElement> el)Makes el the last child of its parent, so it renders in front of the other children.
    toBack(<HTMLElement> el)Makes el the first child of its parent, so it renders behind the other children.
    hasClass(<HTMLElement> el, <String> name)BooleanReturns true if the element's class attribute contains name.
    addClass(<HTMLElement> el, <String> name)Adds name to the element's class attribute.
    removeClass(<HTMLElement> el, <String> name)Removes name from the element's class attribute.
    setClass(<HTMLElement> el, <String> name)Sets the element's class.
    getClass(<HTMLElement> el)StringReturns the element's class.
    setOpacity(<HTMLElement> el, <Number> opacity)Set the opacity of an element (including old IE support). +opacity must be a number from 0 to 1.
    testProp(<String[]> props)String|falseGoes through the array of style names and returns the first name +that is a valid style name for an element. If no such name is found, +it returns false. Useful for vendor-prefixed styles like transform.
    setTransform(<HTMLElement> el, <Point> offset, <Number> scale?)Resets the 3D CSS transform of el so it is translated by offset pixels +and optionally scaled by scale. Does not have an effect if the +browser doesn't support 3D CSS transforms.
    setPosition(<HTMLElement> el, <Point> position)Sets the position of el to coordinates specified by position, +using CSS translate or top/left positioning depending on the browser +(used by Leaflet internally to position its layers).
    getPosition(<HTMLElement> el)PointReturns the coordinates of an element previously positioned with setPosition.
    disableTextSelection()Prevents the user from generating selectstart DOM events, usually generated +when the user drags the mouse through a page with text. Used internally +by Leaflet to override the behaviour of any click-and-drag interaction on +the map. Affects drag interactions on the whole document.
    enableTextSelection()Cancels the effects of a previous L.DomUtil.disableTextSelection.
    disableImageDrag()As L.DomUtil.disableTextSelection, but +for dragstart DOM events, usually generated when the user drags an image.
    enableImageDrag()Cancels the effects of a previous L.DomUtil.disableImageDrag.
    preventOutline(<HTMLElement> el)Makes the outline +of the element el invisible. Used internally by Leaflet to prevent +focusable elements from displaying an outline when the user performs a +drag interaction on them.
    restoreOutline()Cancels the effects of a previous L.DomUtil.preventOutline.
    getSizedParentNode(<HTMLElement> el)HTMLElementFinds the closest parent node which size (width and height) is not null.
    getScale(<HTMLElement> el)ObjectComputes the CSS scale currently applied on the element. +Returns an object with x and y members as horizontal and vertical scales respectively, +and boundingClientRect as the result of getBoundingClientRect().
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    TRANSFORMStringVendor-prefixed transform style name (e.g. 'webkitTransform' for WebKit).
    TRANSITIONStringVendor-prefixed transition style name.
    TRANSITION_ENDStringVendor-prefixed transitionend event name.
    + +
    + + +

    PosAnimation

    Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9.

    + +
    +

    Usage example

    + +
    + + + + + +
    var fx = new L.PosAnimation();
    +fx.run(el, [300, 500], 0.5);
    +
    + + + +
    + + +
    +

    Constructor

    + +
    + + + + + + + + + + + + + + +
    ConstructorDescription
    L.PosAnimation()Creates a PosAnimation object.
    + + +
    + + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    startEventFired when the animation starts
    stepEventFired continuously during the animation.
    endEventFired when the animation ends.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    run(<HTMLElement> el, <Point> newPos, <Number> duration?, <Number> easeLinearity?)

    Run an animation of a given element to a new position, optionally setting +duration in seconds (0.25 by default) and easing linearity factor (3rd +argument of the cubic bezier curve, +0.5 by default).

    +
    stop()

    Stops the animation (if currently running).

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Draggable

    A class for making DOM elements draggable (including touch support). +Used internally for map and marker dragging. Only works for elements +that were positioned with L.DomUtil.setPosition.

    + +
    +

    Usage example

    + +
    + + + + + +
    var draggable = new L.Draggable(elementToDrag);
    +draggable.enable();
    +
    + + + +
    + + +
    +

    Constructor

    + +
    + + + + + + + + + + + + + + +
    ConstructorDescription
    L.Draggable(<HTMLElement> el, <HTMLElement> dragHandle?, <Boolean> preventOutline?, <Draggable options> options?)Creates a Draggable object for moving el when you start dragging the dragHandle element (equals el itself by default).
    + + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    clickToleranceNumber3The max number of pixels a user can shift the mouse pointer during a click +for it to be considered a valid click (as opposed to a mouse drag).
    + +
    + + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    downEventFired when a drag is about to start.
    dragstartEventFired when a drag starts
    predragEventFired continuously during dragging before each corresponding +update of the element's position.
    dragEventFired continuously during dragging.
    dragendDragEndEventFired when the drag ends.
    + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    enable()

    Enables the dragging ability

    +
    disable()

    Disables the dragging ability

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Class

    L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented here.

    +

    In addition to implementing a simple classical inheritance model, it introduces several special properties for convenient code organization — options, includes and statics.

    + +
    +

    Usage example

    + +
    + + + + + +
    var MyClass = L.Class.extend({
    +initialize: function (greeter) {
    +	this.greeter = greeter;
    +	// class constructor
    +},
    +
    +greet: function (name) {
    +	alert(this.greeter + ', ' + name)
    +	}
    +});
    +
    +// create instance of MyClass, passing "Hello" to the constructor
    +var a = new MyClass("Hello");
    +
    +// call greet method, alerting "Hello, World"
    +a.greet("World");
    +
    + + + +
    + +

    Class Factories

    + + + +

    You may have noticed that Leaflet objects are created without using +the new keyword. This is achieved by complementing each class with a +lowercase factory method:

    +
    new L.Map('map'); // becomes:
    +L.map('map');
    +
    +

    The factories are implemented very easily, and you can do this for your own classes:

    +
    L.map = function (id, options) {
    +    return new L.Map(id, options);
    +};
    +
    + + + +
    + +

    Inheritance

    + + + +

    You use L.Class.extend to define new classes, but you can use the same method on any class to inherit from it:

    +
    var MyChildClass = MyClass.extend({
    +    // ... new properties and methods
    +});
    +
    +

    This will create a class that inherits all methods and properties of the parent class (through a proper prototype chain), adding or overriding the ones you pass to extend. It will also properly react to instanceof:

    +
    var a = new MyChildClass();
    +a instanceof MyChildClass; // true
    +a instanceof MyClass; // true
    +
    +

    You can call parent methods (including constructor) from corresponding child ones (as you do with super calls in other languages) by accessing parent class prototype and using JavaScript's call or apply:

    +
    var MyChildClass = MyClass.extend({
    +    initialize: function () {
    +        MyClass.prototype.initialize.call(this, "Yo");
    +    },
    +
    +    greet: function (name) {
    +        MyClass.prototype.greet.call(this, 'bro ' + name + '!');
    +    }
    +});
    +
    +var a = new MyChildClass();
    +a.greet('Jason'); // alerts "Yo, bro Jason!"
    +
    + + + +
    + +

    Options

    + + + +

    options is a special property that unlike other objects that you pass +to extend will be merged with the parent one instead of overriding it +completely, which makes managing configuration of objects and default +values convenient:

    +
    var MyClass = L.Class.extend({
    +    options: {
    +        myOption1: 'foo',
    +        myOption2: 'bar'
    +    }
    +});
    +
    +var MyChildClass = MyClass.extend({
    +    options: {
    +        myOption1: 'baz',
    +        myOption3: 5
    +    }
    +});
    +
    +var a = new MyChildClass();
    +a.options.myOption1; // 'baz'
    +a.options.myOption2; // 'bar'
    +a.options.myOption3; // 5
    +
    +

    There's also L.Util.setOptions, a method for +conveniently merging options passed to constructor with the defaults +defines in the class:

    +
    var MyClass = L.Class.extend({
    +    options: {
    +        foo: 'bar',
    +        bla: 5
    +    },
    +
    +    initialize: function (options) {
    +        L.Util.setOptions(this, options);
    +        ...
    +    }
    +});
    +
    +var a = new MyClass({bla: 10});
    +a.options; // {foo: 'bar', bla: 10}
    +
    +

    Note that the options object allows any keys, not just +the options defined by the class and its base classes. +This means you can use the options object to store +application specific information, as long as you avoid +keys that are already used by the class in question.

    + + + +
    + +

    Includes

    + + + +

    includes is a special class property that merges all specified objects into the class (such objects are called mixins).

    +
     var MyMixin = {
    +    foo: function () { ... },
    +    bar: 5
    +};
    +
    +var MyClass = L.Class.extend({
    +    includes: MyMixin
    +});
    +
    +var a = new MyClass();
    +a.foo();
    +
    +

    You can also do such includes in runtime with the include method:

    +
    MyClass.include(MyMixin);
    +
    +

    statics is just a convenience property that injects specified object properties as the static properties of the class, useful for defining constants:

    +
    var MyClass = L.Class.extend({
    +    statics: {
    +        FOO: 'bar',
    +        BLA: 5
    +    }
    +});
    +
    +MyClass.FOO; // 'bar'
    +
    + + + +
    + +

    Constructor hooks

    + + + +

    If you're a plugin developer, you often need to add additional initialization code to existing classes (e.g. editing hooks for L.Polyline). Leaflet comes with a way to do it easily using the addInitHook method:

    +
    MyClass.addInitHook(function () {
    +    // ... do something in constructor additionally
    +    // e.g. add event listeners, set custom properties etc.
    +});
    +
    +

    You can also use the following shortcut when you just need to make one additional method call:

    +
    MyClass.addInitHook('methodName', arg1, arg2, …);
    +
    + + + +
    + + +
    +

    Functions

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    extend(<Object> props)FunctionExtends the current class given the properties to be included. +Returns a Javascript function that is a class constructor (to be called with new).
    include(<Object> properties)thisIncludes a mixin into the current class.
    mergeOptions(<Object> options)thisMerges options into the defaults of the class.
    addInitHook(<Function> fn)thisAdds a constructor hook to the class.
    + +
    + + +

    Evented

    A set of methods shared between event-powered classes (like Map and Marker). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire 'click' event).

    + +
    +

    Usage example

    + +
    + + + + + +
    map.on('click', function(e) {
    +	alert(e.latlng);
    +} );
    +
    +

    Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:

    +
    function onClick(e) { ... }
    +
    +map.on('click', onClick);
    +map.off('click', onClick);
    +
    + + + +
    + + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    + + +

    Layer

    A set of methods from the Layer base class that all Leaflet layers use. +Inherits all methods, options and events from L.Evented.

    + +
    +

    Usage example

    + +
    + + + + + +
    var layer = L.marker(latlng).addTo(map);
    +layer.addTo(map);
    +layer.remove();
    +
    + + + +
    + + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    + + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    + +

    Popup events

    + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    + +

    Tooltip events

    + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    + + +
    +

    Methods

    + +
    + + + +
    Classes extending L.Layer will inherit the following methods:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    + +

    Extension methods

    + +
    Every layer should extend from L.Layer and (re-)implement the following methods.
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    onAdd(<Map> map)this

    Should contain code that creates DOM elements for the layer, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).

    +
    onRemove(<Map> map)this

    Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).

    +
    getEvents()Object

    This optional method should return an object like { viewreset: this._reset } for addEventListener. The event handlers in this object will be automatically added and removed from the map with your layer.

    +
    getAttribution()String

    This optional method should return a string containing HTML to be shown on the Attribution control whenever the layer is visible.

    +
    beforeAdd(<Map> map)this

    Optional method. Called on map.addLayer(layer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only.

    +
    + +
    + +

    Popup methods

    + +
    All layers share a set of methods convenient for binding popups to it. +
    var layer = L.Polygon(latlngs).bindPopup('Hi There!').addTo(map);
    +layer.openPopup();
    +layer.closePopup();
    +
    +

    Popups will also be automatically opened when the layer is clicked on and closed when the layer is removed from the map or another popup is opened.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    + +

    Tooltip methods

    + +
    All layers share a set of methods convenient for binding tooltips to it. +
    var layer = L.Polygon(latlngs).bindTooltip('Hi There!').addTo(map);
    +layer.openTooltip();
    +layer.closeTooltip();
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Interactive layer

    Some Layers can be made interactive - when the user interacts +with such a layer, mouse events like click and mouseover can be handled. +Use the event handling methods to handle these events.

    + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    interactiveBooleantrueIf false, the layer will not emit mouse events and will act as a part of the underlying map.
    bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map +(unless L.DomEvent.stopPropagation is used).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + +

    Mouse events

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    clickMouseEventFired when the user clicks (or taps) the layer.
    dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
    mousedownMouseEventFired when the user pushes the mouse button on the layer.
    mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
    mouseoverMouseEventFired when the mouse enters the layer.
    mouseoutMouseEventFired when the mouse leaves the layer.
    contextmenuMouseEventFired when the user right-clicks on the layer, prevents +default browser context menu from showing if there are listeners on +this event. Also fired on mobile when the user holds a single touch +for a second (also called long press).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Control

    L.Control is a base class for implementing map controls. Handles positioning. +All other controls extend from this class.

    + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    positionString'topright'The position of the control (one of the map corners). Possible values are 'topleft', +'topright', 'bottomleft' or 'bottomright'
    + +
    + + +
    +

    Methods

    + +
    + + + +
    Classes extending L.Control will inherit the following methods:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    getPosition()string

    Returns the position of the control.

    +
    setPosition(<string> position)this

    Sets the position of the control.

    +
    getContainer()HTMLElement

    Returns the HTMLElement that contains the control.

    +
    addTo(<Map> map)this

    Adds the control to the given map.

    +
    remove()this

    Removes the control from the map it is currently active on.

    +
    + +
    + +

    Extension methods

    + +
    Every control should extend from L.Control and (re-)implement the following methods.
    + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    onAdd(<Map> map)HTMLElement

    Should return the container DOM element for the control and add listeners on relevant map events. Called on control.addTo(map).

    +
    onRemove(<Map> map)

    Optional method. Should contain all clean up code that removes the listeners previously added in onAdd. Called on control.remove().

    +
    + +
    + + +

    Handler

    Abstract class for map interaction handlers

    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    enable()this

    Enables the handler

    +
    disable()this

    Disables the handler

    +
    enabled()Boolean

    Returns true if the handler is enabled

    +
    + +
    + +

    Extension methods

    + +
    Classes inheriting from Handler must implement the two following methods:
    + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addHooks()

    Called when the handler is enabled, should add event hooks.

    +
    removeHooks()

    Called when the handler is disabled, should remove the event hooks added previously.

    +
    + +
    + + +
    +

    Functions

    + +
    + +

    There is static function which can be called without instantiating L.Handler:

    + + + + + + + + + + + + + + +
    FunctionReturnsDescription
    addTo(<Map> map, <String> name)thisAdds a new Handler to the given map with the given name.
    + +
    + + +

    Projection

    An object with methods for projecting geographical coordinates of the world onto +a flat surface (and back). See Map projection.

    + +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    project(<LatLng> latlng)Point

    Projects geographical coordinates into a 2D point. +Only accepts actual L.LatLng instances, not arrays.

    +
    unproject(<Point> point)LatLng

    The inverse of project. Projects a 2D point into a geographical location. +Only accepts actual L.Point instances, not arrays.

    +

    Note that the projection instances do not inherit from Leaflet's Class object, +and can't be instantiated. Also, new classes can't inherit from them, +and methods can't be added to them with the include function.

    +
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    boundsBoundsThe bounds (specified in CRS units) where the projection is valid
    + +
    + + +
    +

    Defined projections

    + +
    + + + +
    Leaflet comes with a set of already defined Projections out of the box:
    + + + + + + + + + + + + + + + + + + + +
    ProjectionDescription
    L.Projection.LonLatEquirectangular, or Plate Carree projection — the most simple projection, +mostly used by GIS enthusiasts. Directly maps x as longitude, and y as +latitude. Also suitable for flat worlds, e.g. game maps. Used by the +EPSG:4326 and Simple CRS.
    L.Projection.MercatorElliptical Mercator projection — more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS.
    L.Projection.SphericalMercatorSpherical Mercator projection — the most common projection for online maps, +used by almost all free and commercial tile providers. Assumes that Earth is +a sphere. Used by the EPSG:3857 CRS.
    + +
    + + +

    CRS

    +
    +

    Methods

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    latLngToPoint(<LatLng> latlng, <Number> zoom)Point

    Projects geographical coordinates into pixel coordinates for a given zoom.

    +
    pointToLatLng(<Point> point, <Number> zoom)LatLng

    The inverse of latLngToPoint. Projects pixel coordinates on a given +zoom into geographical coordinates.

    +
    project(<LatLng> latlng)Point

    Projects geographical coordinates into coordinates in units accepted for +this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).

    +
    unproject(<Point> point)LatLng

    Given a projected coordinate returns the corresponding LatLng. +The inverse of project.

    +
    scale(<Number> zoom)Number

    Returns the scale used when transforming projected coordinates into +pixel coordinates for a particular zoom. For example, it returns +256 * 2^zoom for Mercator-based CRS.

    +
    zoom(<Number> scale)Number

    Inverse of scale(), returns the zoom level corresponding to a scale +factor of scale.

    +
    getProjectedBounds(<Number> zoom)Bounds

    Returns the projection's bounds scaled and transformed for the provided zoom.

    +
    distance(<LatLng> latlng1, <LatLng> latlng2)Number

    Returns the distance between two geographical coordinates.

    +
    wrapLatLng(<LatLng> latlng)LatLng

    Returns a LatLng where lat and lng has been wrapped according to the +CRS's wrapLat and wrapLng properties, if they are outside the CRS's bounds.

    +
    wrapLatLngBounds(<LatLngBounds> bounds)LatLngBounds

    Returns a LatLngBounds with the same size as the given one, ensuring +that its center is within the CRS's bounds. +Only accepts actual L.LatLngBounds instances, not arrays.

    +
    + +
    + + +
    +

    Properties

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    codeStringStandard code name of the CRS passed into WMS services (e.g. 'EPSG:3857')
    wrapLngNumber[]An array of two numbers defining whether the longitude (horizontal) coordinate +axis wraps around a given range and how. Defaults to [-180, 180] in most +geographical CRSs. If undefined, the longitude axis does not wrap around.
    wrapLatNumber[]Like wrapLng, but for the latitude (vertical) axis.
    infiniteBooleanIf true, the coordinate space will be unbounded (infinite in both axes)
    + +
    + + +
    +

    Defined CRSs

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    CRSDescription
    L.CRS.EPSG3395Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
    L.CRS.EPSG3857The most common CRS for online maps, used by almost all free and commercial +tile providers. Uses Spherical Mercator projection. Set in by default in +Map's crs option.
    L.CRS.EPSG4326A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. +

    Leaflet 1.0.x complies with the TMS coordinate scheme for EPSG:4326, +which is a breaking change from 0.7.x behaviour. If you are using a TileLayer +with this CRS, ensure that there are two 256x256 pixel tiles covering the +whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90), +or (-180,-90) for TileLayers with the tms option set.

    L.CRS.EarthServes as the base for CRS that are global such that they cover the earth. +Can only be used as the base for other CRS and cannot be used directly, +since it does not have a code, projection or transformation. distance() returns +meters.
    L.CRS.SimpleA simple CRS that maps longitude and latitude into x and y directly. +May be used for maps of flat surfaces (e.g. game maps). Note that the y +axis should still be inverted (going from bottom to top). distance() returns +simple euclidean distance.
    L.CRS.BaseObject that defines coordinate reference systems for projecting +geographical points into pixel (screen) coordinates and back (and to +coordinates in other units for WMS services). See +spatial reference system. +

    Leaflet defines the most usual CRSs by default. If you want to use a +CRS not defined by default, take a look at the +Proj4Leaflet plugin.

    +

    Note that the CRS instances do not inherit from Leaflet's Class object, +and can't be instantiated. Also, new classes can't inherit from them, +and methods can't be added to them with the include function.

    + +
    + + +

    Renderer

    Base class for vector renderer implementations (SVG, Canvas). Handles the +DOM container of the renderer, its bounds, and its zoom animation.

    +

    A Renderer works as an implicit layer group for all Paths - the renderer +itself can be added or removed to the map. All paths use a renderer, which can +be implicit (the map will decide the type of renderer and use it automatically) +or explicit (using the renderer option of the path).

    +

    Do not use this class directly, use SVG and Canvas instead.

    + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paddingNumber0.1How much to extend the clip area around the map view (relative to its size) +e.g. 0.1 would be 10% of map view in each direction
    toleranceNumber0How much to extend click tolerance round a path/object on the map
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    paneString'overlayPane'By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default.
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + +
    + + + + + + + + + + + + + + + + +
    EventDataDescription
    updateEventFired when the renderer updates its bounds, center and zoom, for example when +its map has moved
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Event objects

    Whenever a class inheriting from Evented fires an event, a listener function +will be called with an event argument, which is a plain object containing +information about the event. For example:

    +
    map.on('click', function(ev) {
    +    alert(ev.latlng); // ev is an event object (MouseEvent in this case)
    +});
    +
    +

    The information available depends on the event type:

    + + + +
    +

    Event

    + +
    + + + +
    The base event object. All other event objects contain these properties too.
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    + + +
    + +
    +

    KeyboardEvent

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    originalEventDOMEventThe original DOM KeyboardEvent that triggered this Leaflet event.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    MouseEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    latlngLatLngThe geographical point where the mouse event occurred.
    layerPointPointPixel coordinates of the point where the mouse event occurred relative to the map layer.
    containerPointPointPixel coordinates of the point where the mouse event occurred relative to the map сontainer.
    originalEventDOMEventThe original DOM MouseEvent or DOM TouchEvent that triggered this Leaflet event.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    LocationEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    latlngLatLngDetected geographical location of the user.
    boundsLatLngBoundsGeographical bounds of the area user is located in (with respect to the accuracy of location).
    accuracyNumberAccuracy of location in meters.
    altitudeNumberHeight of the position above the WGS84 ellipsoid in meters.
    altitudeAccuracyNumberAccuracy of altitude in meters.
    headingNumberThe direction of travel in degrees counting clockwise from true North.
    speedNumberCurrent velocity in meters per second.
    timestampNumberThe time when the position was acquired.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    ErrorEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    messageStringError message.
    codeNumberError code (if applicable).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    LayerEvent

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    layerLayerThe layer that was added or removed.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    + +
    +
    +
    + +
    + +
    +

    LayersControlEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    layerLayerThe layer that was added or removed.
    nameStringThe name of the layer that was added or removed.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    + +
    +
    +
    + +
    + +
    +

    TileEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    tileHTMLElementThe tile element (image).
    coordsPointPoint object with the tile's x, y, and z (zoom level) coordinates.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    TileErrorEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    tileHTMLElementThe tile element (image).
    coordsPointPoint object with the tile's x, y, and z (zoom level) coordinates.
    error*Error passed to the tile's done() callback.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    ResizeEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    oldSizePointThe old size before resize event.
    newSizePointThe new size after the resize event.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    GeoJSONEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    layerLayerThe layer for the GeoJSON feature that is being added to the map.
    propertiesObjectGeoJSON properties of the feature.
    geometryTypeStringGeoJSON geometry type of the feature.
    idStringGeoJSON ID of the feature (if present).
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    + +
    +
    +
    + +
    + +
    +

    PopupEvent

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    popupPopupThe popup that was opened or closed.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    TooltipEvent

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    tooltipTooltipThe tooltip that was opened or closed.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    DragEndEvent

    + +
    + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    distanceNumberThe distance in pixels the draggable element was moved by.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +
    + +
    +

    ZoomAnimEvent

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    centerLatLngThe current center of the map
    zoomNumberThe current zoom level of the map
    noUpdateBooleanWhether layers should update their contents due to this event
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    PropertyTypeDescription
    typeStringThe event type (e.g. 'click').
    targetObjectThe object that fired the event. For propagated events, the last object in +the propagation chain that fired the event.
    sourceTargetObjectThe object that originally fired the event. For non-propagated events, this will +be the same as the target.
    propagatedFromObjectFor propagated events, the last object that propagated the event to its +event parent.
    layerObjectDeprecated. The same as propagatedFrom.
    + +
    +
    +
    + +

    DivOverlay

    Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins.

    + +
    +

    Options

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    offsetPointPoint(0, 7)The offset of the popup position. Useful to control the anchor +of the popup when opening it on some overlays.
    classNameString''A custom CSS class name to assign to the popup.
    paneString'popupPane'Map pane where the popup will be added.
    + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    OptionTypeDefaultDescription
    attributionStringnullString to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
    + +
    +
    +
    + +
    +

    Events

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    addEventFired after the layer is added to a map
    removeEventFired after the layer is removed from a map
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    popupopenPopupEventFired when a popup bound to this layer is opened
    popupclosePopupEventFired when a popup bound to this layer is closed
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    EventDataDescription
    tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
    tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed.
    + +
    +
    +
    + +
    +

    Methods

    + + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    addTo(<Map|LayerGroup> map)this

    Adds the layer to the given map or layer group.

    +
    remove()this

    Removes the layer from the map it is currently active on.

    +
    removeFrom(<Map> map)this

    Removes the layer from the given map

    +
    removeFrom(<LayerGroup> group)this

    Removes the layer from the given LayerGroup

    +
    getPane(<String> name?)HTMLElement

    Returns the HTMLElement representing the named pane on the map. If name is omitted, returns the pane for this layer.

    +
    getAttribution()String

    Used by the attribution control, returns the attribution option.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindPopup(<String|HTMLElement|Function|Popup> content, <Popup options> options?)this

    Binds a popup to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindPopup()this

    Removes the popup previously bound with bindPopup.

    +
    openPopup(<LatLng> latlng?)this

    Opens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.

    +
    closePopup()this

    Closes the popup bound to this layer if it is open.

    +
    togglePopup()this

    Opens or closes the popup bound to this layer depending on its current state.

    +
    isPopupOpen()boolean

    Returns true if the popup bound to this layer is currently open.

    +
    setPopupContent(<String|HTMLElement|Popup> content)this

    Sets the content of the popup bound to this layer.

    +
    getPopup()Popup

    Returns the popup bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip options> options?)this

    Binds a tooltip to the layer with the passed content and sets up the +necessary event listeners. If a Function is passed it will receive +the layer as the first argument and should return a String or HTMLElement.

    +
    unbindTooltip()this

    Removes the tooltip previously bound with bindTooltip.

    +
    openTooltip(<LatLng> latlng?)this

    Opens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.

    +
    closeTooltip()this

    Closes the tooltip bound to this layer if it is open.

    +
    toggleTooltip()this

    Opens or closes the tooltip bound to this layer depending on its current state.

    +
    isTooltipOpen()boolean

    Returns true if the tooltip bound to this layer is currently open.

    +
    setTooltipContent(<String|HTMLElement|Tooltip> content)this

    Sets the content of the tooltip bound to this layer.

    +
    getTooltip()Tooltip

    Returns the tooltip bound to this layer.

    +
    + +
    +
    +
    + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MethodReturnsDescription
    on(<String> type, <Function> fn, <Object> context?)this

    Adds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').

    +
    on(<Object> eventMap)this

    Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}

    +
    off(<String> type, <Function> fn?, <Object> context?)this

    Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.

    +
    off(<Object> eventMap)this

    Removes a set of type/listener pairs.

    +
    off()this

    Removes all listeners to all events on the object. This includes implicitly attached events.

    +
    fire(<String> type, <Object> data?, <Boolean> propagate?)this

    Fires an event of the specified type. You can optionally provide an data +object — the first argument of the listener function will contain its +properties. The event can optionally be propagated to event parents.

    +
    listens(<String> type)Boolean

    Returns true if a particular event type has any listeners attached to it.

    +
    once()this

    Behaves as on(…), except the listener will only get fired once and then removed.

    +
    addEventParent(<Evented> obj)this

    Adds an event parent - an Evented that will receive propagated events

    +
    removeEventParent(<Evented> obj)this

    Removes an event parent, so it will stop receiving propagated events

    +
    addEventListener()this

    Alias to on(…)

    +
    removeEventListener()this

    Alias to off(…)

    +
    clearAllEventListeners()this

    Alias to off()

    +
    addOneTimeEventListener()this

    Alias to once(…)

    +
    fireEvent()this

    Alias to fire(…)

    +
    hasEventListeners()Boolean

    Alias to listens(…)

    +
    + +
    +
    +
    + +

    Global Switches

    Global switches are created for rare cases and generally make +Leaflet to not detect a particular browser feature even if it's +there. You need to set the switch as a global variable to true +before including Leaflet on the page, like this:

    +
    <script>L_NO_TOUCH = true;</script>
    +<script src="leaflet.js"></script>
    +
    + + + + + + + + + + + + + + + + + +
    SwitchDescription
    L_NO_TOUCHForces Leaflet to not use touch events even if it detects them.
    L_DISABLE_3DForces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning (which may cause glitches in some rare environments) even if they're supported.
    + +

    noConflict

    This method restores the L global variable to the original value +it had before Leaflet inclusion, and returns the real Leaflet +namespace so you can put it elsewhere, like this:

    +
    <script src='libs/l.js'>
    +<!-- L points to some other library -->
    +
    +<script src='leaflet.js'>
    +<!-- you include Leaflet, it replaces the L variable to Leaflet namespace -->
    +
    +<script>
    +var Leaflet = L.noConflict();
    +// now L points to that other library again, and you can use Leaflet.Map etc.
    +</script>
    +
    + +

    version

    A constant that represents the Leaflet version in use.

    +
    L.version; // contains "1.0.0" (or whatever version is currently in use)
    +
    diff --git a/package-lock.json b/package-lock.json index 60c647e6ce8..3fb5a3bc6a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,10 @@ "license": "BSD-2-Clause", "devDependencies": { "@rollup/plugin-json": "^4.1.0", + "bundlemon": "^1.3.0", "eslint": "^8.1.0", "eslint-config-mourner": "^2.0.3", + "eslint-plugin-script-tags": "^0.5.0", "git-rev-sync": "^3.0.1", "happen": "~0.3.2", "karma": "^6.3.6", @@ -21,28 +23,144 @@ "karma-firefox-launcher": "^2.1.1", "karma-ie-launcher": "^1.0.0", "karma-mocha": "^2.0.1", - "karma-phantomjs-launcher": "^1.0.4", "karma-rollup-preprocessor": "^7.0.7", "karma-safari-launcher": "~1.0.0", "karma-sinon": "^1.0.5", "leafdoc": "^2.3.0", "mocha": "^9.1.3", - "phantomjs-prebuilt": "^2.1.16", "prosthetic-hand": "^1.3.1", - "rollup": "^2.58.3", + "rollup": "^2.59.0", "rollup-plugin-git-version": "^0.3.1", "sinon": "^7.5.0", "ssri": "^8.0.1", "uglify-js": "^3.14.2" } }, + "node_modules/@babel/code-frame": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", + "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.16.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", + "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.7.tgz", + "integrity": "sha512-aKpPMfLvGO3Q97V0qhw/V2SWNWlwfJknuwAunU7wZLSfrM4xTBvg7E5opUVi1kJTBKihE38CPg4nBiqX83PWYw==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.16.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/runtime": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.7.tgz", + "integrity": "sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/runtime-corejs3": { - "version": "7.15.4", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.15.4.tgz", - "integrity": "sha512-lWcAqKeB624/twtTc3w6w/2o9RqJPaNBhPGK6DKLSiwuVWC7WFkypWyNg+CpZoyJH0jVzv1uMtXZ/5/lQOLtCg==", + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.16.0.tgz", + "integrity": "sha512-Oi2qwQ21X7/d9gn3WiwkDTJmq3TQtYNz89lRnoFy8VeZpWlsyXvzSwiRrRZ8cXluvSwqKxqHJ6dBd9Rv+p0ZGQ==", "dev": true, "dependencies": { - "core-js-pure": "^3.16.0", + "core-js-pure": "^3.19.0", "regenerator-runtime": "^0.13.4" }, "engines": { @@ -50,18 +168,18 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.3.tgz", - "integrity": "sha512-DHI1wDPoKCBPoLZA3qDR91+3te/wDSc1YhKg3jR8NxKKRJq2hwHwcWv31cSwSYvIBrmbENoYMWcenW8uproQqg==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.0.0", + "espree": "^9.2.0", "globals": "^13.9.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", + "js-yaml": "^4.1.0", "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" }, @@ -69,35 +187,13 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@eslint/eslintrc/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@eslint/eslintrc/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" }, @@ -106,9 +202,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "node_modules/@rollup/plugin-json": { @@ -200,12 +296,24 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.178", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz", + "integrity": "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==", + "dev": true + }, "node_modules/@types/node": { "version": "16.11.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz", "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==", "dev": true }, + "node_modules/@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, "node_modules/@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -226,9 +334,9 @@ } }, "node_modules/acorn": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", - "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -320,45 +428,15 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, - "node_modules/asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "node_modules/axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "dev": true, "dependencies": { - "safer-buffer": "~2.1.0" - } - }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "engines": { - "node": ">=0.8" + "follow-redirects": "^1.14.0" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "node_modules/aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", - "dev": true - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -383,15 +461,6 @@ "node": "^4.5.0 || >= 5.9" } }, - "node_modules/bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "dependencies": { - "tweetnacl": "^0.14.3" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -459,26 +528,56 @@ "node": ">=8" } }, + "node_modules/brotli-size": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/brotli-size/-/brotli-size-4.0.0.tgz", + "integrity": "sha512-uA9fOtlTRC0iqKfzff1W34DXUA3GyVqbUaeo3Rw3d4gd1eavKVCETXrn3NzO74W+UVkG3UHu8WxUi+XvKI/huA==", + "dev": true, + "dependencies": { + "duplexer": "0.1.1" + }, + "engines": { + "node": ">= 10.16.0" + } + }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "node_modules/bundlemon": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bundlemon/-/bundlemon-1.3.0.tgz", + "integrity": "sha512-6tSARvzrYf3K8xRC19GXBTCI4p45QxDV4VyyYEh1hUuM7gJdBIAUalhZY/5yidmhthGkonIVTh3taH054BLqGw==", "dev": true, + "dependencies": { + "axios": "^0.21.1", + "brotli-size": "^4.0.0", + "bundlemon-utils": "^0.4.0", + "bytes": "^3.1.0", + "chalk": "^4.1.1", + "commander": "^8.0.0", + "cosmiconfig": "^7.0.0", + "gzip-size": "^6.0.0", + "micromatch": "^4.0.4", + "yup": "^0.32.11" + }, + "bin": { + "bundlemon": "bin/bundlemon.js" + }, "engines": { - "node": "*" + "node": ">=12" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "node_modules/bundlemon-utils": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/bundlemon-utils/-/bundlemon-utils-0.4.0.tgz", + "integrity": "sha512-BqYhoCgkPNgdN3ORpj2Xqphj+OQ4iHGBqq9KfM2aQpj+RAauVS2F0EAe77ZXpme2JLbLJq6MyrUOHoeXvB2lGA==", + "dev": true, + "dependencies": { + "bytes": "^3.1.0" + } }, "node_modules/bytes": { "version": "3.1.0", @@ -510,12 +609,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -576,6 +669,19 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/clone-regexp": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-1.0.1.tgz", + "integrity": "sha512-Fcij9IwRW27XedRIJnSOEupS7RVcXtObJXbcUOX93UCLqqOdRpkvzKywOOSizmEK/Is3S/RHX9dLdfo6R1Q1mw==", + "dev": true, + "dependencies": { + "is-regexp": "^1.0.0", + "is-supported-regexp-flag": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -603,16 +709,13 @@ "node": ">=0.1.90" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", "dev": true, - "dependencies": { - "delayed-stream": "~1.0.0" - }, "engines": { - "node": ">= 0.8" + "node": ">= 12" } }, "node_modules/comment-patterns": { @@ -636,21 +739,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "node_modules/concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "engines": [ - "node >= 0.8" - ], - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "node_modules/connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -710,12 +798,6 @@ "url": "https://opencollective.com/core-js" } }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -729,6 +811,22 @@ "node": ">= 0.10" } }, + "node_modules/cosmiconfig": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", + "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "dev": true, + "dependencies": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.2.1", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.10.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -749,18 +847,6 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, - "node_modules/dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0" - }, - "engines": { - "node": ">=0.10" - } - }, "node_modules/date-format": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-3.0.0.tgz", @@ -811,15 +897,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -868,15 +945,11 @@ "void-elements": "^2.0.0" } }, - "node_modules/ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "dev": true, - "dependencies": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } + "node_modules/duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true }, "node_modules/edge-launcher": { "version": "1.2.2", @@ -938,18 +1011,6 @@ "node": ">=10.0.0" } }, - "node_modules/enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -962,11 +1023,14 @@ "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", "dev": true }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } }, "node_modules/escalade": { "version": "3.1.1", @@ -996,24 +1060,23 @@ } }, "node_modules/eslint": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.1.0.tgz", - "integrity": "sha512-JZvNneArGSUsluHWJ8g8MMs3CfIEzwaLx9KyH4tZ2i+R2/rPWzL8c0zg3rHdwYVpN/1sB9gqnjHwz9HoeJpGHw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.7.0.tgz", + "integrity": "sha512-ifHYzkBGrzS2iDU7KjhCAVMGCvF6M3Xfs8X8b37cgrUlDt6bWRTpRh6T/gtSXv1HJ/BUGgmjvNvOEGu85Iif7w==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.0.3", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", - "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", + "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", + "eslint-visitor-keys": "^3.2.0", + "espree": "^9.3.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -1021,7 +1084,7 @@ "functional-red-black-tree": "^1.0.1", "glob-parent": "^6.0.1", "globals": "^13.6.0", - "ignore": "^4.0.6", + "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", @@ -1032,10 +1095,8 @@ "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "progress": "^2.0.0", "regexpp": "^3.2.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" @@ -1056,10 +1117,22 @@ "integrity": "sha512-ydFFzE/WkqvmozI3CM0lAtDZoYfmN03ycjlHzdPZW5x+o3Me1pI0lyfpsWoz9kOqykZk8qlvOVC5BN5UMwtXrg==", "dev": true }, + "node_modules/eslint-plugin-script-tags": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-script-tags/-/eslint-plugin-script-tags-0.5.0.tgz", + "integrity": "sha512-iomN8+MwDyhRGWKwRKfBg4EchXuOCJ4iPC8bE9q255xdneXdIhvJU0AaWEe9GPXQIrJ3JKNKZbU1dAlAPbyyAg==", + "deprecated": "Now published as @mapbox/eslint-plugin-script-tags", + "dev": true, + "dependencies": { + "execall": "^1.0.0", + "lodash": "^4.16.0", + "split-lines": "^1.1.0" + } + }, "node_modules/eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -1097,39 +1170,35 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz", - "integrity": "sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.2.0.tgz", + "integrity": "sha512-IOzT0X126zn7ALX0dwFiUQEdsfzrm4+ISsQS8nukaJXwEyYKRSnEIIDULYg1mCtGp7UUXgfGl7BIolXREQK+XQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/espree": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", - "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "node_modules/eslint/node_modules/ignore": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", "dev": true, - "dependencies": { - "acorn": "^8.5.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.0.0" - }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": ">= 4" } }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "node_modules/espree": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.0.tgz", + "integrity": "sha512-d/5nCsb0JcqsSEeQzFZ8DH1RmxPcglRWh24EFTlUEmCKoehXGdpsx0RkHDubqUI8LSAIKMQp4r9SzQ3n+sm4HQ==", "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" + "dependencies": { + "acorn": "^8.7.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^3.1.0" }, "engines": { - "node": ">=4" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/esquery": { @@ -1186,6 +1255,18 @@ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", "dev": true }, + "node_modules/execall": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execall/-/execall-1.0.0.tgz", + "integrity": "sha1-c9CQTjlbPKsGWLCNCewlMH8pu3M=", + "dev": true, + "dependencies": { + "clone-regexp": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/expect.js": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.3.1.tgz", @@ -1198,45 +1279,6 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, - "node_modules/extract-zip": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", - "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", - "dev": true, - "dependencies": { - "concat-stream": "^1.6.2", - "debug": "^2.6.9", - "mkdirp": "^0.5.4", - "yauzl": "^2.10.0" - }, - "bin": { - "extract-zip": "cli.js" - } - }, - "node_modules/extract-zip/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/extract-zip/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node_modules/extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true, - "engines": [ - "node >=0.6.0" - ] - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1255,15 +1297,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "node_modules/fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dev": true, - "dependencies": { - "pend": "~1.2.0" - } - }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -1366,9 +1399,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", + "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==", "dev": true, "funding": [ { @@ -1385,39 +1418,25 @@ } } }, - "node_modules/forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" }, "engines": { - "node": ">= 0.12" + "node": ">=6 <7 || >=8" } }, - "node_modules/fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" - } + "node_modules/fs-extra/node_modules/graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true }, "node_modules/fs.realpath": { "version": "1.0.0", @@ -1460,15 +1479,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0" - } - }, "node_modules/git-rev-sync": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-3.0.1.tgz", @@ -1551,6 +1561,27 @@ "node": ">=4.x" } }, + "node_modules/gzip-size": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", + "integrity": "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==", + "dev": true, + "dependencies": { + "duplexer": "^0.1.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gzip-size/node_modules/duplexer": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", + "dev": true + }, "node_modules/handlebars": { "version": "4.7.7", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", @@ -1578,29 +1609,6 @@ "integrity": "sha512-fBouIWb3fMsRCfCySHgk6+/gTEijMAWUZM/TYKmjuui9VsdS2DGWNjcH9cN7/tPn9nSkxGSGLJU6FHh37G0WUg==", "dev": true }, - "node_modules/har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "deprecated": "this library is no longer supported", - "dev": true, - "dependencies": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -1622,19 +1630,6 @@ "node": ">=8" } }, - "node_modules/hasha": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "dependencies": { - "is-stream": "^1.0.1", - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -1680,21 +1675,6 @@ "node": ">=8.0.0" } }, - "node_modules/http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "dependencies": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - }, - "engines": { - "node": ">=0.8", - "npm": ">=1.3.7" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1766,6 +1746,12 @@ "node": ">= 0.10" } }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -1853,20 +1839,23 @@ "node": ">=8" } }, - "node_modules/is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "node_modules/is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true + "node_modules/is-supported-regexp-flag": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.1.tgz", + "integrity": "sha512-3vcJecUUrpgCqc/ca0aWeNu64UGgxcvO60K/Fkr1N6RSvfGCTU60UKN68JDmKokgba0rFFJs12EnzOQa14ubKQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, "node_modules/is-unicode-supported": { "version": "0.1.0", @@ -1893,9 +1882,9 @@ } }, "node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, "node_modules/isbinaryfile": { @@ -1916,10 +1905,10 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "node_modules/isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "node_modules/js-yaml": { @@ -1934,16 +1923,10 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true - }, - "node_modules/json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, "node_modules/json-schema-traverse": { @@ -1958,36 +1941,15 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, "node_modules/jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "optionalDependencies": { "graceful-fs": "^4.1.6" } }, - "node_modules/jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "engines": [ - "node >=0.6.0" - ], - "dependencies": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, "node_modules/just-extend": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", @@ -1995,15 +1957,15 @@ "dev": true }, "node_modules/karma": { - "version": "6.3.6", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.6.tgz", - "integrity": "sha512-xsiu3D6AjCv6Uq0YKXJgC6TvXX2WloQ5+XtHXmC1lwiLVG617DDV3W2DdM4BxCMKHlmz6l3qESZHFQGHAKvrew==", + "version": "6.3.11", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.11.tgz", + "integrity": "sha512-QGUh4yXgizzDNPLB5nWTvP+wysKexngbyLVWFOyikB661hpa2RZLf5anZQzqliWtAQuYVep0ot0D1U7UQKpsxQ==", "dev": true, "dependencies": { "body-parser": "^1.19.0", "braces": "^3.0.2", "chokidar": "^3.5.1", - "colors": "^1.4.0", + "colors": "1.4.0", "connect": "^3.7.0", "di": "^0.0.1", "dom-serialize": "^2.2.1", @@ -2077,9 +2039,9 @@ } }, "node_modules/karma-firefox-launcher": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.1.tgz", - "integrity": "sha512-VzDMgPseXak9DtfyE1O5bB2BwsMy1zzO1kUxVW1rP0yhC4tDNJ0p3JoFdzvrK4QqVzdqUMa9Rx9YzkdFp8hz3Q==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", "dev": true, "dependencies": { "is-wsl": "^2.2.0", @@ -2107,19 +2069,6 @@ "minimist": "^1.2.3" } }, - "node_modules/karma-phantomjs-launcher": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", - "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", - "dev": true, - "dependencies": { - "lodash": "^4.0.1", - "phantomjs-prebuilt": "^2.1.7" - }, - "peerDependencies": { - "karma": ">=0.9" - } - }, "node_modules/karma-rollup-preprocessor": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.7.tgz", @@ -2164,21 +2113,6 @@ "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", "dev": true }, - "node_modules/kew": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true - }, - "node_modules/klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "optionalDependencies": { - "graceful-fs": "^4.1.9" - } - }, "node_modules/leafdoc": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/leafdoc/-/leafdoc-2.3.0.tgz", @@ -2215,6 +2149,12 @@ "integrity": "sha1-EN8sBGrTVG5yT7pV+nLN4YpqAfM=", "dev": true }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, "node_modules/linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", @@ -2245,6 +2185,12 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -2295,18 +2241,6 @@ "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/markdown-it": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-11.0.1.tgz", @@ -2347,6 +2281,19 @@ "node": ">= 0.6" } }, + "node_modules/micromatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "dev": true, + "dependencies": { + "braces": "^3.0.1", + "picomatch": "^2.2.3" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/mime": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", @@ -2410,22 +2357,10 @@ "node": ">=8" } }, - "node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/mocha": { - "version": "9.1.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", - "integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==", + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.4.tgz", + "integrity": "sha512-+q2aV5VlJZuLgCWoBvGI5zEwPF9eEI0kr/sAA9Jm4xMND7RfIEyF8JE7C0JIg8WXRG+P1sdIAb5ccoHPlXLzcw==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", @@ -2524,6 +2459,12 @@ "quotemeta": "0.0.0" } }, + "node_modules/nanoclone": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/nanoclone/-/nanoclone-0.2.1.tgz", + "integrity": "sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA==", + "dev": true + }, "node_modules/nanoid": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", @@ -2588,15 +2529,6 @@ "node": ">=0.10.0" } }, - "node_modules/oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2686,6 +2618,24 @@ "node": ">=6" } }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2737,65 +2687,13 @@ "isarray": "0.0.1" } }, - "node_modules/path-to-regexp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, - "node_modules/phantomjs-prebuilt": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", - "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", - "deprecated": "this package is now deprecated", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "es6-promise": "^4.0.3", - "extract-zip": "^1.6.5", - "fs-extra": "^1.0.0", - "hasha": "^2.2.0", - "kew": "^0.7.0", - "progress": "^1.1.8", - "request": "^2.81.0", - "request-progress": "^2.0.1", - "which": "^1.2.10" - }, - "bin": { - "phantomjs": "bin/phantomjs" - } - }, - "node_modules/phantomjs-prebuilt/node_modules/progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/phantomjs-prebuilt/node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" + "node": ">=8" } }, "node_modules/picomatch": { @@ -2810,27 +2708,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "dependencies": { - "pinkie": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2840,31 +2717,16 @@ "node": ">= 0.8.0" } }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "node_modules/property-expr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.4.tgz", + "integrity": "sha512-sFPkHQjVKheDNnPvotjQmm3KD3uk1fWKUN7CrpdbwmUx3CrG3QiM8QpTSimvig5vTXmTvjz7+TDvXOI9+4rkcg==", "dev": true }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/prosthetic-hand": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/prosthetic-hand/-/prosthetic-hand-1.3.1.tgz", - "integrity": "sha1-qhPUqZ1aOcXRaMviB7zOV26EpzI=", - "dev": true - }, - "node_modules/psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosthetic-hand/-/prosthetic-hand-1.4.0.tgz", + "integrity": "sha512-H0YgNfPFkO6x00Viw8+6LnqYisivAt8i3enoLnCxRUlT80DM/9i99BVBcKGUosPJ635CxlJMsYbjYLHCFpvF2w==", "dev": true }, "node_modules/punycode": { @@ -2933,21 +2795,6 @@ "node": ">= 0.8" } }, - "node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -3008,56 +2855,6 @@ "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", - "dev": true, - "dependencies": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/request-progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", - "dev": true, - "dependencies": { - "throttleit": "^1.0.0" - } - }, - "node_modules/request/node_modules/qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true, - "engines": { - "node": ">=0.6" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3117,9 +2914,9 @@ } }, "node_modules/rollup": { - "version": "2.58.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.3.tgz", - "integrity": "sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==", + "version": "2.64.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.64.0.tgz", + "integrity": "sha512-+c+lbw1lexBKSMb1yxGDVfJ+vchJH3qLbmavR+awDinTDA2C5Ug9u7lkOzj62SCu0PKUExsW36tpgW7Fmpn3yQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -3141,10 +2938,24 @@ } }, "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/safer-buffer": { "version": "2.1.2", @@ -3152,21 +2963,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -3311,37 +3107,21 @@ "node": ">=0.10.0" } }, + "node_modules/split-lines": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-lines/-/split-lines-1.1.0.tgz", + "integrity": "sha1-Oruo9ZhhQUL5240nq2q4dWYqHgk=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "node_modules/sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "dev": true, - "dependencies": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - }, - "bin": { - "sshpk-conv": "bin/sshpk-conv", - "sshpk-sign": "bin/sshpk-sign", - "sshpk-verify": "bin/sshpk-verify" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/ssri": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", @@ -3382,46 +3162,8 @@ "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", "integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA==", "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/streamroller/node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/streamroller/node_modules/graceful-fs": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", - "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", - "dev": true - }, - "node_modules/streamroller/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" + "engines": { + "node": ">=4.0" } }, "node_modules/string-width": { @@ -3480,12 +3222,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "node_modules/throttleit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", - "dev": true - }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -3519,35 +3255,10 @@ "node": ">=0.6" } }, - "node_modules/tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "dependencies": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "dependencies": { - "safe-buffer": "^5.0.1" - }, - "engines": { - "node": "*" - } - }, - "node_modules/tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "node_modules/toposort": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz", + "integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA=", "dev": true }, "node_modules/type-check": { @@ -3596,12 +3307,6 @@ "node": ">= 0.6" } }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, "node_modules/ua-parser-js": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.31.tgz", @@ -3628,9 +3333,9 @@ "dev": true }, "node_modules/uglify-js": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.2.tgz", - "integrity": "sha512-rtPMlmcO4agTUfz10CbgJ1k6UAoXM2gWb3GoMPPZB/+/Ackf8lNWk11K4rYi2D0apgoFRLtQOZhb+/iGNJq26A==", + "version": "3.14.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.5.tgz", + "integrity": "sha512-qZukoSxOG0urUTvjc2ERMTcAy+BiFh3weWAkeurLwjrCba73poHmG3E36XEjd/JGukMzwTL7uCxZiAexj8ppvQ==", "dev": true, "bin": { "uglifyjs": "bin/uglifyjs" @@ -3666,12 +3371,6 @@ "punycode": "^2.1.0" } }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -3681,16 +3380,6 @@ "node": ">= 0.4.0" } }, - "node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "dev": true, - "bin": { - "uuid": "bin/uuid" - } - }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -3706,26 +3395,6 @@ "node": ">= 0.8" } }, - "node_modules/verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "engines": [ - "node >=0.6.0" - ], - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, - "node_modules/verror/node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -3839,6 +3508,15 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -3881,16 +3559,6 @@ "node": ">=10" } }, - "node_modules/yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "dev": true, - "dependencies": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -3902,72 +3570,162 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/yup": { + "version": "0.32.11", + "resolved": "https://registry.npmjs.org/yup/-/yup-0.32.11.tgz", + "integrity": "sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.15.4", + "@types/lodash": "^4.14.175", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "nanoclone": "^0.2.1", + "property-expr": "^2.0.4", + "toposort": "^2.0.2" + }, + "engines": { + "node": ">=10" + } } }, "dependencies": { - "@babel/runtime-corejs3": { - "version": "7.15.4", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.15.4.tgz", - "integrity": "sha512-lWcAqKeB624/twtTc3w6w/2o9RqJPaNBhPGK6DKLSiwuVWC7WFkypWyNg+CpZoyJH0jVzv1uMtXZ/5/lQOLtCg==", + "@babel/code-frame": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", + "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", "dev": true, "requires": { - "core-js-pure": "^3.16.0", - "regenerator-runtime": "^0.13.4" + "@babel/highlight": "^7.16.7" } }, - "@eslint/eslintrc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.3.tgz", - "integrity": "sha512-DHI1wDPoKCBPoLZA3qDR91+3te/wDSc1YhKg3jR8NxKKRJq2hwHwcWv31cSwSYvIBrmbENoYMWcenW8uproQqg==", + "@babel/helper-validator-identifier": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", + "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", + "dev": true + }, + "@babel/highlight": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.7.tgz", + "integrity": "sha512-aKpPMfLvGO3Q97V0qhw/V2SWNWlwfJknuwAunU7wZLSfrM4xTBvg7E5opUVi1kJTBKihE38CPg4nBiqX83PWYw==", "dev": true, "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.0.0", - "globals": "^13.9.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" + "@babel/helper-validator-identifier": "^7.16.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "has-flag": "^3.0.0" } } } }, + "@babel/runtime": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.7.tgz", + "integrity": "sha512-9E9FJowqAsytyOY6LG+1KuueckRL+aQW+mKvXRXnuFGyRAyepJPmEo9vgMfXUA6O9u3IeEdv9MAkppFcaQwogQ==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/runtime-corejs3": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.16.0.tgz", + "integrity": "sha512-Oi2qwQ21X7/d9gn3WiwkDTJmq3TQtYNz89lRnoFy8VeZpWlsyXvzSwiRrRZ8cXluvSwqKxqHJ6dBd9Rv+p0ZGQ==", + "dev": true, + "requires": { + "core-js-pure": "^3.19.0", + "regenerator-runtime": "^0.13.4" + } + }, + "@eslint/eslintrc": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz", + "integrity": "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.2.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + } + }, "@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz", + "integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.0", + "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", "minimatch": "^3.0.4" } }, "@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", - "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, "@rollup/plugin-json": { @@ -4050,12 +3808,24 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "@types/lodash": { + "version": "4.14.178", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.178.tgz", + "integrity": "sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==", + "dev": true + }, "@types/node": { "version": "16.11.6", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz", "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==", "dev": true }, + "@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -4073,9 +3843,9 @@ } }, "acorn": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.5.0.tgz", - "integrity": "sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", "dev": true }, "acorn-jsx": { @@ -4140,39 +3910,15 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, - "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "dev": true, "requires": { - "safer-buffer": "~2.1.0" + "follow-redirects": "^1.14.0" } }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true - }, - "aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", - "dev": true - }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -4191,15 +3937,6 @@ "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", "dev": true }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -4260,23 +3997,47 @@ "fill-range": "^7.0.1" } }, + "brotli-size": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/brotli-size/-/brotli-size-4.0.0.tgz", + "integrity": "sha512-uA9fOtlTRC0iqKfzff1W34DXUA3GyVqbUaeo3Rw3d4gd1eavKVCETXrn3NzO74W+UVkG3UHu8WxUi+XvKI/huA==", + "dev": true, + "requires": { + "duplexer": "0.1.1" + } + }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true + "bundlemon": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bundlemon/-/bundlemon-1.3.0.tgz", + "integrity": "sha512-6tSARvzrYf3K8xRC19GXBTCI4p45QxDV4VyyYEh1hUuM7gJdBIAUalhZY/5yidmhthGkonIVTh3taH054BLqGw==", + "dev": true, + "requires": { + "axios": "^0.21.1", + "brotli-size": "^4.0.0", + "bundlemon-utils": "^0.4.0", + "bytes": "^3.1.0", + "chalk": "^4.1.1", + "commander": "^8.0.0", + "cosmiconfig": "^7.0.0", + "gzip-size": "^6.0.0", + "micromatch": "^4.0.4", + "yup": "^0.32.11" + } }, - "buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "bundlemon-utils": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/bundlemon-utils/-/bundlemon-utils-0.4.0.tgz", + "integrity": "sha512-BqYhoCgkPNgdN3ORpj2Xqphj+OQ4iHGBqq9KfM2aQpj+RAauVS2F0EAe77ZXpme2JLbLJq6MyrUOHoeXvB2lGA==", + "dev": true, + "requires": { + "bytes": "^3.1.0" + } }, "bytes": { "version": "3.1.0", @@ -4296,12 +4057,6 @@ "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", "dev": true }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -4350,6 +4105,16 @@ "wrap-ansi": "^7.0.0" } }, + "clone-regexp": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/clone-regexp/-/clone-regexp-1.0.1.tgz", + "integrity": "sha512-Fcij9IwRW27XedRIJnSOEupS7RVcXtObJXbcUOX93UCLqqOdRpkvzKywOOSizmEK/Is3S/RHX9dLdfo6R1Q1mw==", + "dev": true, + "requires": { + "is-regexp": "^1.0.0", + "is-supported-regexp-flag": "^1.0.0" + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -4371,14 +4136,11 @@ "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", "dev": true }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } + "commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true }, "comment-patterns": { "version": "0.11.0", @@ -4401,18 +4163,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, "connect": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", @@ -4460,12 +4210,6 @@ "integrity": "sha512-UEQk8AxyCYvNAs6baNoPqDADv7BX0AmBLGxVsrAifPPx/C8EAzV4Q+2ZUJqVzfI2TQQEZITnwUkWcHpgc/IubQ==", "dev": true }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true - }, "cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -4476,6 +4220,19 @@ "vary": "^1" } }, + "cosmiconfig": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.1.tgz", + "integrity": "sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==", + "dev": true, + "requires": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.2.1", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.10.0" + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -4493,15 +4250,6 @@ "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, "date-format": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-3.0.0.tgz", @@ -4535,12 +4283,6 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -4580,15 +4322,11 @@ "void-elements": "^2.0.0" } }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "dev": true, - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true }, "edge-launcher": { "version": "1.2.2", @@ -4641,15 +4379,6 @@ "base64-arraybuffer": "~1.0.1" } }, - "enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.1" - } - }, "ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", @@ -4662,11 +4391,14 @@ "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", "dev": true }, - "es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } }, "escalade": { "version": "3.1.1", @@ -4687,24 +4419,23 @@ "dev": true }, "eslint": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.1.0.tgz", - "integrity": "sha512-JZvNneArGSUsluHWJ8g8MMs3CfIEzwaLx9KyH4tZ2i+R2/rPWzL8c0zg3rHdwYVpN/1sB9gqnjHwz9HoeJpGHw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.7.0.tgz", + "integrity": "sha512-ifHYzkBGrzS2iDU7KjhCAVMGCvF6M3Xfs8X8b37cgrUlDt6bWRTpRh6T/gtSXv1HJ/BUGgmjvNvOEGu85Iif7w==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.0.3", - "@humanwhocodes/config-array": "^0.6.0", + "@eslint/eslintrc": "^1.0.5", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", - "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", + "eslint-scope": "^7.1.0", "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", + "eslint-visitor-keys": "^3.2.0", + "espree": "^9.3.0", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -4712,7 +4443,7 @@ "functional-red-black-tree": "^1.0.1", "glob-parent": "^6.0.1", "globals": "^13.6.0", - "ignore": "^4.0.6", + "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", @@ -4723,13 +4454,19 @@ "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "progress": "^2.0.0", "regexpp": "^3.2.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "ignore": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", + "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "dev": true + } } }, "eslint-config-mourner": { @@ -4738,10 +4475,21 @@ "integrity": "sha512-ydFFzE/WkqvmozI3CM0lAtDZoYfmN03ycjlHzdPZW5x+o3Me1pI0lyfpsWoz9kOqykZk8qlvOVC5BN5UMwtXrg==", "dev": true }, + "eslint-plugin-script-tags": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-script-tags/-/eslint-plugin-script-tags-0.5.0.tgz", + "integrity": "sha512-iomN8+MwDyhRGWKwRKfBg4EchXuOCJ4iPC8bE9q255xdneXdIhvJU0AaWEe9GPXQIrJ3JKNKZbU1dAlAPbyyAg==", + "dev": true, + "requires": { + "execall": "^1.0.0", + "lodash": "^4.16.0", + "split-lines": "^1.1.0" + } + }, "eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz", + "integrity": "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==", "dev": true, "requires": { "esrecurse": "^4.3.0", @@ -4766,28 +4514,22 @@ } }, "eslint-visitor-keys": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz", - "integrity": "sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.2.0.tgz", + "integrity": "sha512-IOzT0X126zn7ALX0dwFiUQEdsfzrm4+ISsQS8nukaJXwEyYKRSnEIIDULYg1mCtGp7UUXgfGl7BIolXREQK+XQ==", "dev": true }, "espree": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.0.0.tgz", - "integrity": "sha512-r5EQJcYZ2oaGbeR0jR0fFVijGOcwai07/690YRXLINuhmVeRY4UKSAsQPe/0BNuDgwP7Ophoc1PRsr2E3tkbdQ==", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.0.tgz", + "integrity": "sha512-d/5nCsb0JcqsSEeQzFZ8DH1RmxPcglRWh24EFTlUEmCKoehXGdpsx0RkHDubqUI8LSAIKMQp4r9SzQ3n+sm4HQ==", "dev": true, "requires": { - "acorn": "^8.5.0", + "acorn": "^8.7.0", "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.0.0" + "eslint-visitor-keys": "^3.1.0" } }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, "esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", @@ -4830,6 +4572,15 @@ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", "dev": true }, + "execall": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/execall/-/execall-1.0.0.tgz", + "integrity": "sha1-c9CQTjlbPKsGWLCNCewlMH8pu3M=", + "dev": true, + "requires": { + "clone-regexp": "^1.0.0" + } + }, "expect.js": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.3.1.tgz", @@ -4837,44 +4588,9 @@ "dev": true }, "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extract-zip": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", - "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", - "dev": true, - "requires": { - "concat-stream": "^1.6.2", - "debug": "^2.6.9", - "mkdirp": "^0.5.4", - "yauzl": "^2.10.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, "fast-deep-equal": { @@ -4895,15 +4611,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dev": true, - "requires": { - "pend": "~1.2.0" - } - }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -4987,37 +4694,28 @@ "dev": true }, "follow-redirects": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", + "version": "1.14.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", + "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==", "dev": true }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, "fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + } } }, "fs.realpath": { @@ -5051,15 +4749,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, "git-rev-sync": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-3.0.1.tgz", @@ -5123,6 +4812,23 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, + "gzip-size": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", + "integrity": "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==", + "dev": true, + "requires": { + "duplexer": "^0.1.2" + }, + "dependencies": { + "duplexer": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", + "dev": true + } + } + }, "handlebars": { "version": "4.7.7", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", @@ -5142,22 +4848,6 @@ "integrity": "sha512-fBouIWb3fMsRCfCySHgk6+/gTEijMAWUZM/TYKmjuui9VsdS2DGWNjcH9cN7/tPn9nSkxGSGLJU6FHh37G0WUg==", "dev": true }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, - "har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "dev": true, - "requires": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - } - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -5173,16 +4863,6 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "hasha": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "requires": { - "is-stream": "^1.0.1", - "pinkie-promise": "^2.0.0" - } - }, "he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -5221,17 +4901,6 @@ "requires-port": "^1.0.0" } }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -5285,6 +4954,12 @@ "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==", "dev": true }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -5342,16 +5017,16 @@ "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", "dev": true }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "is-supported-regexp-flag": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.1.tgz", + "integrity": "sha512-3vcJecUUrpgCqc/ca0aWeNu64UGgxcvO60K/Fkr1N6RSvfGCTU60UKN68JDmKokgba0rFFJs12EnzOQa14ubKQ==", "dev": true }, "is-unicode-supported": { @@ -5370,9 +5045,9 @@ } }, "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, "isbinaryfile": { @@ -5387,10 +5062,10 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "js-yaml": { @@ -5402,16 +5077,10 @@ "argparse": "^2.0.1" } }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", "dev": true }, "json-schema-traverse": { @@ -5426,33 +5095,15 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "requires": { "graceful-fs": "^4.1.6" } }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, "just-extend": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", @@ -5460,15 +5111,15 @@ "dev": true }, "karma": { - "version": "6.3.6", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.6.tgz", - "integrity": "sha512-xsiu3D6AjCv6Uq0YKXJgC6TvXX2WloQ5+XtHXmC1lwiLVG617DDV3W2DdM4BxCMKHlmz6l3qESZHFQGHAKvrew==", + "version": "6.3.11", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.11.tgz", + "integrity": "sha512-QGUh4yXgizzDNPLB5nWTvP+wysKexngbyLVWFOyikB661hpa2RZLf5anZQzqliWtAQuYVep0ot0D1U7UQKpsxQ==", "dev": true, "requires": { "body-parser": "^1.19.0", "braces": "^3.0.2", "chokidar": "^3.5.1", - "colors": "^1.4.0", + "colors": "1.4.0", "connect": "^3.7.0", "di": "^0.0.1", "dom-serialize": "^2.2.1", @@ -5537,9 +5188,9 @@ } }, "karma-firefox-launcher": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.1.tgz", - "integrity": "sha512-VzDMgPseXak9DtfyE1O5bB2BwsMy1zzO1kUxVW1rP0yhC4tDNJ0p3JoFdzvrK4QqVzdqUMa9Rx9YzkdFp8hz3Q==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", "dev": true, "requires": { "is-wsl": "^2.2.0", @@ -5564,16 +5215,6 @@ "minimist": "^1.2.3" } }, - "karma-phantomjs-launcher": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", - "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", - "dev": true, - "requires": { - "lodash": "^4.0.1", - "phantomjs-prebuilt": "^2.1.7" - } - }, "karma-rollup-preprocessor": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.7.tgz", @@ -5598,21 +5239,6 @@ "dev": true, "requires": {} }, - "kew": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true - }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, "leafdoc": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/leafdoc/-/leafdoc-2.3.0.tgz", @@ -5643,6 +5269,12 @@ "integrity": "sha1-EN8sBGrTVG5yT7pV+nLN4YpqAfM=", "dev": true }, + "lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, "linkify-it": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", @@ -5667,6 +5299,12 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true + }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -5710,15 +5348,6 @@ "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", "dev": true }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, "markdown-it": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-11.0.1.tgz", @@ -5755,6 +5384,16 @@ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, + "micromatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.2.3" + } + }, "mime": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", @@ -5800,19 +5439,10 @@ "yallist": "^4.0.0" } }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, "mocha": { - "version": "9.1.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz", - "integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==", + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.4.tgz", + "integrity": "sha512-+q2aV5VlJZuLgCWoBvGI5zEwPF9eEI0kr/sAA9Jm4xMND7RfIEyF8JE7C0JIg8WXRG+P1sdIAb5ccoHPlXLzcw==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -5890,6 +5520,12 @@ "quotemeta": "0.0.0" } }, + "nanoclone": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/nanoclone/-/nanoclone-0.2.1.tgz", + "integrity": "sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA==", + "dev": true + }, "nanoid": { "version": "3.1.25", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.25.tgz", @@ -5944,12 +5580,6 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -6015,6 +5645,18 @@ "callsites": "^3.0.0" } }, + "parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -6052,111 +5694,36 @@ "dev": true, "requires": { "isarray": "0.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } } }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, - "phantomjs-prebuilt": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", - "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", - "dev": true, - "requires": { - "es6-promise": "^4.0.3", - "extract-zip": "^1.6.5", - "fs-extra": "^1.0.0", - "hasha": "^2.2.0", - "kew": "^0.7.0", - "progress": "^1.1.8", - "request": "^2.81.0", - "request-progress": "^2.0.1", - "which": "^1.2.10" - }, - "dependencies": { - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, "picomatch": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", "dev": true }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "property-expr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.4.tgz", + "integrity": "sha512-sFPkHQjVKheDNnPvotjQmm3KD3uk1fWKUN7CrpdbwmUx3CrG3QiM8QpTSimvig5vTXmTvjz7+TDvXOI9+4rkcg==", "dev": true }, "prosthetic-hand": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/prosthetic-hand/-/prosthetic-hand-1.3.1.tgz", - "integrity": "sha1-qhPUqZ1aOcXRaMviB7zOV26EpzI=", - "dev": true - }, - "psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosthetic-hand/-/prosthetic-hand-1.4.0.tgz", + "integrity": "sha512-H0YgNfPFkO6x00Viw8+6LnqYisivAt8i3enoLnCxRUlT80DM/9i99BVBcKGUosPJ635CxlJMsYbjYLHCFpvF2w==", "dev": true }, "punycode": { @@ -6210,21 +5777,6 @@ "unpipe": "1.0.0" } }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, "readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -6270,51 +5822,6 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, - "request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "dev": true, - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "dependencies": { - "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", - "dev": true - } - } - }, - "request-progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", - "dev": true, - "requires": { - "throttleit": "^1.0.0" - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -6359,9 +5866,9 @@ } }, "rollup": { - "version": "2.58.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.3.tgz", - "integrity": "sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==", + "version": "2.64.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.64.0.tgz", + "integrity": "sha512-+c+lbw1lexBKSMb1yxGDVfJ+vchJH3qLbmavR+awDinTDA2C5Ug9u7lkOzj62SCu0PKUExsW36tpgW7Fmpn3yQ==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -6377,9 +5884,9 @@ } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, "safer-buffer": { @@ -6388,15 +5895,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, "serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -6513,29 +6011,18 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "split-lines": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-lines/-/split-lines-1.1.0.tgz", + "integrity": "sha1-Oruo9ZhhQUL5240nq2q4dWYqHgk=", + "dev": true + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "sshpk": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", - "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", - "dev": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, "ssri": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", @@ -6567,44 +6054,9 @@ "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.1.0.tgz", "integrity": "sha512-bYQuGLeFxhkxNOF3rcMtiZxvCBAquGzZm6oWA1oZ0g2THUzivaRhv8uOhdr19LmoobSOLoIAxeUK2RdbM8IFTA==", "dev": true - }, - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "graceful-fs": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", - "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", - "dev": true - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } } } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -6646,12 +6098,6 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "throttleit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", - "dev": true - }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -6676,29 +6122,10 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, - "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "toposort": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz", + "integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA=", "dev": true }, "type-check": { @@ -6732,12 +6159,6 @@ "mime-types": "~2.1.24" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, "ua-parser-js": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.31.tgz", @@ -6751,9 +6172,9 @@ "dev": true }, "uglify-js": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.2.tgz", - "integrity": "sha512-rtPMlmcO4agTUfz10CbgJ1k6UAoXM2gWb3GoMPPZB/+/Ackf8lNWk11K4rYi2D0apgoFRLtQOZhb+/iGNJq26A==", + "version": "3.14.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.5.tgz", + "integrity": "sha512-qZukoSxOG0urUTvjc2ERMTcAy+BiFh3weWAkeurLwjrCba73poHmG3E36XEjd/JGukMzwTL7uCxZiAexj8ppvQ==", "dev": true }, "universalify": { @@ -6777,24 +6198,12 @@ "punycode": "^2.1.0" } }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -6807,25 +6216,6 @@ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "dev": true }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - } - } - }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -6904,6 +6294,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -6937,21 +6333,26 @@ "is-plain-obj": "^2.1.0" } }, - "yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "dev": true, - "requires": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true + }, + "yup": { + "version": "0.32.11", + "resolved": "https://registry.npmjs.org/yup/-/yup-0.32.11.tgz", + "integrity": "sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg==", + "dev": true, + "requires": { + "@babel/runtime": "^7.15.4", + "@types/lodash": "^4.14.175", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "nanoclone": "^0.2.1", + "property-expr": "^2.0.4", + "toposort": "^2.0.2" + } } } } diff --git a/package.json b/package.json index 2c1a02aefb1..50da5fe4f2c 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,10 @@ "description": "JavaScript library for mobile-friendly interactive maps", "devDependencies": { "@rollup/plugin-json": "^4.1.0", + "bundlemon": "^1.3.0", "eslint": "^8.1.0", "eslint-config-mourner": "^2.0.3", + "eslint-plugin-script-tags": "^0.5.0", "git-rev-sync": "^3.0.1", "happen": "~0.3.2", "karma": "^6.3.6", @@ -16,15 +18,13 @@ "karma-firefox-launcher": "^2.1.1", "karma-ie-launcher": "^1.0.0", "karma-mocha": "^2.0.1", - "karma-phantomjs-launcher": "^1.0.4", "karma-rollup-preprocessor": "^7.0.7", "karma-safari-launcher": "~1.0.0", "karma-sinon": "^1.0.5", "leafdoc": "^2.3.0", "mocha": "^9.1.3", - "phantomjs-prebuilt": "^2.1.16", "prosthetic-hand": "^1.3.1", - "rollup": "^2.58.3", + "rollup": "^2.59.0", "rollup-plugin-git-version": "^0.3.1", "sinon": "^7.5.0", "ssri": "^8.0.1", @@ -35,21 +35,33 @@ "files": [ "dist", "src", - "!dist/leaflet.zip" + "!dist/leaflet.zip", + "!*.leafdoc" ], "scripts": { "docs": "node ./build/docs.js", "test": "karma start ./spec/karma.conf.js", "build": "npm run rollup && npm run uglify", - "release": "./build/publish.sh", - "lint": "eslint src spec/suites docs/docs/js build", + "lint": "eslint .", "lintfix": "npm run lint -- --fix", "rollup": "rollup -c build/rollup-config.js", - "watch": "rollup -w -c build/rollup-watch-config.js", + "watch": "rollup -w -c build/rollup-config.js", "uglify": "uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments", - "integrity": "node ./build/integrity.js" + "integrity": "node ./build/integrity.js", + "bundlemon": "bundlemon --subProject no-compression --defaultCompression none && bundlemon --subProject gzip-compression --defaultCompression gzip" }, "eslintConfig": { + "ignorePatterns": [ + "dist", + "debug", + "docs/docs/highlight", + "docs/examples/choropleth/us-states.js", + "docs/examples/geojson/sample-geojson.js", + "docs/examples/map-panes/eu-countries.js", + "docs/examples/extending/extending-2-layers.md", + "docs/_posts/2012*", + "docs/_site" + ], "root": true, "globals": { "L": true @@ -60,6 +72,9 @@ "node": false }, "extends": "mourner", + "plugins": [ + "script-tags" + ], "parserOptions": { "ecmaVersion": 6, "sourceType": "module" @@ -96,13 +111,24 @@ }, "overrides": [ { - "files": ["build/**/*"], + "files": [ + "build/**/*" + ], "env": { "node": true }, "rules": { "global-require": 0 } + }, + { + "files": [ + "*.md" + ], + "rules": { + "eol-last": 0, + "no-unused-vars": 0 + } } ] }, diff --git a/spec/before.js b/spec/before.js index 33816425043..e69de29bb2d 100644 --- a/spec/before.js +++ b/spec/before.js @@ -1,2 +0,0 @@ -// Trick Leaflet into believing we have a touchscreen (for desktop) -if (window.TouchEvent) { window.ontouchstart = function(){} }; diff --git a/spec/index.html b/spec/index.html index ac9a0d7212a..f0e74016b26 100644 --- a/spec/index.html +++ b/spec/index.html @@ -42,6 +42,7 @@ + @@ -53,10 +54,15 @@ - + + + + + + @@ -89,15 +95,14 @@ + - - - + diff --git a/spec/karma.conf.js b/spec/karma.conf.js index 940dee374a8..f1aed91a9c7 100644 --- a/spec/karma.conf.js +++ b/spec/karma.conf.js @@ -1,13 +1,13 @@ var json = require('@rollup/plugin-json'); const outro = `var oldL = window.L; -exports.noConflict = function() { +leaflet.noConflict = function() { window.L = oldL; return this; } // Always export us to window global (see #2364) -window.L = exports;`; +window.L = leaflet;`; // Karma configuration module.exports = function (config) { @@ -39,7 +39,6 @@ module.exports = function (config) { 'karma-mocha', 'karma-sinon', 'karma-expect', - 'karma-phantomjs-launcher', 'karma-edge-launcher', 'karma-ie-launcher', 'karma-chrome-launcher', @@ -64,7 +63,7 @@ module.exports = function (config) { ], output: { format: 'umd', - name: 'L', + name: 'leaflet', outro: outro, freeze: false, }, @@ -93,9 +92,8 @@ module.exports = function (config) { // - Firefox // - Opera // - Safari (only Mac) - // - PhantomJS // - IE (only Windows) - browsers: ['PhantomJSCustom'], + browsers: ['Chrome1280x1024'], customLaunchers: { 'Chrome1280x1024': { @@ -104,57 +102,41 @@ module.exports = function (config) { // https://github.com/Leaflet/Leaflet/issues/7113#issuecomment-619528577 flags: ['--window-size=1280,1024'] }, - 'FirefoxPointer': { - base: 'FirefoxHeadless', - prefs: { - 'dom.w3c_pointer_events.enabled': true, - 'dom.w3c_touch_events.enabled': 0 - } - }, 'FirefoxTouch': { base: 'FirefoxHeadless', - prefs: { - 'dom.w3c_pointer_events.enabled': false, + prefs: { 'dom.w3c_touch_events.enabled': 1 - } + } }, - 'FirefoxPointerTouch': { + 'FirefoxNoTouch': { base: 'FirefoxHeadless', - prefs: { - 'dom.w3c_pointer_events.enabled': true, - 'dom.w3c_touch_events.enabled': 1 - } - }, - 'PhantomJSCustom': { - base: 'PhantomJS', - flags: ['--load-images=true'], - options: { - onCallback: function (data) { - if (data.render) { - page.render(data.render); - } - } + prefs: { + 'dom.w3c_touch_events.enabled': 0 } + }, + IE10: { + base: 'IE', + 'x-ua-compatible': 'IE=EmulateIE10' } }, concurrency: 1, // If browser does not capture in given timeout [ms], kill it - captureTimeout: 10000, + captureTimeout: 60000, - // Workaround for PhantomJS random DISCONNECTED error - browserDisconnectTimeout: 10000, // default 2000 - browserDisconnectTolerance: 1, // default 0 + // Timeout for the client socket connection [ms]. + browserSocketTimeout: 30000, // Continuous Integration mode // if true, it capture browsers, run tests and exit singleRun: true, client: { - mocha: { - forbidOnly: process.env.CI || false - } + mocha: { + // eslint-disable-next-line no-undef + forbidOnly: process.env.CI || false + } } }); }; diff --git a/spec/suites/SpecHelper.js b/spec/suites/SpecHelper.js index bcc6e27b20e..f6a6fbc3a48 100644 --- a/spec/suites/SpecHelper.js +++ b/spec/suites/SpecHelper.js @@ -26,6 +26,7 @@ if (!Array.prototype.map) { } expect.Assertion.prototype.near = function (expected, delta) { + expected = L.point(expected); delta = delta || 1; expect(this.obj.x).to .be.within(expected.x - delta, expected.x + delta); @@ -34,6 +35,7 @@ expect.Assertion.prototype.near = function (expected, delta) { }; expect.Assertion.prototype.nearLatLng = function (expected, delta) { + expected = L.latLng(expected); delta = delta || 1e-4; expect(this.obj.lat).to .be.within(expected.lat - delta, expected.lat + delta); @@ -53,6 +55,17 @@ happen.at = function (what, x, y, props) { }, props || {})); }; +happen.makeEvent = (function (makeEvent) { + return function (o) { + var evt = makeEvent(o); + if (o.type.substring(0, 7) === 'pointer') { + evt.pointerId = o.pointerId; + evt.pointerType = o.pointerType; + } + return evt; + }; +})(happen.makeEvent); + // We'll want to skip a couple of things when in PhantomJS, due to lack of CSS animations it.skipIfNo3d = L.Browser.any3d ? it : it.skip; @@ -60,12 +73,11 @@ it.skipIfNo3d = L.Browser.any3d ? it : it.skip; it.skipIf3d = L.Browser.any3d ? it.skip : it; // A couple of tests need the browser to be touch-capable -it.skipIfNotTouch = (L.Browser.touch || L.Browser.pointer) ? it : it.skip; +it.skipIfNotTouch = L.Browser.touch ? it : it.skip; -// ATM Leaflet prefers pointer events even for touch (see #7077) -var touchEventType = L.Browser.pointer ? 'pointer' : 'touch'; // eslint-disable-line no-unused-vars +var touchEventType = L.Browser.touchNative ? 'touch' : 'pointer'; // eslint-disable-line no-unused-vars // Note: this override is needed to workaround prosthetic-hand fail, // see https://github.com/Leaflet/prosthetic-hand/issues/14 console.log('L.Browser.pointer', L.Browser.pointer); -console.log('L.Browser.touch', L.Browser.touch); +console.log('L.Browser.touchNative', L.Browser.touchNative); diff --git a/spec/suites/control/Control.LayersSpec.js b/spec/suites/control/Control.LayersSpec.js index 7c6d85b0951..0c737ff33c1 100644 --- a/spec/suites/control/Control.LayersSpec.js +++ b/spec/suites/control/Control.LayersSpec.js @@ -189,6 +189,13 @@ describe("Control.Layers", function () { }); describe("collapse when collapsed: true", function () { + it('expands on toggle focus', function () { + var layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map); + var toggle = layersCtrl._container.querySelector('.leaflet-control-layers-toggle'); + happen.once(toggle, {type:'focus'}); + expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok(); + }); + it('expands when mouse is over', function () { var layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map); happen.once(layersCtrl._container, {type:'mouseover'}); diff --git a/spec/suites/core/ClassSpec.js b/spec/suites/core/ClassSpec.js index 62f45c4e28b..83b717caa3c 100644 --- a/spec/suites/core/ClassSpec.js +++ b/spec/suites/core/ClassSpec.js @@ -2,6 +2,7 @@ describe("Class", function () { describe("#extend", function () { var Klass, + props, constructor, method; @@ -9,14 +10,15 @@ describe("Class", function () { constructor = sinon.spy(); method = sinon.spy(); - Klass = L.Class.extend({ + props = { statics: {bla: 1}, includes: {mixin: true}, initialize: constructor, foo: 5, bar: method - }); + }; + Klass = L.Class.extend(props); }); it("creates a class with the given constructor & properties", function () { @@ -46,10 +48,25 @@ describe("Class", function () { expect(method.called).to.be.ok(); }); + it("does not modify source props object", function () { + expect(props).to.eql({ + statics: {bla: 1}, + includes: {mixin: true}, + + initialize: constructor, + foo: 5, + bar: method + }); + }); + it("supports static properties", function () { expect(Klass.bla).to.eql(1); }); + it("does not merge 'statics' property itself", function () { + expect('statics' in Klass.prototype).to.not.be.ok(); + }); + it("inherits parent static properties", function () { var Klass2 = Klass.extend({}); @@ -67,6 +84,10 @@ describe("Class", function () { expect(a.mixin).to.be.ok(); }); + it("does not merge 'includes' property itself", function () { + expect('includes' in Klass.prototype).to.not.be.ok(); + }); + it("includes multiple mixins", function () { var Klass2 = L.Class.extend({ includes: [{mixin: true}, {mixin2: true}] @@ -117,6 +138,28 @@ describe("Class", function () { expect(K2.prototype.options.foo).to.eql('bar'); }); + it("does not reuse original props.options", function () { + var props = {options: {}}; + var K = L.Class.extend(props); + + expect(K.prototype.options).not.to.be(props.options); + }); + + it("does not replace source props.options object", function () { + var K1 = L.Class.extend({options: {}}); + var opts = {}; + var props = {options: opts}; + K1.extend(props); + + expect(props.options).to.be(opts); + }); + + it("prevents change of prototype options", function () { + var Klass = L.Class.extend({options: {}}); + var instance = new Klass(); + expect(Klass.prototype.options).to.not.be(instance.options); + }); + it("adds constructor hooks correctly", function () { var spy1 = sinon.spy(); @@ -193,6 +236,37 @@ describe("Class", function () { b.quux(); expect(q.called).to.be.ok(); }); + + it("keeps parent options", function () { // #6070 + + var Quux = L.Class.extend({ + options: {foo: 'Foo!'} + }); + + Quux.include({ + options: {bar: 'Bar!'} + }); + + var q = new Quux(); + expect(q.options).to.have.property('foo'); + expect(q.options).to.have.property('bar'); + }); + + it("does not reuse original props.options", function () { + var props = {options: {}}; + var K = Klass.include(props); + + expect(K.prototype.options).not.to.be(props.options); + }); + + it("does not replace source props.options object", function () { + var K1 = Klass.include({options: {}}); + var opts = {}; + var props = {options: opts}; + K1.extend(props); + + expect(props.options).to.be(opts); + }); }); // TODO Class.mergeOptions diff --git a/spec/suites/core/EventsSpec.js b/spec/suites/core/EventsSpec.js index d29e560c033..722b02495c0 100644 --- a/spec/suites/core/EventsSpec.js +++ b/spec/suites/core/EventsSpec.js @@ -378,6 +378,38 @@ describe('Events', function () { }); describe('#on, #off & #fire', function () { + it('does not remove all listeners when any fn argument specified', function () { + var obj = new L.Evented(); + obj.on('test', L.Util.falseFn); + obj.off('test', undefined); + obj.off({test: undefined}); + + expect(obj.listens('test')).to.be(true); + }); + + it('ignores non-function listeners passed', function () { + var obj = new L.Evented(); + var off = obj.off.bind(obj); + ['string', {}, [], true, false, undefined].forEach(function (fn) { + obj.on('test', fn); + expect(obj.listens('test')).to.be(false); + expect(off).withArgs('test', fn).to.not.throwException(); + }); + }); + + it('throws with wrong types passed', function () { + var obj = new L.Evented(); + var on = obj.on.bind(obj); + var off = obj.off.bind(obj); + // todo? make it throw with [] + [true, false, undefined, 1].forEach(function (type) { + expect(on).withArgs(type, L.Util.falseFn).to.throwException(); + expect(off).withArgs(type, L.Util.falseFn).to.throwException(); + }); + + // todo? make `fire` and `listen` to throw with wrong type + }); + it('works like #addEventListener && #removeEventListener', function () { var obj = new L.Evented(), spy = sinon.spy(); diff --git a/spec/suites/core/GeneralSpec.js b/spec/suites/core/GeneralSpec.js index fce1f215a0e..662cd37b089 100644 --- a/spec/suites/core/GeneralSpec.js +++ b/spec/suites/core/GeneralSpec.js @@ -1,15 +1,12 @@ describe('General', function () { - describe('noConflict', function () { + it('noConflict', function () { var leaflet = L; - - after(function () { - L = leaflet; - }); - expect(L.noConflict()).to.eql(leaflet); + expect(L).to.eql(undefined); + L = leaflet; }); - describe('namespace extension', function () { + it('namespace extension', function () { L.Util.foo = 'bar'; L.Foo = 'Bar'; diff --git a/spec/suites/core/UtilSpec.js b/spec/suites/core/UtilSpec.js index 80a4063795a..caac6ad71ae 100644 --- a/spec/suites/core/UtilSpec.js +++ b/spec/suites/core/UtilSpec.js @@ -85,6 +85,7 @@ describe('Util', function () { expect(L.Util.formatNum(13.12325555, 3)).to.eql(13.123); expect(L.Util.formatNum(13.12325555)).to.eql(13.123256); expect(L.Util.formatNum(13.12325555, 0)).to.eql(13); + expect(L.Util.formatNum(13.12325555, false)).to.eql(13.12325555); expect(isNaN(L.Util.formatNum(-7.993322e-10))).to.eql(false); }); }); diff --git a/spec/suites/dom/DomEvent.DoubleTapSpec.js b/spec/suites/dom/DomEvent.DoubleTapSpec.js new file mode 100644 index 00000000000..005fa57ad25 --- /dev/null +++ b/spec/suites/dom/DomEvent.DoubleTapSpec.js @@ -0,0 +1,116 @@ +describe('DomEvent.DoubleTapSpec.js', function () { + var el, clock, spy; + + beforeEach(function () { + el = document.createElement('div'); + document.body.appendChild(el); + + clock = sinon.useFakeTimers(); + clock.tick(1000); + spy = sinon.spy(); + L.DomEvent.on(el, 'dblclick', spy); + }); + + afterEach(function () { + clock.restore(); + document.body.removeChild(el); + }); + + it('fires synthetic dblclick after two clicks with delay<200', function () { + happen.click(el, {detail: 1}); + clock.tick(100); + happen.click(el, {detail: 1}); + + expect(spy.called).to.be.ok(); + expect(spy.calledOnce).to.be.ok(); + expect(spy.lastCall.args[0]._simulated).to.be.ok(); + }); + + it('does not fire dblclick when delay>200', function () { + happen.click(el, {detail: 1}); + clock.tick(300); + happen.click(el, {detail: 1}); + + expect(spy.notCalled).to.be.ok(); + }); + + it('does not fire dblclick when detail !== 1', function () { + happen.click(el, {detail: 0}); // like in IE + clock.tick(100); + happen.click(el, {detail: 0}); + clock.tick(100); + + expect(spy.notCalled).to.be.ok(); + }); + + it('does not fire dblclick after removeListener', function () { + L.DomEvent.off(el, 'dblclick', spy); + + happen.click(el, {detail: 1}); + clock.tick(100); + happen.click(el, {detail: 1}); + clock.tick(100); + + expect(spy.notCalled).to.be.ok(); + }); + + it('does not conflict with native dblclick', function () { + happen.click(el, {detail: 1}); + clock.tick(100); + happen.click(el, {detail: 2}); // native dblclick expected + happen.dblclick(el); + expect(spy.called).to.be.ok(); + expect(spy.calledOnce).to.be.ok(); + expect(spy.lastCall.args[0]._simulated).not.to.be.ok(); + }); + + it('synthetic dblclick event has expected properties', function () { + var click = { + detail: 1, + clientX: 2, + clientY: 3, + screenX: 4, + screenY: 5 + }; + happen.click(el, click); + clock.tick(100); + happen.click(el, click); + + var event = spy.lastCall.args[0]; + var expectedProps = L.extend(click, { + type: 'dblclick', + // bubbles: true, // not important, as we do not actually dispatch the event + // cancelable: true, // + detail: 2, + target: el + }); + for (var prop in expectedProps) { + expect(event[prop]).to.be(expectedProps[prop]); + } + expect(event.isTrusted).not.to.be.ok(); + }); + + it('respects disableClickPropagation', function () { + var spyMap = sinon.spy(); + var map = L.map(el).setView([51.505, -0.09], 13); + map.on('dblclick', spyMap); + + var spyCtrl = sinon.spy(); + var ctrl = L.DomUtil.create('div'); + L.DomEvent.disableClickPropagation(ctrl); + var MyControl = L.Control.extend({ + onAdd: function () { + return ctrl; + } + }); + map.addControl(new MyControl()); + L.DomEvent.on(ctrl, 'dblclick', spyCtrl); + + happen.click(ctrl, {detail: 1}); + clock.tick(100); + happen.click(ctrl, {detail: 1}); + + expect(spyCtrl.called).to.be.ok(); + expect(spyMap.notCalled).to.be.ok(); + }); +}); diff --git a/spec/suites/dom/DomEvent.PointerSpec.js b/spec/suites/dom/DomEvent.PointerSpec.js new file mode 100644 index 00000000000..a190cb46d83 --- /dev/null +++ b/spec/suites/dom/DomEvent.PointerSpec.js @@ -0,0 +1,180 @@ +describe('DomEvent.Pointer', function () { + var el, + listeners = {}; + + var pointerEvents = ['pointerdown', 'pointermove', 'pointerup', 'pointercancel']; + var touchEvents = ['touchstart', 'touchmove', 'touchend', 'touchcancel']; + + beforeEach(function () { + el = document.createElement('div'); + document.body.appendChild(el); + touchEvents.forEach(function (type) { + listeners[type] = sinon.spy(); + L.DomEvent.on(el, type, listeners[type]); + }); + }); + + afterEach(function () { + happen.once(el, {type: 'pointercancel'}); // to reset prosphetic-hand + happen.once(el, {type: 'touchcancel'}); // + document.body.removeChild(el); + }); + + var skip = describe.skip; + + var pointerToTouch = L.Browser.pointer && !L.Browser.touchNative; + (pointerToTouch ? describe : skip)('#Simulates touch based on pointer events', function () { + it('adds a listener and calls it on pointer event', function () { + pointerEvents.forEach(function (type) { + happen.once(el, {type: type}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].called).to.be.ok(); + expect(listeners[type].calledOnce).to.be.ok(); + }); + }); + + it('does not call removed listener', function () { + touchEvents.forEach(function (type) { + L.DomEvent.off(el, type, listeners[type]); + }); + pointerEvents.forEach(function (type) { + happen.once(el, {type: type}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].notCalled).to.be.ok(); + }); + }); + + it('ignores events from mouse', function () { + pointerEvents.forEach(function (type) { + happen.once(el, {type: type, pointerType: 'mouse'}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].notCalled).to.be.ok(); + }); + }); + + it('ignores native touch events', function () { + touchEvents.forEach(function (type) { + happen.once(el, {type: type}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].notCalled).to.be.ok(); + }); + }); + + it('does not throw on invalid event names', function () { + L.DomEvent.on(el, 'touchleave', L.Util.falseFn); + L.DomEvent.off(el, 'touchleave', L.Util.falseFn); + }); + + it('simulates touch events with correct properties', function () { + function containIn(props, evt) { + if (Array.isArray(props)) { + return props.every(function (props0) { + return containIn(props0, evt); + }); + } + if ('length' in evt) { + return Array.prototype.some.call(evt, containIn.bind(this, props)); + } + for (var prop in props) { + var res = true; + if (props[prop] !== evt[prop]) { + return false; + } + } + return res; + } + // test helper function + expect(containIn(undefined, {a:1})).not.to.be.ok(); + expect(containIn({}, {a:1})).not.to.be.ok(); + expect(containIn({a:1}, {a:2})).not.to.be.ok(); + expect(containIn({a:1}, {a:1, b:2})).to.be.ok(); + expect(containIn({a:1, b:2}, {a:1})).not.to.be.ok(); + expect(containIn({a:1}, [{a:1}, {b:2}])).to.be.ok(); + expect(containIn({a:1}, [{a:0}, {b:2}])).not.to.be.ok(); + expect(containIn([{a:1}, {b:2}], [{a:1}, {b:2}, {c:3}])).to.be.ok(); + expect(containIn([{a:1}, {b:2}], [{a:0}, {b:2}])).not.to.be.ok(); + + // pointerdown/touchstart + var pointer1 = {clientX:1, clientY:1, pointerId: 1}; + happen.once(el, L.extend({type: 'pointerdown'}, pointer1)); + var evt = listeners.touchstart.lastCall.args[0]; + expect(evt.type).to.be('pointerdown'); + expect(evt).to.have.keys('touches', 'changedTouches'); + expect(evt.changedTouches).to.have.length(1); + expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok(); + expect(evt.touches).to.have.length(1); + expect(containIn(pointer1, evt.touches[0])).to.be.ok(); + + // another pointerdown/touchstart (multitouch) + var pointer2 = {clientX:2, clientY:2, pointerId: 2}; + happen.once(el, L.extend({type: 'pointerdown'}, pointer2)); + evt = listeners.touchstart.lastCall.args[0]; + expect(evt.type).to.be('pointerdown'); + expect(evt).to.have.keys('touches', 'changedTouches'); + expect(evt.changedTouches).to.have.length(1); + expect(containIn(pointer2, evt.changedTouches[0])).to.be.ok(); + expect(evt.touches).to.have.length(2); + expect(containIn([pointer1, pointer2], evt.touches)).to.be.ok(); + + // pointermove/touchmove (multitouch) + L.extend(pointer1, {clientX:11, clientY:11}); + happen.once(el, L.extend({type: 'pointermove'}, pointer1)); + evt = listeners.touchmove.lastCall.args[0]; + expect(evt.type).to.be('pointermove'); + expect(evt).to.have.keys('touches', 'changedTouches'); + expect(evt.changedTouches).to.have.length(1); + expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok(); + expect(evt.touches).to.have.length(2); + expect(containIn([pointer1, pointer2], evt.touches)).to.be.ok(); + + // pointerup/touchend (multitouch) + happen.once(el, L.extend({type: 'pointerup'}, pointer2)); + evt = listeners.touchend.lastCall.args[0]; + expect(evt.type).to.be('pointerup'); + expect(evt).to.have.keys('touches', 'changedTouches'); + expect(evt.changedTouches).to.have.length(1); + expect(containIn(pointer2, evt.changedTouches[0])).to.be.ok(); + expect(evt.touches).to.have.length(1); + expect(containIn(pointer1, evt.touches[0])).to.be.ok(); + + // pointercancel/touchcancel + happen.once(el, L.extend({type: 'pointercancel'}, pointer1)); + evt = listeners.touchcancel.lastCall.args[0]; + expect(evt.type).to.be('pointercancel'); + expect(evt).to.have.keys('touches', 'changedTouches'); + expect(evt.changedTouches).to.have.length(1); + expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok(); + expect(evt.touches).to.be.empty(); + + expect(listeners.touchstart.calledTwice).to.be.ok(); + expect(listeners.touchmove.calledOnce).to.be.ok(); + expect(listeners.touchend.calledOnce).to.be.ok(); + expect(listeners.touchcancel.calledOnce).to.be.ok(); + }); + }); + + (L.Browser.pointer ? skip : describe)('#Does not intrude if pointer events are not available', function () { + it('adds a listener and calls it on touch event', function () { + touchEvents.forEach(function (type) { + happen.once(el, {type: type}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].calledOnce).to.be.ok(); + }); + }); + + it('ignores pointer events', function () { + pointerEvents.forEach(function (type) { + happen.once(el, {type: type}); + }); + touchEvents.forEach(function (type) { + expect(listeners[type].notCalled).to.be.ok(); + }); + }); + }); + +}); diff --git a/spec/suites/dom/DomEventSpec.js b/spec/suites/dom/DomEventSpec.js index 2ca69a375e9..48a459af2f3 100644 --- a/spec/suites/dom/DomEventSpec.js +++ b/spec/suites/dom/DomEventSpec.js @@ -11,7 +11,36 @@ describe('DomEvent', function () { document.body.removeChild(el); }); + describe('#arguments check', function () { + it('throws when el is not HTMLElement', function () { + expect(L.DomEvent.on).withArgs({}, 'click', L.Util.falseFn) + .to.throwException(); + expect(L.DomEvent.disableScrollPropagation).withArgs({}) + .to.throwException(); + expect(L.DomEvent.disableClickPropagation).withArgs({}) + .to.throwException(); + expect(L.DomEvent.getMousePosition).withArgs({clientX: 0, clientY: 0}, {}) + .to.throwException(); + // .off and .isExternalTarget do not throw atm + }); + }); + describe('#on (addListener)', function () { + it('throws when types/fn are undefined/null/false', function () { + expect(L.DomEvent.on).withArgs(el, undefined, L.Util.falseFn) + .to.throwException(); + expect(L.DomEvent.on).withArgs(el, null, L.Util.falseFn) + .to.throwException(); + expect(L.DomEvent.on).withArgs(el, false, L.Util.falseFn) + .to.throwException(); + expect(L.DomEvent.on).withArgs(el, 'click', undefined) + .to.throwException(); + expect(L.DomEvent.on).withArgs(el, 'click', null) + .to.throwException(); + expect(L.DomEvent.on).withArgs(el, 'click', false) + .to.throwException(); + }); + it('adds a listener and calls it on event', function () { var listener2 = sinon.spy(); L.DomEvent.on(el, 'click', listener); @@ -23,6 +52,16 @@ describe('DomEvent', function () { expect(listener2.called).to.be.ok(); }); + it('adds a listener when passed an event map', function () { + var listener = sinon.spy(); + + L.DomEvent.on(el, {click: listener}); + + happen.click(el); + + sinon.assert.called(listener); + }); + it('binds "this" to the given context', function () { var obj = {foo: 'bar'}; L.DomEvent.on(el, 'click', listener, obj); @@ -32,6 +71,17 @@ describe('DomEvent', function () { expect(listener.calledOn(obj)).to.be.ok(); }); + it('binds "this" to the given context when passed an event map', function () { + var listener = sinon.spy(), + ctx = {foo: 'bar'}; + + L.DomEvent.on(el, {click: listener}, ctx); + + happen.click(el); + + sinon.assert.calledOn(listener, ctx); + }); + it('passes an event object to the listener', function () { L.DomEvent.on(el, 'click', listener); @@ -61,6 +111,157 @@ describe('DomEvent', function () { expect(listener.notCalled).to.be.ok(); }); + it('only removes the specified listener', function () { + var listenerA = sinon.spy(), + listenerB = sinon.spy(); + + L.DomEvent.on(el, 'click', listenerA); + L.DomEvent.on(el, 'click', listenerB); + L.DomEvent.off(el, 'click', listenerA); + + happen.click(el); + + expect(listenerA.called).to.not.be.ok(); + expect(listenerB.called).to.be.ok(); + }); + + it('removes a previously added listener when passed an event map', function () { + var listener = sinon.spy(), + events = {click: listener}; + + L.DomEvent.on(el, events); + L.DomEvent.off(el, events); + + happen.click(el); + + sinon.assert.notCalled(listener); + }); + + it('removes listener added with context', function () { + var listener = sinon.spy(), + ctx = {foo: 'bar'}; + + L.DomEvent.on(el, 'click', listener, ctx); + L.DomEvent.off(el, 'click', listener, ctx); + + happen.click(el); + + sinon.assert.notCalled(listener); + }); + + it('removes listener added with context when passed an event map', function () { + var listener = sinon.spy(), + events = {click: listener}, + ctx = {foo: 'bar'}; + + L.DomEvent.on(el, events, ctx); + L.DomEvent.off(el, events, ctx); + + happen.click(el); + + sinon.assert.notCalled(listener); + }); + + it('only removes listener when proper context specified', function () { + var listener = sinon.spy(), + ctx = {foo: 'bar'}; + + L.DomEvent.on(el, 'click', listener); + L.DomEvent.off(el, 'click', listener, ctx); + + happen.click(el); + + sinon.assert.called(listener); + + listener = sinon.spy(); + L.DomEvent.on(el, 'click', listener, ctx); + L.DomEvent.off(el, 'click', listener, {}); // wrong context + L.DomEvent.off(el, 'click', listener); + + happen.click(el); + + sinon.assert.called(listener); + }); + + it('only removes listener when proper context specified when passed an event map', function () { + var listener = sinon.spy(), + events = {click: listener}, + ctx = {foo: 'bar'}; + + L.DomEvent.on(el, events); + L.DomEvent.off(el, events, ctx); + + happen.click(el); + + sinon.assert.called(listener); + + listener = sinon.spy(); + events = {click: listener}; + + L.DomEvent.on(el, events, ctx); + L.DomEvent.off(el, events); + L.DomEvent.off(el, events, {}); // wrong context + + happen.click(el); + + sinon.assert.called(listener); + }); + + it('removes all listeners when only passed the HTMLElement', function () { + var listenerA = sinon.spy(), + listenerB = sinon.spy(); + + L.DomEvent.on(el, 'click', listenerA); + L.DomEvent.on(el, 'click', listenerB, {}); + L.DomEvent.off(el); + + happen.click(el); + + expect(listenerA.called).to.not.be.ok(); + expect(listenerB.called).to.not.be.ok(); + }); + + it('only removes specified listeners type', function () { + var listenerClick = sinon.spy(), + listenerDblClick = sinon.spy(); + + L.DomEvent.on(el, 'click', listenerClick); + L.DomEvent.on(el, 'dblclick', listenerDblClick); + L.DomEvent.off(el, 'click'); + happen.click(el); + happen.dblclick(el); + + sinon.assert.notCalled(listenerClick); + sinon.assert.called(listenerDblClick); + }); + + it('throws when types/fn are undefined/null/false', function () { + expect(L.DomEvent.off).withArgs(el, undefined) + .to.throwException(); + expect(L.DomEvent.off).withArgs(el, null) + .to.throwException(); + expect(L.DomEvent.off).withArgs(el, false) + .to.throwException(); + + expect(L.DomEvent.off).withArgs(el, 'click', undefined) + .to.throwException(); + expect(L.DomEvent.off).withArgs(el, 'click', null) + .to.throwException(); + expect(L.DomEvent.off).withArgs(el, 'click', false) + .to.throwException(); + }); + + it('removes listener when passed an event map', function () { + var listener = sinon.spy(); + + L.DomEvent.on(el, 'click', listener); + L.DomEvent.off(el, {'click': listener}); + + happen.click(el); + + expect(listener.called).to.not.be.ok(); + }); + it('is chainable', function () { var res = L.DomEvent.off(el, 'click', function () {}); @@ -104,9 +305,10 @@ describe('DomEvent', function () { var child = document.createElement('div'); el.appendChild(child); L.DomEvent.disableClickPropagation(child); - L.DomEvent.on(el, 'dblclick mousedown touchstart', listener); + L.DomEvent.on(el, 'dblclick contextmenu mousedown touchstart', listener); happen.once(child, {type: 'dblclick'}); + happen.once(child, {type: 'contextmenu'}); happen.once(child, {type: 'mousedown'}); happen.once(child, {type: 'touchstart', touches: []}); @@ -142,40 +344,28 @@ describe('DomEvent', function () { map.remove(); }); + }); - it('does not interfere with stopPropagation', function () { // test for #1925 - var child = document.createElement('div'); - el.appendChild(child); - L.DomEvent.disableClickPropagation(child); - L.DomEvent.on(child, 'click', L.DomEvent.stopPropagation); - var map = L.map(el).setView([0, 0], 0); - map.on('click', listener); - - happen.once(child, {type: 'click'}); - - expect(listener.notCalled).to.be.ok(); - - happen.once(map.getContainer(), {type: 'click'}); + describe('#preventDefault', function () { + function isPrevented(e) { + if ('defaultPrevented' in e) { + return e.defaultPrevented; + } else { // IE<11 + return !e.returnValue; + } + } - expect(listener.called).to.be.ok(); + it('prevents the default action of event', function (done) { + L.DomEvent.on(el, 'click', function (e) { + expect(isPrevented(e)).not.to.be.ok(); // control case - map.remove(); - }); - }); + L.DomEvent.preventDefault(e); - describe('#preventDefault', function () { - it('prevents the default action of event', function () { - L.DomEvent.on(el, 'click', listener); - L.DomEvent.on(el, 'click', L.DomEvent.preventDefault); + expect(isPrevented(e)).to.be.ok(); + done(); + }); happen.click(el); - - var e = listener.lastCall.args[0]; - if ('defaultPrevented' in e) { - expect(e.defaultPrevented).to.be.ok(); - } else { - expect(e.returnValue).not.to.be.ok(); - } }); }); }); diff --git a/spec/suites/geo/CRSSpec.js b/spec/suites/geo/crs/CRSSpec.js similarity index 86% rename from spec/suites/geo/CRSSpec.js rename to spec/suites/geo/crs/CRSSpec.js index 1c10083fec7..28986519f48 100644 --- a/spec/suites/geo/CRSSpec.js +++ b/spec/suites/geo/crs/CRSSpec.js @@ -3,37 +3,37 @@ describe("CRS.EPSG3857", function () { describe("#latLngToPoint", function () { it("projects a center point", function () { - expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01); + expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near([128, 128], 0.01); }); it("projects the northeast corner of the world", function () { - expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0)); + expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near([256, 0]); }); }); describe("#pointToLatLng", function () { it("reprojects a center point", function () { - expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01); + expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng([0, 0], 0.01); }); it("reprojects the northeast corner of the world", function () { - expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180)); + expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng([85.0511287798, 180]); }); }); describe("project", function () { it('projects geo coords into meter coords correctly', function () { - expect(crs.project(new L.LatLng(50, 30))).near(new L.Point(3339584.7238, 6446275.84102)); - expect(crs.project(new L.LatLng(85.0511287798, 180))).near(new L.Point(20037508.34279, 20037508.34278)); - expect(crs.project(new L.LatLng(-85.0511287798, -180))).near(new L.Point(-20037508.34279, -20037508.34278)); + expect(crs.project(new L.LatLng(50, 30))).near([3339584.7238, 6446275.84102]); + expect(crs.project(new L.LatLng(85.0511287798, 180))).near([20037508.34279, 20037508.34278]); + expect(crs.project(new L.LatLng(-85.0511287798, -180))).near([-20037508.34279, -20037508.34278]); }); }); describe("unproject", function () { it('unprojects meter coords into geo coords correctly', function () { - expect(crs.unproject(new L.Point(3339584.7238, 6446275.84102))).nearLatLng(new L.LatLng(50, 30)); - expect(crs.unproject(new L.Point(20037508.34279, 20037508.34278))).nearLatLng(new L.LatLng(85.051129, 180)); - expect(crs.unproject(new L.Point(-20037508.34279, -20037508.34278))).nearLatLng(new L.LatLng(-85.051129, -180)); + expect(crs.unproject(new L.Point(3339584.7238, 6446275.84102))).nearLatLng([50, 30]); + expect(crs.unproject(new L.Point(20037508.34279, 20037508.34278))).nearLatLng([85.051129, 180]); + expect(crs.unproject(new L.Point(-20037508.34279, -20037508.34278))).nearLatLng([-85.051129, -180]); }); }); @@ -164,21 +164,21 @@ describe("CRS.EPSG3395", function () { describe("#latLngToPoint", function () { it("projects a center point", function () { - expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01); + expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near([128, 128], 0.01); }); it("projects the northeast corner of the world", function () { - expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0)); + expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near([256, 0]); }); }); describe("#pointToLatLng", function () { it("reprojects a center point", function () { - expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01); + expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng([0, 0], 0.01); }); it("reprojects the northeast corner of the world", function () { - expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180)); + expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng([85.0840591556, 180]); }); }); }); @@ -188,17 +188,17 @@ describe("CRS.Simple", function () { describe("#latLngToPoint", function () { it("converts LatLng coords to pixels", function () { - expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(0, 0)); - expect(crs.latLngToPoint(L.latLng(700, 300), 0)).near(new L.Point(300, -700)); - expect(crs.latLngToPoint(L.latLng(-200, 1000), 1)).near(new L.Point(2000, 400)); + expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near([0, 0]); + expect(crs.latLngToPoint(L.latLng(700, 300), 0)).near([300, -700]); + expect(crs.latLngToPoint(L.latLng(-200, 1000), 1)).near([2000, 400]); }); }); describe("#pointToLatLng", function () { it("converts pixels to LatLng coords", function () { - expect(crs.pointToLatLng(L.point(0, 0), 0)).nearLatLng(new L.LatLng(0, 0)); - expect(crs.pointToLatLng(L.point(300, -700), 0)).nearLatLng(new L.LatLng(700, 300)); - expect(crs.pointToLatLng(L.point(2000, 400), 1)).nearLatLng(new L.LatLng(-200, 1000)); + expect(crs.pointToLatLng(L.point(0, 0), 0)).nearLatLng([0, 0]); + expect(crs.pointToLatLng(L.point(300, -700), 0)).nearLatLng([700, 300]); + expect(crs.pointToLatLng(L.point(2000, 400), 1)).nearLatLng([-200, 1000]); }); }); @@ -219,7 +219,7 @@ describe("CRS.Simple", function () { wrapLat: [-200, 200] }); - expect(crs.wrapLatLng(new L.LatLng(300, -250))).nearLatLng(new L.LatLng(-100, 150)); + expect(crs.wrapLatLng(new L.LatLng(300, -250))).nearLatLng([-100, 150]); }); }); }); diff --git a/spec/suites/geo/ProjectionSpec.js b/spec/suites/geo/projection/ProjectionSpec.js similarity index 57% rename from spec/suites/geo/ProjectionSpec.js rename to spec/suites/geo/projection/ProjectionSpec.js index 731f53ee74f..83d46a48d0a 100644 --- a/spec/suites/geo/ProjectionSpec.js +++ b/spec/suites/geo/projection/ProjectionSpec.js @@ -4,23 +4,23 @@ describe("Projection.Mercator", function () { describe("#project", function () { it("projects a center point", function () { // edge cases - expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0)); + expect(p.project(new L.LatLng(0, 0))).near([0, 0]); }); it("projects the northeast corner of the world", function () { - expect(p.project(new L.LatLng(85.0840591556, 180))).near(new L.Point(20037508, 20037508)); + expect(p.project(new L.LatLng(85.0840591556, 180))).near([20037508, 20037508]); }); it("projects the southwest corner of the world", function () { - expect(p.project(new L.LatLng(-85.0840591556, -180))).near(new L.Point(-20037508, -20037508)); + expect(p.project(new L.LatLng(-85.0840591556, -180))).near([-20037508, -20037508]); }); it("projects other points", function () { - expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524)); + expect(p.project(new L.LatLng(50, 30))).near([3339584, 6413524]); // from https://github.com/Leaflet/Leaflet/issues/1578 expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001))) - .near(new L.Point(8918060.964088084, 6755099.410887127)); + .near([8918060.964088084, 6755099.410887127]); }); }); @@ -30,14 +30,14 @@ describe("Projection.Mercator", function () { } it("unprojects a center point", function () { - expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0)); + expect(pr(new L.Point(0, 0))).near([0, 0]); }); it("unprojects pi points", function () { - expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI)); - expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI)); + expect(pr(new L.Point(-Math.PI, Math.PI))).near([-Math.PI, Math.PI]); + expect(pr(new L.Point(-Math.PI, -Math.PI))).near([-Math.PI, -Math.PI]); - expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683)); + expect(pr(new L.Point(0.523598775598, 1.010683188683))).near([0.523598775598, 1.010683188683]); }); it('unprojects other points', function () { @@ -53,23 +53,23 @@ describe("Projection.SphericalMercator", function () { describe("#project", function () { it("projects a center point", function () { // edge cases - expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0)); + expect(p.project(new L.LatLng(0, 0))).near([0, 0]); }); it("projects the northeast corner of the world", function () { - expect(p.project(new L.LatLng(85.0511287798, 180))).near(new L.Point(20037508, 20037508)); + expect(p.project(new L.LatLng(85.0511287798, 180))).near([20037508, 20037508]); }); it("projects the southwest corner of the world", function () { - expect(p.project(new L.LatLng(-85.0511287798, -180))).near(new L.Point(-20037508, -20037508)); + expect(p.project(new L.LatLng(-85.0511287798, -180))).near([-20037508, -20037508]); }); it("projects other points", function () { - expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6446275)); + expect(p.project(new L.LatLng(50, 30))).near([3339584, 6446275]); // from https://github.com/Leaflet/Leaflet/issues/1578 expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001))) - .near(new L.Point(8918060.96409, 6788763.38325)); + .near([8918060.96409, 6788763.38325]); }); }); @@ -79,14 +79,14 @@ describe("Projection.SphericalMercator", function () { } it("unprojects a center point", function () { - expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0)); + expect(pr(new L.Point(0, 0))).near([0, 0]); }); it("unprojects pi points", function () { - expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI)); - expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI)); + expect(pr(new L.Point(-Math.PI, Math.PI))).near([-Math.PI, Math.PI]); + expect(pr(new L.Point(-Math.PI, -Math.PI))).near([-Math.PI, -Math.PI]); - expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683)); + expect(pr(new L.Point(0.523598775598, 1.010683188683))).near([0.523598775598, 1.010683188683]); }); it('unprojects other points', function () { diff --git a/spec/suites/layer/GeoJSONSpec.js b/spec/suites/layer/GeoJSONSpec.js index 3c81fa4e193..74a00f44520 100644 --- a/spec/suites/layer/GeoJSONSpec.js +++ b/spec/suites/layer/GeoJSONSpec.js @@ -512,3 +512,358 @@ describe("L.LayerGroup#toGeoJSON", function () { }); }); }); + +describe("L.GeoJSON functions", function () { + describe("#geometryToLayer", function () { + var point = { + type: "Point", + coordinates: [0, 0] + }; + var multiPoint = { + type: "MultiPoint", + coordinates: [ + [0, 0], [10, 10] + ] + }; + var line = { + type: "LineString", + coordinates: [ + [0, 0], [10, 10], [20, 20] + ] + }; + var multiLine = { + type: "MultiLineString", + coordinates: [ + [[10, 10], [20, 20], [30, 30]], + [[50, 50], [60, 60], [70, 70]] + ] + }; + var polygon = { + type: "Polygon", + coordinates: [ + [[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]] + ] + }; + var multiPolygon = { + type: "MultiPolygon", + coordinates: [ + [ + [[30, 20], [45, 40], [10, 40], [30, 20]] + ], + [ + [[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]] + ] + ] + }; + var geometryCollection = { + type: "GeometryCollection", + geometries: [ + { + type: "Point", + coordinates: [0, 0] + }, + { + type: "LineString", + coordinates: [ + [10, 10], [20, 20] + ] + } + ] + }; + + function customPointToLayer(geojsonPoint, latLng) { + return L.circle(latLng, { + radius: geojsonPoint.properties.radius + }); + } + + function customCoordstoLatLng(coords) { + return L.latLng(coords[1] + 1, coords[0] + 1, coords[2] + 1); + } + + [ + [point, L.Marker], + [line, L.Polyline], + [polygon, L.Polygon], + [multiPoint, L.FeatureGroup], + [multiLine, L.Polyline], + [multiPolygon, L.Polygon], + [geometryCollection, L.FeatureGroup] + ].forEach(function (item) { + var geometry = item[0], expectedType = item[1]; + + it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () { + var layer = L.GeoJSON.geometryToLayer({ + type: "Feature", + geometry: geometry + }); + expect(layer).to.be.a(expectedType); + }); + + it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () { + var layer = L.GeoJSON.geometryToLayer(geometry); + expect(layer).to.be.a(expectedType); + }); + }); + + it("throws an error if feature is an invalid GeoJSON object", function () { + expect(L.GeoJSON.geometryToLayer).withArgs({ + type: "Feature", + geometry: { + type: "invalid", + coordinates: [0, 0] + } + }).to.throwError("Invalid GeoJSON object."); + }); + + it("returns nothing if feature does not have a geometry property", function () { + var ret = L.GeoJSON.geometryToLayer({type: "Feature"}); + expect(ret).not.to.be.ok(); + }); + + it("creates a Layer using pointToLayer option (Point)", function () { + var layer = L.GeoJSON.geometryToLayer({ + type: "Feature", + geometry: point, + properties: {radius: 100} + }, { + pointToLayer: customPointToLayer + }); + expect(layer).to.be.a(L.Circle); + expect(layer.options.radius).to.be(100); + }); + + it("creates a Layer using pointToLayer option (MultiPoint)", function () { + var layer = L.GeoJSON.geometryToLayer({ + type: "Feature", + geometry: multiPoint, + properties: {radius: 100} + }, { + pointToLayer: customPointToLayer + }); + layer.eachLayer(function (lyr) { + expect(lyr).to.be.a(L.Circle); + expect(lyr.options.radius).to.be(100); + }); + }); + + it("creates a Layer using coordsToLatLng option (Point)", function () { + var layer = L.GeoJSON.geometryToLayer({ + type: "Feature", + geometry: { + type: "Point", + coordinates: [1, 2, 3] + } + }, { + coordsToLatLng: customCoordstoLatLng + }); + expect(layer.getLatLng()).to.eql({lat: 3, lng: 2, alt: 4}); + }); + + it("creates a Layer using coordsToLatLng option (MultiPoint)", function () { + var layer = L.GeoJSON.geometryToLayer({ + type: "Feature", + geometry: { + type: "MultiPoint", + coordinates: [ + [1, 2, 3], [4, 5, 6] + ] + } + }, { + coordsToLatLng: customCoordstoLatLng + }); + expect(layer.getLayers().map(function (lyr) { + return lyr.getLatLng(); + })).to.eql([ + {lat: 3, lng: 2, alt: 4}, + {lat: 6, lng: 5, alt: 7} + ]); + }); + }); + + describe("#coordsToLatLng", function () { + it("creates a LatLng object with given coordinates", function () { + var latLng = L.GeoJSON.coordsToLatLng([1, 2]); + var latLngWithAlt = L.GeoJSON.coordsToLatLng([3, 4, 5]); + expect(latLng).to.be.a(L.LatLng); + expect(latLngWithAlt).to.be.a(L.LatLng); + expect(latLng).to.eql({lng: 1, lat: 2}); + expect(latLngWithAlt).to.eql({lng: 3, lat: 4, alt: 5}); + }); + }); + + describe("#coordsToLatLngs", function () { + + function customCoordsToLatLng(coords) { + return L.latLng(coords[1] + 1, coords[0] + 1, coords[2] + 1); + } + + it("creates a multidimensional array of LatLngs", function () { + var latLngs = L.GeoJSON.coordsToLatLngs([[1, 2], [3, 4], [5, 6]]); + expect(latLngs).to.eql([{lng: 1, lat: 2}, {lng: 3, lat: 4}, {lng: 5, lat: 6}]); + latLngs.forEach(function (latLng) { + expect(latLng).to.be.a(L.LatLng); + }); + }); + + it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () { + var latLngs = L.GeoJSON.coordsToLatLngs([ + [[1, 2], [3, 4], [5, 6]], + [[5, 6], [7, 8], [9, 10]] + ], 1); + expect(latLngs).to.eql([ + [{lng: 1, lat: 2}, {lng: 3, lat: 4}, {lng: 5, lat: 6}], + [{lng: 5, lat: 6}, {lng: 7, lat: 8}, {lng: 9, lat: 10}] + ]); + latLngs.forEach(function (arr) { + arr.forEach(function (latlng) { + expect(latlng).to.be.a(L.LatLng); + }); + }); + }); + + it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () { + var coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + var latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng); + expect(latLngs).to.eql([ + {lat: 3, lng: 2, alt: 4}, + {lat: 6, lng: 5, alt: 7}, + {lat: 9, lng: 8, alt: 10} + ]); + }); + + it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () { + var coords = [ + [[1, 2, 3], [4, 5, 6]], + [[12, 13, 14], [15, 16, 17]] + ]; + var latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng); + expect(latLngs).to.eql([ + [ + {lat: 3, lng: 2, alt: 4}, + {lat: 6, lng: 5, alt: 7} + ], + [ + {lat: 14, lng: 13, alt: 15}, + {lat: 17, lng: 16, alt: 18} + ] + ]); + }); + }); + + describe("#latLngToCoords", function () { + it("returns an array of coordinates and altitude", function () { + var coords = L.GeoJSON.latLngToCoords(L.latLng(2, 1)); + var coordsWithAlt = L.GeoJSON.latLngToCoords(L.latLng(2, 1, 3)); + expect(coords).to.eql([1, 2]); + expect(coordsWithAlt).to.eql([1, 2, 3]); + }); + + it("returns an array of coordinates with given precision", function () { + var coords = L.GeoJSON.latLngToCoords(L.latLng( + 2.123456, 1.123456 + ), 3); + var coordsWithAlt = L.GeoJSON.latLngToCoords(L.latLng( + 2.123456, 1.123456, 3.123456 + ), 3); + expect(coords).to.eql([1.123, 2.123]); + expect(coordsWithAlt).to.eql([1.123, 2.123, 3.123]); + }); + }); + + describe("#latLngsToCoords", function () { + it("returns a multidimensional array of coordinates", function () { + var coords = L.GeoJSON.latLngsToCoords([L.latLng(2, 1), L.latLng(4, 3)]); + var coordWithAlt = L.GeoJSON.latLngsToCoords([L.latLng(2, 1, 3), L.latLng(5, 4, 6)]); + expect(coords).to.eql([[1, 2], [3, 4]]); + expect(coordWithAlt).to.eql([[1, 2, 3], [4, 5, 6]]); + }); + + it("returns a multidimensional array of coordinates (levelDeep=1)", function () { + var latLngs = [ + [L.latLng(2, 1), L.latLng(4, 3)], + [L.latLng(6, 5), L.latLng(8, 7)] + ]; + var coords = L.GeoJSON.latLngsToCoords(latLngs, 1); + expect(coords).to.eql([ + [[1, 2], [3, 4]], + [[5, 6], [7, 8]] + ]); + }); + + it("returns a multidimensional array of coordinates (closed=True)", function () { + var latLngs = [L.latLng(2, 1), L.latLng(4, 3), L.latLng(6, 5)]; + var coords = L.GeoJSON.latLngsToCoords(latLngs, 0, true); + expect(coords).to.eql([[1, 2], [3, 4], [5, 6], [1, 2]]); + }); + + it("returns a multidimensional array of coordinates (levelsDeep=1, closed=True)", function () { + var latLngs = [ + [L.latLng(2, 1), L.latLng(4, 3), L.latLng(6, 5)], + [L.latLng(8, 7), L.latLng(10, 9), L.latLng(12, 11)] + ]; + var coords = L.GeoJSON.latLngsToCoords(latLngs, 1, true); + expect(coords).to.eql([ + [[1, 2], [3, 4], [5, 6], [1, 2]], + [[7, 8], [9, 10], [11, 12], [7, 8]] + ]); + }); + + it("returns a multidimensional array of coordinates with given precision", function () { + var latLngs = [L.latLng(2.123456, 1.123456), L.latLng(4.123456, 3.123456)]; + var coords = L.GeoJSON.latLngsToCoords(latLngs, 0, false, 3); + expect(coords).to.eql([[1.123, 2.123], [3.123, 4.123]]); + }); + }); + + describe("#asFeature", function () { + var geometry1 = { + type: "Point", + coordinates: [0, 0] + }; + + var geometry2 = { + type: "Point", + coordinates: [1, 1] + }; + + var feature1 = { + type: "Feature", + geometry: geometry1, + properties: {a: 1} + }; + + var feature2 = { + type: "Feature", + geometry: geometry2, + properties: {b: 2} + }; + + var featureCollection = { + type: "FeatureCollection", + features: [ + feature1, + feature2 + ] + }; + + it("given a bare geometry returns a GeoJSON-like feature", function () { + var ret = L.GeoJSON.asFeature(geometry1); + expect(ret).to.eql({ + type: "Feature", + properties: {}, + geometry: geometry1 + }); + }); + + it("given a GeoJSON feature directly returns it", function () { + var ret = L.GeoJSON.asFeature(feature1); + expect(ret).to.eql(feature1); + }); + + it("given a GeoJSON feature collection directly returns it", function () { + var ret = L.GeoJSON.asFeature(featureCollection); + expect(ret).to.eql(featureCollection); + }); + }); +}); diff --git a/spec/suites/layer/ImageOverlaySpec.js b/spec/suites/layer/ImageOverlaySpec.js index 7f4870c100d..0db082ecf24 100644 --- a/spec/suites/layer/ImageOverlaySpec.js +++ b/spec/suites/layer/ImageOverlaySpec.js @@ -63,7 +63,7 @@ describe('ImageOverlay', function () { function raiseImageEvent(event) { var domEvent = document.createEvent('Event'); - domEvent.initEvent(event); + domEvent.initEvent(event, false, false); overlay._image.dispatchEvent(domEvent); } @@ -108,23 +108,23 @@ describe('ImageOverlay', function () { it('should update the z-index of the image if it has allready been added to the map', function () { var overlay = L.imageOverlay('', imageBounds); overlay.addTo(map); - expect(overlay._image.style.zIndex).to.be('1'); + expect(overlay._image.style.zIndex).to.eql('1'); // Number type in IE overlay.setZIndex('10'); - expect(overlay._image.style.zIndex).to.be('10'); + expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE }); it('should set the z-index of the image when it is added to the map', function () { var overlay = L.imageOverlay('', imageBounds); overlay.setZIndex('10'); overlay.addTo(map); - expect(overlay._image.style.zIndex).to.be('10'); + expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE }); it('should use the z-index specified in options', function () { var overlay = L.imageOverlay('', imageBounds, {zIndex: 20}); overlay.addTo(map); - expect(overlay._image.style.zIndex).to.be('20'); + expect(overlay._image.style.zIndex).to.eql('20'); // Number type in IE }); it('should be fluent', function () { @@ -133,9 +133,21 @@ describe('ImageOverlay', function () { }); }); + describe('#getCenter', function () { + it('should return the correct center', function () { + var overlay = L.imageOverlay('', imageBounds).addTo(map); + expect(overlay.getCenter()).to.be.nearLatLng([40.743078, -74.175995]); + }); + it('should open popup at the center', function () { + var overlay = L.imageOverlay('', imageBounds).addTo(map); + overlay.bindPopup('Center').openPopup(); + expect(overlay.getPopup().getLatLng()).to.be.nearLatLng([40.743078, -74.175995]); + }); + }); // For tests that do not actually need to append the map container to the document. // This saves PhantomJS memory. - describe('_image2', function () { + var _describe = 'crossOrigin' in L.DomUtil.create('img') ? describe : describe.skip; // skip in IE<11 + _describe('crossOrigin option', function () { var overlay; var blankUrl = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; diff --git a/spec/suites/layer/LayerGroupSpec.js b/spec/suites/layer/LayerGroupSpec.js index 3767e4b488a..2dba44f3619 100644 --- a/spec/suites/layer/LayerGroupSpec.js +++ b/spec/suites/layer/LayerGroupSpec.js @@ -1,10 +1,14 @@ describe('LayerGroup', function () { describe("#hasLayer", function () { - it("returns false when passed undefined, null, or false", function () { + it("throws when called without proper argument", function () { var lg = L.layerGroup(); - expect(lg.hasLayer(undefined)).to.equal(false); - expect(lg.hasLayer(null)).to.equal(false); - expect(lg.hasLayer(false)).to.equal(false); + var hasLayer = L.Util.bind(lg.hasLayer, lg); + expect(hasLayer).withArgs(new L.Layer()).to.not.throwException(); // control case + + expect(hasLayer).withArgs(undefined).to.throwException(); + expect(hasLayer).withArgs(null).to.throwException(); + expect(hasLayer).withArgs(false).to.throwException(); + expect(hasLayer).to.throwException(); }); }); diff --git a/spec/suites/layer/PopupSpec.js b/spec/suites/layer/PopupSpec.js index 552f758fd2d..c85fcdcc6fb 100644 --- a/spec/suites/layer/PopupSpec.js +++ b/spec/suites/layer/PopupSpec.js @@ -413,6 +413,26 @@ describe("L.Map#openPopup", function () { .down().moveBy(10, 10, 20).up(); }); + it('moves the map over a long distance to the popup if it is not in the view (keepInView)', function (done) { + c.style.position = 'absolute'; + c.style.left = 0; + c.style.top = 0; + c.style.zIndex = 10000; + + // to prevent waiting until the animation is finished + map.options.inertia = false; + + var spy = sinon.spy(); + map.on('autopanstart', spy); + var p = new L.Popup({keepInView: true}).setContent('Popup').setLatLng([center[0], center[1] + 50]); + map.openPopup(p); + + setTimeout(function () { + expect(spy.called).to.be(true); + expect(map.getBounds().contains(p.getLatLng())).to.be(true); + done(); + }, 800); + }); }); describe('L.Layer#_popup', function () { @@ -479,4 +499,51 @@ describe('L.Layer#_popup', function () { done(); }).to.not.throwException(); }); + + it("does not close popup when clicking on it's tip", function () { + if (L.Browser.ie) { this.skip(); } // fixme + c.style.position = "absolute"; + c.style.top = "0"; + c.style.left = "0"; + var popup = L.popup().setLatLng(map.getCenter()) + .openOn(map); + + var point = map.latLngToContainerPoint(map.getCenter()); + point.y -= 2; // move mouse into the popup-tip + var el = document.elementFromPoint(point.x, point.y); + expect(el).to.be(popup._tip); + + happen.click(el, { + clientX: point.x, + clientY: point.y + }); + expect(popup.isOpen()).to.be.ok(); + }); + + it("does not open for empty FeatureGroup", function () { + var popup = L.popup(); + L.featureGroup([]) + .addTo(map) + .bindPopup(popup) + .openPopup(); + + expect(map.hasLayer(popup)).to.not.be.ok(); + }); + + it("uses only visible layers of FeatureGroup for popup content source", function () { + var marker1 = L.marker([1, 1]); + var marker2 = L.marker([2, 2]); + var marker3 = L.marker([3, 3]); + var popup = L.popup(); + var group = L.featureGroup([marker1, marker2, marker3]) + .bindPopup(popup) + .addTo(map); + + marker1.remove(); + marker3.remove(); + group.openPopup(); + + expect(map.hasLayer(popup)).to.be.ok(); + expect(popup._source).to.be(marker2); + }); }); diff --git a/spec/suites/layer/TooltipSpec.js b/spec/suites/layer/TooltipSpec.js index ceaa032199d..b6aea553ad4 100644 --- a/spec/suites/layer/TooltipSpec.js +++ b/spec/suites/layer/TooltipSpec.js @@ -68,6 +68,18 @@ describe('Tooltip', function () { expect(spy.calledOnce).to.be(true); }); + it("has class leaflet-interactive", function () { + var layer = new L.Marker(center).addTo(map); + layer.bindTooltip('Tooltip', {permanent: true, interactive: true}); + expect(L.DomUtil.hasClass(layer._tooltip._container, 'leaflet-interactive')).to.be(true); + }); + + it("has not class leaflet-interactive", function () { + var layer = new L.Marker(center).addTo(map); + layer.bindTooltip('Tooltip', {permanent: true}); + expect(L.DomUtil.hasClass(layer._tooltip._container, 'leaflet-interactive')).to.be(false); + }); + it("can be forced on left direction", function () { var layer = new L.Marker(center).addTo(map); var spy = sinon.spy(); @@ -278,9 +290,100 @@ describe('Tooltip', function () { map.openTooltip('Tooltip', center); }); + it("map.openTooltip considers interactive option", function () { + if (!window.getComputedStyle) { this.skip(); } // IE9+ + + var tooltip = L.tooltip({interactive: true}).setContent('Tooltip'); + map.openTooltip(tooltip, center); + expect(getComputedStyle(tooltip._container).pointerEvents).to.equal('auto'); + }); + it("can call closeTooltip while not on the map", function () { var layer = new L.Marker(center); layer.bindTooltip('Tooltip', {interactive: true}); layer.closeTooltip(); }); + + it("opens a tooltip and follow the mouse (sticky)", function () { + var layer = L.rectangle([[58, 39.7], [54, 35.3]]).addTo(map); + layer.bindTooltip('Sticky', {sticky: true}).openTooltip(); + var tooltip = layer.getTooltip(); + expect(tooltip.getLatLng().equals(layer.getCenter())).to.be(true); + + happen.at('click', 120, 120); + var latlng = map.containerPointToLatLng([120, 120]); + expect(tooltip.getLatLng().equals(latlng)).to.be(true); + }); + + it("opens a permanent tooltip and follow the mouse (sticky)", function (done) { + var layer = L.rectangle([[58, 39.7], [54, 35.3]]).addTo(map); + layer.bindTooltip('Sticky', {sticky: true, permanent: true}).openTooltip(); + var tooltip = layer.getTooltip(); + expect(tooltip.getLatLng().equals(layer.getCenter())).to.be(true); + + var hand = new Hand({ + timing: 'fastframe', + onStop: function () { + var latlng = map.containerPointToLatLng([120, 120]); + expect(tooltip.getLatLng().equals(latlng)).to.be(true); + done(); + } + }); + var toucher = hand.growFinger('mouse'); + toucher.wait(100).moveTo(120, 120, 1000).wait(100); + }); + + it("closes existent tooltip on new bindTooltip call", function () { + var layer = new L.Marker(center).addTo(map); + var eventSpy = sinon.spy(layer, "unbindTooltip"); + layer.bindTooltip('Tooltip1', {permanent: true}); + var tooltip1 = layer.getTooltip(); + layer.bindTooltip('Tooltip2').openTooltip(); + layer.unbindTooltip.restore(); // unwrap the spy + expect(map.hasLayer(tooltip1)).to.not.be.ok(); + expect(eventSpy.calledOnce).to.be.ok(); + }); + + it("don't opens the tooltip on marker mouseover while dragging map", function () { + // Sometimes the mouse is moving faster then the map while dragging and then the marker can be hover and + // the tooltip opened / closed. + var layer = L.marker(center).addTo(map).bindTooltip('Tooltip'); + var tooltip = layer.getTooltip(); + + // simulate map dragging + map.dragging.moving = function () { + return true; + }; + happen.at('mouseover', 210, 195); + expect(tooltip.isOpen()).to.be(false); + + // simulate map not dragging anymore + map.dragging.moving = function () { + return false; + }; + happen.at('mouseover', 210, 195); + expect(tooltip.isOpen()).to.be.ok(); + }); + + it("closes the tooltip on marker mouseout while dragging map and don't open it again", function () { + // Sometimes the mouse is moving faster then the map while dragging and then the marker can be hover and + // the tooltip opened / closed. + var layer = L.marker(center).addTo(map).bindTooltip('Tooltip'); + var tooltip = layer.getTooltip(); + + // open tooltip before "dragging map" + happen.at('mouseover', 210, 195); + expect(tooltip.isOpen()).to.be.ok(); + + // simulate map dragging + map.dragging.moving = function () { + return true; + }; + happen.mouseout(layer._icon, {relatedTarget: map._container}); + expect(tooltip.isOpen()).to.be(false); + + // tooltip should not open again while dragging + happen.at('mouseover', 210, 195); + expect(tooltip.isOpen()).to.be(false); + }); }); diff --git a/spec/suites/layer/marker/Icon.DefaultSpec.js b/spec/suites/layer/marker/Icon.DefaultSpec.js index f29c033952e..5994995eb88 100644 --- a/spec/suites/layer/marker/Icon.DefaultSpec.js +++ b/spec/suites/layer/marker/Icon.DefaultSpec.js @@ -14,6 +14,33 @@ describe("Icon.Default", function () { document.body.removeChild(div); }); + it("detect icon images path", function () { + var origPath = L.Icon.Default.imagePath; // set in after.js + expect(origPath).to.be.ok(); + delete L.Icon.Default.imagePath; + var marker = new L.Marker([0, 0]); + + expect(L.Icon.Default.imagePath).to.not.be.ok(); + marker.addTo(map); + + // polyfill for IE<11 + var origin = document.location.origin || window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); + expect(L.Icon.Default.imagePath).to.equal(origin + origPath); + + var stripUrl = L.Icon.Default.prototype._stripUrl; + var properPath = 'http://localhost:8000/base/dist/images/'; + [ // valid + 'url("http://localhost:8000/base/dist/images/marker-icon.png")', // Firefox + "url('http://localhost:8000/base/dist/images/marker-icon.png')", + 'url(http://localhost:8000/base/dist/images/marker-icon.png)', // IE, Edge + ].map(stripUrl).forEach(function (str) { expect(str).to.be(properPath); }); + + [ // invalid + 'url("http://localhost:8000/base/dist/images/marker-icon.png?2x)"', + 'url("data:image/png;base64,iVBORw...")', // inline image (bundlers) + ].map(stripUrl).forEach(function (str) { expect(str).not.to.be.ok(); }); + }); + it("icon measures 25x41px", function () { var img = map.getPane('markerPane').querySelector('img'); expect(img.clientHeight).to.be(41); diff --git a/spec/suites/layer/marker/Marker.DragSpec.js b/spec/suites/layer/marker/Marker.DragSpec.js index f2035763d4b..72fea583658 100644 --- a/spec/suites/layer/marker/Marker.DragSpec.js +++ b/spec/suites/layer/marker/Marker.DragSpec.js @@ -55,7 +55,8 @@ describe("Marker.Drag", function () { div.style.webkitTransform = 'scale(' + scaleX + ', ' + scaleY + ')'; }); - it("drags a marker with mouse, compensating for CSS scale", function (done) { + // fixme IE + (L.Browser.ie ? it.skip : it)("drags a marker with mouse, compensating for CSS scale", function (done) { var marker = new L.Marker([0, 0], { draggable: true }).addTo(map); diff --git a/spec/suites/layer/marker/MarkerSpec.js b/spec/suites/layer/marker/MarkerSpec.js index 8453c721246..bfce336e70e 100644 --- a/spec/suites/layer/marker/MarkerSpec.js +++ b/spec/suites/layer/marker/MarkerSpec.js @@ -190,12 +190,12 @@ describe("Marker", function () { expect(marker._shadow.parentNode).to.be(map._panes.shadowPane); }); - it("sets the alt attribute to an empty string when no alt text is passed", function () { + it("sets the alt attribute to a default value when no alt text is passed", function () { var marker = L.marker([0, 0], {icon: icon1}); map.addLayer(marker); var icon = marker._icon; expect(icon.hasAttribute('alt')).to.be(true); - expect(icon.alt).to.be(''); + expect(icon.alt).to.be('Marker'); }); it("doesn't set the alt attribute for DivIcons", function () { diff --git a/spec/suites/layer/tile/GridLayerSpec.js b/spec/suites/layer/tile/GridLayerSpec.js index f5ce05f6b05..dd70c9081c0 100644 --- a/spec/suites/layer/tile/GridLayerSpec.js +++ b/spec/suites/layer/tile/GridLayerSpec.js @@ -354,6 +354,18 @@ describe('GridLayer', function () { map.addLayer(grid); }); + + it("redraws tiles properly after changing maxNativeZoom", function () { + var initialZoom = 12; + map.setView([0, 0], initialZoom); + + var grid = L.gridLayer().addTo(map); + expect(grid._tileZoom).to.be(initialZoom); + + grid.options.maxNativeZoom = 11; + grid.redraw(); + expect(grid._tileZoom).to.be(11); + }); }); describe("number of 256px tiles loaded in synchronous non-animated grid @800x600px", function () { diff --git a/spec/suites/layer/tile/TileLayerSpec.js b/spec/suites/layer/tile/TileLayerSpec.js index 2caed401900..84fde9ef1eb 100644 --- a/spec/suites/layer/tile/TileLayerSpec.js +++ b/spec/suites/layer/tile/TileLayerSpec.js @@ -1,7 +1,7 @@ describe('TileLayer', function () { var div, map; - // Placekitten via http://placekitten.com/attribution.html + // Placekitten via https://placekitten.com/attribution.html // Image licensed under CC-by-sa by http://flickr.com/photos/lachlanrogers/ var placeKitten = "data:image/jpeg;base64," + @@ -407,7 +407,8 @@ describe('TileLayer', function () { }); - describe('options', function () { + var _describe = 'crossOrigin' in L.DomUtil.create('img') ? describe : describe.skip; // skip in IE<11 + _describe('crossOrigin option', function () { beforeEach(function () { map.setView([0, 0], 2); }); diff --git a/spec/suites/layer/vector/CanvasSpec.js b/spec/suites/layer/vector/CanvasSpec.js index 375bc014128..5faeaad1402 100644 --- a/spec/suites/layer/vector/CanvasSpec.js +++ b/spec/suites/layer/vector/CanvasSpec.js @@ -67,6 +67,40 @@ describe('Canvas', function () { expect(spy.callCount).to.eql(1); }); + it("should be transparent for DOM events going to non-canvas features", function () { + var marker = L.marker(map.layerPointToLatLng([150, 150])) + .addTo(map); + var circle = L.circle(map.layerPointToLatLng([200, 200]), { + radius: 20000, + renderer: L.svg() + }).addTo(map); + + var spyPolygon = sinon.spy(); + var spyMap = sinon.spy(); + var spyMarker = sinon.spy(); + var spyCircle = sinon.spy(); + layer.on("click", spyPolygon); + map.on("click", spyMap); + marker.on("click", spyMarker); + circle.on("click", spyCircle); + + happen.at('click', 50, 50); // polygon (canvas) + happen.at('click', 151, 151); // empty space + happen.at('click', 150, 148); // marker + happen.at('click', 200, 200); // circle (svg) + expect(spyPolygon.callCount).to.eql(1); + expect(spyMap.callCount).to.eql(3); // except marker + expect(spyMarker.callCount).to.eql(1); + expect(spyCircle.callCount).to.eql(1); + }); + + it("should not block mousemove event going to non-canvas features", function () { + var spyMap = sinon.spy(); + map.on("mousemove", spyMap); + happen.at('mousemove', 151, 151); // empty space + expect(spyMap.calledOnce).to.be.ok(); + }); + it("should fire preclick before click", function () { var clickSpy = sinon.spy(); var preclickSpy = sinon.spy(); @@ -110,6 +144,25 @@ describe('Canvas', function () { .down().moveBy(20, 10, 200).up(); }); + it("does fire mousedown on layer after dragging map", function (done) { // #7775 + var spy = sinon.spy(); + var circle = L.circle(p2ll(300, 300)).addTo(map); + circle.on('mousedown', spy); + + var hand = new Hand({ + timing: 'fastframe', + onStop: function () { + expect(spy.callCount).to.eql(2); + done(); + } + }); + var mouse = hand.growFinger('mouse'); + + mouse.wait(100) + .moveTo(300, 300, 0).down().moveBy(5, 0, 20).up() + .moveTo(100, 100, 0).down().moveBy(5, 0, 20).up() + .moveTo(300, 300, 0).down().moveBy(5, 0, 20).up(); + }); }); describe("#events(interactive=false)", function () { diff --git a/spec/suites/layer/vector/CircleSpec.js b/spec/suites/layer/vector/CircleSpec.js index 86abc669376..9a00e4c7c7f 100644 --- a/spec/suites/layer/vector/CircleSpec.js +++ b/spec/suites/layer/vector/CircleSpec.js @@ -28,8 +28,8 @@ describe('Circle', function () { it('returns bounds', function () { var bounds = circle.getBounds(); - expect(bounds.getSouthWest()).nearLatLng(new L.LatLng(49.99820, 29.99720)); - expect(bounds.getNorthEast()).nearLatLng(new L.LatLng(50.00179, 30.00279)); + expect(bounds.getSouthWest()).nearLatLng([49.99820, 29.99720]); + expect(bounds.getNorthEast()).nearLatLng([50.00179, 30.00279]); }); }); @@ -37,8 +37,8 @@ describe('Circle', function () { it('returns same bounds as 1.0 factory', function () { var bounds = circle.getBounds(); - expect(bounds.getSouthWest()).nearLatLng(new L.LatLng(49.99820, 29.99720)); - expect(bounds.getNorthEast()).nearLatLng(new L.LatLng(50.00179, 30.00279)); + expect(bounds.getSouthWest()).nearLatLng([49.99820, 29.99720]); + expect(bounds.getNorthEast()).nearLatLng([50.00179, 30.00279]); }); }); }); diff --git a/spec/suites/layer/vector/PolygonSpec.js b/spec/suites/layer/vector/PolygonSpec.js index 5f6ca64dfb5..1518fe71a12 100644 --- a/spec/suites/layer/vector/PolygonSpec.js +++ b/spec/suites/layer/vector/PolygonSpec.js @@ -153,7 +153,7 @@ describe('Polygon', function () { [[0, 0], [10, 0], [10, 10], [0, 10]] ]; var layer = new L.Polygon(latlngs).addTo(map); - expect(layer.getCenter()).to.be.nearLatLng(L.latLng([5, 5]), 1e-1); + expect(layer.getCenter()).to.be.nearLatLng([5, 5], 1e-1); }); it('should compute center of a small simple polygon', function () { @@ -162,7 +162,7 @@ describe('Polygon', function () { ]; var layer = new L.Polygon(latlngs).addTo(map); map.setZoom(0); // Make the polygon disappear in screen. - expect(layer.getCenter()).to.be.nearLatLng(L.latLng([0, 0])); + expect(layer.getCenter()).to.be.nearLatLng([0, 0]); }); it('throws error if not yet added to map', function () { diff --git a/spec/suites/layer/vector/PolylineSpec.js b/spec/suites/layer/vector/PolylineSpec.js index b5e4e867200..b0835fd6e1b 100644 --- a/spec/suites/layer/vector/PolylineSpec.js +++ b/spec/suites/layer/vector/PolylineSpec.js @@ -111,28 +111,28 @@ describe('Polyline', function () { it('should compute center of a big flat line close to the pole', function () { var polyline = new L.Polyline([[80, 0], [80, 90]]).addTo(map); - expect(polyline.getCenter()).to.be.nearLatLng(L.latLng([80, 45]), 1e-2); + expect(polyline.getCenter()).to.be.nearLatLng([80, 45], 1e-2); }); it('should compute center of a big diagonal line', function () { var polyline = new L.Polyline([[0, 0], [80, 80]]).addTo(map); - expect(polyline.getCenter()).to.be.nearLatLng(L.latLng([57, 40]), 1); + expect(polyline.getCenter()).to.be.nearLatLng([57, 40], 1); }); it('should compute center of a diagonal line close to the pole', function () { var polyline = new L.Polyline([[70, 70], [84, 84]]).addTo(map); - expect(polyline.getCenter()).to.be.nearLatLng(L.latLng([79, 77]), 1); + expect(polyline.getCenter()).to.be.nearLatLng([79, 77], 1); }); it('should compute center of a big multiline', function () { var polyline = new L.Polyline([[10, -80], [0, 0], [0, 10], [10, 90]]).addTo(map); - expect(polyline.getCenter()).to.be.nearLatLng(L.latLng([0, 5]), 1); + expect(polyline.getCenter()).to.be.nearLatLng([0, 5], 1); }); it('should compute center of a small flat line', function () { var polyline = new L.Polyline([[0, 0], [0, 0.090]]).addTo(map); map.setZoom(0); // Make the line disappear in screen; - expect(polyline.getCenter()).to.be.nearLatLng(L.latLng([0, 0]), 1e-2); + expect(polyline.getCenter()).to.be.nearLatLng([0, 0], 1e-2); }); it('throws error if not yet added to map', function () { diff --git a/spec/suites/map/MapSpec.js b/spec/suites/map/MapSpec.js index bb3792c44a0..75a9c2b5c28 100644 --- a/spec/suites/map/MapSpec.js +++ b/spec/suites/map/MapSpec.js @@ -357,12 +357,17 @@ describe("Map", function () { }); describe("#hasLayer", function () { - it("returns false when passed undefined, null, or false", function () { + it("throws when called without proper argument", function () { var map = L.map(document.createElement("div")); + var hasLayer = L.Util.bind(map.hasLayer, map); + expect(hasLayer).withArgs(new L.Layer()).to.not.throwException(); // control case + + expect(hasLayer).withArgs(undefined).to.throwException(); + expect(hasLayer).withArgs(null).to.throwException(); + expect(hasLayer).withArgs(false).to.throwException(); + expect(hasLayer).to.throwException(); + map.remove(); // clean up - expect(map.hasLayer(undefined)).to.equal(false); - expect(map.hasLayer(null)).to.equal(false); - expect(map.hasLayer(false)).to.equal(false); }); }); @@ -631,6 +636,7 @@ describe("Map", function () { clock; beforeEach(function () { + container.style.height = "100px"; container.style.width = origWidth + "px"; map.setView([0, 0], 0); map.invalidateSize({pan: false}); @@ -1249,6 +1255,39 @@ describe("Map", function () { happen.click(layer._icon); expect(called).to.eql(4); }); + + it("prevents default action of contextmenu if there is any listener", function () { + if (!L.Browser.canvas) { this.skip(); } + + map.remove(); + var container = document.createElement('div'); + container.style.width = container.style.height = '300px'; + container.style.top = container.style.left = 0; + container.style.position = 'absolute'; + document.body.appendChild(container); + + map = L.map(container, { + renderer: L.canvas(), + center: [0, 0], + zoom: 0 + }); + map.setView(L.latLng([0, 0]), 12); + var spy = sinon.spy(); + map.on('contextmenu', function (e) { + spy(e.originalEvent.defaultPrevented); + }); + var marker = L.circleMarker([0, 0]).addTo(map); + + happen.at('contextmenu', 0, 0); // first + + happen.at('contextmenu', marker._point.x, marker._point.y); // second (#5995) + + document.body.removeChild(container); // cleanup + + expect(spy.callCount).to.be(2); + expect(spy.firstCall.lastArg).to.be.ok(); + expect(spy.secondCall.lastArg).to.be.ok(); + }); }); describe("#getScaleZoom && #getZoomScale", function () { @@ -1279,4 +1318,22 @@ describe("Map", function () { expect(map.getZoom()).to.be(undefined); }); }); + + describe("#Geolocation", function () { + it("doesn't throw error if location is found and map is not existing", function () { + var fn = L.Util.bind(map._handleGeolocationResponse, map); + map.remove(); + expect(function () { + fn({coords: {latitude: 40.415296, longitude: 10.7419264, accuracy: 1129.5646101470752}}); + }).to.not.throwException(); + }); + it("doesn't throw error if location is not found and map is not existing", function () { + map._locateOptions = {setView: true}; + var fn = L.Util.bind(map._handleGeolocationError, map); + map.remove(); + expect(function () { + fn({coords: {latitude: 40.415296, longitude: 10.7419264, accuracy: 1129.5646101470752}}); + }).to.not.throwException(); + }); + }); }); diff --git a/spec/suites/map/handler/Map.DragSpec.js b/spec/suites/map/handler/Map.DragSpec.js index 0b7cbf53abd..c86701104d6 100644 --- a/spec/suites/map/handler/Map.DragSpec.js +++ b/spec/suites/map/handler/Map.DragSpec.js @@ -97,7 +97,8 @@ describe("Map.Drag", function () { container.style.webkitTransform = 'scale(' + scaleX + ', ' + scaleY + ')'; }); - it("change the center of the map, compensating for CSS scale", function (done) { + // fixme IE + (L.Browser.ie ? it.skip : it)("change the center of the map, compensating for CSS scale", function (done) { map = new L.Map(container, { dragging: true, inertia: false diff --git a/spec/suites/map/handler/Map.KeyboardSpec.js b/spec/suites/map/handler/Map.KeyboardSpec.js index c8988956b6e..a3b5a5e76ba 100644 --- a/spec/suites/map/handler/Map.KeyboardSpec.js +++ b/spec/suites/map/handler/Map.KeyboardSpec.js @@ -1,12 +1,12 @@ describe("Map.Keyboard", function () { - const KEYCODE_LOWERCASE_A = 65; - const KEYCODE_ARROW_LEFT = 37; - const KEYCODE_ARROW_UP = 38; - const KEYCODE_ARROW_RIGHT = 39; - const KEYCODE_ARROW_DOWN = 40; - const KEYCODE_PLUS = 171; - const KEYCODE_MINUS = 173; - const KEYCODE_ESC = 27; + var KEYCODE_LOWERCASE_A = 65; + var KEYCODE_ARROW_LEFT = 37; + var KEYCODE_ARROW_UP = 38; + var KEYCODE_ARROW_RIGHT = 39; + var KEYCODE_ARROW_DOWN = 40; + var KEYCODE_PLUS = 171; + var KEYCODE_MINUS = 173; + var KEYCODE_ESC = 27; var map, container; diff --git a/spec/suites/map/handler/Map.TapHoldSpec.js b/spec/suites/map/handler/Map.TapHoldSpec.js new file mode 100644 index 00000000000..6378ff08ca8 --- /dev/null +++ b/spec/suites/map/handler/Map.TapHoldSpec.js @@ -0,0 +1,209 @@ +describe('Map.TapHoldSpec.js', function () { + var el, clock, spy, map; + + var posStart = {clientX:1, clientY:1}; + var posNear = {clientX:10, clientY:10}; + var posFar = {clientX:100, clientY:100}; + + beforeEach(function () { + el = document.createElement('div'); + document.body.appendChild(el); + + clock = sinon.useFakeTimers(); + clock.tick(1000); + spy = sinon.spy(); + + map = L.map(el, { + center: [51.505, -0.09], + zoom: 13, + tapHold: true + }); + map.on('contextmenu', spy); + + posStart.target = el; + posNear.target = el; + posFar.target = el; + }); + + afterEach(function () { + happen.once(el, {type: 'touchend'}); + for (var id = 0; id <= 2; id++) { // reset pointers (for prosphetic-hand) + happen.once(el, {type: 'pointercancel', pointerId:id}); + } + clock.restore(); + map.remove(); + document.body.removeChild(el); + }); + + it('fires synthetic contextmenu after hold delay>600', function () { + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(550); + + expect(spy.notCalled).to.be.ok(); + + clock.tick(100); + + expect(spy.called).to.be.ok(); + expect(spy.calledOnce).to.be.ok(); + + var event = spy.lastCall.args[0]; + expect(event.type).to.be('contextmenu'); + expect(event.originalEvent._simulated).to.be.ok(); + }); + + it('does not fire contextmenu when touches > 1', function () { + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(100); + happen.once(el, {type: 'touchstart', touches: [posStart, posNear]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:1}, posNear)); + clock.tick(550); + + expect(spy.notCalled).to.be.ok(); + }); + + it('does not fire contextmenu when touches > 1 (case:2)', function () { + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(100); + happen.once(el, {type: 'touchstart', touches: [posStart, posNear]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:1}, posNear)); + clock.tick(100); + happen.once(el, {type: 'touchend', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerup', pointerId:0}, posNear)); + clock.tick(450); + + expect(spy.notCalled).to.be.ok(); + }); + + (L.Browser.pointer ? it : it.skip)('ignores events from mouse', function () { + happen.once(el, L.extend({type: 'pointerdown', pointerId:0, pointerType:'mouse'}, posStart)); + clock.tick(650); + + expect(spy.notCalled).to.be.ok(); + }); + + it('does not conflict with native contextmenu', function () { + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(550); + + happen.once(el, {type: 'contextmenu'}); + + clock.tick(100); + + expect(spy.called).to.be.ok(); + expect(spy.calledOnce).to.be.ok(); + expect(spy.lastCall.args[0].originalEvent._simulated).not.to.be.ok(); + + // Note: depending on tapHoldDelay value it's also possible that native contextmenu may come after simulated one + // and the only way to handle this gracefully - increase tapHoldDelay value. + // Anyway that is edge case, as tapHold is meant for browsers where native contextmenu is not fired on touch. + }); + + it.skip('prevents native click', function () { // to be performed by hand + // Not valid here, as there is no way to initiate native click with fake touch + var clickSpy = sinon.spy(); + map.on('click', clickSpy); + + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(650); + happen.once(el, {type: 'touchend', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerup', pointerId:0}, posNear)); + + expect(clickSpy.notCalled).to.be.ok(); + }); + + it('allows short movements', function () { + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(550); + + happen.once(el, {type: 'touchmove', touches: [posNear]}); + happen.once(el, L.extend({type: 'pointermove', pointerId:0}, posNear)); + + clock.tick(100); + + expect(spy.called).to.be.ok(); + }); + + it('ignores long movements', function () { + expect(L.point(posStart.clientX, posStart.clientY).distanceTo([posFar.clientX, posFar.clientY])) + .to.be.above(map.options.tapTolerance); + + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(550); + + happen.once(el, {type: 'touchmove', touches: [posFar]}); + happen.once(el, L.extend({type: 'pointermove', pointerId:0}, posFar)); + + clock.tick(100); + + expect(spy.notCalled).to.be.ok(); + }); + + it('.originalEvent has expected properties', function () { + L.extend(posStart, { + screenX: 2, + screenY: 2, + }); + + happen.once(el, {type: 'touchstart', touches: [posStart]}); + happen.once(el, L.extend({type: 'pointerdown', pointerId:0}, posStart)); + clock.tick(650); + + var originalEvent = spy.lastCall.args[0].originalEvent; + var expectedProps = L.extend({ + type: 'contextmenu', + bubbles: true, + cancelable: true, + target: el + }, posStart); + for (var prop in expectedProps) { + expect(originalEvent[prop]).to.be(expectedProps[prop]); + } + }); +}); + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent#polyfill +// required for PhantomJS + +(function (window) { + try { + new MouseEvent('test'); // eslint-disable-line no-new + return false; // No need to polyfill + } catch (e) { + // Need to polyfill - fall through + } + + // Polyfills DOM4 MouseEvent + var MouseEventPolyfill = function (eventType, params) { + params = params || {bubbles: false, cancelable: false}; + var mouseEvent = document.createEvent('MouseEvent'); + mouseEvent.initMouseEvent(eventType, + params.bubbles, + params.cancelable, + window, + 0, + params.screenX || 0, + params.screenY || 0, + params.clientX || 0, + params.clientY || 0, + params.ctrlKey || false, + params.altKey || false, + params.shiftKey || false, + params.metaKey || false, + params.button || 0, + params.relatedTarget || null + ); + + return mouseEvent; + }; + + MouseEventPolyfill.prototype = Event.prototype; + + window.MouseEvent = MouseEventPolyfill; +})(window); diff --git a/src/control/Control.Attribution.js b/src/control/Control.Attribution.js index 48e738a838e..6177c48e6dc 100644 --- a/src/control/Control.Attribution.js +++ b/src/control/Control.Attribution.js @@ -45,9 +45,24 @@ export var Attribution = Control.extend({ this._update(); + map.on('layeradd', this._addAttribution, this); + return this._container; }, + onRemove: function (map) { + map.off('layeradd', this._addAttribution, this); + }, + + _addAttribution: function (ev) { + if (ev.layer.getAttribution) { + this.addAttribution(ev.layer.getAttribution()); + ev.layer.once('remove', function () { + this.removeAttribution(ev.layer.getAttribution()); + }, this); + } + }, + // @method setPrefix(prefix: String): this // Sets the text before the attributions. setPrefix: function (prefix) { diff --git a/src/control/Control.Layers.js b/src/control/Control.Layers.js index f2876e50f92..f5718709d03 100644 --- a/src/control/Control.Layers.js +++ b/src/control/Control.Layers.js @@ -1,7 +1,6 @@ import {Control} from './Control'; import * as Util from '../core/Util'; -import * as Browser from '../core/Browser'; import * as DomEvent from '../dom/DomEvent'; import * as DomUtil from '../dom/DomUtil'; @@ -10,7 +9,7 @@ import * as DomUtil from '../dom/DomUtil'; * @aka L.Control.Layers * @inherits Control * - * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](http://leafletjs.com/examples/layers-control/)). Extends `Control`. + * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](https://leafletjs.com/examples/layers-control/)). Extends `Control`. * * @example * @@ -187,24 +186,25 @@ export var Layers = Control.extend({ if (collapsed) { this._map.on('click', this.collapse, this); - if (!Browser.android) { - DomEvent.on(container, { - mouseenter: this.expand, - mouseleave: this.collapse - }, this); - } + DomEvent.on(container, { + mouseenter: function () { + DomEvent.on(section, 'click', DomEvent.preventDefault); + this.expand(); + setTimeout(function () { + DomEvent.off(section, 'click', DomEvent.preventDefault); + }); + }, + mouseleave: this.collapse + }, this); } var link = this._layersLink = DomUtil.create('a', className + '-toggle', container); link.href = '#'; link.title = 'Layers'; + link.setAttribute('role', 'button'); - if (Browser.touch) { - DomEvent.on(link, 'click', DomEvent.stop); - DomEvent.on(link, 'click', this.expand, this); - } else { - DomEvent.on(link, 'focus', this.expand, this); - } + DomEvent.on(link, 'click', DomEvent.preventDefault); // prevent link function + DomEvent.on(link, 'focus', this.expand, this); if (!collapsed) { this.expand(); @@ -409,16 +409,6 @@ export var Layers = Control.extend({ this.expand(); } return this; - }, - - _expand: function () { - // Backward compatibility, remove me in 1.1. - return this.expand(); - }, - - _collapse: function () { - // Backward compatibility, remove me in 1.1. - return this.collapse(); } }); diff --git a/src/control/Control.Zoom.js b/src/control/Control.Zoom.js index 3c8055003ae..65307f9d5b6 100644 --- a/src/control/Control.Zoom.js +++ b/src/control/Control.Zoom.js @@ -18,17 +18,17 @@ export var Zoom = Control.extend({ options: { position: 'topleft', - // @option zoomInText: String = '+' + // @option zoomInText: String = '' // The text set on the 'zoom in' button. - zoomInText: '+', + zoomInText: '', // @option zoomInTitle: String = 'Zoom in' // The title set on the 'zoom in' button. zoomInTitle: 'Zoom in', - // @option zoomOutText: String = '−' + // @option zoomOutText: String = '' // The text set on the 'zoom out' button. - zoomOutText: '−', + zoomOutText: '', // @option zoomOutTitle: String = 'Zoom out' // The title set on the 'zoom out' button. diff --git a/src/core/Browser.js b/src/core/Browser.js index ee2583e0fa3..0187d811686 100644 --- a/src/core/Browser.js +++ b/src/core/Browser.js @@ -19,104 +19,108 @@ import {svgCreate} from '../layer/vector/SVG.Util'; var style = document.documentElement.style; // @property ie: Boolean; `true` for all Internet Explorer versions (not Edge). -export var ie = 'ActiveXObject' in window; +var ie = 'ActiveXObject' in window; // @property ielt9: Boolean; `true` for Internet Explorer versions less than 9. -export var ielt9 = ie && !document.addEventListener; +var ielt9 = ie && !document.addEventListener; // @property edge: Boolean; `true` for the Edge web browser. -export var edge = 'msLaunchUri' in navigator && !('documentMode' in document); +var edge = 'msLaunchUri' in navigator && !('documentMode' in document); // @property webkit: Boolean; // `true` for webkit-based browsers like Chrome and Safari (including mobile versions). -export var webkit = userAgentContains('webkit'); +var webkit = userAgentContains('webkit'); // @property android: Boolean -// `true` for any browser running on an Android platform. -export var android = userAgentContains('android'); +// **Deprecated.** `true` for any browser running on an Android platform. +var android = userAgentContains('android'); -// @property android23: Boolean; `true` for browsers running on Android 2 or Android 3. -export var android23 = userAgentContains('android 2') || userAgentContains('android 3'); +// @property android23: Boolean; **Deprecated.** `true` for browsers running on Android 2 or Android 3. +var android23 = userAgentContains('android 2') || userAgentContains('android 3'); /* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */ var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit -// @property androidStock: Boolean; `true` for the Android stock browser (i.e. not Chrome) -export var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window); +// @property androidStock: Boolean; **Deprecated.** `true` for the Android stock browser (i.e. not Chrome) +var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window); // @property opera: Boolean; `true` for the Opera browser -export var opera = !!window.opera; +var opera = !!window.opera; // @property chrome: Boolean; `true` for the Chrome browser. -export var chrome = !edge && userAgentContains('chrome'); +var chrome = !edge && userAgentContains('chrome'); // @property gecko: Boolean; `true` for gecko-based browsers like Firefox. -export var gecko = userAgentContains('gecko') && !webkit && !opera && !ie; +var gecko = userAgentContains('gecko') && !webkit && !opera && !ie; // @property safari: Boolean; `true` for the Safari browser. -export var safari = !chrome && userAgentContains('safari'); +var safari = !chrome && userAgentContains('safari'); -export var phantom = userAgentContains('phantom'); +var phantom = userAgentContains('phantom'); // @property opera12: Boolean // `true` for the Opera browser supporting CSS transforms (version 12 or later). -export var opera12 = 'OTransition' in style; +var opera12 = 'OTransition' in style; // @property win: Boolean; `true` when the browser is running in a Windows platform -export var win = navigator.platform.indexOf('Win') === 0; +var win = navigator.platform.indexOf('Win') === 0; // @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms. -export var ie3d = ie && ('transition' in style); +var ie3d = ie && ('transition' in style); // @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms. -export var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23; +var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23; // @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms. -export var gecko3d = 'MozPerspective' in style; +var gecko3d = 'MozPerspective' in style; // @property any3d: Boolean // `true` for all browsers supporting CSS transforms. -export var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom; +var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom; // @property mobile: Boolean; `true` for all browsers running in a mobile device. -export var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile'); +var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile'); // @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device. -export var mobileWebkit = mobile && webkit; +var mobileWebkit = mobile && webkit; // @property mobileWebkit3d: Boolean // `true` for all webkit-based browsers in a mobile device supporting CSS transforms. -export var mobileWebkit3d = mobile && webkit3d; +var mobileWebkit3d = mobile && webkit3d; // @property msPointer: Boolean // `true` for browsers implementing the Microsoft touch events model (notably IE10). -export var msPointer = !window.PointerEvent && window.MSPointerEvent; +var msPointer = !window.PointerEvent && window.MSPointerEvent; // @property pointer: Boolean // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx). -export var pointer = !!(window.PointerEvent || msPointer); +var pointer = !!(window.PointerEvent || msPointer); -// @property touch: Boolean +// @property touchNative: Boolean // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). -// This does not necessarily mean that the browser is running in a computer with +// **This does not necessarily mean** that the browser is running in a computer with // a touchscreen, it only means that the browser is capable of understanding // touch events. -export var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window || - (window.DocumentTouch && document instanceof window.DocumentTouch)); +var touchNative = 'ontouchstart' in window || !!window.TouchEvent; + +// @property touch: Boolean +// `true` for all browsers supporting either [touch](#browser-touch) or [pointer](#browser-pointer) events. +// Note: pointer events will be preferred (if available), and processed for all `touch*` listeners. +var touch = !window.L_NO_TOUCH && (touchNative || pointer); // @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device. -export var mobileOpera = mobile && opera; +var mobileOpera = mobile && opera; // @property mobileGecko: Boolean // `true` for gecko-based browsers running in a mobile device. -export var mobileGecko = mobile && gecko; +var mobileGecko = mobile && gecko; // @property retina: Boolean // `true` for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%. -export var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1; +var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1; // @property passiveEvents: Boolean // `true` for browsers that support passive events. -export var passiveEvents = (function () { +var passiveEvents = (function () { var supportsPassiveOption = false; try { var opts = Object.defineProperty({}, 'passive', { @@ -134,17 +138,17 @@ export var passiveEvents = (function () { // @property canvas: Boolean // `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). -export var canvas = (function () { +var canvas = (function () { return !!document.createElement('canvas').getContext; }()); // @property svg: Boolean // `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG). -export var svg = !!(document.createElementNS && svgCreate('svg').createSVGRect); +var svg = !!(document.createElementNS && svgCreate('svg').createSVGRect); // @property vml: Boolean // `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language). -export var vml = !svg && (function () { +var vml = !svg && (function () { try { var div = document.createElement('div'); div.innerHTML = ''; @@ -163,3 +167,39 @@ export var vml = !svg && (function () { function userAgentContains(str) { return navigator.userAgent.toLowerCase().indexOf(str) >= 0; } + + +export default { + ie: ie, + ielt9: ielt9, + edge: edge, + webkit: webkit, + android: android, + android23: android23, + androidStock: androidStock, + opera: opera, + chrome: chrome, + gecko: gecko, + safari: safari, + phantom: phantom, + opera12: opera12, + win: win, + ie3d: ie3d, + webkit3d: webkit3d, + gecko3d: gecko3d, + any3d: any3d, + mobile: mobile, + mobileWebkit: mobileWebkit, + mobileWebkit3d: mobileWebkit3d, + msPointer: msPointer, + pointer: pointer, + touch: touch, + touchNative: touchNative, + mobileOpera: mobileOpera, + mobileGecko: mobileGecko, + retina: retina, + passiveEvents: passiveEvents, + canvas: canvas, + svg: svg, + vml: vml, +}; diff --git a/src/core/Class.js b/src/core/Class.js index f60bda9e13e..7d1c1b26a88 100644 --- a/src/core/Class.js +++ b/src/core/Class.js @@ -17,6 +17,8 @@ Class.extend = function (props) { // Returns a Javascript function that is a class constructor (to be called with `new`). var NewClass = function () { + Util.setOptions(this); + // call the constructor if (this.initialize) { this.initialize.apply(this, arguments); @@ -43,24 +45,25 @@ Class.extend = function (props) { // mix static properties into the class if (props.statics) { Util.extend(NewClass, props.statics); - delete props.statics; } // mix includes into the prototype if (props.includes) { checkDeprecatedMixinEvents(props.includes); Util.extend.apply(null, [proto].concat(props.includes)); - delete props.includes; } + // mix given properties into the prototype + Util.extend(proto, props); + delete proto.statics; + delete proto.includes; + // merge options if (proto.options) { - props.options = Util.extend(Util.create(proto.options), props.options); + proto.options = parentProto.options ? Util.create(parentProto.options) : {}; + Util.extend(proto.options, props.options); } - // mix given properties into the prototype - Util.extend(proto, props); - proto._initHooks = []; // add method for calling all hooks @@ -86,7 +89,12 @@ Class.extend = function (props) { // @function include(properties: Object): this // [Includes a mixin](#class-includes) into the current class. Class.include = function (props) { + var parentOptions = this.prototype.options; Util.extend(this.prototype, props); + if (props.options) { + this.prototype.options = parentOptions; + this.mergeOptions(props.options); + } return this; }; diff --git a/src/core/Events.js b/src/core/Events.js index d2a18bb6a93..c8d5da258f1 100644 --- a/src/core/Events.js +++ b/src/core/Events.js @@ -69,7 +69,7 @@ export var Events = { */ off: function (types, fn, context) { - if (!types) { + if (!arguments.length) { // clear all listeners if called without arguments delete this._events; @@ -81,8 +81,13 @@ export var Events = { } else { types = Util.splitWords(types); + var removeAll = arguments.length === 1; for (var i = 0, len = types.length; i < len; i++) { - this._off(types[i], fn, context); + if (removeAll) { + this._off(types[i]); + } else { + this._off(types[i], fn, context); + } } } @@ -91,6 +96,10 @@ export var Events = { // attach listener (without syntactic sugar now) _on: function (type, fn, context) { + if (typeof fn !== 'function') { + console.warn('wrong listener type: ' + typeof fn); + return; + } this._events = this._events || {}; /* get/init listeners for type */ @@ -130,10 +139,13 @@ export var Events = { return; } - if (!fn) { - // Set all removed listeners to noop so they are not called if remove happens in fire - for (i = 0, len = listeners.length; i < len; i++) { - listeners[i].fn = Util.falseFn; + if (arguments.length === 1) { // remove all + if (this._firingCount) { + // Set all removed listeners to noop + // so they are not called if remove happens in fire + for (i = 0, len = listeners.length; i < len; i++) { + listeners[i].fn = Util.falseFn; + } } // clear all listeners for a type if function isn't specified delete this._events[type]; @@ -144,27 +156,28 @@ export var Events = { context = undefined; } - if (listeners) { - - // find fn and remove it - for (i = 0, len = listeners.length; i < len; i++) { - var l = listeners[i]; - if (l.ctx !== context) { continue; } - if (l.fn === fn) { - + if (typeof fn !== 'function') { + console.warn('wrong listener type: ' + typeof fn); + return; + } + // find fn and remove it + for (i = 0, len = listeners.length; i < len; i++) { + var l = listeners[i]; + if (l.ctx !== context) { continue; } + if (l.fn === fn) { + if (this._firingCount) { // set the removed listener to noop so that's not called if remove happens in fire l.fn = Util.falseFn; - if (this._firingCount) { - /* copy array in case events are being fired */ - this._events[type] = listeners = listeners.slice(); - } - listeners.splice(i, 1); - - return; + /* copy array in case events are being fired */ + this._events[type] = listeners = listeners.slice(); } + listeners.splice(i, 1); + + return; } } + console.warn('listener not found'); }, // @method fire(type: String, data?: Object, propagate?: Boolean): this @@ -202,9 +215,13 @@ export var Events = { return this; }, - // @method listens(type: String): Boolean + // @method listens(type: String, propagate?: Boolean): Boolean // Returns `true` if a particular event type has any listeners attached to it. + // The verification can optionally be propagated, it will return `true` if parents have the listener attached to it. listens: function (type, propagate) { + if (typeof type !== 'string') { + console.warn('"string" type argument expected'); + } var listeners = this._events && this._events[type]; if (listeners && listeners.length) { return true; } diff --git a/src/core/Util.js b/src/core/Util.js index fa97caf01d6..ac4fcdfd850 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -52,10 +52,10 @@ export var lastId = 0; // @function stamp(obj: Object): Number // Returns the unique ID of an object, assigning it one if it doesn't have it. export function stamp(obj) { - /*eslint-disable */ - obj._leaflet_id = obj._leaflet_id || ++lastId; + if (!('_leaflet_id' in obj)) { + obj['_leaflet_id'] = ++lastId; + } return obj._leaflet_id; - /* eslint-enable */ } // @function throttle(fn: Function, time: Number, context: Object): Function @@ -108,10 +108,13 @@ export function wrapNum(x, range, includeMax) { // Returns a function which always returns `false`. export function falseFn() { return false; } -// @function formatNum(num: Number, digits?: Number): Number -// Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default. -export function formatNum(num, digits) { - var pow = Math.pow(10, (digits === undefined ? 6 : digits)); +// @function formatNum(num: Number, precision?: Number|false): Number +// Returns the number `num` rounded with specified `precision`. +// The default `precision` value is 6 decimal places. +// `false` can be passed to skip any processing (can be useful to avoid round-off errors). +export function formatNum(num, precision) { + if (precision === false) { return num; } + var pow = Math.pow(10, precision === undefined ? 6 : precision); return Math.round(num * pow) / pow; } @@ -194,7 +197,7 @@ export function indexOf(array, el) { // mobile devices (by setting image `src` to this string). export var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; -// inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// inspired by https://paulirish.com/2011/requestanimationframe-for-smart-animating/ function getPrefixed(name) { return window['webkit' + name] || window['moz' + name] || window['ms' + name]; diff --git a/src/core/index.js b/src/core/index.js index ae9297d4a80..8c5ccc1e48b 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -1,4 +1,4 @@ -import * as Browser from './Browser'; +import Browser from './Browser'; export {Browser}; export {Class} from './Class'; diff --git a/src/dom/DomEvent.DoubleTap.js b/src/dom/DomEvent.DoubleTap.js index a302df84bc2..1c75e96cf16 100644 --- a/src/dom/DomEvent.DoubleTap.js +++ b/src/dom/DomEvent.DoubleTap.js @@ -1,81 +1,70 @@ -import * as Browser from '../core/Browser'; - /* * Extends the event handling code with double tap support for mobile browsers. + * + * Note: currently most browsers fire native dblclick, with only a few exceptions + * (see https://github.com/Leaflet/Leaflet/issues/7012#issuecomment-595087386) */ -var _touchstart = Browser.msPointer ? 'MSPointerDown' : Browser.pointer ? 'pointerdown' : 'touchstart'; -var _touchend = Browser.msPointer ? 'MSPointerUp' : Browser.pointer ? 'pointerup' : 'touchend'; -var _pre = '_leaflet_'; - -// inspired by Zepto touch code by Thomas Fuchs -export function addDoubleTapListener(obj, handler, id) { - var last, touch, - doubleTap = false, - delay = 250; - - function onTouchStart(e) { +function makeDblclick(event) { + // in modern browsers `type` cannot be just overridden: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only + var newEvent = {}, + prop, i; + for (i in event) { + prop = event[i]; + newEvent[i] = prop && prop.bind ? prop.bind(event) : prop; + } + event = newEvent; + newEvent.type = 'dblclick'; + newEvent.detail = 2; + newEvent.isTrusted = false; + newEvent._simulated = true; // for debug purposes + return newEvent; +} - if (Browser.pointer) { - if (!e.isPrimary) { return; } - if (e.pointerType === 'mouse') { return; } // mouse fires native dblclick - } else if (e.touches.length > 1) { +var delay = 200; +export function addDoubleTapListener(obj, handler) { + // Most browsers handle double tap natively + obj.addEventListener('dblclick', handler); + + // On some platforms the browser doesn't fire native dblclicks for touch events. + // It seems that in all such cases `detail` property of `click` event is always `1`. + // So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed. + var last = 0, + detail; + function simDblclick(e) { + if (e.detail !== 1) { + detail = e.detail; // keep in sync to avoid false dblclick in some cases return; } - var now = Date.now(), - delta = now - (last || now); - - touch = e.touches ? e.touches[0] : e; - doubleTap = (delta > 0 && delta <= delay); - last = now; - } + if (e.pointerType === 'mouse' || + (e.sourceCapabilities && !e.sourceCapabilities.firesTouchEvents)) { - function onTouchEnd(e) { - if (doubleTap && !touch.cancelBubble) { - if (Browser.pointer) { - if (e.pointerType === 'mouse') { return; } - // work around .type being readonly with MSPointer* events - var newTouch = {}, - prop, i; + return; + } - for (i in touch) { - prop = touch[i]; - newTouch[i] = prop && prop.bind ? prop.bind(touch) : prop; - } - touch = newTouch; + var now = Date.now(); + if (now - last <= delay) { + detail++; + if (detail === 2) { + handler(makeDblclick(e)); } - touch.type = 'dblclick'; - touch.button = 0; - handler(touch); - last = null; + } else { + detail = 1; } + last = now; } - obj[_pre + _touchstart + id] = onTouchStart; - obj[_pre + _touchend + id] = onTouchEnd; - obj[_pre + 'dblclick' + id] = handler; - - obj.addEventListener(_touchstart, onTouchStart, Browser.passiveEvents ? {passive: false} : false); - obj.addEventListener(_touchend, onTouchEnd, Browser.passiveEvents ? {passive: false} : false); + obj.addEventListener('click', simDblclick); - // On some platforms (notably, chrome<55 on win10 + touchscreen + mouse), - // the browser doesn't fire touchend/pointerup events but does fire - // native dblclicks. See #4127. - // Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180. - obj.addEventListener('dblclick', handler, false); - - return this; + return { + dblclick: handler, + simDblclick: simDblclick + }; } -export function removeDoubleTapListener(obj, id) { - var touchstart = obj[_pre + _touchstart + id], - touchend = obj[_pre + _touchend + id], - dblclick = obj[_pre + 'dblclick' + id]; - - obj.removeEventListener(_touchstart, touchstart, Browser.passiveEvents ? {passive: false} : false); - obj.removeEventListener(_touchend, touchend, Browser.passiveEvents ? {passive: false} : false); - obj.removeEventListener('dblclick', dblclick, false); - - return this; +export function removeDoubleTapListener(obj, handlers) { + obj.removeEventListener('dblclick', handlers.dblclick); + obj.removeEventListener('click', handlers.simDblclick); } diff --git a/src/dom/DomEvent.Pointer.js b/src/dom/DomEvent.Pointer.js index 8aac40edb9d..0f179d453ac 100644 --- a/src/dom/DomEvent.Pointer.js +++ b/src/dom/DomEvent.Pointer.js @@ -1,67 +1,68 @@ import * as DomEvent from './DomEvent'; -import * as Util from '../core/Util'; -import * as Browser from '../core/Browser'; +import Browser from '../core/Browser'; /* * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. */ - var POINTER_DOWN = Browser.msPointer ? 'MSPointerDown' : 'pointerdown'; var POINTER_MOVE = Browser.msPointer ? 'MSPointerMove' : 'pointermove'; var POINTER_UP = Browser.msPointer ? 'MSPointerUp' : 'pointerup'; var POINTER_CANCEL = Browser.msPointer ? 'MSPointerCancel' : 'pointercancel'; - +var pEvent = { + touchstart : POINTER_DOWN, + touchmove : POINTER_MOVE, + touchend : POINTER_UP, + touchcancel : POINTER_CANCEL +}; +var handle = { + touchstart : _onPointerStart, + touchmove : _handlePointer, + touchend : _handlePointer, + touchcancel : _handlePointer +}; var _pointers = {}; var _pointerDocListener = false; // Provides a touch events wrapper for (ms)pointer events. -// ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 +// ref https://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 -export function addPointerListener(obj, type, handler, id) { +export function addPointerListener(obj, type, handler) { if (type === 'touchstart') { - _addPointerStart(obj, handler, id); - - } else if (type === 'touchmove') { - _addPointerMove(obj, handler, id); - - } else if (type === 'touchend') { - _addPointerEnd(obj, handler, id); + _addPointerDocListener(); } - - return this; + if (!handle[type]) { + console.warn('wrong event specified:', type); + return L.Util.falseFn; + } + handler = handle[type].bind(this, handler); + obj.addEventListener(pEvent[type], handler, false); + return handler; } -export function removePointerListener(obj, type, id) { - var handler = obj['_leaflet_' + type + id]; - - if (type === 'touchstart') { - obj.removeEventListener(POINTER_DOWN, handler, false); - - } else if (type === 'touchmove') { - obj.removeEventListener(POINTER_MOVE, handler, false); - - } else if (type === 'touchend') { - obj.removeEventListener(POINTER_UP, handler, false); - obj.removeEventListener(POINTER_CANCEL, handler, false); +export function removePointerListener(obj, type, handler) { + if (!pEvent[type]) { + console.warn('wrong event specified:', type); + return; } - - return this; + obj.removeEventListener(pEvent[type], handler, false); } -function _addPointerStart(obj, handler, id) { - var onDown = Util.bind(function (e) { - // IE10 specific: MsTouch needs preventDefault. See #2000 - if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) { - DomEvent.preventDefault(e); - } +function _globalPointerDown(e) { + _pointers[e.pointerId] = e; +} - _handlePointer(e, handler); - }); +function _globalPointerMove(e) { + if (_pointers[e.pointerId]) { + _pointers[e.pointerId] = e; + } +} - obj['_leaflet_touchstart' + id] = onDown; - obj.addEventListener(POINTER_DOWN, onDown, false); +function _globalPointerUp(e) { + delete _pointers[e.pointerId]; +} +function _addPointerDocListener() { // need to keep track of what pointers and how many are active to provide e.touches emulation if (!_pointerDocListener) { // we listen document as any drags that end by moving the touch off the screen get fired there @@ -74,21 +75,9 @@ function _addPointerStart(obj, handler, id) { } } -function _globalPointerDown(e) { - _pointers[e.pointerId] = e; -} - -function _globalPointerMove(e) { - if (_pointers[e.pointerId]) { - _pointers[e.pointerId] = e; - } -} - -function _globalPointerUp(e) { - delete _pointers[e.pointerId]; -} +function _handlePointer(handler, e) { + if (e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) { return; } -function _handlePointer(e, handler) { e.touches = []; for (var i in _pointers) { e.touches.push(_pointers[i]); @@ -98,26 +87,10 @@ function _handlePointer(e, handler) { handler(e); } -function _addPointerMove(obj, handler, id) { - var onMove = function (e) { - // don't fire touch moves when mouse isn't down - if ((e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) && e.buttons === 0) { - return; - } - - _handlePointer(e, handler); - }; - - obj['_leaflet_touchmove' + id] = onMove; - obj.addEventListener(POINTER_MOVE, onMove, false); -} - -function _addPointerEnd(obj, handler, id) { - var onUp = function (e) { - _handlePointer(e, handler); - }; - - obj['_leaflet_touchend' + id] = onUp; - obj.addEventListener(POINTER_UP, onUp, false); - obj.addEventListener(POINTER_CANCEL, onUp, false); +function _onPointerStart(handler, e) { + // IE10 specific: MsTouch needs preventDefault. See #2000 + if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) { + DomEvent.preventDefault(e); + } + _handlePointer(handler, e); } diff --git a/src/dom/DomEvent.js b/src/dom/DomEvent.js index 734eb502033..b6ebcbcf947 100644 --- a/src/dom/DomEvent.js +++ b/src/dom/DomEvent.js @@ -1,6 +1,6 @@ import {Point} from '../geometry/Point'; import * as Util from '../core/Util'; -import * as Browser from '../core/Browser'; +import Browser from '../core/Browser'; import {addPointerListener, removePointerListener} from './DomEvent.Pointer'; import {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap'; import {getScale} from './DomUtil'; @@ -23,7 +23,7 @@ import {getScale} from './DomUtil'; // Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` export function on(obj, types, fn, context) { - if (typeof types === 'object') { + if (types && typeof types === 'object') { for (var type in types) { addOne(obj, type, types[type], fn); } @@ -48,32 +48,48 @@ var eventsKey = '_leaflet_events'; // @alternative // @function off(el: HTMLElement, eventMap: Object, context?: Object): this // Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` + +// @alternative +// @function off(el: HTMLElement, types: String): this +// Removes all previously added listeners of given types. + +// @alternative +// @function off(el: HTMLElement): this +// Removes all previously added listeners from given HTMLElement export function off(obj, types, fn, context) { - if (typeof types === 'object') { + if (arguments.length === 1) { + batchRemove(obj); + delete obj[eventsKey]; + + } else if (types && typeof types === 'object') { for (var type in types) { removeOne(obj, type, types[type], fn); } - } else if (types) { - types = Util.splitWords(types); - for (var i = 0, len = types.length; i < len; i++) { - removeOne(obj, types[i], fn, context); - } } else { - for (var j in obj[eventsKey]) { - removeOne(obj, j, obj[eventsKey][j]); + types = Util.splitWords(types); + + if (arguments.length === 2) { + batchRemove(obj, function (type) { + return Util.indexOf(types, type) !== -1; + }); + } else { + for (var i = 0, len = types.length; i < len; i++) { + removeOne(obj, types[i], fn, context); + } } - delete obj[eventsKey]; } return this; } -function browserFiresNativeDblClick() { - // See https://github.com/w3c/pointerevents/issues/171 - if (Browser.pointer) { - return !(Browser.edge || Browser.safari); +function batchRemove(obj, filterFn) { + for (var id in obj[eventsKey]) { + var type = id.split(/\d/)[0]; + if (!filterFn || filterFn(type)) { + removeOne(obj, type, null, null, id); + } } } @@ -94,12 +110,12 @@ function addOne(obj, type, fn, context) { var originalHandler = handler; - if (Browser.pointer && type.indexOf('touch') === 0) { + if (!Browser.touchNative && Browser.pointer && type.indexOf('touch') === 0) { // Needs DomEvent.Pointer.js - addPointerListener(obj, type, handler, id); + handler = addPointerListener(obj, type, handler); - } else if (Browser.touch && (type === 'dblclick') && !browserFiresNativeDblClick()) { - addDoubleTapListener(obj, handler, id); + } else if (Browser.touch && (type === 'dblclick')) { + handler = addDoubleTapListener(obj, handler); } else if ('addEventListener' in obj) { @@ -119,7 +135,7 @@ function addOne(obj, type, fn, context) { obj.addEventListener(type, originalHandler, false); } - } else if ('attachEvent' in obj) { + } else { obj.attachEvent('on' + type, handler); } @@ -127,24 +143,23 @@ function addOne(obj, type, fn, context) { obj[eventsKey][id] = handler; } -function removeOne(obj, type, fn, context) { - - var id = type + Util.stamp(fn) + (context ? '_' + Util.stamp(context) : ''), - handler = obj[eventsKey] && obj[eventsKey][id]; +function removeOne(obj, type, fn, context, id) { + id = id || type + Util.stamp(fn) + (context ? '_' + Util.stamp(context) : ''); + var handler = obj[eventsKey] && obj[eventsKey][id]; if (!handler) { return this; } - if (Browser.pointer && type.indexOf('touch') === 0) { - removePointerListener(obj, type, id); + if (!Browser.touchNative && Browser.pointer && type.indexOf('touch') === 0) { + removePointerListener(obj, type, handler); - } else if (Browser.touch && (type === 'dblclick') && !browserFiresNativeDblClick()) { - removeDoubleTapListener(obj, id); + } else if (Browser.touch && (type === 'dblclick')) { + removeDoubleTapListener(obj, handler); } else if ('removeEventListener' in obj) { obj.removeEventListener(mouseSubst[type] || type, handler, false); - } else if ('detachEvent' in obj) { + } else { obj.detachEvent('on' + type, handler); } @@ -167,7 +182,6 @@ export function stopPropagation(e) { } else { e.cancelBubble = true; } - skipped(e); return this; } @@ -180,11 +194,11 @@ export function disableScrollPropagation(el) { } // @function disableClickPropagation(el: HTMLElement): this -// Adds `stopPropagation` to the element's `'click'`, `'dblclick'`, +// Adds `stopPropagation` to the element's `'click'`, `'dblclick'`, `'contextmenu'`, // `'mousedown'` and `'touchstart'` events (plus browser variants). export function disableClickPropagation(el) { - on(el, 'mousedown touchstart dblclick', stopPropagation); - addOne(el, 'click', fakeStop); + on(el, 'mousedown touchstart dblclick contextmenu', stopPropagation); + el['_leaflet_disable_click'] = true; return this; } @@ -252,20 +266,6 @@ export function getWheelDelta(e) { 0; } -var skipEvents = {}; - -export function fakeStop(e) { - // fakes stopPropagation by setting a special event flag, checked/reset with skipped(e) - skipEvents[e.type] = true; -} - -export function skipped(e) { - var events = skipEvents[e.type]; - // reset when checking, as it's only used in map container and propagates outside of the map - skipEvents[e.type] = false; - return events; -} - // check if element really left/entered the event target (for mouseenter/mouseleave) export function isExternalTarget(el, e) { diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index aabcef31b73..8296548d672 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -1,7 +1,7 @@ import * as DomEvent from './DomEvent'; import * as Util from '../core/Util'; import {Point} from '../geometry/Point'; -import * as Browser from '../core/Browser'; +import Browser from '../core/Browser'; /* * @namespace DomUtil diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js index 8a4a456cb7f..3958cd51098 100644 --- a/src/dom/Draggable.js +++ b/src/dom/Draggable.js @@ -1,5 +1,5 @@ import {Evented} from '../core/Events'; -import * as Browser from '../core/Browser'; +import Browser from '../core/Browser'; import * as DomEvent from './DomEvent'; import * as DomUtil from './DomUtil'; import * as Util from '../core/Util'; @@ -22,19 +22,6 @@ import {Point} from '../geometry/Point'; */ var START = Browser.touch ? 'touchstart mousedown' : 'mousedown'; -var END = { - mousedown: 'mouseup', - touchstart: 'touchend', - pointerdown: 'touchend', - MSPointerDown: 'touchend' -}; -var MOVE = { - mousedown: 'mousemove', - touchstart: 'touchmove', - pointerdown: 'touchmove', - MSPointerDown: 'touchmove' -}; - export var Draggable = Evented.extend({ @@ -85,12 +72,9 @@ export var Draggable = Evented.extend({ }, _onDown: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 + // Ignore the event if disabled; this happens in IE11 // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } + if (!this._enabled) { return; } this._moved = false; @@ -120,17 +104,15 @@ export var Draggable = Evented.extend({ // Cache the scale, so that we can continuously compensate for it during drag (_onMove). this._parentScale = DomUtil.getScale(sizedParent); - DomEvent.on(document, MOVE[e.type], this._onMove, this); - DomEvent.on(document, END[e.type], this._onUp, this); + var mouseevent = e.type === 'mousedown'; + DomEvent.on(document, mouseevent ? 'mousemove' : 'touchmove', this._onMove, this); + DomEvent.on(document, mouseevent ? 'mouseup' : 'touchend touchcancel', this._onUp, this); }, _onMove: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 + // Ignore the event if disabled; this happens in IE11 // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } + if (!this._enabled) { return; } if (e.touches && e.touches.length > 1) { this._moved = true; @@ -192,13 +174,10 @@ export var Draggable = Evented.extend({ this.fire('drag', e); }, - _onUp: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 + _onUp: function () { + // Ignore the event if disabled; this happens in IE11 // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } + if (!this._enabled) { return; } this.finishDrag(); }, @@ -210,10 +189,8 @@ export var Draggable = Evented.extend({ this._lastTarget = null; } - for (var i in MOVE) { - DomEvent.off(document, MOVE[i], this._onMove, this); - DomEvent.off(document, END[i], this._onUp, this); - } + DomEvent.off(document, 'mousemove touchmove', this._onMove, this); + DomEvent.off(document, 'mouseup touchend touchcancel', this._onUp, this); DomUtil.enableImageDrag(); DomUtil.enableTextSelection(); diff --git a/src/dom/PosAnimation.js b/src/dom/PosAnimation.js index 05290c11394..fb442268c4e 100644 --- a/src/dom/PosAnimation.js +++ b/src/dom/PosAnimation.js @@ -25,7 +25,7 @@ export var PosAnimation = Evented.extend({ // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number) // Run an animation of a given element to a new position, optionally setting // duration in seconds (`0.25` by default) and easing linearity factor (3rd - // argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1), + // argument of the [cubic bezier curve](https://cubic-bezier.com/#0,0,.5,1), // `0.5` by default). run: function (el, newPos, duration, easeLinearity) { this.stop(); diff --git a/src/geo/crs/CRS.Earth.js b/src/geo/crs/CRS.Earth.js index 6ecff658929..b32b026b1d6 100755 --- a/src/geo/crs/CRS.Earth.js +++ b/src/geo/crs/CRS.Earth.js @@ -16,7 +16,7 @@ export var Earth = Util.extend({}, CRS, { // Mean Earth Radius, as recommended for use by // the International Union of Geodesy and Geophysics, - // see http://rosettacode.org/wiki/Haversine_formula + // see https://rosettacode.org/wiki/Haversine_formula R: 6371000, // distance between two geographical points using spherical law of cosines approximation diff --git a/src/geo/crs/CRS.js b/src/geo/crs/CRS.js index d1ca4ed6a12..bfbdae6ac9d 100644 --- a/src/geo/crs/CRS.js +++ b/src/geo/crs/CRS.js @@ -10,7 +10,7 @@ import * as Util from '../../core/Util'; * Object that defines coordinate reference systems for projecting * geographical points into pixel (screen) coordinates and back (and to * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See - * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system). + * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system). * * Leaflet defines the most usual CRSs by default. If you want to use a * CRS not defined by default, take a look at the diff --git a/src/geo/projection/index.js b/src/geo/projection/index.js index b577d6b5e58..c64664e5172 100644 --- a/src/geo/projection/index.js +++ b/src/geo/projection/index.js @@ -2,7 +2,7 @@ * @class Projection * An object with methods for projecting geographical coordinates of the world onto - * a flat surface (and back). See [Map projection](http://en.wikipedia.org/wiki/Map_projection). + * a flat surface (and back). See [Map projection](https://en.wikipedia.org/wiki/Map_projection). * @property bounds: Bounds * The bounds (specified in CRS units) where the projection is valid diff --git a/src/geometry/LineUtil.js b/src/geometry/LineUtil.js index 8e291259f3d..4dcaa76b0db 100644 --- a/src/geometry/LineUtil.js +++ b/src/geometry/LineUtil.js @@ -14,11 +14,11 @@ import * as Util from '../core/Util'; // @function simplify(points: Point[], tolerance: Number): Point[] // Dramatically reduces the number of points in a polyline while retaining // its shape and returns a new array of simplified points, using the -// [Douglas-Peucker algorithm](http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm). +// [Ramer-Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm). // Used for a huge performance boost when processing/displaying Leaflet polylines for // each zoom level and also reducing visual noise. tolerance affects the amount of // simplification (lesser value means higher quality but slower and with more points). -// Also released as a separated micro-library [Simplify.js](http://mourner.github.com/simplify-js/). +// Also released as a separated micro-library [Simplify.js](https://mourner.github.io/simplify-js/). export function simplify(points, tolerance) { if (!tolerance || !points.length) { return points.slice(); @@ -47,7 +47,7 @@ export function closestPointOnSegment(p, p1, p2) { return _sqClosestPointOnSegment(p, p1, p2); } -// Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm +// Ramer-Douglas-Peucker simplification, see https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm function _simplifyDP(points, sqTolerance) { var len = points.length, diff --git a/src/images/marker.svg b/src/images/marker.svg index d9ee408c783..29faabb7a1e 100644 --- a/src/images/marker.svg +++ b/src/images/marker.svg @@ -1 +1 @@ - Use this one. Select it and the area around with box select. should be exactly 25x41 at 90dpi How to do the inset border: Delete the existing inset border. Select the background, duplicate. Path, Dynamic offset. Fill: None, Stroke Paint: RGBA #ffffff1f Zoom down to the top and grab the diamond, drag it down and fiddle it untill it looks in line with the main color layers border. \ No newline at end of file + diff --git a/src/layer/DivOverlay.js b/src/layer/DivOverlay.js index 7bbd37b4198..f60d04da832 100644 --- a/src/layer/DivOverlay.js +++ b/src/layer/DivOverlay.js @@ -1,3 +1,4 @@ +import {Map} from '../map/Map'; import {Layer} from './Layer'; import {FeatureGroup} from './FeatureGroup'; import * as Util from '../core/Util'; @@ -9,7 +10,7 @@ import * as DomUtil from '../dom/DomUtil'; * @class DivOverlay * @inherits Layer * @aka L.DivOverlay - * Base model for L.Popup and L.Tooltip. Inherit from it for custom popup like plugins. + * Base model for L.Popup and L.Tooltip. Inherit from it for custom overlays like plugins. */ // @namespace DivOverlay @@ -18,18 +19,17 @@ export var DivOverlay = Layer.extend({ // @section // @aka DivOverlay options options: { - // @option offset: Point = Point(0, 7) - // The offset of the popup position. Useful to control the anchor - // of the popup when opening it on some overlays. - offset: [0, 7], + // @option offset: Point = Point(0, 0) + // The offset of the overlay position. + offset: [0, 0], // @option className: String = '' - // A custom CSS class name to assign to the popup. + // A custom CSS class name to assign to the overlay. className: '', - // @option pane: String = 'popupPane' - // `Map pane` where the popup will be added. - pane: 'popupPane' + // @option pane: String = undefined + // `Map pane` where the overlay will be added. + pane: undefined }, initialize: function (options, source) { @@ -38,6 +38,49 @@ export var DivOverlay = Layer.extend({ this._source = source; }, + // @method openOn(map: Map): this + // Adds the overlay to the map. + // Alternative to `map.openPopup(popup)`/`.openTooltip(tooltip)`. + openOn: function (map) { + map = arguments.length ? map : this._source._map; // experimental, not the part of public api + if (!map.hasLayer(this)) { + map.addLayer(this); + } + return this; + }, + + // @method close(): this + // Closes the overlay. + // Alternative to `map.closePopup(popup)`/`.closeTooltip(tooltip)` + // and `layer.closePopup()`/`.closeTooltip()`. + close: function () { + if (this._map) { + this._map.removeLayer(this); + } + return this; + }, + + // @method toggle(layer?: Layer): this + // Opens or closes the overlay bound to layer depending on its current state. + // Argument may be omitted only for overlay bound to layer. + // Alternative to `layer.togglePopup()`/`.toggleTooltip()`. + toggle: function (layer) { + if (this._map) { + this.close(); + } else { + if (arguments.length) { + this._source = layer; + } else { + layer = this._source; + } + this._prepareOpen(); + + // open the overlay on the map + this.openOn(layer._map); + } + return this; + }, + onAdd: function (map) { this._zoomAnimated = map._zoomAnimated; @@ -69,15 +112,15 @@ export var DivOverlay = Layer.extend({ } }, - // @namespace Popup + // @namespace DivOverlay // @method getLatLng: LatLng - // Returns the geographical point of popup. + // Returns the geographical point of the overlay. getLatLng: function () { return this._latlng; }, // @method setLatLng(latlng: LatLng): this - // Sets the geographical point where the popup will open. + // Sets the geographical point where the overlay will open. setLatLng: function (latlng) { this._latlng = toLatLng(latlng); if (this._map) { @@ -88,13 +131,14 @@ export var DivOverlay = Layer.extend({ }, // @method getContent: String|HTMLElement - // Returns the content of the popup. + // Returns the content of the overlay. getContent: function () { return this._content; }, // @method setContent(htmlContent: String|HTMLElement|Function): this - // Sets the HTML content of the popup. If a function is passed the source layer will be passed to the function. The function should return a `String` or `HTMLElement` to be used in the popup. + // Sets the HTML content of the overlay. If a function is passed the source layer will be passed to the function. + // The function should return a `String` or `HTMLElement` to be used in the overlay. setContent: function (content) { this._content = content; this.update(); @@ -102,13 +146,13 @@ export var DivOverlay = Layer.extend({ }, // @method getElement: String|HTMLElement - // Returns the HTML container of the popup. + // Returns the HTML container of the overlay. getElement: function () { return this._container; }, // @method update: null - // Updates the popup content, layout and position. Useful for updating the popup after something inside changed, e.g. image loaded. + // Updates the overlay content, layout and position. Useful for updating the overlay after something inside changed, e.g. image loaded. update: function () { if (!this._map) { return; } @@ -136,13 +180,13 @@ export var DivOverlay = Layer.extend({ }, // @method isOpen: Boolean - // Returns `true` when the popup is visible on the map. + // Returns `true` when the overlay is visible on the map. isOpen: function () { return !!this._map && this._map.hasLayer(this); }, // @method bringToFront: this - // Brings this popup in front of other popups (in the same map pane). + // Brings this overlay in front of other overlays (in the same map pane). bringToFront: function () { if (this._map) { DomUtil.toFront(this._container); @@ -151,7 +195,7 @@ export var DivOverlay = Layer.extend({ }, // @method bringToBack: this - // Brings this popup to the back of other popups (in the same map pane). + // Brings this overlay to the back of other overlays (in the same map pane). bringToBack: function () { if (this._map) { DomUtil.toBack(this._container); @@ -159,38 +203,45 @@ export var DivOverlay = Layer.extend({ return this; }, - _prepareOpen: function (parent, layer, latlng) { - if (!(layer instanceof Layer)) { - latlng = layer; - layer = parent; - } - - if (layer instanceof FeatureGroup) { - for (var id in parent._layers) { - layer = parent._layers[id]; - break; + // prepare bound overlay to open: update latlng pos / content source (for FeatureGroup) + _prepareOpen: function (latlng) { + var source = this._source; + if (!source._map) { return false; } + + if (source instanceof FeatureGroup) { + source = null; + var layers = this._source._layers; + for (var id in layers) { + if (layers[id]._map) { + source = layers[id]; + break; + } } + if (!source) { return false; } // Unable to get source layer. + + // set overlay source to this layer + this._source = source; } if (!latlng) { - if (layer.getCenter) { - latlng = layer.getCenter(); - } else if (layer.getLatLng) { - latlng = layer.getLatLng(); - } else if (layer.getBounds) { - latlng = layer.getBounds().getCenter(); + if (source.getCenter) { + latlng = source.getCenter(); + } else if (source.getLatLng) { + latlng = source.getLatLng(); + } else if (source.getBounds) { + latlng = source.getBounds().getCenter(); } else { throw new Error('Unable to get source layer LatLng.'); } } + this.setLatLng(latlng); - // set overlay source to this layer - this._source = layer; - - // update the overlay (content, layout, ect...) - this.update(); + if (this._map) { + // update the overlay (content, layout, etc...) + this.update(); + } - return latlng; + return true; }, _updateContent: function () { @@ -207,6 +258,11 @@ export var DivOverlay = Layer.extend({ } node.appendChild(content); } + + // @namespace DivOverlay + // @section DivOverlay events + // @event contentupdate: Event + // Fired when the content of the overlay is updated this.fire('contentupdate'); }, @@ -226,7 +282,7 @@ export var DivOverlay = Layer.extend({ var bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x; - // bottom position the popup in case the height of the popup changes (images loading etc) + // bottom position the overlay in case the height of the overlay changes (images loading etc) this._container.style.bottom = bottom + 'px'; this._container.style.left = left + 'px'; }, @@ -236,3 +292,31 @@ export var DivOverlay = Layer.extend({ } }); + +Map.include({ + _initOverlay: function (OverlayClass, content, latlng, options) { + var overlay = content; + if (!(overlay instanceof OverlayClass)) { + overlay = new OverlayClass(options).setContent(content); + } + if (latlng) { + overlay.setLatLng(latlng); + } + return overlay; + } +}); + + +Layer.include({ + _initOverlay: function (OverlayClass, old, content, options) { + var overlay = content; + if (overlay instanceof OverlayClass) { + Util.setOptions(overlay, options); + overlay._source = this; + } else { + overlay = (old && !options) ? old : new OverlayClass(options, this); + overlay.setContent(content); + } + return overlay; + } +}); diff --git a/src/layer/GeoJSON.js b/src/layer/GeoJSON.js index c5f130ab064..230c15c9de4 100644 --- a/src/layer/GeoJSON.js +++ b/src/layer/GeoJSON.js @@ -253,18 +253,19 @@ export function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) { return latlngs; } -// @function latLngToCoords(latlng: LatLng, precision?: Number): Array +// @function latLngToCoords(latlng: LatLng, precision?: Number|false): Array // Reverse of [`coordsToLatLng`](#geojson-coordstolatlng) +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function. export function latLngToCoords(latlng, precision) { - precision = typeof precision === 'number' ? precision : 6; return latlng.alt !== undefined ? [Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision), Util.formatNum(latlng.alt, precision)] : [Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision)]; } -// @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array +// @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean, precision?: Number|false): Array // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs) // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default. +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function. export function latLngsToCoords(latlngs, levelsDeep, closed, precision) { var coords = []; @@ -312,26 +313,23 @@ var PointToGeoJSON = { // @namespace Marker // @section Other methods -// @method toGeoJSON(precision?: Number): Object -// `precision` is the number of decimal places for coordinates. -// The default value is 6 places. -// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature). +// @method toGeoJSON(precision?: Number|false): Object +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`. +// Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature). Marker.include(PointToGeoJSON); // @namespace CircleMarker -// @method toGeoJSON(precision?: Number): Object -// `precision` is the number of decimal places for coordinates. -// The default value is 6 places. -// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature). +// @method toGeoJSON(precision?: Number|false): Object +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`. +// Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature). Circle.include(PointToGeoJSON); CircleMarker.include(PointToGeoJSON); // @namespace Polyline -// @method toGeoJSON(precision?: Number): Object -// `precision` is the number of decimal places for coordinates. -// The default value is 6 places. -// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature). +// @method toGeoJSON(precision?: Number|false): Object +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`. +// Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature). Polyline.include({ toGeoJSON: function (precision) { var multi = !LineUtil.isFlat(this._latlngs); @@ -346,10 +344,9 @@ Polyline.include({ }); // @namespace Polygon -// @method toGeoJSON(precision?: Number): Object -// `precision` is the number of decimal places for coordinates. -// The default value is 6 places. -// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature). +// @method toGeoJSON(precision?: Number|false): Object +// Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`. +// Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature). Polygon.include({ toGeoJSON: function (precision) { var holes = !LineUtil.isFlat(this._latlngs), @@ -384,10 +381,9 @@ LayerGroup.include({ }); }, - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `FeatureCollection`, `GeometryCollection`, or `MultiPoint`). + // @method toGeoJSON(precision?: Number|false): Object + // Coordinates values are rounded with [`formatNum`](#util-formatnum) function with given `precision`. + // Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `FeatureCollection`, `GeometryCollection`, or `MultiPoint`). toGeoJSON: function (precision) { var type = this.feature && this.feature.geometry && this.feature.geometry.type; diff --git a/src/layer/ImageOverlay.js b/src/layer/ImageOverlay.js index 4a543ad62c9..75667fe33f5 100644 --- a/src/layer/ImageOverlay.js +++ b/src/layer/ImageOverlay.js @@ -14,7 +14,7 @@ import * as DomUtil from '../dom/DomUtil'; * @example * * ```js - * var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', + * var imageUrl = 'https://maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', * imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]]; * L.imageOverlay(imageUrl, imageBounds).addTo(map); * ``` @@ -253,6 +253,12 @@ export var ImageOverlay = Layer.extend({ this._url = errorUrl; this._image.src = errorUrl; } + }, + + // @method getCenter(): LatLng + // Returns the center of the ImageOverlay. + getCenter: function () { + return this._bounds.getCenter(); } }); diff --git a/src/layer/Layer.js b/src/layer/Layer.js index c6285a9c057..8d379f24fad 100644 --- a/src/layer/Layer.js +++ b/src/layer/Layer.js @@ -113,10 +113,6 @@ export var Layer = Evented.extend({ this.onAdd(map); - if (this.getAttribution && map.attributionControl) { - map.attributionControl.addAttribution(this.getAttribution()); - } - this.fire('add'); map.fire('layeradd', {layer: this}); } @@ -189,10 +185,6 @@ Map.include({ layer.onRemove(this); } - if (layer.getAttribution && this.attributionControl) { - this.attributionControl.removeAttribution(layer.getAttribution()); - } - delete this._layers[id]; if (this._loaded) { @@ -208,7 +200,7 @@ Map.include({ // @method hasLayer(layer: Layer): Boolean // Returns `true` if the given layer is currently added to the map hasLayer: function (layer) { - return !!layer && (Util.stamp(layer) in this._layers); + return Util.stamp(layer) in this._layers; }, /* @method eachLayer(fn: Function, context?: Object): this @@ -235,7 +227,7 @@ Map.include({ }, _addZoomLimit: function (layer) { - if (isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) { + if (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) { this._zoomBoundLayers[Util.stamp(layer)] = layer; this._updateZoomLevels(); } diff --git a/src/layer/LayerGroup.js b/src/layer/LayerGroup.js index 202328380ab..afbdc1ff5bc 100644 --- a/src/layer/LayerGroup.js +++ b/src/layer/LayerGroup.js @@ -73,7 +73,6 @@ export var LayerGroup = Layer.extend({ // @method hasLayer(id: Number): Boolean // Returns `true` if the given internal ID is currently added to the group. hasLayer: function (layer) { - if (!layer) { return false; } var layerId = typeof layer === 'number' ? layer : this.getLayerId(layer); return layerId in this._layers; }, diff --git a/src/layer/Popup.js b/src/layer/Popup.js index f74fe15f892..ebe3c77d5af 100644 --- a/src/layer/Popup.js +++ b/src/layer/Popup.js @@ -4,7 +4,6 @@ import * as DomUtil from '../dom/DomUtil'; import {Point, toPoint} from '../geometry/Point'; import {Map} from '../map/Map'; import {Layer} from './Layer'; -import * as Util from '../core/Util'; import {Path} from './vector/Path'; /* @@ -40,6 +39,14 @@ export var Popup = DivOverlay.extend({ // @section // @aka Popup options options: { + // @option pane: String = 'popupPane' + // `Map pane` where the popup will be added. + pane: 'popupPane', + + // @option offset: Point = Point(0, 7) + // The offset of the popup position. + offset: [0, 7], + // @option maxWidth: Number = 300 // Max width of the popup, in pixels. maxWidth: 300, @@ -102,10 +109,17 @@ export var Popup = DivOverlay.extend({ // @namespace Popup // @method openOn(map: Map): this - // Adds the popup to the map and closes the previous one. The same as `map.openPopup(popup)`. + // Alternative to `map.openPopup(popup)`. + // Adds the popup to the map and closes the previous one. openOn: function (map) { - map.openPopup(this); - return this; + map = arguments.length ? map : this._source._map; // experimental, not the part of public api + + if (!map.hasLayer(this) && map._popup && map._popup.options.autoClose) { + map.removeLayer(map._popup); + } + map._popup = this; + + return DivOverlay.prototype.openOn.call(this, map); }, onAdd: function (map) { @@ -156,7 +170,7 @@ export var Popup = DivOverlay.extend({ var events = DivOverlay.prototype.getEvents.call(this); if (this.options.closeOnClick !== undefined ? this.options.closeOnClick : this._map.options.closePopupOnClick) { - events.preclick = this._close; + events.preclick = this.close; } if (this.options.keepInView) { @@ -166,12 +180,6 @@ export var Popup = DivOverlay.extend({ return events; }, - _close: function () { - if (this._map) { - this._map.closePopup(this); - } - }, - _initLayout: function () { var prefix = 'leaflet-popup', container = this._container = DomUtil.create('div', @@ -190,10 +198,12 @@ export var Popup = DivOverlay.extend({ if (this.options.closeButton) { var closeButton = this._closeButton = DomUtil.create('a', prefix + '-close-button', container); + closeButton.setAttribute('role', 'button'); // overrides the implicit role=link of elements #7399 + closeButton.setAttribute('aria-label', 'Close popup'); closeButton.href = '#close'; - closeButton.innerHTML = '×'; + closeButton.innerHTML = ''; - DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); + DomEvent.on(closeButton, 'click', this.close, this); } }, @@ -233,7 +243,7 @@ export var Popup = DivOverlay.extend({ DomUtil.setPosition(this._container, pos.add(anchor)); }, - _adjustPan: function () { + _adjustPan: function (e) { if (!this.options.autoPan) { return; } if (this._map._panAnim) { this._map._panAnim.stop(); } @@ -273,15 +283,10 @@ export var Popup = DivOverlay.extend({ if (dx || dy) { map .fire('autopanstart') - .panBy([dx, dy]); + .panBy([dx, dy], {animate: e && e.type === 'moveend'}); } }, - _onCloseButtonClick: function (e) { - this._close(); - DomEvent.stop(e); - }, - _getAnchor: function () { // Where should we anchor the popup on the source layer? return toPoint(this._source && this._source._getPopupAnchor ? this._source._getPopupAnchor() : [0, 0]); @@ -316,35 +321,18 @@ Map.include({ // @method openPopup(content: String|HTMLElement, latlng: LatLng, options?: Popup options): this // Creates a popup with the specified content and options and opens it in the given point on a map. openPopup: function (popup, latlng, options) { - if (!(popup instanceof Popup)) { - popup = new Popup(options).setContent(popup); - } - - if (latlng) { - popup.setLatLng(latlng); - } - - if (this.hasLayer(popup)) { - return this; - } + this._initOverlay(Popup, popup, latlng, options) + .openOn(this); - if (this._popup && this._popup.options.autoClose) { - this.closePopup(); - } - - this._popup = popup; - return this.addLayer(popup); + return this; }, // @method closePopup(popup?: Popup): this // Closes the popup previously opened with [openPopup](#map-openpopup) (or the given one). closePopup: function (popup) { - if (!popup || popup === this._popup) { - popup = this._popup; - this._popup = null; - } + popup = arguments.length ? popup : this._popup; if (popup) { - this.removeLayer(popup); + popup.close(); } return this; } @@ -373,18 +361,7 @@ Layer.include({ // necessary event listeners. If a `Function` is passed it will receive // the layer as the first argument and should return a `String` or `HTMLElement`. bindPopup: function (content, options) { - - if (content instanceof Popup) { - Util.setOptions(content, options); - this._popup = content; - content._source = this; - } else { - if (!this._popup || options) { - this._popup = new Popup(options, this); - } - this._popup.setContent(content); - } - + this._popup = this._initOverlay(Popup, this._popup, content, options); if (!this._popupHandlersAdded) { this.on({ click: this._openPopup, @@ -416,14 +393,11 @@ Layer.include({ // @method openPopup(latlng?: LatLng): this // Opens the bound popup at the specified `latlng` or at the default popup anchor if no `latlng` is passed. - openPopup: function (layer, latlng) { - if (this._popup && this._map) { - latlng = this._popup._prepareOpen(this, layer, latlng); - + openPopup: function (latlng) { + if (this._popup && this._popup._prepareOpen(latlng)) { // open the popup on the map - this._map.openPopup(this._popup, latlng); + this._popup.openOn(this._map); } - return this; }, @@ -431,20 +405,16 @@ Layer.include({ // Closes the popup bound to this layer if it is open. closePopup: function () { if (this._popup) { - this._popup._close(); + this._popup.close(); } return this; }, // @method togglePopup(): this // Opens or closes the popup bound to this layer depending on its current state. - togglePopup: function (target) { + togglePopup: function () { if (this._popup) { - if (this._popup._map) { - this.closePopup(); - } else { - this.openPopup(target); - } + this._popup.toggle(this); } return this; }, @@ -471,33 +441,25 @@ Layer.include({ }, _openPopup: function (e) { - var layer = e.layer || e.target; - - if (!this._popup) { - return; - } - - if (!this._map) { + if (!this._popup || !this._map) { return; } - // prevent map click DomEvent.stop(e); - // if this inherits from Path its a vector and we can just - // open the popup at the new location - if (layer instanceof Path) { - this.openPopup(e.layer || e.target, e.latlng); + var target = e.layer || e.target; + if (this._popup._source === target && !(target instanceof Path)) { + // treat it like a marker and figure out + // if we should toggle it open/closed + if (this._map.hasLayer(this._popup)) { + this.closePopup(); + } else { + this.openPopup(e.latlng); + } return; } - - // otherwise treat it like a marker and figure out - // if we should toggle it open/closed - if (this._map.hasLayer(this._popup) && this._popup._source === layer) { - this.closePopup(); - } else { - this.openPopup(layer, e.latlng); - } + this._popup._source = target; + this.openPopup(e.latlng); }, _movePopup: function (e) { diff --git a/src/layer/Tooltip.js b/src/layer/Tooltip.js index 172430af922..ac8d3e1db78 100644 --- a/src/layer/Tooltip.js +++ b/src/layer/Tooltip.js @@ -1,10 +1,7 @@ - -import * as Browser from '../core/Browser'; import {DivOverlay} from './DivOverlay'; import {toPoint} from '../geometry/Point'; import {Map} from '../map/Map'; import {Layer} from './Layer'; -import * as Util from '../core/Util'; import * as DomUtil from '../dom/DomUtil'; /* @@ -70,6 +67,13 @@ export var Tooltip = DivOverlay.extend({ DivOverlay.prototype.onAdd.call(this, map); this.setOpacity(this.options.opacity); + if (this.options.interactive) { + DomUtil.addClass(this._container, 'leaflet-interactive'); + if (this._source) { + this._source.addInteractiveTarget(this._container); + } + } + // @namespace Map // @section Tooltip events // @event tooltipopen: TooltipEvent @@ -88,6 +92,13 @@ export var Tooltip = DivOverlay.extend({ onRemove: function (map) { DivOverlay.prototype.onRemove.call(this, map); + if (this.options.interactive) { + DomUtil.removeClass(this._container, 'leaflet-interactive'); + if (this._source) { + this._source.removeInteractiveTarget(this._container); + } + } + // @namespace Map // @section Tooltip events // @event tooltipclose: TooltipEvent @@ -106,19 +117,13 @@ export var Tooltip = DivOverlay.extend({ getEvents: function () { var events = DivOverlay.prototype.getEvents.call(this); - if (Browser.touch && !this.options.permanent) { - events.preclick = this._close; + if (!this.options.permanent) { + events.preclick = this.close; } return events; }, - _close: function () { - if (this._map) { - this._map.closeTooltip(this); - } - }, - _initLayout: function () { var prefix = 'leaflet-tooltip', className = prefix + ' ' + (this.options.className || '') + ' leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide'); @@ -219,27 +224,16 @@ Map.include({ // @method openTooltip(content: String|HTMLElement, latlng: LatLng, options?: Tooltip options): this // Creates a tooltip with the specified content and options and open it. openTooltip: function (tooltip, latlng, options) { - if (!(tooltip instanceof Tooltip)) { - tooltip = new Tooltip(options).setContent(tooltip); - } - - if (latlng) { - tooltip.setLatLng(latlng); - } + this._initOverlay(Tooltip, tooltip, latlng, options) + .openOn(this); - if (this.hasLayer(tooltip)) { - return this; - } - - return this.addLayer(tooltip); + return this; }, - // @method closeTooltip(tooltip?: Tooltip): this + // @method closeTooltip(tooltip: Tooltip): this // Closes the tooltip given as parameter. closeTooltip: function (tooltip) { - if (tooltip) { - this.removeLayer(tooltip); - } + tooltip.close(); return this; } @@ -267,18 +261,11 @@ Layer.include({ // the layer as the first argument and should return a `String` or `HTMLElement`. bindTooltip: function (content, options) { - if (content instanceof Tooltip) { - Util.setOptions(content, options); - this._tooltip = content; - content._source = this; - } else { - if (!this._tooltip || options) { - this._tooltip = new Tooltip(options, this); - } - this._tooltip.setContent(content); - + if (this._tooltip && this.isTooltipOpen()) { + this.unbindTooltip(); } + this._tooltip = this._initOverlay(Tooltip, this._tooltip, content, options); this._initTooltipInteractions(); if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) { @@ -309,36 +296,24 @@ Layer.include({ if (!this._tooltip.options.permanent) { events.mouseover = this._openTooltip; events.mouseout = this.closeTooltip; - if (this._tooltip.options.sticky) { - events.mousemove = this._moveTooltip; - } - if (Browser.touch) { - events.click = this._openTooltip; - } + events.click = this._openTooltip; } else { events.add = this._openTooltip; } + if (this._tooltip.options.sticky) { + events.mousemove = this._moveTooltip; + } this[onOff](events); this._tooltipHandlersAdded = !remove; }, // @method openTooltip(latlng?: LatLng): this // Opens the bound tooltip at the specified `latlng` or at the default tooltip anchor if no `latlng` is passed. - openTooltip: function (layer, latlng) { - if (this._tooltip && this._map) { - latlng = this._tooltip._prepareOpen(this, layer, latlng); - + openTooltip: function (latlng) { + if (this._tooltip && this._tooltip._prepareOpen(latlng)) { // open the tooltip on the map - this._map.openTooltip(this._tooltip, latlng); - - // Tooltip container may not be defined if not permanent and never - // opened. - if (this._tooltip.options.interactive && this._tooltip._container) { - DomUtil.addClass(this._tooltip._container, 'leaflet-clickable'); - this.addInteractiveTarget(this._tooltip._container); - } + this._tooltip.openOn(this._map); } - return this; }, @@ -346,24 +321,15 @@ Layer.include({ // Closes the tooltip bound to this layer if it is open. closeTooltip: function () { if (this._tooltip) { - this._tooltip._close(); - if (this._tooltip.options.interactive && this._tooltip._container) { - DomUtil.removeClass(this._tooltip._container, 'leaflet-clickable'); - this.removeInteractiveTarget(this._tooltip._container); - } + return this._tooltip.close(); } - return this; }, // @method toggleTooltip(): this // Opens or closes the tooltip bound to this layer depending on its current state. - toggleTooltip: function (target) { + toggleTooltip: function () { if (this._tooltip) { - if (this._tooltip._map) { - this.closeTooltip(); - } else { - this.openTooltip(target); - } + this._tooltip.toggle(this); } return this; }, @@ -390,12 +356,12 @@ Layer.include({ }, _openTooltip: function (e) { - var layer = e.layer || e.target; - - if (!this._tooltip || !this._map) { + if (!this._tooltip || !this._map || (this._map.dragging && this._map.dragging.moving())) { return; } - this.openTooltip(layer, this._tooltip.options.sticky ? e.latlng : undefined); + this._tooltip._source = e.layer || e.target; + + this.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined); }, _moveTooltip: function (e) { diff --git a/src/layer/marker/Icon.Default.js b/src/layer/marker/Icon.Default.js index fc6996c51c7..32372892b50 100644 --- a/src/layer/marker/Icon.Default.js +++ b/src/layer/marker/Icon.Default.js @@ -31,7 +31,7 @@ export var IconDefault = Icon.extend({ }, _getIconUrl: function (name) { - if (!IconDefault.imagePath) { // Deprecated, backwards-compatibility only + if (typeof IconDefault.imagePath !== 'string') { // Deprecated, backwards-compatibility only IconDefault.imagePath = this._detectIconPath(); } @@ -42,19 +42,25 @@ export var IconDefault = Icon.extend({ return (this.options.imagePath || IconDefault.imagePath) + Icon.prototype._getIconUrl.call(this, name); }, + _stripUrl: function (path) { // separate function to use in tests + var strip = function (str, re, idx) { + var match = re.exec(str); + return match && match[idx]; + }; + path = strip(path, /^url\((['"])?(.+)\1\)$/, 2); + return path && strip(path, /^(.*)marker-icon\.png$/, 1); + }, + _detectIconPath: function () { var el = DomUtil.create('div', 'leaflet-default-icon-path', document.body); var path = DomUtil.getStyle(el, 'background-image') || DomUtil.getStyle(el, 'backgroundImage'); // IE8 document.body.removeChild(el); - - if (path === null || path.indexOf('url') !== 0) { - path = ''; - } else { - path = path.replace(/^url\(["']?/, '').replace(/marker-icon\.png["']?\)$/, ''); - } - - return path; + path = this._stripUrl(path); + if (path) { return path; } + var link = document.querySelector('link[href$="leaflet.css"]'); + if (!link) { return ''; } + return link.href.substring(0, link.href.length - 'leaflet.css'.length - 1); } }); diff --git a/src/layer/marker/Icon.js b/src/layer/marker/Icon.js index 489c8df1a0f..ed32484e92b 100644 --- a/src/layer/marker/Icon.js +++ b/src/layer/marker/Icon.js @@ -1,7 +1,7 @@ import {Class} from '../../core/Class'; import {setOptions} from '../../core/Util'; import {toPoint as point} from '../../geometry/Point'; -import {retina} from '../../core/Browser'; +import Browser from '../../core/Browser'; /* * @class Icon @@ -153,7 +153,7 @@ export var Icon = Class.extend({ }, _getIconUrl: function (name) { - return retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url']; + return Browser.retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url']; } }); diff --git a/src/layer/marker/Marker.js b/src/layer/marker/Marker.js index 077b0f15eac..5f36dd5feb6 100644 --- a/src/layer/marker/Marker.js +++ b/src/layer/marker/Marker.js @@ -40,9 +40,9 @@ export var Marker = Layer.extend({ // Text for the browser tooltip that appear on marker hover (no tooltip by default). title: '', - // @option alt: String = '' + // @option alt: String = 'Marker' // Text for the `alt` attribute of the icon image (useful for accessibility). - alt: '', + alt: 'Marker', // @option zIndexOffset: Number = 0 // By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like `1000` (or high negative value, respectively). @@ -225,6 +225,7 @@ export var Marker = Layer.extend({ if (options.keyboard) { icon.tabIndex = '0'; + icon.setAttribute('role', 'button'); } this._icon = icon; diff --git a/src/layer/tile/GridLayer.js b/src/layer/tile/GridLayer.js index c6e1e84405f..df6f1288143 100755 --- a/src/layer/tile/GridLayer.js +++ b/src/layer/tile/GridLayer.js @@ -1,5 +1,5 @@ import {Layer} from '../Layer'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; import * as Util from '../../core/Util'; import * as DomUtil from '../../dom/DomUtil'; import {Point} from '../../geometry/Point'; @@ -228,6 +228,11 @@ export var GridLayer = Layer.extend({ redraw: function () { if (this._map) { this._removeAllTiles(); + var tileZoom = this._clampZoom(this._map.getZoom()); + if (tileZoom !== this._tileZoom) { + this._tileZoom = tileZoom; + this._updateLevels(); + } this._update(); } return this; @@ -796,12 +801,6 @@ export var GridLayer = Layer.extend({ if (Browser.ielt9 && this.options.opacity < 1) { DomUtil.setOpacity(tile, this.options.opacity); } - - // without this hack, tiles disappear after zoom on Chrome for Android - // https://github.com/Leaflet/Leaflet/issues/2078 - if (Browser.android && !Browser.android23) { - tile.style.WebkitBackfaceVisibility = 'hidden'; - } }, _addTile: function (coords, container) { diff --git a/src/layer/tile/TileLayer.WMS.js b/src/layer/tile/TileLayer.WMS.js index 7ace31c62d5..b7f671d6ab4 100644 --- a/src/layer/tile/TileLayer.WMS.js +++ b/src/layer/tile/TileLayer.WMS.js @@ -1,6 +1,6 @@ import {TileLayer} from './TileLayer'; import {extend, setOptions, getParamString} from '../../core/Util'; -import {retina} from '../../core/Browser'; +import Browser from '../../core/Browser'; import {EPSG4326} from '../../geo/crs/CRS.EPSG4326'; import {toBounds} from '../../geometry/Bounds'; @@ -28,7 +28,7 @@ export var TileLayerWMS = TileLayer.extend({ // @aka TileLayer.WMS options // If any custom options not documented here are used, they will be sent to the // WMS server as extra parameters in each request URL. This can be useful for - // [non-standard vendor WMS parameters](http://docs.geoserver.org/stable/en/user/services/wms/vendor.html). + // [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html). defaultWmsParams: { service: 'WMS', request: 'GetMap', @@ -80,7 +80,7 @@ export var TileLayerWMS = TileLayer.extend({ options = setOptions(this, options); - var realRetina = options.detectRetina && retina ? 2 : 1; + var realRetina = options.detectRetina && Browser.retina ? 2 : 1; var tileSize = this.getTileSize(); wmsParams.width = tileSize.x * realRetina; wmsParams.height = tileSize.y * realRetina; diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index a9a4d675cc0..2b1f553ef2c 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -1,5 +1,5 @@ import {GridLayer} from './GridLayer'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; import * as Util from '../../core/Util'; import * as DomEvent from '../../dom/DomEvent'; import * as DomUtil from '../../dom/DomUtil'; @@ -23,7 +23,7 @@ import * as DomUtil from '../../dom/DomUtil'; * A string of the following form: * * ``` - * 'http://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png' + * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png' * ``` * * `{s}` means one of the available subdomains (used sequentially to help with browser parallel requests per domain limitation; subdomain values are specified in options; `a`, `b` or `c` by default, can be omitted), `{z}` — zoom level, `{x}` and `{y}` — tile coordinates. `{r}` can be used to add "@2x" to the URL to load retina tiles. @@ -31,7 +31,7 @@ import * as DomUtil from '../../dom/DomUtil'; * You can use custom keys in the template, which will be [evaluated](#util-template) from TileLayer options, like this: * * ``` - * L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'}); + * L.tileLayer('https://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'}); * ``` */ @@ -106,10 +106,7 @@ export var TileLayer = GridLayer.extend({ options.subdomains = options.subdomains.split(''); } - // for https://github.com/Leaflet/Leaflet/issues/137 - if (!Browser.android) { - this.on('tileunload', this._onTileRemove); - } + this.on('tileunload', this._onTileRemove); }, // @method setUrl(url: String, noRedraw?: Boolean): this @@ -145,7 +142,7 @@ export var TileLayer = GridLayer.extend({ /* Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons - http://www.w3.org/TR/WCAG20-TECHS/H67 + https://www.w3.org/TR/WCAG20-TECHS/H67 */ tile.alt = ''; @@ -236,8 +233,15 @@ export var TileLayer = GridLayer.extend({ if (!tile.complete) { tile.src = Util.emptyImageUrl; + var coords = this._tiles[i].coords; DomUtil.remove(tile); delete this._tiles[i]; + // @event tileabort: TileEvent + // Fired when a tile was loading but is now not wanted. + this.fire('tileabort', { + tile: tile, + coords: coords + }); } } } @@ -248,11 +252,7 @@ export var TileLayer = GridLayer.extend({ if (!tile) { return; } // Cancels any pending http requests associated with the tile - // unless we're on Android's stock browser, - // see https://github.com/Leaflet/Leaflet/issues/137 - if (!Browser.androidStock) { - tile.el.setAttribute('src', Util.emptyImageUrl); - } + tile.el.setAttribute('src', Util.emptyImageUrl); return GridLayer.prototype._removeTile.call(this, key); }, diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index 726465f0b9d..6a8521b6471 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -1,7 +1,7 @@ import {Renderer} from './Renderer'; import * as DomUtil from '../../dom/DomUtil'; import * as DomEvent from '../../dom/DomEvent'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; import * as Util from '../../core/Util'; import {Bounds} from '../../geometry/Bounds'; @@ -13,7 +13,7 @@ import {Bounds} from '../../geometry/Bounds'; * Allows vector layers to be displayed with [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). * Inherits `Renderer`. * - * Due to [technical limitations](http://caniuse.com/#search=canvas), Canvas is not + * Due to [technical limitations](https://caniuse.com/canvas), Canvas is not * available in all web browsers, notably IE8, and overlapping geometries might * not display properly in some edge cases. * @@ -38,6 +38,15 @@ import {Bounds} from '../../geometry/Bounds'; */ export var Canvas = Renderer.extend({ + + // @section + // @aka Canvas options + options: { + // @option tolerance: Number = 0 + // How much to extend the click tolerance around a path/object on the map. + tolerance: 0 + }, + getEvents: function () { var events = Renderer.prototype.getEvents.call(this); events.viewprereset = this._onViewPreReset; @@ -63,6 +72,7 @@ export var Canvas = Renderer.extend({ DomEvent.on(container, 'mousemove', this._onMouseMove, this); DomEvent.on(container, 'click dblclick mousedown mouseup contextmenu', this._onClick, this); DomEvent.on(container, 'mouseout', this._handleMouseOut, this); + container['_leaflet_disable_events'] = true; this._ctx = container.getContext('2d'); }, @@ -349,15 +359,12 @@ export var Canvas = Renderer.extend({ for (var order = this._drawFirst; order; order = order.next) { layer = order.layer; if (layer.options.interactive && layer._containsPoint(point)) { - if (!(e.type === 'click' || e.type !== 'preclick') || !this._map._draggableMoved(layer)) { + if (!(e.type === 'click' || e.type === 'preclick') || !this._map._draggableMoved(layer)) { clickedLayer = layer; } } } - if (clickedLayer) { - DomEvent.fakeStop(e); - this._fireEvent([clickedLayer], e); - } + this._fireEvent(clickedLayer ? [clickedLayer] : false, e); }, _onMouseMove: function (e) { @@ -403,9 +410,7 @@ export var Canvas = Renderer.extend({ } } - if (this._hoveredLayer) { - this._fireEvent([this._hoveredLayer], e); - } + this._fireEvent(this._hoveredLayer ? [this._hoveredLayer] : false, e); this._mouseHoverThrottled = true; setTimeout(Util.bind(function () { diff --git a/src/layer/vector/Path.js b/src/layer/vector/Path.js index 9d80273ea74..494a420c358 100644 --- a/src/layer/vector/Path.js +++ b/src/layer/vector/Path.js @@ -142,6 +142,7 @@ export var Path = Layer.extend({ _clickTolerance: function () { // used when doing hit detection for Canvas layers - return (this.options.stroke ? this.options.weight / 2 : 0) + this._renderer.options.tolerance; + return (this.options.stroke ? this.options.weight / 2 : 0) + + (this._renderer.options.tolerance || 0); } }); diff --git a/src/layer/vector/Polyline.js b/src/layer/vector/Polyline.js index 003eaf82643..317c583fa87 100644 --- a/src/layer/vector/Polyline.js +++ b/src/layer/vector/Polyline.js @@ -114,7 +114,7 @@ export var Polyline = Path.extend({ }, // @method getCenter(): LatLng - // Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the polyline. + // Returns the center ([centroid](https://en.wikipedia.org/wiki/Centroid)) of the polyline. getCenter: function () { // throws error when not yet added to map as this center calculation requires projected coordinates if (!this._map) { diff --git a/src/layer/vector/Renderer.js b/src/layer/vector/Renderer.js index 424a179b8c2..8e635a88ddc 100644 --- a/src/layer/vector/Renderer.js +++ b/src/layer/vector/Renderer.js @@ -1,7 +1,7 @@ import {Layer} from '../Layer'; import * as DomUtil from '../../dom/DomUtil'; import * as Util from '../../core/Util'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; import {Bounds} from '../../geometry/Bounds'; @@ -34,11 +34,7 @@ export var Renderer = Layer.extend({ // @option padding: Number = 0.1 // How much to extend the clip area around the map view (relative to its size) // e.g. 0.1 would be 10% of map view in each direction - padding: 0.1, - - // @option tolerance: Number = 0 - // How much to extend click tolerance round a path/object on the map - tolerance : 0 + padding: 0.1 }, initialize: function (options) { diff --git a/src/layer/vector/SVG.Util.js b/src/layer/vector/SVG.Util.js index 2a547972ca9..9c7fd9394b5 100644 --- a/src/layer/vector/SVG.Util.js +++ b/src/layer/vector/SVG.Util.js @@ -1,4 +1,4 @@ -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; // @namespace SVG; @section // There are several static functions which can be called without instantiating L.SVG: diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index 8c085e4043a..41434533003 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -1,7 +1,7 @@ import {Renderer} from './Renderer'; import * as DomUtil from '../../dom/DomUtil'; import * as DomEvent from '../../dom/DomEvent'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; import {stamp} from '../../core/Util'; import {svgCreate, pointsToPath} from './SVG.Util'; export {pointsToPath}; @@ -17,7 +17,7 @@ export var create = Browser.vml ? vmlCreate : svgCreate; * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG). * Inherits `Renderer`. * - * Due to [technical limitations](http://caniuse.com/#search=svg), SVG is not + * Due to [technical limitations](https://caniuse.com/svg), SVG is not * available in all web browsers, notably Android 2.x and 3.x. * * Although SVG is not available on IE7 and IE8, these browsers support diff --git a/src/map/Map.js b/src/map/Map.js index 0d50cfb14d5..06deb2606e4 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -5,7 +5,7 @@ import {Point, toPoint} from '../geometry/Point'; import {Bounds, toBounds} from '../geometry/Bounds'; import {LatLng, toLatLng} from '../geo/LatLng'; import {LatLngBounds, toLatLngBounds} from '../geo/LatLngBounds'; -import * as Browser from '../core/Browser'; +import Browser from '../core/Browser'; import * as DomEvent from '../dom/DomEvent'; import * as DomUtil from '../dom/DomUtil'; import {PosAnimation} from '../dom/PosAnimation'; @@ -511,10 +511,9 @@ export var Map = Evented.extend({ return this; }, - // @method panInside(latlng: LatLng, options?: options): this + // @method panInside(latlng: LatLng, options?: padding options): this // Pans the map the minimum amount to make the `latlng` visible. Use - // `padding`, `paddingTopLeft` and `paddingBottomRight` options to fit - // the display to more restricted bounds, like [`fitBounds`](#map-fitbounds). + // padding options to fit the display to more restricted bounds. // If `latlng` is already within the (optionally padded) display bounds, // the map will not be panned. panInside: function (latlng, options) { @@ -665,6 +664,8 @@ export var Map = Evented.extend({ }, _handleGeolocationError: function (error) { + if (!this._container._leaflet_id) { return; } + var c = error.code, message = error.message || (c === 1 ? 'permission denied' : @@ -684,6 +685,8 @@ export var Map = Evented.extend({ }, _handleGeolocationResponse: function (pos) { + if (!this._container._leaflet_id) { return; } + var lat = pos.coords.latitude, lng = pos.coords.longitude, latlng = new LatLng(lat, lng), @@ -736,7 +739,7 @@ export var Map = Evented.extend({ remove: function () { this._initEvents(true); - this.off('moveend', this._panInsideMaxBounds); + if (this.options.maxBounds) { this.off('moveend', this._panInsideMaxBounds); } if (this._containerId !== this._container._leaflet_id) { throw new Error('Map container is being reused by another instance'); @@ -1335,7 +1338,7 @@ export var Map = Evented.extend({ var pos = this._getMapPanePos(); if (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) { // https://bugzilla.mozilla.org/show_bug.cgi?id=1203873 but Webkit also have - // a pixel offset on very high values, see: http://jsfiddle.net/dg6r5hhb/ + // a pixel offset on very high values, see: https://jsfiddle.net/dg6r5hhb/ this._resetView(this.getCenter(), this.getZoom()); } }, @@ -1349,7 +1352,7 @@ export var Map = Evented.extend({ while (src) { target = this._targets[Util.stamp(src)]; - if (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) { + if (target && (type === 'click' || type === 'preclick') && this._draggableMoved(target)) { // Prevent firing click after you just dragged an object. dragging = true; break; @@ -1362,20 +1365,30 @@ export var Map = Evented.extend({ if (src === this._container) { break; } src = src.parentNode; } - if (!targets.length && !dragging && !isHover && DomEvent.isExternalTarget(src, e)) { + if (!targets.length && !dragging && !isHover && this.listens(type, true)) { targets = [this]; } return targets; }, + _isClickDisabled: function (el) { + while (el !== this._container) { + if (el['_leaflet_disable_click']) { return true; } + el = el.parentNode; + } + }, + _handleDOMEvent: function (e) { - if (!this._loaded || DomEvent.skipped(e)) { return; } + var el = (e.target || e.srcElement); + if (!this._loaded || el['_leaflet_disable_events'] || e.type === 'click' && this._isClickDisabled(el)) { + return; + } var type = e.type; if (type === 'mousedown') { // prevents outline when clicking on keyboard-focusable element - DomUtil.preventOutline(e.target || e.srcElement); + DomUtil.preventOutline(el); } this._fireDOMEvent(e, type); @@ -1383,7 +1396,7 @@ export var Map = Evented.extend({ _mouseEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu'], - _fireDOMEvent: function (e, type, targets) { + _fireDOMEvent: function (e, type, canvasTargets) { if (e.type === 'click') { // Fire a synthetic 'preclick' event which propagates up (mainly for closing popups). @@ -1393,21 +1406,29 @@ export var Map = Evented.extend({ // handlers start running). var synth = Util.extend({}, e); synth.type = 'preclick'; - this._fireDOMEvent(synth, synth.type, targets); + this._fireDOMEvent(synth, synth.type, canvasTargets); } - if (e._stopped) { return; } - // Find the layer the event is propagating from and its parents. - targets = (targets || []).concat(this._findEventTargets(e, type)); + var targets = this._findEventTargets(e, type); + + if (canvasTargets) { + var filtered = []; // pick only targets with listeners + for (var i = 0; i < canvasTargets.length; i++) { + if (canvasTargets[i].listens(type, true)) { + filtered.push(canvasTargets[i]); + } + } + targets = filtered.concat(targets); + } if (!targets.length) { return; } - var target = targets[0]; - if (type === 'contextmenu' && target.listens(type, true)) { + if (type === 'contextmenu') { DomEvent.preventDefault(e); } + var target = targets[0]; var data = { originalEvent: e }; @@ -1420,7 +1441,7 @@ export var Map = Evented.extend({ data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint); } - for (var i = 0; i < targets.length; i++) { + for (i = 0; i < targets.length; i++) { targets[i].fire(type, data, true); if (data.originalEvent._stopped || (targets[i].options.bubblingMouseEvents === false && Util.indexOf(this._mouseEvents, type) !== -1)) { return; } diff --git a/src/map/Map.methodOptions.leafdoc b/src/map/Map.methodOptions.leafdoc index 8ce8aad5af2..a625fee8c78 100644 --- a/src/map/Map.methodOptions.leafdoc +++ b/src/map/Map.methodOptions.leafdoc @@ -31,7 +31,7 @@ Maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, `locate` will return a cached location. @option enableHighAccuracy: Boolean = false -Enables high accuracy, see [description in the W3C spec](http://dev.w3.org/geo/api/spec-source.html#high-accuracy). +Enables high accuracy, see [description in the W3C spec](https://w3c.github.io/geolocation-api/#enablehighaccuracy-member). @@ -72,7 +72,7 @@ Duration of animated panning, in seconds. @option easeLinearity: Number = 0.25 The curvature factor of panning animation easing (third parameter of the -[Cubic Bezier curve](http://cubic-bezier.com/)). 1.0 means linear animation, +[Cubic Bezier curve](https://cubic-bezier.com/)). 1.0 means linear animation, and the smaller this number, the more bowed the curve. @option noMoveStart: Boolean = false @@ -86,10 +86,8 @@ panning inertia). @inherits Pan options -@miniclass FitBounds options (Map) -@aka fitBounds options -@inherits Zoom/pan options - +@miniclass Padding options (Map) +@aka padding options @option paddingTopLeft: Point = [0, 0] Sets the amount of padding in the top left corner of a map container that shouldn't be accounted for when setting the view to fit bounds. Useful if you @@ -102,6 +100,12 @@ The same for the bottom right corner of the map. @option padding: Point = [0, 0] Equivalent of setting both top left and bottom right padding to the same value. + +@miniclass FitBounds options (Map) +@aka fitBounds options +@inherits Zoom/pan options +@inherits Padding options + @option maxZoom: Number = null The maximum possible zoom to use. diff --git a/src/map/handler/Map.Drag.js b/src/map/handler/Map.Drag.js index 69597bd7763..3971a6fd537 100644 --- a/src/map/handler/Map.Drag.js +++ b/src/map/handler/Map.Drag.js @@ -1,5 +1,4 @@ import {Map} from '../Map'; -import * as Browser from '../../core/Browser'; import {Handler} from '../../core/Handler'; import {Draggable} from '../../dom/Draggable'; import * as Util from '../../core/Util'; @@ -23,8 +22,8 @@ Map.mergeOptions({ // If enabled, panning of the map will have an inertia effect where // the map builds momentum while dragging and continues moving in // the same direction for some time. Feels especially nice on touch - // devices. Enabled by default unless running on old Android devices. - inertia: !Browser.android23, + // devices. Enabled by default. + inertia: true, // @option inertiaDeceleration: Number = 3000 // The rate with which the inertial movement slows down, in pixels/second². diff --git a/src/map/handler/Map.Tap.js b/src/map/handler/Map.Tap.js deleted file mode 100644 index 99712e327f8..00000000000 --- a/src/map/handler/Map.Tap.js +++ /dev/null @@ -1,136 +0,0 @@ -import {Map} from '../Map'; -import {Handler} from '../../core/Handler'; -import * as DomEvent from '../../dom/DomEvent'; -import {Point} from '../../geometry/Point'; -import * as Util from '../../core/Util'; -import * as DomUtil from '../../dom/DomUtil'; -import * as Browser from '../../core/Browser'; - - -/* - * L.Map.Tap is used to enable mobile hacks like quick taps and long hold. - */ - -// @namespace Map -// @section Interaction Options -Map.mergeOptions({ - // @section Touch interaction options - // @option tap: Boolean - // Enables mobile hacks for supporting instant taps (fixing 200ms click - // delay on iOS/Android) and touch holds (fired as `contextmenu` events). - // This is legacy option, by default enabled in mobile Safari only - // (because we still need `contextmenu` simulation for iOS). - tap: Browser.safari && Browser.mobile, - - // @option tapTolerance: Number = 15 - // The max number of pixels a user can shift his finger during touch - // for it to be considered a valid tap. - tapTolerance: 15 -}); - -export var Tap = Handler.extend({ - addHooks: function () { - DomEvent.on(this._map._container, 'touchstart', this._onDown, this); - }, - - removeHooks: function () { - DomEvent.off(this._map._container, 'touchstart', this._onDown, this); - }, - - _onDown: function (e) { - if (!e.touches) { return; } - - DomEvent.preventDefault(e); - - this._fireClick = true; - - // don't simulate click or track longpress if more than 1 touch - if (e.touches.length > 1) { - this._fireClick = false; - clearTimeout(this._holdTimeout); - return; - } - - var first = e.touches[0], - el = first.target; - - this._startPos = this._newPos = new Point(first.clientX, first.clientY); - - // if touching a link, highlight it - if (el.tagName && el.tagName.toLowerCase() === 'a') { - DomUtil.addClass(el, 'leaflet-active'); - } - - // simulate long hold but setting a timeout - this._holdTimeout = setTimeout(Util.bind(function () { - if (this._isTapValid()) { - this._fireClick = false; - this._onUp(); - this._simulateEvent('contextmenu', first); - } - }, this), 1000); - - this._simulateEvent('mousedown', first); - - DomEvent.on(document, { - touchmove: this._onMove, - touchend: this._onUp - }, this); - }, - - _onUp: function (e) { - clearTimeout(this._holdTimeout); - - DomEvent.off(document, { - touchmove: this._onMove, - touchend: this._onUp - }, this); - - if (this._fireClick && e && e.changedTouches) { - - var first = e.changedTouches[0], - el = first.target; - - if (el && el.tagName && el.tagName.toLowerCase() === 'a') { - DomUtil.removeClass(el, 'leaflet-active'); - } - - this._simulateEvent('mouseup', first); - - // simulate click if the touch didn't move too much - if (this._isTapValid()) { - this._simulateEvent('click', first); - } - } - }, - - _isTapValid: function () { - return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance; - }, - - _onMove: function (e) { - var first = e.touches[0]; - this._newPos = new Point(first.clientX, first.clientY); - this._simulateEvent('mousemove', first); - }, - - _simulateEvent: function (type, e) { - var simulatedEvent = document.createEvent('MouseEvents'); - - simulatedEvent._simulated = true; - e.target._simulatedClick = true; - - simulatedEvent.initMouseEvent( - type, true, true, window, 1, - e.screenX, e.screenY, - e.clientX, e.clientY, - false, false, false, false, 0, null); - - e.target.dispatchEvent(simulatedEvent); - } -}); - -// @section Handlers -// @property tap: Handler -// Mobile touch hacks (quick tap and touch hold) handler. -Map.addInitHook('addHandler', 'tap', Tap); diff --git a/src/map/handler/Map.TapHold.js b/src/map/handler/Map.TapHold.js new file mode 100644 index 00000000000..558ba77e5d3 --- /dev/null +++ b/src/map/handler/Map.TapHold.js @@ -0,0 +1,102 @@ +import {Map} from '../Map'; +import {Handler} from '../../core/Handler'; +import * as DomEvent from '../../dom/DomEvent'; +import {Point} from '../../geometry/Point'; +import * as Util from '../../core/Util'; +import Browser from '../../core/Browser'; + +/* + * L.Map.TapHold is used to simulate `contextmenu` event on long hold, + * which otherwise is not fired by mobile Safari. + */ + +var tapHoldDelay = 600; + +// @namespace Map +// @section Interaction Options +Map.mergeOptions({ + // @section Touch interaction options + // @option tapHold: Boolean + // Enables simulation of `contextmenu` event, default is `true` for mobile Safari. + tapHold: Browser.touchNative && Browser.safari && Browser.mobile, + + // @option tapTolerance: Number = 15 + // The max number of pixels a user can shift his finger during touch + // for it to be considered a valid tap. + tapTolerance: 15 +}); + +export var TapHold = Handler.extend({ + addHooks: function () { + DomEvent.on(this._map._container, 'touchstart', this._onDown, this); + }, + + removeHooks: function () { + DomEvent.off(this._map._container, 'touchstart', this._onDown, this); + }, + + _onDown: function (e) { + clearTimeout(this._holdTimeout); + if (e.touches.length !== 1) { return; } + + var first = e.touches[0]; + this._startPos = this._newPos = new Point(first.clientX, first.clientY); + + this._holdTimeout = setTimeout(Util.bind(function () { + this._cancel(); + if (!this._isTapValid()) { return; } + + // prevent simulated mouse events https://w3c.github.io/touch-events/#mouse-events + DomEvent.on(document, 'touchend', DomEvent.preventDefault); + DomEvent.on(document, 'touchend touchcancel', this._cancelClickPrevent); + this._simulateEvent('contextmenu', first); + }, this), tapHoldDelay); + + DomEvent.on(document, 'touchend touchcancel contextmenu', this._cancel, this); + DomEvent.on(document, 'touchmove', this._onMove, this); + }, + + _cancelClickPrevent: function cancelClickPrevent() { + DomEvent.off(document, 'touchend', DomEvent.preventDefault); + DomEvent.off(document, 'touchend touchcancel', cancelClickPrevent); + }, + + _cancel: function () { + clearTimeout(this._holdTimeout); + DomEvent.off(document, 'touchend touchcancel contextmenu', this._cancel, this); + DomEvent.off(document, 'touchmove', this._onMove, this); + }, + + _onMove: function (e) { + var first = e.touches[0]; + this._newPos = new Point(first.clientX, first.clientY); + }, + + _isTapValid: function () { + return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance; + }, + + _simulateEvent: function (type, e) { + var simulatedEvent = new MouseEvent(type, { + bubbles: true, + cancelable: true, + view: window, + // detail: 1, + screenX: e.screenX, + screenY: e.screenY, + clientX: e.clientX, + clientY: e.clientY, + // button: 2, + // buttons: 2 + }); + + simulatedEvent._simulated = true; + + e.target.dispatchEvent(simulatedEvent); + } +}); + +// @section Handlers +// @property tapHold: Handler +// Long tap handler to simulate `contextmenu` event (useful in mobile Safari). +Map.addInitHook('addHandler', 'tapHold', TapHold); diff --git a/src/map/handler/Map.TouchZoom.js b/src/map/handler/Map.TouchZoom.js index 9febac6d097..9ca240cc1d0 100644 --- a/src/map/handler/Map.TouchZoom.js +++ b/src/map/handler/Map.TouchZoom.js @@ -3,7 +3,7 @@ import {Handler} from '../../core/Handler'; import * as DomEvent from '../../dom/DomEvent'; import * as Util from '../../core/Util'; import * as DomUtil from '../../dom/DomUtil'; -import * as Browser from '../../core/Browser'; +import Browser from '../../core/Browser'; /* * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers. @@ -17,8 +17,8 @@ Map.mergeOptions({ // Whether the map can be zoomed by touch-dragging with two fingers. If // passed `'center'`, it will zoom to the center of the view regardless of // where the touch events (fingers) were. Enabled for touch-capable web - // browsers except for old Androids. - touchZoom: Browser.touch && !Browser.android23, + // browsers. + touchZoom: Browser.touch, // @option bounceAtZoomLimits: Boolean = true // Set it to false if you don't want the map to zoom beyond min/max zoom @@ -59,7 +59,7 @@ export var TouchZoom = Handler.extend({ map._stop(); DomEvent.on(document, 'touchmove', this._onTouchMove, this); - DomEvent.on(document, 'touchend', this._onTouchEnd, this); + DomEvent.on(document, 'touchend touchcancel', this._onTouchEnd, this); DomEvent.preventDefault(e); }, @@ -113,7 +113,7 @@ export var TouchZoom = Handler.extend({ Util.cancelAnimFrame(this._animRequest); DomEvent.off(document, 'touchmove', this._onTouchMove, this); - DomEvent.off(document, 'touchend', this._onTouchEnd, this); + DomEvent.off(document, 'touchend touchcancel', this._onTouchEnd, this); // Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate. if (this._map.options.zoomAnimation) { diff --git a/src/map/index.js b/src/map/index.js index bc737908668..e35f7553364 100644 --- a/src/map/index.js +++ b/src/map/index.js @@ -9,8 +9,8 @@ import {Keyboard} from './handler/Map.Keyboard'; Map.Keyboard = Keyboard; import {ScrollWheelZoom} from './handler/Map.ScrollWheelZoom'; Map.ScrollWheelZoom = ScrollWheelZoom; -import {Tap} from './handler/Map.Tap'; -Map.Tap = Tap; +import {TapHold} from './handler/Map.TapHold'; +Map.TapHold = TapHold; import {TouchZoom} from './handler/Map.TouchZoom'; Map.TouchZoom = TouchZoom;