The MapWeave observations layer shows identifiable real-world beings or objects, such as a person or vehicle, at a particular time and location. It consumes data made up of multiple observations in a format that uniquely identifies each entity - the object or being - with a location and time stamp. MapWeave can then 'connect-the-dots' to infer the trajectory - the path taken - of each entity.
Data Format
An example of ObservationsLayerData is as follows:
const vehicleObservations = {
entities: { vehicle1: { color: '#F2A688' } },
observations: {
vehicle1_1: {
type: 'observation',
entityId: 'vehicle1',
latitude: 49.2827,
longitude: -123.1207,
time: new Date('2024-12-16T08:00:00'),
},
vehicle1_2: {
type: 'observation',
entityId: 'vehicle1',
latitude: 49.2835,
longitude: -123.1167,
time: new Date('2024-12-16T08:05:00'),
},
vehicle1_3: {
type: 'observation',
entityId: 'vehicle1',
latitude: 49.284,
longitude: -123.1123,
time: new Date('2024-12-16T08:10:00'),
},
vehicle1_4: {
type: 'observation',
entityId: 'vehicle1',
latitude: 49.2832,
longitude: -123.1085,
time: new Date('2024-12-16T08:15:00'),
},
vehicle1_5: {
type: 'observation',
entityId: 'vehicle1',
latitude: 49.2808,
longitude: -123.106,
time: new Date('2024-12-16T08:20:00'),
},
},
}; Entities
An entity is a physical object or being that can be tracked as it moves through space and time, and can be assigned a color. In the API, an entity is defined as an ObservedEntity in ObservationsLayerData.
You can control whether entities are displayed as individual observations, trajectories or both by changing the mode set in the ObservationsLayerOptions.
They are displayed in 'auto' mode by default. Set the min and max zoom levels in the autoRange objects to determine when MapWeave switches between individual observations and trajectories.
The example below shows the path of a drone with both individual observations and the inferred trajectory. Both the observations and the trajectory inherit the color of the entity.
MapWeave Example
Log in to view live examplesMapWeave Example
Log in to view live examplesObservations
Observations are a series of records that capture the time, latitude and longitude of an entity. Each observation can also be assigned a color.
When the observations are shown individually (by setting the mode to 'individual' or 'auto'), each observation is represented on the map by a circle. The radius of the circle can be set using the minimumRadiusMeters and radiusPixels properties in the individual object in ObservationsLayerOptions.
A code snippet is shown below. Open the example in the playground to see the full code.
MapWeave Example
Log in to view live examplesMapWeave Example
Log in to view live examplesconst observationsLayerOptions = {
mode: 'individual',
};
const microAerialVehicleLayer = new ObservationsLayer({
data: microAerialVehicle,
options: observationsLayerOptions,
}); const observationsLayerOptions = { mode: 'individual' };
function App() {
return (
<>
<MapWeave options={options}>
<ObservationsLayer data={microAerialVehicle} options={observationsLayerOptions} />
</MapWeave>
</>
);
} Trajectories
MapWeave can infer the trajectory, or path, of an entity by linking its observations with a line. Trajectories are created only when the observations are within a set time interval.
When the observations are shown as trajectories (by setting the mode to 'trajectory' or 'auto'), the path is represented on the map by a line. The width of the line can be set using the minimumWidthMeters and widthPixels properties in the trajectory object in ObservationsLayerOptions.
By default, MapWeave infers a trajectory when consecutive observations are less than 60,000 milliseconds (1 minute) apart. The interval can be set using the maximumInterval property.
In this example, maximumInterval is set to 27,000 milliseconds, so two separate trajectories are created.
A code snippet is shown below. Open the example in the playground to see the full code.
MapWeave Example
Log in to view live examplesMapWeave Example
Log in to view live examplesconst observationsLayerOptions = {
mode: 'trajectory',
trajectory: {
maximumInterval: 27000,
},
};
const microAerialVehicleLayer = new ObservationsLayer({
data: microAerialVehicle,
options: observationsLayerOptions,
}); const observationsLayerOptions = {
mode: 'trajectory',
trajectory: {
maximumInterval: 27000,
},
};
function App() {
return (
<>
<MapWeave options={options}>
<ObservationsLayer data={microAerialVehicle} options={observationsLayerOptions} />
</MapWeave>
</>
);
} Tracker Nodes
You can associate a trajectory with a node on a network layer by giving the entity in observations layer data the same id as the networkNode in network layer data. These nodes are called tracker nodes and can be dragged along a trajectory to estimate the location of an entity at the currentTime.
Use networkLayerId to specify the network layer that contains the tracker node.