1.0.2 • Published 10 months ago

@placemarkio/geo-viewport v1.0.2

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
10 months ago

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
})