Skip to content
Evan Siroky edited this page Dec 15, 2016 · 6 revisions

API

Transitive(options)

Creates a new Transitive instance. Options include:

  • data (Object) - the Transitive data object to render (see example)
  • styles (Object) - styles to apply (see example)
  • el (Element) - the DOM element to render the main display to
  • legendEl (Element) - the DOM element to render the legend to
  • drawGrid (Boolean) - whether to draw a background grid (defaults to false)
  • gridCellSize (Number) - resolution of the grid in Spherical Mercator meters
  • draggableTypes (Array) - a list of network element types to enable dragging for
  • initialBounds (Array) - initial lon/lat bounds for the display expressed as [[west, south], [east, north]]
  • displayMargins (Object) - padding to apply to the initial rendered network within the display. Expressed in pixels for top/bottom/left/right
  • mapboxId (String) - an Mapbox tileset id for rendering background tiles (Deprecated -- use Leaflet with Leaflet.TransitiveLayer)
  • zoomEnabled (Boolean) - whether to enable the display's built-in zoom/pan functionality (defaults to true)
  • autoResize (Boolean) - whether the display should listen for window resize events and update automatically (defaults to true)
  • zoomFactors (Object Array) - detailed control over zoom-sensitive rendering. See full documentation.

.setElement(element, legendElement)

Sets/updates the main container DOM element, and (optionally), a separate element for the legend.

.setRenderer(type)

Updates the current Renderer used to draw the network. Current supported types are 'default' (the standard network renderer) and 'wireframe' (draws a simplified representation of the graph edges and vertices, useful for testing/debugging).

.render()

Creates and renders the transitive network for the currently loaded Transitive data object.

.renderTo(element)

Sets the container element and renders the network in a single call.

.refresh()

Redraws a rendered network, e.g. on a pan/zoom action (calls render() first if network has not been rendered).

.clearData()

Clears the current Transitive data object.

.updateData(data)

Updates the current Transitive data object.

.focusJourney(journeyId)

Highlights a specific journey (i.e. an individual path through the network) using the journey's id as defined in the Transitive data object.

.getModeStyles(mode)

Returns an object containing the display's current SVG styling for a given mode, as defined by an OTP mode identifier ("WALK", "BUS", etc.)

.setDisplayBounds(llBounds)

Sets the lon/lat bounding box for the display, expressed as [ [west, south], [east, north] ]

.getNetworkBounds()

Returns the lon/lat bounding box for the currently loaded network, expressed as [ [west, south], [east, north] ]

.resize(width, height)

Updates the dimensions of the display in pixels