+ import of Utils.js
authortgambet
Wed, 24 Aug 2011 17:12:03 -0400
changeset 47 c12248cd29ee
parent 46 c96c92e92021
child 48 d899f044b8c9
+ import of Utils.js
~ getBounds now takes an event array as parameter
src/main/resources/templates/index.html
--- a/src/main/resources/templates/index.html	Wed Aug 24 17:10:36 2011 -0400
+++ b/src/main/resources/templates/index.html	Wed Aug 24 17:12:03 2011 -0400
@@ -8,14 +8,16 @@
 		#stats li h2 { display: inline }
 	</style>
 	
+	<script src="../scripts/Utils.js" type="text/javascript"></script>
 	<script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
-	<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript"></script>
+	<!--<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript"></script>-->
 	
 	<script type="text/javascript">
 		var OLMap = {
 			map : null,
 			createMap : function() {
-					OLMap.map = new OpenLayers.Map ("map", {
+				OLMap.map = new OpenLayers.Map ({
+					div : "map",
 					controls:[
 						new OpenLayers.Control.Navigation(),
 						new OpenLayers.Control.PanZoom(),
@@ -23,11 +25,12 @@
 					//maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
 					//maxResolution: 156543.0399,
 					//zoom: 2,
-					numZoomLevels: 5,
-					minZoomLevel: 5,
+					//numZoomLevels: 5,
+					//minZoomLevel: 5,
 					//units: 'm',
-					projection: new OpenLayers.Projection("EPSG:900913"),
-					displayProjection: new OpenLayers.Projection("EPSG:4326")
+					//projection: new OpenLayers.Projection("EPSG:900913"),
+					//displayProjection: new OpenLayers.Projection("EPSG:4326"),
+					//baseLayer: new OpenLayers.Layer.OSM()
 				});
 				OLMap.map.addLayer(new OpenLayers.Layer.OSM());
 			},
@@ -39,27 +42,27 @@
 				});
 				OLMap.map.addLayer(layer);
 			},
-			centerMap : function(json) {
-				var bounds = OLMap.getBounds(json);
+			centerMap : function(events) {
+				var bounds = OLMap.getBounds(events);
 				var lonLat = bounds.getCenterLonLat().transform(new OpenLayers.Projection("EPSG:4326"), OLMap.map.getProjectionObject());
 				OLMap.map.setCenter(lonLat, OLMap.map.getZoomForExtent(bounds.transform(new OpenLayers.Projection("EPSG:4326"), OLMap.map.getProjectionObject())));
 			},
-			getBounds : function(json) {
-				var minLat = json.events[0].c[0];
+			getBounds : function(events) {
+				var minLat = events[0].c[0];
 				var maxLat = minLat;
-				var minLong = json.events[0].c[1];
+				var minLong = events[0].c[1];
 				var maxLong = minLong;
-				for (i=1; i < json.events.length; i++) {
-					if ((lat = json.events[i].c[0]) < minLat) {
+				for (i=1; i < events.length; i++) {
+					if ((lat = events[i].c[0]) < minLat) {
 						minLat = lat;
 						continue;
-					} if ((lat = json.events[i].c[0]) > maxLat) {
+					} if ((lat = events[i].c[0]) > maxLat) {
 						maxLat = lat;
 						continue;
-					} if ((longi = json.events[i].c[1]) < minLong) {
+					} if ((longi = events[i].c[1]) < minLong) {
 						minLong = longi;
 						continue;
-					} if ((longi = json.events[i].c[1]) > maxLong) {
+					} if ((longi = events[i].c[1]) > maxLong) {
 						maxLong = longi;
 						continue;
 					}
@@ -69,25 +72,28 @@
 				bounds.extend(new OpenLayers.LonLat(maxLong,maxLat));
 				return bounds;
 			}
+		}
+		
+		function getWorkouts() {
+			
+			
+		}
+		
+		function getWorkout(uri) {
 			
 		}
 
+
+
 		function init() {
-			var jsonData;
-			var http = new XMLHttpRequest();
-			http.open('GET','Jun-26-11.json',false);
-			http.onreadystatechange = function () {
-				console.log("state: " + http.readyState);
-				if(http.readyState == 4 && http.responseText != ""){
-					jsonData = eval('(' + http.responseText + ')');
-				}
-			};
-			http.send(null);
-			initGraphs();	
+			var workoutJson = eval('(' + Util.request('Jun-26-11.json') + ')');
+			console.log(workoutJson);
 			OLMap.createMap();
 			OLMap.addTrail("Jun-26-11.gpx","blue");
 			OLMap.addTrail("Aug-10-11.gpx","red");
-			OLMap.centerMap(jsonData);
+			OLMap.centerMap(workoutJson.events);
+			
+			initGraphs();	
 		}
 
 		function initGraphs() {