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
|
|||||||||||||||||||||||||||||||||
settings |
object | Settings for the agentmap, filled with defaults.
Properties
|
|||||||||||||||||||||||||||||||||
update_func |
function |
<nullable> |
Function to be called on each update. |
- Source:
Methods
(static) seqUnitAgentMaker()
A standard agentFeatureMaker, which sets an agent's location to be the point at the center of the iᵗʰ unit of the map,
its place property to be that unit's, and its layer_options to be red and of radius .5 meters.
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: