Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces

traffic.provider.Forecast

Extends ITrafficProvider.

Provider for the traffic forecast. Accessible in the provider storage by the key 'traffic#forecast'.

Constructor | Fields | Events | Methods

Constructor

traffic.provider.Forecast([options[, state]])

Creates a provider for the traffic forecast.

Parameters:

ParameterDefault valueDescription
options

Type: Object

Provider options. Options for provider layers are set via the options for the global collection of layers, Map.layers.

  • Options for the image layer Layer are defined with the 'trafficImage' prefix.
  • Options for the hotspot layer hotspot.Layer are defined with the 'trafficJam' prefix.

options.autoUpdate true

Type: Boolean

Flag that enables automatically updating traffic data. Automatic updates occur only when the "mousemove" event occurs every 4 minutes on the map. If this event does not occur, traffic stops being updated until there is a new event.

state

Type: Object

Provider state.

state.timeOffset 900

Type: Boolean

time interval between the current time and forecast time. Measured in seconds, in 15-minute intervals (900 seconds).

// Creating a traffic provider that predicts traffic in half an hour,
// and putting it on the map.
var forecastProvider = new ymaps.traffic.provider.Forecast({}, {timeOffset: 30 * 60});
forecastProvider.setMap(myMap);

// Forbidding displaying popup hints for traffic.
myMap.layers.options.set({
    // The option name is formed by adding the 'trafficJam' prefix
    // to the hotspot layer option 'openHintOnHover'.
    trafficJamOpenHintOnHover: false
});
// ...
// Removing the provider from the map.
forecastProvider.setMap(null);

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

statedata.Manager

Provider state. Names of fields that are available via the data.Manager.get method:

  • isInited - Flag for whether the provider is ready to provide data.
  • timestamp - Current time in Unix timestamp format, in seconds.
  • localtime - Local time that the server is currently sending data for, in the format HH:MM.
  • level - Traffic level in points from 0 to 10.
  • timeOffset - Time interval between the current time and forecast time. Measured in seconds, in 15-minute intervals (900 seconds)
  • isotime - String containing the current date in the format "YYYY-MM-DDThh:mm:ss±hhmm".

Events

NameDescription
optionschange

Change to the object options.

Inherited from ICustomizable.

Methods

NameReturnsDescription
getMap()

Map|null

Returns reference to the map.

Inherited from ITrafficProvider.

getTime()

Object|null

Returns the time the user sees in the traffic control. The object has the following fields:

  • dayOfWeek - Abbreviations of days of the week. 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'.
  • hours - Hours.
  • minutes - Minutes.
If the map center is located at a point that we cannot determine the time zone for, the function returns null; if we don't know which time zone we are in, we can't find out the local time.

setMap(Reference)

Fields details

state

{data.Manager} state

Provider state. Names of fields that are available via the data.Manager.get method:

  • isInited - Flag for whether the provider is ready to provide data.
  • timestamp - Current time in Unix timestamp format, in seconds.
  • localtime - Local time that the server is currently sending data for, in the format HH:MM.
  • level - Traffic level in points from 0 to 10.
  • timeOffset - Time interval between the current time and forecast time. Measured in seconds, in 15-minute intervals (900 seconds)
  • isotime - String containing the current date in the format "YYYY-MM-DDThh:mm:ss±hhmm".

Methods details

getTime

{Object|null} getTime()

Returns the time the user sees in the traffic control. The object has the following fields:

  • dayOfWeek - Abbreviations of days of the week. 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'.
  • hours - Hours.
  • minutes - Minutes.
If the map center is located at a point that we cannot determine the time zone for, the function returns null; if we don't know which time zone we are in, we can't find out the local time.