Leaflet.RotatedMarker

Leaflet plugin to enable the rotation of map marker icons

  • Owner: bbecquet/Leaflet.RotatedMarker
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    1
      Compare:

Github stars Tracking Chart

Leaflet Rotated Marker

Enables rotation of marker icons in Leaflet. Demo

Compatible with versions 0.7.* and 1.* of Leaflet. Doesn't work on IE < 9.

npm install leaflet-rotatedmarker

Usage

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

API

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

Option, Type, Default, Description
-------, ------, ---------, ------------
rotationAngle, Number, 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

On purpose, it doesn't rotate marker icon shadows. Mainly because there is no way to make it look good with the perspective of classic, pin type shadows (anyway, these shadows are so 2005, right?).

So just disable icon shadows, or use simple ones which will work for all marker angles.

Main metrics

Overview
Name With Ownerbbecquet/Leaflet.RotatedMarker
Primary LanguageJavaScript
Program languageHTML (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2015-11-18 21:58:53
Pushed At2024-05-31 10:53:04
Last Commit At2018-05-21 17:59:51
Release Count4
Last Release Name0.2.0 (Posted on )
First Release Name0.1.0 (Posted on )
用户参与
Stargazers Count273
Watchers Count8
Fork Count104
Commits Count22
Has Issues Enabled
Issues Count30
Issue Open Count17
Pull Requests Count4
Pull Requests Open Count7
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private