Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanocudini/leaflet-compass
Leaflet plugin to show a rotating Compass!
https://github.com/stefanocudini/leaflet-compass
compass javascript leaflet-plugin leafletjs mapping mobile-app webmapping
Last synced: 4 days ago
JSON representation
Leaflet plugin to show a rotating Compass!
- Host: GitHub
- URL: https://github.com/stefanocudini/leaflet-compass
- Owner: stefanocudini
- License: mit
- Created: 2014-07-12T20:52:31.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-26T22:51:44.000Z (over 1 year ago)
- Last Synced: 2025-01-08T14:33:18.140Z (12 days ago)
- Topics: compass, javascript, leaflet-plugin, leafletjs, mapping, mobile-app, webmapping
- Language: JavaScript
- Homepage: https://opengeo.tech/maps/leaflet-compass/
- Size: 982 KB
- Stars: 95
- Watchers: 7
- Forks: 23
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
Leaflet.Control.Compass
============[![npm version](https://badge.fury.io/js/leaflet-compass.svg)](https://badge.fury.io/js/leaflet-compass)
A leaflet control plugin to make simple rotating compass
If this project helped your work help me to keep this alive by [Paypal **DONATION ❤**](https://www.paypal.me/stefanocudini)
Tested in Leaflet 0.7 and 1.2
require HTML5 API on mobile device!
**Try the Demo online here:**
[opengeo.tech/maps/leaflet-compass](https://opengeo.tech/maps/leaflet-compass/)**Tested platforms:**
this project needs many tests on different devices, please help us using the demo page and report problems by opening an issue.
* Chrome on Android
* Safari on iOS![Image](./images/leaflet-compass.png)
# Usage
Adding the Compass Control to the map:
```
map.addControl( new L.Control.Compass() );```
# Options
| Option | Default | Description |
| ----------- | -------- | ----------------------------- |
| autoActive | false | activate control at startup |
| showDigit | false | show angle value bottom compass |
| textErr | '' | error message on alert notification |
| callErr | null | function that run on compass error activating |
| angleOffset | 2 | min angle deviation before rotate, big angleOffset is need for device have noise in orientation sensor |
| position | 'topright' | position of control inside map |# Methods
| Method | Arguments | Description |
| ----------- | -------------- | ----------------------------- |
| autoActive | false | activate control at startup |
| getAngle | | return Azimut angle |
| setAngle | angle | set rotation compass |
| activate | | active tracking on runtime |
| deactivate | | deactive tracking on runtime |# Events
| Event | Data | Description |
| ----------------- | -------------- | ----------------------------------- |
| 'compass:rotated' | angle | fired after compass data is rotated |
| 'compass:disabled'| | fired when compass is disabled |# Where
**Source code:**
[Github](https://github.com/stefanocudini/leaflet-compass)
[NPM](https://npmjs.org/package/leaflet-compass)