Options
All
  • Public
  • Public/Protected
  • All
Menu

A google maps library to replay gps locations with animations.

author

Manpreet Singh

description

A google maps library to replay gps locations with animations.

class

TravelMarker

  • npm package: travel-marker

Hierarchy

  • TravelMarker

Index

Constructors

constructor

  • Creates an instance of TravelMarker.

    Example

    Create default marker

      // options
      const options = {
        map: map,  // map object
        speed: 50,  // default 10 , animation speed
        interval: 30, // default 10, marker refresh time
        speedMultiplier: 1, // default 1, for fast-forward/rewind
        cameraOnMarker: false,  // default false, move camera with marker
        markerOptions: { title: "Travel Marker" }
      };
      let marker = new TravelMarker(options);

    Create Overlay marker

      // options
      const options = {
        map: map,  // map object
        speed: 50,  // default 10 , animation speed
        interval: 30, // default 10, marker refresh time
        speedMultiplier: 1, // default 1, for fast-forward/rewind
        cameraOnMarker: false,  // default false, move camera with marker
        markerType: 'overlay',  // default: 'default'
        overlayOptions: {
          offsetX: 0, // default: 0, x-offset for overlay
          offsetY: 0, // default: 0, y-offset for overlay
          offsetAngle: 0, // default: 0, rotation-offset for overlay
          imageUrl: 'https://i.stack.imgur.com/lDrin.png', // image used for overlay
          imageWidth: 36, // image width of overlay
          imageHeight: 58, // image height of overlay
        }
      };
      let marker = new TravelMarker(options);

    Parameters

    Returns TravelMarker

Properties

Private angle

angle: number = 0

Private delta

delta: any = null

Private deltaCurr

deltaCurr: any = null

Private deltaIndex

deltaIndex: number = 0

Private deltaLast

deltaLast: any = null

event

event: TravelEvents = null

Use events to subscribe to animation events

Example

//  EventType = 'play' | 'paused' | 'finished' | 'reset' | 'checkpoint';
// checkpoint - when marker arrives on a location present in locationArray
// TravelData = {
//  location: LatLng; // marker current location
//  playing: boolean; // is animation playing?
//  index: number;  // index in locationArray
//  status: 'reset' | 'playing' | 'paused' | 'finished';  // animation status
// }
marker.event.onEvent((event: EventType, data: TravelData) => {
  // .... do something
 });

Private index

index: number = 0

Private marker

Private numDelta

numDelta: number = 0

Private options

Private path

path: any[] = []

playing

playing: boolean = false

Tells whether animation is playing or not

Methods

addListener

  • addListener(eventName: string, handler: Function): any
  • Add Listener to maker events like click, mouseover etc.

    Example - Listen for click events

    marker.addListener('click', () => {
        // do something...
      })

    Parameters

    • eventName: string

      click,mousover,mouseout etc.

    • handler: Function

      handler function

    Returns any

addLocation

  • addLocation(locationArray?: LatLng[]): void
  • Add Location points for animation

    Example

    ```ts const locationArray = [new google.maps.Latlng(74,23), new google.maps.LatLng(74.02,23.02), new google.maps.LatLng(74.04, 23.04)];

    marker.addLocation(locationArray); ```

    Parameters

    • Default value locationArray: LatLng[] = []

    Returns void

getOptions

getPosition

  • Return Current position of the marker aa LatLng object.

    Example

    marker.getPosition(); // returns LatLng object

    Returns LatLng

    returns LatLng object

Private isValidOptions

next

  • next(): void

pause

  • pause(): void

play

  • play(): void

prev

  • prev(): void

reset

  • reset(): void

setInterval

  • setInterval(interval?: number): void
  • Set Maker Update interval

    Example

      marker.setInterval(30);

    Parameters

    • Default value interval: number = this.options.interval

    Returns void

Private setListener

  • setListener(): void

setMap

setMarkerOptions

  • Set Marker options like opacity etc. Only applicable for default marker types. Returns false if not applicable

    Example

     marker.setMarkerOptions({ opacity: 0.8 });

    Parameters

    • Default value options: MarkerOptions = this.options.markerOptions

    Returns boolean

    returns false if not applicable

setOverlayOptions

  • setOverlayOptions(options: any): boolean
  • Set Overlay Options like offsets. Only applicable for overlay. Returns false if not applicable

    Example

      marker.setOverlayOptions({ offsetAngle: 90 });

    Parameters

    • options: any

      Overlay Options

    Returns boolean

    returns false if not applicable

setSpeed

  • setSpeed(speed?: number): void
  • Set Animation Speed

    Example

      marker.setSpeed(100);

    Parameters

    • Default value speed: number = this.options.speed

    Returns void

setSpeedMultiplier

  • setSpeedMultiplier(multiplier: number): void
  • Set speed multiplier to control animation speed

    Example

    Fast-Forward by 2X

    marker.setSpeedMultiplier(2);

    Rewind/Slow by 0.5X

    marker.setSpeedMultiplier(0.5);

    Parameters

    • multiplier: number

    Returns void

Object literals

Private defaultMarkerOptions

defaultMarkerOptions: object

draggable

draggable: boolean = false

Private defaultOptions

defaultOptions: object

Defaults for TravelMarkerOptions for constructor

cameraOnMarker

cameraOnMarker: false = false

interval

interval: number = 20

line

line: null = null

map

map: null = null

markerType

markerType: "default" = "default"

speed

speed: number = 35

speedMultiplier

speedMultiplier: number = 1

markerOptions

markerOptions: object

position

position: object

lat

lat: number = 0

lng

lng: number = 0

overlayOptions

overlayOptions: object

imageHeight

imageHeight: number = 58

imageUrl

imageUrl: string = "https://i.stack.imgur.com/lDrin.png"

imageWidth

imageWidth: number = 36

offsetAngle

offsetAngle: number = 0

offsetX

offsetX: number = 0

offsetY

offsetY: number = 0

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc