JSPM

leaflet-marker-rotation

0.4.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1885
  • Score
    100M100P100Q119498F
  • License MIT

Leaflet plugin to enable the rotation of map marker icons

Package Exports

  • leaflet-marker-rotation

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (leaflet-marker-rotation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Leaflet Rotated Marker

Enables rotation of marker icons in Leaflet. Demo

npm version

npm install leaflet-marker-rotation

Usage

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 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.