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

@math.gl/web-mercator

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@math.gl/web-mercator

Utilities for perspective-enabled Web Mercator projections

  • 3.5.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
213K
decreased by-14.02%
Maintainers
3
Weekly downloads
 
Created

What is @math.gl/web-mercator?

@math.gl/web-mercator is a JavaScript library that provides utilities for working with Web Mercator projections. It is part of the math.gl suite of libraries and is designed to facilitate geographic calculations and transformations, particularly for mapping and visualization applications.

What are @math.gl/web-mercator's main functionalities?

Project geographic coordinates to Web Mercator

This feature allows you to project geographic coordinates (longitude and latitude) to Web Mercator coordinates. The code sample demonstrates how to create a WebMercatorViewport and project a specific geographic coordinate to Web Mercator coordinates.

const { WebMercatorViewport } = require('@math.gl/web-mercator');

const viewport = new WebMercatorViewport({
  width: 800,
  height: 600,
  longitude: -122.45,
  latitude: 37.78,
  zoom: 12
});

const [x, y] = viewport.project([-122.45, 37.78]);
console.log(`Projected coordinates: (${x}, ${y})`);

Unproject Web Mercator coordinates to geographic coordinates

This feature allows you to unproject Web Mercator coordinates back to geographic coordinates (longitude and latitude). The code sample demonstrates how to create a WebMercatorViewport and unproject a specific Web Mercator coordinate to geographic coordinates.

const { WebMercatorViewport } = require('@math.gl/web-mercator');

const viewport = new WebMercatorViewport({
  width: 800,
  height: 600,
  longitude: -122.45,
  latitude: 37.78,
  zoom: 12
});

const [longitude, latitude] = viewport.unproject([400, 300]);
console.log(`Geographic coordinates: (${longitude}, ${latitude})`);

Calculate the bounding box of a viewport

This feature allows you to calculate the geographic bounding box of a viewport. The code sample demonstrates how to create a WebMercatorViewport and get the bounding box of the viewport.

const { WebMercatorViewport } = require('@math.gl/web-mercator');

const viewport = new WebMercatorViewport({
  width: 800,
  height: 600,
  longitude: -122.45,
  latitude: 37.78,
  zoom: 12
});

const bounds = viewport.getBounds();
console.log(`Bounding box: ${JSON.stringify(bounds)}`);

Other packages similar to @math.gl/web-mercator

Keywords

FAQs

Package last updated on 19 Jul 2021

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