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

@mapbox/mapbox-sdk

Package Overview
Dependencies
Maintainers
28
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/mapbox-sdk

JS SDK for accessing Mapbox APIs

  • 0.16.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134K
decreased by-16.86%
Maintainers
28
Weekly downloads
 
Created

What is @mapbox/mapbox-sdk?

@mapbox/mapbox-sdk is a JavaScript library that provides a set of tools for interacting with Mapbox APIs. It allows developers to integrate various Mapbox services such as maps, geocoding, directions, and more into their applications.

What are @mapbox/mapbox-sdk's main functionalities?

Static Maps

This feature allows you to generate static map images. The code sample demonstrates how to create a static map image centered on specific coordinates.

const mbxClient = require('@mapbox/mapbox-sdk');
const mbxStatic = require('@mapbox/mapbox-sdk/services/static');
const baseClient = mbxClient({ accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN' });
const staticClient = mbxStatic(baseClient);

staticClient.getStaticImage({
  ownerId: 'mapbox',
  styleId: 'streets-v11',
  width: 600,
  height: 400,
  position: { coordinates: [-122.42, 37.78], zoom: 14 }
}).send().then(response => {
  const image = response.body;
  // Do something with the image
});

Geocoding

This feature allows you to convert addresses into geographic coordinates. The code sample demonstrates how to perform forward geocoding to get coordinates for a given address.

const mbxClient = require('@mapbox/mapbox-sdk');
const mbxGeocoding = require('@mapbox/mapbox-sdk/services/geocoding');
const baseClient = mbxClient({ accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN' });
const geocodingClient = mbxGeocoding(baseClient);

geocodingClient.forwardGeocode({
  query: '1600 Pennsylvania Ave NW, Washington, DC 20500',
  limit: 2
}).send().then(response => {
  const match = response.body;
  // Do something with the geocoding result
});

Directions

This feature allows you to get driving, walking, or cycling directions between multiple waypoints. The code sample demonstrates how to get driving directions between two sets of coordinates.

const mbxClient = require('@mapbox/mapbox-sdk');
const mbxDirections = require('@mapbox/mapbox-sdk/services/directions');
const baseClient = mbxClient({ accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN' });
const directionsClient = mbxDirections(baseClient);

directionsClient.getDirections({
  profile: 'driving',
  waypoints: [
    { coordinates: [-122.42, 37.78] },
    { coordinates: [-77.03, 38.91] }
  ]
}).send().then(response => {
  const directions = response.body;
  // Do something with the directions
});

Other packages similar to @mapbox/mapbox-sdk

Keywords

FAQs

Package last updated on 13 Sep 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