Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codingspark/tiles-downloader

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codingspark/tiles-downloader

A small library to download map tiles

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
59
Maintainers
0
Weekly downloads
 
Created
Source

Tiles downloader

[!IMPORTANT] This module is ESM only.

This module allows you to download tiles from a tile server. Therefore you can use it to download tiles from OpenStreetMap, etc. for offline use or caching.

Example usage

import path from "node:path";
import { downloadTiles } from "@codingspark/tiles-downloader";

await downloadTiles(
  {
    url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
    zoomLevels: [14, 15, 16],
    throttleConfig: { limit: 3, interval: 1000 },
    bounds: {
      minLat: 43.5704,
      maxLat: 43.645,
      minLon: 3.8095,
      maxLon: 3.923,
    },
  },
  async ({ x, y, z, buffer }) => {
    const outputPath = path.join(
      "./map",
      z.toString(),
      x.toString(),
      `${y}.png`
    );

    console.log(`Writing tile ${z}/${x}/${y}`);

    // Using bun but use anything you want to write the buffer to a file
    Bun.write(outputPath, buffer);
  }
);

FAQs

Package last updated on 17 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc