0.0.12 • Published 11 months ago

l.movemarker v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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

MarkerPolyline
animate markeranimate polyline
duration by speedduration by speed ❌
rotate markershow/hide polyline
show/hide markerlimit max polyline length
disable/enable animate markerdisable/enable animate polyline
stop animate markerstop animate polyline
follow marker when moving

How to install

you can go to npm package

npm i l.movemarker

Import

if you are using ES6, you can import

import 'l.movemarker'

Demo

demodescription
basic demo (codesandbox)basic demo is a simple usage example
basic demo (github)basic demo is a simple usage example
real case demoan 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

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

propstypedefault valuedescription
colorstringredused to set the color of the polylines
weightnumber4used to set the weight of the polylines
animatebooleantruethis will activate the moving animation effect on the polyline
durationnumber5000value in milliseconds, we recommended duration the marker and the polyline must same
hidePolylinesbooleanfalsehide polylines from map, you can also show/hide with method hidePolylines(boolean), for more detail see on method documentation
removeFirstLinesbooleanfalsethis will remove first line of polylines, this prop have relation with prop maxLengthLines
maxLengthLinesnumber3This 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

Marker Options

propstypedefault valuedescription
animatebooleantruethis will activate the moving animation effect on the marker
durationnumber5000value in milliseconds, we recommended duration the marker and the polyline must same
followMarkerbooleanfalsethis will activate the follow marker feature, when the marker moves, the screen will follow the movement of the marker
hideMarkerbooleantruehide marker from map, you can also show/hide with method hideMarker(boolean), for more detail see on method documentation
rotateMarkerbooleanfalsethis will activate the rotation marker and props rotateAngle will be required
rotateAnglenumber00 to 360 degrees
speednumber0if 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

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

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)

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

instance.getMarker()
hideMarker

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

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)

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)

instance.getMarker().activeFollowMarker(true)
getCurrentPolyline

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

instance.getCurrentPolyline()
hidePolylines

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

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)

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

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

thanks, kadek.

0.0.12

11 months ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago