Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Demo

This is a runnable demo. Copy all files in the `demo` folder to your local computer and open de `index.html` file. Or fork the whole repo and serve it via Github Pages. Be sure to refer to the demo folder in your url: *yourorganizationname*.github.io/AgentMaps/demo/index.html
40 changes: 40 additions & 0 deletions demo/agentmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

let boundings = [
[39.9058, -86.091],
[39.8992, -86.1017],
]

let map = L.map("demo").fitBounds(boundings)

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map)

let agentmap = L.A.agentmap(map)

console.log(boundings)

agentmap.buildingify(boundings, mdata)
agentmap.agentify(50, agentmap.seqUnitAgentMaker)
if (agentmap.state.ticks % 300 === 0) {
agentmap.agents.eachLayer(function (agent) {
let random_index = Math.floor(
agentmap.units.count() * Math.random()
),
random_unit = agentmap.units.getLayers()[random_index],
random_unit_id = agentmap.units.getLayerId(random_unit),
random_unit_center = random_unit.getBounds().getCenter()

agent.scheduleTrip(
random_unit_center,
{ type: "unit", id: random_unit_id },
1,
false,
true
)
agent.controller = function () {
agent.moveIt()
}
})
}
agentmap.run()
40 changes: 40 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="Description" content="Enter your description here" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""
/>
<script
src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""
></script>
<script src="https://unpkg.com/[email protected]/site/dist/agentmaps.js"></script>
<link rel="stylesheet" href="styles.css" />
<title>AgentMaps</title>
</head>
<body>
<div class="d-flex justify-content-center">
<div class="m-5" id="demo"></div>
</div>
<script src="mapdata.js"></script>
<script src="agentmap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.2/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.0/js/bootstrap.min.js"></script>
</body>
</html>
Loading