• Stars
    star
    257
  • Rank 158,728 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Leaflet plugin to enable the rotation of map marker icons

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

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.

More Repositories

1

Leaflet.PolylineDecorator

A plug-in for the JS map library Leaflet, allowing to define patterns (like dashes, arrows, icons, etc.) on Polylines.
JavaScript
493
star
2

Leaflet.PolylineOffset

Apply a relative pixel offset to polylines without changing their coordinates.
JavaScript
151
star
3

Leaflet.MagnifyingGlass

A plugin to add a customizable magnifying glass tool to a Leaflet map.
JavaScript
105
star
4

jkstra

JavaScript graph routing library
JavaScript
49
star
5

thread-reader-reader

Parse Twitter thread already simplified by third-party Thread Reader app, and produce dead simple HTML
JavaScript
20
star
6

FirefoxOS.GeoTracker

GPS track recording web app for Firefox OS… and mobile browsers in general.
JavaScript
20
star
7

bird-tracking

Interactive data viz of migrating birds
JavaScript
13
star
8

react-staticMapZoom

A React component which mimics the auto zoom mini-map found on geo-tagged photos Flickr pages.
JavaScript
10
star
9

clean-cnrtl

Clean and responsive proxy to CNRTL French dictionary website
CSS
10
star
10

simple-static-map-server

Raster map service based on MapLibre GL JS
JavaScript
9
star
11

metro-pili

JavaScript
5
star
12

irish-tune-map

A map of irish folk tunes
JavaScript
5
star
13

GeoTracker

JavaScript
3
star
14

updatable-priority-queue

A priority queue implementation based on a binary heap, with an efficient update-key operation
JavaScript
3
star
15

mapbox-gl-style-optimizer

Suggests optimizations to Mapbox-GL style files to improve rendering perfs.
JavaScript
3
star
16

place-place

Place-Place, a place positioning game to test spatial knowledge of your city
TypeScript
3
star
17

pw2014

Atelier Paris Web 2014
JavaScript
2
star
18

alt-route-labeller

A library to compute the best position to put labels on multiple routes between two points
JavaScript
2
star
19

bbecquet

1
star