API Docs for: 2.2
Show:

MQ.Routing.RouteLayer Class

Extends L.LayerGroup

Constructor

MQ.Routing.RouteLayer

(
  • options
)
MQ.Routing.RouteLayer

Parameters:

  • options Object
    • directions MQ.Routing.Directions
    • [fitBounds] Object | Boolean default = false
    • [draggable] Boolean default = true
    • [ribbonOptions] Object optional
      • [ribbonDisplay] Object optional
      • [ribbonDisplay.color] String optional
      • [ribbonDisplay.opacity] Number optional
      • [widths] defaults to `[10,10,10,10,9,8,7,7,7,6,6,6,6,7,8,9,10] Array optional `
    • [altRibbonOptions] Object optional
      • [show] Boolean default = true
      • [selectTime] Number default = 1000
      • [ribbonDisplay] Object optional
      • [ribbonDisplay.color] String default = '#F78181'
      • [ribbonDisplay.opacity] Number default = 0.7
      • [hoverDisplay] Object optional
      • [hoverDisplay.color] String default = 'red'
      • [hoverDisplay.opacity] Number default = 0.6

Properties

dragIntervalMs

Number

The interval at which to process route drags. Once entering the drag state, the interval timer will be started to recur at this frequency (in millis). When leaving the drag state, the interval timer will be stopped. Drag route calls are fairly expensive, so we use this interval to buffer out multiple mousemove events.

Default: 333

ribbonOverscanFactor

Number

Factor by which to expand the bounds of the map when requesting shape points (applies to width and height of the map viewport). Allows map drags to occur without having to request a new ribbon shape as often.

Default: 5.0

routeData

Unknown

Route Data

Methods

_addAltRibbon

(
  • shapePoints
)
MQ.Routing.Ribbon private

Parameters:

Returns <MQ.Routing.Ribbon>

_altRouteShapeCallback

(
  • shapeResponse
)
private

Called when route shape information is loaded for an alternate route ribbon

Parameters:

_clear

() private

Remove all managed map objects and reset state.

_construct

(
  • routeData
  • mapState
  • shape
)
private

Constructs managed route objects from a new routeData

Parameters:

_constructLocations

(
  • locations
)
private

Construct locations

Parameters:

_dragDispatcher

() private

Setup on an interval for the duration of a drag gesture to process new requests scheduled with _queueDragRequest.

_onAlternateSuccess

(
  • result
)
private

Parameters:

_onDirectionsError

(
  • error
)
private

Parameters:

_onDirectionsSuccess

(
  • result
)
private

Parameters:

_queueDragRequest

(
  • dragRequest
)
private

Queues a new drag request

Parameters:

_removeAltRibbons

() private

_routeShapeCallback

(
  • shapeResponse
)
private

Called when route shape information is loaded for the main route ribbon.

Parameters:

_schedRibbonUpdate

() private

Called when the ribbon bounds are about to be violated. Schedules a new shape point download.

_setHoverMessage

(
  • route
  • [location]
  • [ribbon]
)
private

Parameters:

_stopDragTime

() private

Ensure that the drag timer and dispatch loop are stopped following completion of a drag gesture.

_updateRibbonInfo

() private

_validateMap

() private

Called when the map position or zoom changes

_validateRibbonAttrs

() private

validate ribbon attrs

addAltRouteData

(
  • altRouteData
  • ribbon
)

Parameters:

clearDragState

()

clears drag state

createEndMarker

(
  • location
  • stopNumber
)
L.Marker

Create a Marker for the last stop of a route.

Parameters:

  • location Object

    the object representing the location associated with the marker

  • stopNumber Number

    the index of the location

Returns <L.Marker>

the created Marker

createStartMarker

(
  • location
  • stopNumber
)
L.Marker

Create a Marker for the first stop.

Parameters:

  • location Object

    the object representing the location associated with the marker

  • stopNumber Number

    the index of the location

Returns <L.Marker>

the created Marker

createStopMarker

(
  • location
  • stopNumber
)
L.Marker

Create a Marker for a given stop.

Parameters:

  • location Object

    the object representing the location associated with the marker

  • stopNumber Number

    the index of the location

Returns <L.Marker>

the created Marker

createViaMarker

(
  • location
  • locIndex
)
L.marker

Create a Marker for a given via location. Return null if a marker should not be created.

Parameters:

  • location Object

    the location associated with the POI

  • locIndex Number

    the index associated with the POI

Returns <L.marker>

the created via marker

customizeInvisibleRibbon

(
  • ribbon
)

Make an invisible ribbon for the traffic polyline ribbon

Parameters:

customizeMarker

(
  • marker
)

Called after a POI is created in provide a chance to customize it. This method does nothing in the delegate and can be completely overriden by sub classes.

Parameters:

  • marker L.Marker

    the created poi

customizeRibbonAtZoom

(
  • ribbon
  • zoom
)

Parameters:

fitBounds

(
  • boundsOpts
)

Parameters:

getBounds

()

Get the bounds of the entire route

initialize

(
  • options
)

Parameters:

onAdd

(
  • map
)

Parameters:

onRemove

(
  • map
)

Parameters:

onRibbonDrag

(
  • event
)

Handles ribbon drag

Parameters:

onRibbonDragEnd

()

on ribbon drag end

onRibbonDragStart

(
  • event
)

setup ribbon drag starting

Parameters:

recomputeChangedRoute

(
  • newLocations
)

Called when a drag route completes and a new via point needs to be created. This method should reconstruct the locations with the inserted via location, re-run the route and either call setRouteData on success or clearDragState on failure/cancel in order to remove the drag state.

Parameters:

virtualMapState

(
  • map
)

Returns a map state object spanning the desired expanded size of the map for the purposes of drawing route ribbons.

Parameters:

  • map L.Map

Events

altRibbonSelected

Fired when an alternate route ribbon has been selected on mobile via tap-and-hold touch event must last at least selectTime milliseconds as set in the routeLayer config (defaults to 1000ms)

Event Payload:

altRibbonUpdated

Fired when an alternate route ribbon has been updated with new shape data

Event Payload:

markerDrag

Fired for each movement during the drag event on a POI/marker The returned Marker object has a property (stopNumber) which is the index of that marker on the route (1 = origin)

Event Payload:

  • response L.Marker

markerDragEnd

Fired when the drag event on a POI/marker has completed The returned Marker object has a property (stopNumber) which is the index of that marker on the route (1 = origin)

Event Payload:

  • response L.Marker

markerDragStart

Fired at the beginning of a drag event on a POI/marker The returned Marker object has a property (stopNumber) which is the index of that marker on the route (1 = origin)

Event Payload:

  • response L.Marker

routeRibbonUpdated

Fired when the main route ribbon has been updated with new shape data

Event Payload: