# @jawg/map-session

> Map session for the Jawg MapLoad pricing

Latest version **1.0.0** (published 2022-12-15) · 0 weekly downloads

## Install

```sh
npm install @jawg/map-session
pnpm add @jawg/map-session
yarn add @jawg/map-session
bun add @jawg/map-session
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-12-15 |
| First published | 2022-12-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jawg Maps |
| Maintainers | jawg-bot, joxit |

## Links

- npm: https://www.npmjs.com/package/@jawg/map-session
- Issues: https://github.com/jawg/map-session/issues
- npm.io page: https://npm.io/package/@jawg/map-session

## Recent versions

- 1.0.0 (latest) — 2022-12-15
- 1.0.0-pre.1 — 2022-12-15
- 1.0.0-pre.0 — 2022-12-08

## README

![Jawg Logo](https://media.jawg.io/logo/jawgmaps-blue.svg)

# MapSession

[![npm](https://img.shields.io/npm/v/@jawg/map-session)](https://www.npmjs.com/package/@jawg/map-session)

Generate a map session token and authenticate request URLs for the JawgMaps mapload pricing with [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js).

> Note that your account requires the per-mapload pricing to be enabled.
> Please contact us at [contact@jawg.io](mailto:contact@jawg.io) for more information.

## Install

Available via npm as the package [@jawg/map-session](https://www.npmjs.com/package/@jawg/map-session).

```sh
npm i @jawg/map-session
```

or

```sh
yarn add @jawg/map-session
```

Alternatively you may add the umd package directly to the html document using the unpkg link.

```html
<script src="https://unpkg.com/@jawg/map-session@1.0.0/dist/map-session.js"></script>
```

When adding via unpkg, the `MapSession` class can be accessed with the module name:

```javascript
const MapSession = window.jawg_map_session;

const session = new MapSession();
```

## Usage

This library is intended to work with maplibre-gl-js. See the [Quickstart](https://maplibre.org/maplibre-gl-js-docs/api/#quickstart) section for installation.

> Get your own access-token in the [Lab](https://www.jawg.io/lab/access-tokens).

```javascript
import MapSession from "@jawg/map-session";
import maplibregl from "maplibre-gl";

// Create a new map session and generate a session token
// The MapLoad count will be incremented only on the first tile request
const session = new MapSession();

var map = new maplibregl.Map({
  container: "map",
  style:
    "https://api.jawg.io/styles/jawg-streets.json?access-token=<YOUR_ACCESS_TOKEN>",
  zoom: 15,
  center: [1.43649, 43.59818],
  transformRequest: (url, resourceType) => {
    return {
      // Add the session token as query parameter
      url: session.authenticateUrl(url, resourceType),
    };
  },
});
```

## Feedback

Contact us at [contact@jawg.io](mailto:contact@jawg.io) for new features or when something is not working properly.

---
_Source: https://npm.io/package/@jawg/map-session · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
