# l.movemarker

> L.MoveMarker is leaflet plugin used to create moving marker animation and polyline animation

Latest version **0.0.12** (published 2023-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install l.movemarker
pnpm add l.movemarker
yarn add l.movemarker
bun add l.movemarker
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2023-06-21 |
| First published | 2022-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 40.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | I Kadek Teguh Mahesa |
| Maintainers | dekguh |
| Keywords | leaflet, animation marker, animation polyline, moving marker, leaflet plugin, javascript |

## Links

- npm: https://www.npmjs.com/package/l.movemarker
- Repository: https://github.com/dekguh/Leaflet.MoveMarker
- Homepage: https://github.com/dekguh/Leaflet.MoveMarker#readme
- Issues: https://github.com/dekguh/Leaflet.MoveMarker/issues
- npm.io page: https://npm.io/package/l.movemarker

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 0.0.12 (latest) — 2023-06-21
- 0.0.11 — 2022-12-09
- 0.0.10 — 2022-12-08
- 0.0.9 — 2022-12-06
- 0.0.8 — 2022-12-05
- 0.0.7 — 2022-12-04
- 0.0.6 — 2022-12-03
- 0.0.5 — 2022-12-02
- 0.0.4 — 2022-11-30
- 0.0.3 — 2022-11-28
- 0.0.2 — 2022-11-28

## README

### General Information

L.MoveMarker is a leaflet plugin that is used to create moving marker and also trail polylines animation, equipped with a variety of features that are quite complete. plugin currently built in `leaflet version ^1.9.2`.

#### Feature

| Marker                        | Polyline                        |
| ----------------------------- | ------------------------------- |
| animate marker                | animate polyline                |
| duration by speed             | duration by speed ❌            |
| rotate marker                 | show/hide polyline              |
| show/hide marker              | limit max polyline length       |
| disable/enable animate marker | disable/enable animate polyline |
| stop animate marker           | stop animate polyline           |
| follow marker when moving     |                                 |

### How to install

you can go to [npm package](https://www.npmjs.com/package/l.movemarker)

```js
npm i l.movemarker
```

### Import

if you are using ES6, you can import

```js
import 'l.movemarker'
```

### Demo

| demo                                                                                 | description                                                                                      |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
| [basic demo (codesandbox)](https://codesandbox.io/s/l-movemarker-basic-usage-fkdvty) | basic demo is a simple usage example                                                             |
| [basic demo (github)](https://github.com/dekguh/basic-usage-leaflet-movemarker)      | basic demo is a simple usage example                                                             |
| [real case demo](https://github.com/dekguh/real-usage-leaflet-movemarker)            | an example of a real L.MoveMarker implementation using multiple markers and the lat lng mock API |

### First Call

`prevLatLng = [lat, lng]` (required) first position
`nextLatLng = [lat, lng]` (optional) it will be call animate to next position
if you just fill lat lng without nextLatLng, it will still work and will only create marker that are positioned in prevLatLng

```js
const instance = L.MoveMarker(
  [[prevLatLng], [nextLatLng]],
  polylineOptions,
  markerOptions,
  featureGroupOtions
)
```

the `L.MoveMarker` will return the instance layer `L.FeatureGroup` and it inside have many layers L.MotionLine and one layer L.MotionMarker.

### Options

### Polyline Options

| props            | type    | default value | description                                                                                                                     |
| ---------------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| color            | string  | red           | used to set the color of the polylines                                                                                          |
| weight           | number  | 4             | used to set the weight of the polylines                                                                                         |
| animate          | boolean | true          | this will activate the moving animation effect on the polyline                                                                  |
| duration         | number  | 5000          | value in milliseconds, we recommended duration the marker and the polyline must same                                            |
| hidePolylines    | boolean | false         | hide polylines from map, you can also show/hide with method hidePolylines(boolean), for more detail see on method documentation |
| removeFirstLines | boolean | false         | this will remove first line of polylines, this prop have relation with prop maxLengthLines                                      |
| maxLengthLines   | number  | 3             | This prop used to limit the number of polylines and if it exceeds the limit then the first polyline will be deleted             |

You can also fill in the default options polyline from the leaflet polyline [options polyline](https://leafletjs.com/reference.html#polyline-option)

#### Marker Options

| props        | type    | default value | description                                                                                                               |
| ------------ | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
| animate      | boolean | true          | this will activate the moving animation effect on the marker                                                              |
| duration     | number  | 5000          | value in milliseconds, we recommended duration the marker and the polyline must same                                      |
| followMarker | boolean | false         | this will activate the follow marker feature, when the marker moves, the screen will follow the movement of the marker    |
| hideMarker   | boolean | true          | hide marker from map, you can also show/hide with method hideMarker(boolean), for more detail see on method documentation |
| rotateMarker | boolean | false         | this will activate the rotation marker and props rotateAngle will be required                                             |
| rotateAngle  | number  | 0             | 0 to 360 degrees                                                                                                          |
| speed        | number  | 0             | if the speed value is filled then the duration props will not work and the value unit is km/h                             |

You can also fill in the default options marker from the leaflet marker [options marker](https://leafletjs.com/reference.html#marker-option)

### Feature Group Options

currently we dont make specific props for feature group, you can also fill in the default options feature group from the leaflet feature group [options feature group](https://leafletjs.com/reference.html#featuregroup)

### Methods

after you make a first call, you can call severals method from the instance

##### addMoreLine

this method used to add more line and move the marker, example usage method `addMoreLine(latLng, options)`

```js
instance.addMoreLine([-8.822512, 115.186803], {
  duration: 5000, // in milliseconds (optional)
  speed: 25, // in km/h (optional)
  rotateAngle: 141, // (required if rotateMarker enable)
  animatePolyline: true, // (required)
})
```

##### getMarker

this is used to get marker instance and will return object class of marker, example usage method `getMarker()`

```js
instance.getMarker()
```

##### hideMarker

this is used to hide/show the marker and this method called from `getMarker`, example usage method `getMarker().hideMarker(boolean)`

```js
instance.getMarker().hideMarker(true)
```

##### activeAnimate (marker)

this is used to enable/disable the marker and this method called from `getMarker`, example usage method `getMarker().activeAnimate(boolean)`

```js
instance.getMarker().activeAnimate(true)
```

##### activeFollowMarker

this used to disable/enable screen follow the marker moving and this method called from `getMarker`, example usage method `getMarker().activeFollowMarker(boolean)`

```js
instance.getMarker().activeFollowMarker(true)
```

##### getCurrentPolyline

this is used to get the polyline instance which is moving, example usage method `getCurrentPolyline()`

```js
instance.getCurrentPolyline()
```

##### hidePolylines

this is used to hide/show the polylines and this method not called from `getCurrentPolyline`, example usage method `hidePolylines(boolean)`

```js
instance.hidePolylines(true)
```

##### activeAnimate (polyline)

this is used to disable/enable the current polyline which is moving and this method called from `getCurrentPolyline`, example usage method `getCurrentPolyline().activeAnimate(boolean)`

```js
instance.getCurrentPolyline().activeAnimate(true)
```

##### stop

This is used to end the animation of the marker and polyline that are currently in moving animation and this method not called from `getCurrentPolyline`, example usage method `stop()`

```js
instance.stop()
```

### Report Issue/Question

if you have a question about `L.MoveMarker` or if you found a bug, you can make a issue, more detail how to make a report/question [here](https://github.com/dekguh/Leaflet.MoveMarker/issues/4)

thanks,
kadek.

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