# leaflet-notifications

> Leaflet plugin to show notification (toasts) inside the map

Latest version **1.0.7** (published 2021-07-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install leaflet-notifications
pnpm add leaflet-notifications
yarn add leaflet-notifications
bun add leaflet-notifications
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-07-10 |
| First published | 2021-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Manuel Richter |
| Maintainers | manuel_ri |
| Keywords | leaflet, notification, alerts, messages, toast, plugin |

## Links

- npm: https://www.npmjs.com/package/leaflet-notifications
- Repository: https://gitlab.com/manuel.richter95/leaflet.notifications
- Homepage: https://gitlab.com/manuel.richter95/leaflet.notifications#readme
- Issues: https://gitlab.com/manuel.richter95/leaflet.notifications/issues
- npm.io page: https://npm.io/package/leaflet-notifications

## Dependencies (1)

- [font-awesome](https://npm.io/package/font-awesome.md) ^4.7.0

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2021-07-10
- 1.0.5 — 2021-07-10
- 1.0.4 — 2021-07-09
- 1.0.3 — 2021-07-08
- 1.0.2 — 2021-07-08
- 1.0.1 — 2021-07-08
- 1.0.0 — 2021-07-08

## README

# Leaflet.Notifications [Demo](http://leaflet-notifications.manuel-ri.de/)

A leaflet plugin to show notification messages (toasts) inside the map.
![Image](https://gitlab.com/manuel.richter95/leaflet.notifications/-/raw/master/doc/leaflet-notifications.PNG)

## Installation

```bash
npm install leaflet-notifications
```

## Usage

```javascript
var mymap = L.map('mapid').setView([50, 8], 13);
var notification = L.control
    .notifications({
        timeout: 3000,
        position: 'topright',
        closable: true,
        dismissable: true,
    })
    .addTo(mymap);

//spawn notification popups
notification.alert('Alert', 'some alert message');
notification.info('Info', 'some infomessage');
notification.success('Success', 'some successmessage');
notification.warning('Warning', 'some warning message');
notification.custom('Custom', 'some <span>custom</span> message'); //HTML works for every notification, not only custom()

//custom options per notification
notification.alert('Alert', 'some more important alert message', {
    timeout: 6000,
    closable: false,
    dismissable: false,
    icon: 'fa fa-times-circle',
    className: 'important-alert',
});

/* STYLE CLASS */

/* default (picture 1) */
var notifications = L.control.notifications().addTo(mymap);
/* pastel (picture 2) */
var pastelNotifications = L.control.notifications({ className: 'pastel' }).addTo(mymap);
/* modern (picture 3) */
var modernNotifications = L.control.notifications({ className: 'modern' }).addTo(mymap);
```

### Control options

| Property    | Type          | Default    | Description                                                                                           |
| ----------- | ------------- | ---------- | ----------------------------------------------------------------------------------------------------- |
| timeout     | Number        | 3000       | Time after which the notification will vanish                                                         |
| position    | String        | 'topright' | Position of the notifications. Possible values are _topright_, _topleft_, _bottomright_, _bottomleft_ |
| closable    | Boolean       | true       | Shows a close button on all notifications                                                             |
| dismissable | Boolean       | true       | If true a click on a notification will close it                                                       |
| className   | String        | null       | A custom class name for styling                                                                       |
| icons       | object        | null       | Icon (class) names. Defaults are font-awesome icons                                                   |
| marginLeft  | String/Number | null       | margin-left, e.g. _"5rem"_, _20_, _"30px"_                                                            |
| marginRight | String/Number | null       | margin-right, e.g. _"5rem"_, _20_, _"30px"_                                                           |

#### icons options

| Property | Type   | Default                      | Description             |
| -------- | ------ | ---------------------------- | ----------------------- |
| alert    | String | 'fa fa-exclamation-circle'   | alert icon class name   |
| success  | String | 'fa fa-check-circle'         | success icon class name |
| warning  | String | 'fa fa-exclamation-triangle' | warning icon class name |
| info     | String | 'fa fa-info-circle'          | info icon class name    |
| custom   | String | 'fa fa-cog'                  | custom icon class name  |

> **Hint**: you might need to include the ./node_modules/font-awesome/css/font-awesome.min.css to your project

### Notification options

| Property    | Type    | Default | Description                                                                      |
| ----------- | ------- | ------- | -------------------------------------------------------------------------------- |
| icon        | String  |         | Icon (class) name for the specific notification. Defaults are font-awesome icons |
| timeout     | Number  | null    | Time after which the specific notification will vanish                           |
| closable    | Boolean | true    | Shows a close button                                                             |
| dismissable | Boolean | true    | If true a click on the specific notification will close it                       |
| className   | String  | null    | A custom class name for styling                                                  |

## Methods

| Method                           | Returns | Example                                     | Description                          |
| -------------------------------- | ------- | ------------------------------------------- | ------------------------------------ |
| alert(title, message, options)   | void    | notification.alert("title", "some message") | shows an alert message notification  |
| info(title, message, options)    | void    | notification.alert("title", "some message") | shows an info message notification   |
| success(title, message, options) | void    | notification.alert("title", "some message") | shows a success message notification |
| warn(title, message, options)    | void    | notification.alert("title", "some message") | shows a warning message notification |
| custom(title, message, options)  | void    | notification.alert("title", "some message") | shows a custom message notification  |
| clear()                          | void    | notification.clear()                        | removes all notifications            |

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