--- a/src/main/resources/templates/index.html Tue Aug 23 17:40:45 2011 -0400
+++ b/src/main/resources/templates/index.html Tue Aug 23 17:56:42 2011 -0400
@@ -12,8 +12,6 @@
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript"></script>
<script type="text/javascript">
- //var lat=42.412704
- //var lon=-71.140267
var zoom=13
var map;
function init() {
@@ -21,8 +19,6 @@
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom(),
- //new OpenLayers.Control.LayerSwitcher(),
- //new OpenLayers.Control.Attribution()
],
//maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
//maxResolution: 156543.0399,
@@ -54,7 +50,7 @@
http.open('GET','Jun-26-11.json',false);
http.onreadystatechange = function () {
console.log("state: " + http.readyState);
- if(http.readyState == 4){
+ if(http.readyState == 4 && http.responseText != ""){
jsonData = eval('(' + http.responseText + ')');
}
};
@@ -65,9 +61,10 @@
function centerMapOnTrail(json) {
var bounds = getBounds(json);
- //var lonLat = new OpenLayers.LonLat(centerLon,centerLat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
+
var lonLat = bounds.getCenterLonLat().transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
- map.setCenter(lonLat, zoom);
+ map.setCenter(lonLat, map.getZoomForExtent(bounds.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())));
+
}
function getBounds(json) {
@@ -94,7 +91,6 @@
bounds.extend(new OpenLayers.LonLat(minLong,minLat));
bounds.extend(new OpenLayers.LonLat(maxLong,maxLat));
return bounds;
- //return {'longRange': [minLong,maxLong], 'latRange': [minLat,maxLat]}
}
function initGraphs() {