Class: Agentmap

Agentmap(map)

new Agentmap(map)

The main class for building, storing, simulating, and manipulating agent-based models on Leaflet maps.
Parameters:
Name Type Description
map object A Leaflet Map instance.
Properties:
Name Type Attributes Description
map object A Leaflet Map instance.
agents FeatureGroup A featureGroup containing all agents.
units FeatureGroup A featureGroup containing all units.
streets FeatureGroup A featureGroup containing all streets.
state object Properties detailing the state of the simulation process.
Properties
Name Type Attributes Description
running boolean Whether the simulation is running or not.
paused boolean Whether the simulation is paused.
animation_frame_id number <nullable>
The id of the agentmap's update function in the queue of functions to call for the coming animation frame.
time number <nullable>
The time elapsed since the start of the simulation.
ticks number <nullable>
The number of ticks elapsed since the start of the simulation.
prev_time number <nullable>
The time (time in seconds) when the last update was started.
time_start_delay number <nullable>
Ticks corresponding to the time of the last animation frame before the trip started. Subtracted from all subsequent time measurements so that the clock starts at 0, instead of whatever the actual time of that initial animation frame was.
settings object Settings for the agentmap, filled with defaults.
Properties
Name Type Description
movement_precision number On each interval of this many miliseconds between requestAnimationFrame calls, the agent's movements will be updated (for more precise movements than just updating on each call to requestAnimationFrame (60 fps max)).
update_func function <nullable>
Function to be called on each update.
Source:

Methods

(static) agent()

Returns an agent object.
Source:

(static) seqUnitAgentMaker()

A standard agentFeatureMaker callback, which sets an agent's location as the center of a unit on the map.
Source:

getNearestIntersection(lat_lng, place) → {LatLng}

Given a point on a street, find the nearest intersection on that street (with any other street).
Parameters:
Name Type Description
lat_lng LatLng The coordinates of the point on the street to search from.
place Place A place object corresponding to the street.
Source:
Returns:
- The coordinates of the nearest intersection.
Type
LatLng

getStreetNearDoor(unit_id) → {LatLng}

Get the point on the adjacent street in front of the unit's door.
Parameters:
Name Type Description
unit_id number The unique id of the unit whose door's corresponding point on the street you want.
Source:
Returns:
- The coordinates point of the adjacent street directly in front of unit's door.
Type
LatLng

getUnitDoor(unit_id) → {LatLng}

Get a point through which an agent can exit/enter a unit.
Parameters:
Name Type Description
unit_id number The unique id of the unit whose door you want.
Source:
Returns:
- The coordinates of the center point of the segment of the unit parallel to the street.
Type
LatLng

pause()

Stop the animation, stop updating the agents.
Source:

reset()

Stop the animation, reset the animation state properties, and delete the agents.
Source:

run()

Get an animation frame, have the agents update & get ready to be drawn, and keep doing that until paused or reset.
Source:

(private) update(rAF_time)

Update the simulation at the given time.
Parameters:
Name Type Description
rAF_time number Time passed by the browser's most recent animation frame.
Source: