forked from kjahan/VanCityTalks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·151 lines (138 loc) · 4.38 KB
/
index.php
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
<?php
//$curTime_mongo = microtime(true);
error_reporting(E_ALL);
require_once '/var/www/VanCityTalks/segmentation.php';
require_once '/var/www/VanCityTalks/rank.php';
require_once '/var/www/VanCityTalks/helper.php';
//define radius for segmentation
$radius = 1.0;
//segmentize first
$segments = new Segmentation;
$segments->segmentize($radius);
//var_dump($segments);
$rank = new Rank();
//print_r($rank);
$rank->computeScores($segments->regions);
$scores = $rank->getScores();
//$mongo_timeConsumed = round(microtime(true) - $curTime_mongo,3);
//print "mongo total time: $mongo_timeConsumed<br />";
//print_r($scores);
$helper = new Helper;
$js_array = $helper->phpArrayToJSArray($scores);
//print_r($js_array);
?>
<!DOCTYPE html>
<html>
<head>
<title>Vancouver City Talks</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 25px; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?libraries=visualization&key=AIzaSyDTd_bReBaN0_QCy2OvqCczXEHoD6pMrmQ&sensor=false">
</script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="maps/getareas.js"></script>
<script src="maps/assetMapping.js"></script>
<script type="text/javascript">
var locations = <?php echo $js_array; ?>;
var radius = <?php echo $radius; ?> * 150;
var map;
var hmap;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(49.25954525059982, -123.10933642578),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
//map = createMap ("#map_canvas");
google.maps.event.addListener(map, 'zoom_changed', function () {
// $('#radius').html(map.getWorldWidth());
});
hmap = new google.maps.visualization.HeatmapLayer({
data: new google.maps.MVCArray(),
map: map,
radius: radius,
//maxIntensity: 40,
/*gradient: [
'rgba(0, 0, 0, 0)',
'rgba(0, 255, 0, 1.0)',
'rgba(255, 0, 0, 1.0)'
],*/
gradient: [
'rgba(0, 0, 0, 0.0)',
'rgba(255, 0, 0, 0.1)',
'rgba(255, 0, 0, 0.4)',
'rgba(0, 255, 0, 0.6)',
'rgba(0, 255, 0, 0.9)'
],
opacity: 1.0
});
/*var customLayer = new google.maps.KmlLayer('http://142.104.68.169/cov_localareas.kml');
customLayer.setMap(map);*/
var infowindow = new google.maps.InfoWindow();
var rect = null;
google.maps.event.addListener(map, 'click', function () {
if (rect)
rect.setMap(null);
});
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
//map: map
});
var weightedpoint = {
location: new google.maps.LatLng(locations[i][0], locations[i][1]),
weight: locations[i][2]*100
};
hmap.getData().push(weightedpoint);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
/*hmap.getData().push({
location: marker.position,
weight: Math.random()*20
});*/
if (locations[i][2] != 0) {
infowindow.setContent(locations[i][2]);
infowindow.open(map, marker);
}
//findNeighborhood(locations[i][1], locations[i][2], function (neighborhood) {
//infowindow.setContent(neighborhood);
//infowindow.open(map, marker);
/*getBoundry(neighborhood, function (bounds) {
if(rect)
rect.setMap(null);
rect = new google.maps.Rectangle({
bounds: bounds,
fillColor: "#FFFF00",
fillOpacity: 0.3,
strokeColor: "#0000FF",
strokeWeight: 2,
map: map
});
google.maps.event.addListener(rect, 'click', function(event) {
alert("clicked");
});
});*/
//});
};
})(marker, i));
}
}
</script>
</head>
<body onload="initialize()">
<h1>Vancouver City Talks</h1>
<!-- <input id="areaname" value="40.714224,-73.961452"/>
<button id="findboundry">Find Boundries</button>
-->
<span id="radius"></span>
<div id="map_canvas" style="width:80%; height:80%"></div>
</body>
</html>