-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotlyoption.php
More file actions
166 lines (139 loc) · 4.43 KB
/
plotlyoption.php
File metadata and controls
166 lines (139 loc) · 4.43 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
$GLOBALS['CURRENT_PAGE'] = "Map";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Map of the Chicago Crash</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<script src="js/jquery.min.js"></script>
<script src="js/skel.min.js"></script>
<script src="js/skel-layers.min.js"></script>
<script src="js/init.js"></script>
<!--script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script -->
<noscript>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="css/skel.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/style-xlarge.css" />
</noscript>
</head>
<!--style>
.dropdown {
position: relative;
display: inline-block;
min-height: 300px;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
position: absolute;
background-color: #f6f6f6;
min-width: 300px;
border: 1px solid #ddd;
z-index: 1;
}
</style-->
<body>
<!-- Header -->
<?php include "header.php"; ?>
<!-- Main -->
<section id="main" class="wrapper">
<div class="container">
<header class="major">
<h2>Distribution of Chicago Crash</h2>
</header>
<?php
/* Database connection settings */
require 'connection.php';
//query to get data from the table
$sql = "SELECT LATITUDE,LONGITUDE,RD_NO FROM accidents where CRASH_DATE > '2019-01-01'";
$result = $conn->query($sql);
//loop through the returned data
while ($row = mysqli_fetch_array($result)) {
$LATITUDE = $LATITUDE . '"'. $row['LATITUDE'].'",';
$LONGITUDE = $LONGITUDE . '"'. $row['LONGITUDE'].'",';
$RD_NO = $RD_NO . '"'. $row['RD_NO'].'",';
}
$LATITUDE = "[" . rtrim($LATITUDE,","). "]";
$LONGITUDE = "[" . rtrim($LONGITUDE,","). "]";
$RD_NO = "[" . rtrim($RD_NO,","). "]";
?>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v1.9.0/mapbox-gl.js"></script>
<div id="maptest" "container-md"></div>
<script>
var data = [{
type:'scattermapbox',
//locationmode: 'geojson-id',
//geojson: 'https://data.cityofchicago.org/api/geospatial/cauq-8yn6?method=export&format=GeoJSON'
lon: <?php echo $LONGITUDE; ?>,
lat: <?php echo $LATITUDE; ?>,
//hoverinfo:"text",
text: <?php echo $RD_NO; ?>,
mode: 'markers',
marker: {
size: 10,
opacity: 0.8,
//reversescale: true,
//autocolorscale: true,
symbol: 'circle'
//line: {
//width: 1,
//color: 'rgb(102,102,102)'
//},
}
}];
var layout = {
mapbox:{
center: {lon: -87.623177, lat:41.881832},
zoom:10
},
width:1200, height: 1100
};
var config = {mapboxAccessToken: "pk.eyJ1Ijoic2hlaWxhMDEyMWoiLCJhIjoiY2s4a3hycWdmMDNpcTNlbDMzeHBxaGthcSJ9.MVWI71kfFxtL_hfw3Z1Ntw"};
Plotly.newPlot("maptest", data, layout,config);
</script>
<?php
//Get location
require 'connection.php';
$sql = "SELECT location_id, community_area, community_side FROM location Order By 3";
$result = $conn->query($sql);
$location_select = "";
if ($result->num_rows > 0) {
// output data of each row
$location_select = '<select id="location" size="7" name="location[]" class="form-control" multiple><option value="" selected>-select locations-</option>';
while($row = $result->fetch_assoc()) {
$lid = $row["location_id"];
$area = $row["community_area"];
$community = $row["community_side"];
$location_select = $location_select.'<option value="'.$lid.'">'.$area.' - '.$community.'</option>';
}
$result->free();
$location_select = $location_select.'</select>';
}
?>
<form action="update_map.php" method="post">
<?php
if(!empty($_GET['error'])){
echo '<p color="red">'.$_GET['error'].'</p>';
}
?>
Location:
<?php echo $location_select; ?>
<header class="major">
<div class="form-group">
<input type="submit" class="button medium" value="Update Map">
<input type="reset" class="button medium" value="Reset">
</div>
</header>
</form>
</div>
</section>
<!-- Footer -->
<?php include "footer.php"; ?>
</body>
</html>