diff --git a/WebContent/OSRM.JSONP.js b/WebContent/OSRM.JSONP.js index c29e634e6..f62ed470d 100644 --- a/WebContent/OSRM.JSONP.js +++ b/WebContent/OSRM.JSONP.js @@ -66,8 +66,8 @@ OSRM.JSONP = { OSRM.JSONP.fences[id] = undefined; // clean fence } -// OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); -// OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); + OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] ); + OSRM.debug.log("[jsonp] response handling: "+id+" "+ (OSRM.JSONP.sum[id]/OSRM.JSONP.counter[id]).toFixed(2) ); }; // clean DOM (unfortunately, script elements cannot be reused by all browsers) @@ -85,9 +85,9 @@ OSRM.JSONP = { // start timeout timer OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout); -// if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } -// if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} -// OSRM.JSONP.durations[id] = new Date(); + if(!OSRM.JSONP.durations) { OSRM.JSONP.durations = {}; OSRM.JSONP.counter = {}; OSRM.JSONP.sum = {}; } + if(OSRM.JSONP.counter[id]) OSRM.JSONP.counter[id]++; else {OSRM.JSONP.counter[id] = 1;OSRM.JSONP.sum[id] = 0;} + OSRM.JSONP.durations[id] = new Date(); // OSRM.debug.log("[jsonp] init: "+id); return true; diff --git a/WebContent/OSRM.Map.js b/WebContent/OSRM.Map.js index 1031f3f0a..f53874d59 100644 --- a/WebContent/OSRM.Map.js +++ b/WebContent/OSRM.Map.js @@ -121,6 +121,8 @@ init: function() { // initial map position and zoom var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE); OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ZOOM_LEVEL); + if (navigator.geolocation && document.URL.indexOf("file://") == -1) + navigator.geolocation.getCurrentPosition(OSRM.Map.geolocationResponse); // map events OSRM.G.map.on('zoomend', OSRM.Map.zoomed ); @@ -146,6 +148,10 @@ click: function(e) { OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() ); OSRM.Routing.getRoute(); - } + } +}, +geolocationResponse: function(response) { + var latlng = new L.LatLng(response.coords.latitude, response.coords.longitude); + OSRM.G.map.setViewUI(latlng, OSRM.DEFAULTS.ZOOM_LEVEL ); } }; \ No newline at end of file diff --git a/WebContent/main.html b/WebContent/main.html index 939df3ea5..a561bd4e0 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -46,7 +46,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - + diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 03df8d4ca..e1f19a8e9 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -18,43 +18,73 @@ or see http://www.gnu.org/licenses/agpl.txt. // OSRM printer // [printing support] - OSRM.Printing = { -x: function(){ - OSRM.printwindow.test(); -// var pos1 = OSRM.printwindow.document.getElementById('map1'); -// var pos2 = OSRM.printwindow.document.getElementById('map2'); -// // setup map -// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', -// osmorgOptions = {maxZoom: 18}; -// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions); -// var temp1 = new OSRM.MapView(pos1, { -// center: new L.LatLng(51.505, -0.09), -// zoom: 13, -// zoomAnimation: false, // false: removes animations and hiding of routes during zoom -// fadeAnimation: false, -// layers: [osmorg] -// }); -// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', -// osmorgOptions = {maxZoom: 18}; -// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions); -// var temp2 = new OSRM.MapView(pos2, { -// center: new L.LatLng(51.505, -0.09), -// zoom: 13, -// zoomAnimation: false, // false: removes animations and hiding of routes during zoom -// fadeAnimation: false, -// layers: [osmorg] -// }); +windowLoaded: function(){ + OSRM.printwindow.initialize(); + OSRM.Printing.show( OSRM.G.response ); + OSRM.printwindow.focus(); +}, + +show: function(response) { + // create route description + var route_desc = ""; + route_desc += '
';
+ route_desc += ' | ";
+
+ route_desc += ''; + route_desc += ''; + route_desc += response.route_instructions[i][0]; + if( i == 0 ) + route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); + if( response.route_instructions[i][1] != "" ) { + route_desc += ' on '; + route_desc += '' + response.route_instructions[i][1] + ''; + } + //route_desc += ' for '; + route_desc += ''; + route_desc += " | "; + + route_desc += ''; + if( i != response.route_instructions.length-1 ) + route_desc += ''+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+''; + route_desc += " | "; + + route_desc += "