# mbgl-dl-ctrl

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

Latest version **2.1.1** (published 2019-01-10) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2019-01-10 |
| First published | 2018-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 16.7 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-dl-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-dl-ctrl

## Dependencies (5)

- [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
- [get-form-data](https://npm.io/package/get-form-data.md) ^2.0.0
- [tile-dl-client](https://npm.io/package/tile-dl-client.md) ^1.3.0

## 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

- 2.1.1 (latest) — 2019-01-10
- 2.1.0 — 2019-01-10
- 2.0.1 — 2019-01-10
- 2.0.0 — 2019-01-09
- 1.0.0 — 2018-05-16

## README

# mbgl-dl-ctrl

MapBox 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.

Will download the tiles to a `tar` file, without hitting the server.

Only works in Google Chrome. 

## Usage

```js
var DownloadControl = require('mpgl-dl-ctrl')
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-dl-ctrl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
