React
ObservationsLayer
The observations layer allows you to track entities as they move around the map. See the Observations Layer docs for more details.
Parameters
object
data
optionalThe data to load into the layer.
id
optionalstringA unique id of the layer. If not specified, it will be generated automatically.
options
optionalThe options to set on the layer.
Overrides the style properties set in ObservedEntity and Observation.
ref
optionalRefObject<LayerRefProps>Ref prop for use with React's useRef or createRef. This allows access to the imperative part of the layer's API.
visible
optionalbooleanWhether the layer is visible.
Returns ReactNode
Defines the observation of an entity at a specific place and time.
color
optionalstringThe color of the observation.
stringThe id of the observed entity.
numberThe latitude of the observation in degrees. Should be in the range -90 to 90.
numberThe longitude of the observation in degrees. Should be in the range -180 to 180.
number | DateThe time of the observation as a Date in local time or a millisecond number in UTC.
"observation"The type of the item.
Defines the style properties to override for the specified observed entities and observations.
string | string[]The id or ids of the ObservedEntity or Observation items.
The style properties to apply to the specified observed entities and observations.
ObservationsItemObservation | TrajectoryAn observation or trajectory that can appear in the ObservationsLayer.
Defines the data to load into the ObservationsLayer.
Record<string, ObservedEntity>A dictionary of observed entities, where the keys are the entity ids and the values are ObservedEntity objects.
Record<string, Observation>A dictionary of observations, where the keys are the observation ids and the values are Observation objects.
ObservationsLayerMode"individual" | "trajectory" | "auto"Defines how individual observations and trajectories are shown. If set to 'auto', the individual observations are displayed as defined in individual.autoRange and trajectories are displayed as defined in trajectory.autoRange.
Options related to the observations layer.
autoModeFadeTime
optionalnumberdefault: 500Time in milliseconds to change between 'individual' and 'trajectory' when ObservationsLayerMode is set to 'auto'.
backgroundAlpha
optionalnumberdefault: 0.2The alpha value to apply to observations that are not within the timeForegroundRange.
individual
optionalobjectOptions applied when observations are shown individually.
autoRange
optionalobjectDefines the range of zoom levels where individual observations are displayed when ObservationsLayerMode is set to 'auto'.
max
optionalnumberdefault: 22The maximum zoom level at which individual observations are displayed. Must be in the range 0 to 22 where 0 is fully zoomed out and 22 is fully zoomed in.
min
optionalnumberdefault: 14The minimum zoom level at which individual observations are displayed. Must be in the range 0 to 22 where 0 is fully zoomed out and 22 is fully zoomed in.
minimumRadiusMeters
optionalnumberdefault: 1Minimum radius of individual observations in meters. If set alongside radiusPixels, the option that creates the largest circle will be used.
radiusPixels
optionalnumberdefault: 2Radius of individual observations in pixels. If set alongside minimumRadiusMeters, the option that creates the largest circle will be used.
mode
optionalObservationsLayerModedefault: 'auto'The mode of the observations layer.
timeFilterRange
optionalTimeRangedefault: nullThe time filter range. If non-null, observations will be hidden if their time is fully outside the range.
timeForegroundRange
optionalTimeRangedefault: nullDefines the time range of the observations to be foregrounded, which emphasizes foregrounded observations by fading the rest into the background. If set, will override timeFilterRange.
trackerNodes
optionalobjectOptions applied to tracker nodes, which are associated with an entity by a shared id. See the Tracker Nodes docs for more.
currentTime
optionalnumber | Datedefault: nullThe time at which to place a tracker node on a trajectory as a Date in local time or a millisecond number in UTC.
networkLayerId
optionalstringdefault: nullThe id of a NetworkLayer. Nodes in NetworkLayerData with an id that matches an entityId will have their position constrained to the corresponding trajectory.
trajectory
optionalobjectOptions applied when observations are shown as a trajectory. See the Trajectory docs for more.
autoRange
optionalobjectDefines the range of zoom levels where trajectories are displayed when ObservationsLayerMode is set to 'auto'.
max
optionalnumberdefault: 22The maximum zoom level at which trajectories are displayed. Must be in the range 0 to 22 where 0 is fully zoomed out and 22 is fully zoomed in.
min
optionalnumberdefault: 0The minimum zoom level at which trajectories are displayed. Must be in the range 0 to 22 where 0 is fully zoomed out and 22 is fully zoomed in.
maximumInterval
optionalnumberdefault: 60000Two observations must occur in a specified time period to be considered as part of the same trajectory. This value defines this interval, in milliseconds.
minimumWidthMeters
optionalnumberdefault: 0.5Minimum width of trajectory lines in meters. If set alongside widthPixels, the option that creates the thickest line will be used.
opacity
optionalnumberdefault: 1Opacity of trajectory lines. Must be in the range 0 to 1 where 0 is transparent and 1 is fully visible.
widthPixels
optionalnumberdefault: 1Width of trajectory lines in pixels. If set alongside minimumWidthMeters, the option that creates the thickest line will be used.
An instance method to return the bounds of the items in the layer with the specified ids, or all items if no ids are specified. Returns null if there are no items to compute bounds for.
Parameters
- ids optional
string[]
Returns LngLatBounds
An object defining the bounds of the specified items.
Specifies the properties of an Observation that can be overridden with overrideStyles.
color
optionalstringThe color of the observation.
Defines the entity that is observed in the ObservationsLayer. Each entity has one or more observations.
color
optionalstringdefault: 'white'The color of the entity shown on the map.
Specifies the properties of an ObservedEntity that can be overridden with overrideStyles.
color
optionalstringdefault: 'white'The color of the entity shown on the map.
Defines an inferred path from more than one observation of the same entity.
stringThe id of the entity.
The observations of the entity in time order.
"trajectory"The type of the item.