@placemarkio/geo-viewport
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

geo-viewport

On npm as @placemarkio/geo-viewport.

Docs

geo-viewport development is supported by 🌎 placemark.io

Turns bounding boxes / extents into centerpoint & zoom combos for static maps.

This is a maintained fork of the Mapbox repository, with the following changes:

  • Fixed crashing bug introduced in 0.5.0
  • Includes TypeScript types
  • Modernized project & dependencies
  • Smaller module and bundle size, with no dependencies
  • ESM & CJS output types

Changes

Most of the improvements to this package are internal, but the viewport method has changed. In the Mapbox version, it grew quite a few parameters and is now:

viewport(bounds, dimensions, minzoom, maxzoom, tileSize, allowFloat, allowAntiMeridian)

In this fork this has changed so that there is less remembering required. The method signature is:

// Showing default values
viewport(bounds, dimensions, {
    minzoom: 0,
    maxzoom: 20,
    tileSize: 256,
    allowFloat: false,
    allowAntiMeridian: false
})

// You can omit any options or the options array:
viewport(bounds, dimensions);

// Just one option:
viewport(bounds, dimensions, {
    tileSize: 256
})

Package Sidebar

Install

npm i @placemarkio/geo-viewport

Weekly Downloads

4,988

Version

1.0.2

License

BSD-2-Clause

Unpacked Size

54.6 kB

Total Files

13

Last publish

Collaborators

  • tmcw