-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,62 @@ | ||
var map; | ||
var myLocation = {lat: 41.8077, lng: -72.2540}; | ||
var markersArr = []; | ||
var myLocation = {lat: 0, lng: 0}; | ||
|
||
// Map constructor | ||
function initMap() { | ||
map = new google.maps.Map(document.getElementById('map-canvas'), { | ||
zoom: 13, | ||
zoom: 2, | ||
center: myLocation, | ||
rotateControl: true | ||
}); | ||
|
||
/* var marker = new google.maps.Marker({ | ||
position: myLatLng, | ||
map: map, | ||
animation:google.maps.Animation.DROP, | ||
title: 'Hello World!' | ||
}); */ | ||
} | ||
|
||
function addMarker(lt, ln, prov) | ||
function updateMapCenter(fileData) | ||
{ | ||
// Troubleshooting call: | ||
//console.log("Latitude: " + lt + ". Longitude: " + ln); | ||
var centerLat = 0; | ||
var centerLon = 0; | ||
var centerLatTotal = 0; | ||
var centerLonTotal = 0; | ||
for(var i=0; i<fileData.data.length; i++) | ||
{ | ||
centerLatTotal += fileData.data[i].latitude; | ||
centerLonTotal += fileData.data[i].longitude; | ||
} | ||
centerLat = centerLatTotal / (fileData.data.length); | ||
centerLon = centerLonTotal / (fileData.data.length); | ||
var newCenter = {lat: centerLat, lng: centerLon}; | ||
console.log("CenterLat: " + centerLatTotal + ". CenterLon: " + centerLonTotal); | ||
map.setCenter(newCenter); | ||
map.setZoom(8); | ||
} | ||
|
||
function addMarker(lt, ln, prov, timeMillis) { | ||
var location = new google.maps.LatLng(lt, ln); | ||
var marker = new google.maps.Marker({ | ||
position: location, | ||
map: map | ||
}); | ||
if (prov == "GPS") { | ||
marker.setIcon("http://maps.google.com/mapfiles/ms/icons/red-dot.png"); | ||
} | ||
else { | ||
marker.setIcon("http://maps.google.com/mapfiles/ms/icons/green-dot.png"); | ||
} | ||
marker.provider = prov; | ||
marker.timeStamp = timeMillis; | ||
markersArr.push(marker); | ||
} | ||
|
||
|
||
function updateMarkers(timeStart, timeEnd) { | ||
for (var i = 0; i < markersArr.length; i++) { | ||
thisMarker = markersArr[i]; | ||
markerTime = new Date(thisMarker.timeStamp); | ||
if (markerTime < timeStart || markerTime > timeEnd) { | ||
thisMarker.setMap(null); | ||
} | ||
else { | ||
thisMarker.setMap(map); | ||
} | ||
} | ||
} |