# mbgl-downloadl-ctrl

> Control for downloading the background tiles in the map you're currently viewing.

Latest version **1.0.0** (published 2018-05-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mbgl-downloadl-ctrl
pnpm add mbgl-downloadl-ctrl
yarn add mbgl-downloadl-ctrl
bun add mbgl-downloadl-ctrl
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-16 |
| First published | 2018-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Karissa McKelvey |
| Maintainers | karissa |
| Keywords | mapbox, download, control, ctrl, tiles, streamsaver, stream, tar |

## Links

- npm: https://www.npmjs.com/package/mbgl-downloadl-ctrl
- Repository: https://github.com/karissa/mapbox-download-ctrl
- Homepage: https://github.com/karissa/mapbox-download-ctrl#readme
- Issues: https://github.com/karissa/mapbox-download-ctrl/issues
- npm.io page: https://npm.io/package/mbgl-downloadl-ctrl

## Dependencies (12)

- [react](https://npm.io/package/react.md) ^16.3.2
- [react-dom](https://npm.io/package/react-dom.md) ^16.3.2
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.1
- [streamsaver](https://npm.io/package/streamsaver.md) ^1.0.1
- [pretty-bytes](https://npm.io/package/pretty-bytes.md) ^4.0.2
- [tilelive-tar](https://npm.io/package/tilelive-tar.md) ^1.1.0
- [get-form-data](https://npm.io/package/get-form-data.md) ^2.0.0
- [tilelive-http](https://npm.io/package/tilelive-http.md) ^0.14.0
- [@mapbox/tilejson](https://npm.io/package/@mapbox/tilejson.md) ^1.1.0
- [@mapbox/tilelive](https://npm.io/package/@mapbox/tilelive.md) github:karissa/tilelive
- [@yaga/tile-utils](https://npm.io/package/@yaga/tile-utils.md) ^1.0.0
- [tilelive-streaming](https://npm.io/package/tilelive-streaming.md) ^0.7.7

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-05-16

## README

# mbgl-download-ctrl

Control for downloading the background tiles in the map you're currently viewing.

[See Example at http://tiles.okdistribute.xyz](http://tiles.okdistribute.xyz)

It's recommended to use Bing background tiles because Mapbox's terms of service
are more restrictive when it comes to downloading and using tiles offline.

By Default, the download control will use `StreamSaver.js` to download the
tiles to a `tar` file, without hitting the server. This is cool! But it only
works on the latest version of Google Chrome (and maybe some others, but you
should really check).

If you want to control the download yourself, you can override that default
behavior by passing your own `onDownload` funciton to the control. 

## Usage

```js
var DownloadControl = require('mpgl-download-control')
var mapboxgl = require('mapbox-gl')

const bingSource = {
  type: 'raster',
  tiles: [
    'https://ecn.t0.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=1',
    'https://ecn.t1.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=1',
    'https://ecn.t2.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=1',
    'https://ecn.t3.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=1'
  ],
  minzoom: 1,
  maxzoom: 21,
  tileSize: 256
}

const bing = {
  id: 'bing',
  type: 'raster',
  source: 'bing',
  layout: {
    visibility: 'visible'
  },
  paint: {
  }
}

mapboxgl.accessToken = accessToken

var map = new mapboxgl.Map({
  container: 'map',
  style: {
    version: 8,
    sources: {'bing': bingSource},
    layers: [bing]
  }
})
map.on('style.load', function () {
  var underlays = [{
    name: 'Bing Satellite',
    ids: ['bing']
  }]
  var downloadControl = new DownloadControl()
  map.addControl(downloadControl, 'bottom-left')
})
```

## API

### `new DownloadControl(options)`

Options: 

  * `onDownload`: optional function that takes parameter `data`, which is the
    user-defined area to download: `minZoom`, `maxZoom`, `minLat`, `minLng`, `maxLat`, `maxLng`.

## License

MIT

---
_Source: https://npm.io/package/mbgl-downloadl-ctrl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
