# leaflet-marker-rotation

> Leaflet plugin to enable the rotation of map marker icons

Latest version **0.4.0** (published 2021-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install leaflet-marker-rotation
pnpm add leaflet-marker-rotation
yarn add leaflet-marker-rotation
bun add leaflet-marker-rotation
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2021-07-07 |
| First published | 2020-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Abdul Khan |
| Maintainers | abdulk1 |
| Keywords | gis, map, leaflet, marker, rotated |

## Links

- npm: https://www.npmjs.com/package/leaflet-marker-rotation
- Repository: https://github.com/abdulk1/Leaflet.RotatedMarker
- Homepage: https://github.com/abdulk1/Leaflet.RotatedMarker#readme
- Issues: https://github.com/abdulk1/Leaflet.RotatedMarker/issues
- npm.io page: https://npm.io/package/leaflet-marker-rotation

## Recent versions

- 0.4.0 (latest) — 2021-07-07
- 0.3.0 — 2021-03-26
- 0.2.0 — 2021-01-22
- 0.1.0 — 2020-11-15

## README

# Leaflet Rotated Marker

Enables rotation of marker icons in Leaflet. [Demo](https://abdulk1.github.io/Leaflet.RotatedMarker/)

[![npm version](https://badge.fury.io/js/leaflet-marker-rotation.svg)](https://www.npmjs.com/package/leaflet-marker-rotation)

```bash
npm install leaflet-marker-rotation
```

## Usage

```js
L.rotatedMarker([48.8631169, 2.3708919], {
  rotationAngle: 45,
}).addTo(map);

var marker = new L.RotatedMarker([48.8631169, 2.3708919], {
  rotationAngle: 145,
  rotationOrigin: "bottom center",
}).addTo(map);
```

## API

It extends the `L.Marker` class with two new options:

| Option               | Type     | Default           | Description                                                                                                                 |
| -------------------- | -------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------- |
| **`rotationAngle`**  | `Number` | 0                 | Rotation angle, in degrees, clockwise.                                                                                      |
| **`rotationOrigin`** | `String` | `'bottom center'` | The rotation center, as a [`transform-origin`](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin) CSS rule. |

and two new methods:

| Method                             | Returns | Description                     |
| ---------------------------------- | ------- | ------------------------------- |
| **`setRotationAngle(newAngle)`**   | `this`  | Sets the rotation angle value.  |
| **`setRotationOrigin(newOrigin)`** | `this`  | Sets the rotation origin value. |

The default `rotationOrigin` value will rotate around the bottom center point, corresponding to the "tip" of the marker for most commonly used icons. If your marker icon has no tip, or you want to rotate around its center, use `center center`.

## Note

It doesn't rotate marker icon shadows. There is no way to make it look good with the perspective of classic, pin type shadows.

It's advised to disable icon shadows, or use simple ones which will work for all marker angles.

---
_Source: https://npm.io/package/leaflet-marker-rotation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
