-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php.vis2
35 lines (31 loc) · 1.18 KB
/
index.php.vis2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once('customer.php');
// Generate a JSON-formatted string that holds the name and location of each customer.
$places .= '\'{"type": "FeatureCollection","features": [';
// Append data from each row
$comma = "";
foreach (get_sample_customers() as $key=>$customer) {
$places .= $comma.'{ "type": "Feature", "properties": { "name": "['.($key+1)."] ".$customer->first_name." ".$customer->last_name.'" }, "geometry": { "type": "Point", "coordinates": [ '.$customer->longitude.', '.$customer->latitude.' ] } }';
$comma = ",";
}
$places .= ']}\'';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo gethostname(); ?>: Customers</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<script src="vis.js"></script>
<script type="text/javascript">
function show_customers() {
create_map(JSON.parse(<?php echo $places; ?>));
}
window.onload = show_customers;
</script>
</body>
</html>