Skip to content
Snippets Groups Projects
Commit bb6a070c authored by Winnie's avatar Winnie
Browse files

Updates

- Working Map, Heatmap
parent d1f7464b
No related branches found
No related tags found
No related merge requests found
......@@ -3,44 +3,41 @@
// Displays markers on a map centred at the Laurentian Great Lakes
// When the user clicks the marker, an info window opens
var openWindow;
function initInfo(lati, longi,name, date, count ) {
console.log("Trying to gen. info map");
function initInfo(lati, longi,name, date, individualCount) {
// Generate map centred at Great Lakes
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5.5,
center: {lat: 45.0349575, lng: -88.6941305}
center: {lat: 45.0349575, lng: -88.6941305}
});
console.log("Gened info map");
setMarkers(map, lati, longi,name, date, individualCount);
}
// Set info window contents to input string
function setMarkers(map, lati, longi,name, date, individualCount) {
for (var i = 0; i < lati.length; i++)
{
var marker = new google.maps.Marker({position: new google.maps.LatLng(lati[i], longi[i]), map: map});
// var content = "point numero" + i;
var content = '<div>' +
'Name:' + name[i] +
'<br>Date:' + findMonth(date[i].month) + ' ' + date[i].day + ', ' + date[i].year +
'<br>Count:' + individualCount[i] + '</div></div>';
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
return function() {
console.log("Clicked!!!!");
if (openWindow)
openWindow.close();
infowindow.setContent(content);
openWindow = infowindow;
infowindow.open(map,marker);
};
})(marker,content,infowindow));
console.log(i);
}
}
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < lati.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(lati[i], longi[i]),
map: map
});
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infowindow.setContent('<div id=“content”>' +
'<div id=“siteNotice”>' +
'</div>' +
'<h1 id=“firstHeading” class=“firstHeading”>' + name[i] + '</h1>' +
'<div id=“bodyContent”>' +
'<p><b>Name: </b>' + name[i] + '</p>' +
'<p><b>Date: </b>' + findMonth(date[i].month) + ' ' + date[i].day + ', ' + date[i].year + '</p>' +
'<p><b>Count: </b>' + count[i] + '</p>' +
'</div>' +
'</div>');
infowindow.open(map, marker);
}
})(marker, i));
console.log("Plotted" + i + " markers");
}
}
\ No newline at end of file
......@@ -195,7 +195,7 @@ function reqMap(params){
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
var nodeList = JSON.parse(this.responseText);
console.log(nodeList);
initInfo(nodeList["latitude"], nodeList["longitude"], nodeList["name"], nodeList["date"], nodeList["individual count"]);
initInfo(nodeList["latitude"], nodeList["longitude"], nodeList["name"], nodeList["date"], nodeList["individualCount"]);
}
else {
console.log("Server Response: Error"); //RME
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment