more testing on printing
This commit is contained in:
parent
abba49a44e
commit
28a241c371
@ -66,8 +66,8 @@ OSRM.JSONP = {
|
|||||||
OSRM.JSONP.fences[id] = undefined; // clean fence
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
}
|
}
|
||||||
|
|
||||||
// OSRM.JSONP.sum[id] += new Number( new Date() - OSRM.JSONP.durations[id] );
|
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.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)
|
// clean DOM (unfortunately, script elements cannot be reused by all browsers)
|
||||||
@ -85,9 +85,9 @@ OSRM.JSONP = {
|
|||||||
// start timeout timer
|
// start timeout timer
|
||||||
OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout);
|
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.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;}
|
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.JSONP.durations[id] = new Date();
|
||||||
// OSRM.debug.log("[jsonp] init: "+id);
|
// OSRM.debug.log("[jsonp] init: "+id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -121,6 +121,8 @@ init: function() {
|
|||||||
// initial map position and zoom
|
// initial map position and zoom
|
||||||
var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE);
|
var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE);
|
||||||
OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ZOOM_LEVEL);
|
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
|
// map events
|
||||||
OSRM.G.map.on('zoomend', OSRM.Map.zoomed );
|
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].show();
|
||||||
OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() );
|
OSRM.G.markers.route[index].centerView( OSRM.G.map.getZoom() );
|
||||||
OSRM.Routing.getRoute();
|
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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -46,7 +46,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
<script src="OSRM.base.js" type="text/javascript"></script>
|
<script src="OSRM.base.js" type="text/javascript"></script>
|
||||||
<script src="OSRM.config.js" type="text/javascript"></script>
|
<script src="OSRM.config.js" type="text/javascript"></script>
|
||||||
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
|
<script defer="defer" src="OSRM.debug.js" type="text/javascript"></script>
|
||||||
<script src="main.js" type="text/javascript"></script>
|
<script src="main.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<script src="OSRM.Markers.js" type="text/javascript"></script>
|
<script src="OSRM.Markers.js" type="text/javascript"></script>
|
||||||
|
@ -18,43 +18,73 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
// OSRM printer
|
// OSRM printer
|
||||||
// [printing support]
|
// [printing support]
|
||||||
|
|
||||||
|
|
||||||
OSRM.Printing = {
|
OSRM.Printing = {
|
||||||
|
|
||||||
x: function(){
|
windowLoaded: function(){
|
||||||
OSRM.printwindow.test();
|
OSRM.printwindow.initialize();
|
||||||
// var pos1 = OSRM.printwindow.document.getElementById('map1');
|
OSRM.Printing.show( OSRM.G.response );
|
||||||
// var pos2 = OSRM.printwindow.document.getElementById('map2');
|
OSRM.printwindow.focus();
|
||||||
// // setup map
|
},
|
||||||
// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
||||||
// osmorgOptions = {maxZoom: 18};
|
show: function(response) {
|
||||||
// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
|
// create route description
|
||||||
// var temp1 = new OSRM.MapView(pos1, {
|
var route_desc = "";
|
||||||
// center: new L.LatLng(51.505, -0.09),
|
route_desc += '<table class="results-table">';
|
||||||
// zoom: 13,
|
|
||||||
// zoomAnimation: false, // false: removes animations and hiding of routes during zoom
|
for(var i=0; i < response.route_instructions.length; i++){
|
||||||
// fadeAnimation: false,
|
//odd or even ?
|
||||||
// layers: [osmorg]
|
var rowstyle='results-odd';
|
||||||
// });
|
if(i%2==0) { rowstyle='results-even'; }
|
||||||
// var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
||||||
// osmorgOptions = {maxZoom: 18};
|
route_desc += '<tr class="'+rowstyle+'">';
|
||||||
// var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
|
|
||||||
// var temp2 = new OSRM.MapView(pos2, {
|
route_desc += '<td class="result-directions">';
|
||||||
// center: new L.LatLng(51.505, -0.09),
|
route_desc += '<img width="18px" src="../images/'+OSRM.RoutingDescription.getDirectionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||||
// zoom: 13,
|
route_desc += "</td>";
|
||||||
// zoomAnimation: false, // false: removes animations and hiding of routes during zoom
|
|
||||||
// fadeAnimation: false,
|
route_desc += '<td class="result-items">';
|
||||||
// layers: [osmorg]
|
route_desc += '<span class="result-item">';
|
||||||
// });
|
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 += '<b>' + response.route_instructions[i][1] + '</b>';
|
||||||
|
}
|
||||||
|
//route_desc += ' for ';
|
||||||
|
route_desc += '</span>';
|
||||||
|
route_desc += "</td>";
|
||||||
|
|
||||||
|
route_desc += '<td class="result-distance">';
|
||||||
|
if( i != response.route_instructions.length-1 )
|
||||||
|
route_desc += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
|
||||||
|
route_desc += "</td>";
|
||||||
|
|
||||||
|
route_desc += "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
route_desc += '</table>';
|
||||||
|
headline = "";
|
||||||
|
headline += OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
|
headline += '<div style="float:left;width:40%">';
|
||||||
|
headline += "<span class='route-summary'>"
|
||||||
|
+ OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance)
|
||||||
|
+ "<br>"
|
||||||
|
+ OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time)
|
||||||
|
+ "</span>";
|
||||||
|
headline += '</div>';
|
||||||
|
|
||||||
|
var output = "";
|
||||||
|
output += route_desc;
|
||||||
|
|
||||||
|
OSRM.printwindow.document.getElementById('description-headline').innerHTML = headline;
|
||||||
|
OSRM.printwindow.document.getElementById('description').innerHTML = output;
|
||||||
},
|
},
|
||||||
|
|
||||||
// react to click
|
// react to click
|
||||||
print: function() {
|
print: function() {
|
||||||
OSRM.printwindow = window.open("printing.html", "Popupfenster", "width=400,height=300,resizable=yes");
|
OSRM.printwindow = window.open("printing/printing.html","","width=400,height=300,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
|
||||||
// fenster.document.write("<div id='map1' style='width:100px;height:100px'>a</div><div id='map2' style='width:100px;height:100px'>b</div>");
|
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.windowLoaded, false);
|
||||||
OSRM.printwindow.focus();
|
|
||||||
|
|
||||||
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.x, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
105
WebContent/printing/printing.css
Normal file
105
WebContent/printing/printing.css
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU AFFERO General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
or see http://www.gnu.org/licenses/agpl.txt.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* OSRM CSS styles for printing*/
|
||||||
|
|
||||||
|
|
||||||
|
/* printer button */
|
||||||
|
.printer-inactive
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
background-image:url("../images/printer_inactive.png");
|
||||||
|
}
|
||||||
|
.printer
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
background-image:url("../images/printer.png");
|
||||||
|
}
|
||||||
|
.printer:hover
|
||||||
|
{
|
||||||
|
background-image:url("../images/printer_hover.png");
|
||||||
|
}
|
||||||
|
.printer:active
|
||||||
|
{
|
||||||
|
background-image:url("../images/printer_active.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* route summary */
|
||||||
|
.route-summary
|
||||||
|
{
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* route description box */
|
||||||
|
#description
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
bottom:15px;
|
||||||
|
top:60px;
|
||||||
|
width:380px;
|
||||||
|
font-size:12px;
|
||||||
|
margin:5px;
|
||||||
|
}
|
||||||
|
.results-table
|
||||||
|
{
|
||||||
|
border-spacing:0px;
|
||||||
|
}
|
||||||
|
.results-odd
|
||||||
|
{
|
||||||
|
background-color: #FAF3E9; //#ffffff;
|
||||||
|
}
|
||||||
|
.results-even
|
||||||
|
{
|
||||||
|
background-color: #F2DE9C; //#ffffe0;
|
||||||
|
}
|
||||||
|
.result-items
|
||||||
|
{
|
||||||
|
text-align:left;
|
||||||
|
vertical-align: middle;
|
||||||
|
width:100%;
|
||||||
|
padding-left:1px;
|
||||||
|
padding-right:1px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-direction
|
||||||
|
{
|
||||||
|
width:30px;
|
||||||
|
padding-left:1px;
|
||||||
|
padding-right:1px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-distance
|
||||||
|
{
|
||||||
|
text-align:right;
|
||||||
|
vertical-align: middle;
|
||||||
|
width:30px;
|
||||||
|
padding-left:1px;
|
||||||
|
padding-right:1px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-bottom:1px;
|
||||||
|
}
|
||||||
|
.result-item
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
color:#000000
|
||||||
|
}
|
@ -30,17 +30,18 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
<meta name="author" content="Dennis Schieferdecker" />
|
<meta name="author" content="Dennis Schieferdecker" />
|
||||||
|
|
||||||
<!-- favicon -->
|
<!-- favicon -->
|
||||||
<link rel="shortcut icon" href="images/osrm-favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="../images/osrm-favicon.ico" type="image/x-icon" />
|
||||||
|
|
||||||
<!-- stylesheets -->
|
<!-- stylesheets -->
|
||||||
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
|
<link rel="stylesheet" href="../leaflet/leaflet.css" type="text/css"/>
|
||||||
<!--[if lte IE 8]><link rel="stylesheet" href="leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
|
<!--[if lte IE 8]><link rel="stylesheet" href="../leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
|
||||||
|
<link rel="stylesheet" href="printing.css" type="text/css"/>
|
||||||
|
|
||||||
<!-- scripts -->
|
<!-- scripts -->
|
||||||
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
|
<script src="../leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||||
<script>
|
<script>
|
||||||
function test() {
|
function initialize() {
|
||||||
// setup map
|
/* // setup map
|
||||||
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
osmorgOptions = {maxZoom: 18};
|
osmorgOptions = {maxZoom: 18};
|
||||||
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
|
var osmorg = new L.TileLayer(osmorgURL, osmorgOptions);
|
||||||
@ -65,7 +66,11 @@ function test() {
|
|||||||
layers: [osmorg],
|
layers: [osmorg],
|
||||||
attributionControl: false,
|
attributionControl: false,
|
||||||
zoomControl: false
|
zoomControl: false
|
||||||
});
|
}); */
|
||||||
|
}
|
||||||
|
|
||||||
|
function printsite() {
|
||||||
|
window.print();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -74,10 +79,13 @@ function test() {
|
|||||||
|
|
||||||
<!-- body -->
|
<!-- body -->
|
||||||
<body>
|
<body>
|
||||||
|
<div style="position:absolute;right:5px;top:5px;" class="printer" onclick="printsite();"></div>
|
||||||
<!--maps-->
|
<!--maps-->
|
||||||
<div id="map1" style='width:100px;height:100px'></div>
|
<!-- <div id="map1" style='width:100px;height:100px'></div>
|
||||||
<div id="map2" style='width:100px;height:100px'></div>
|
<div id="map2" style='width:100px;height:100px'></div> -->
|
||||||
|
<!--description-->
|
||||||
|
<div id="description-headline"></div>
|
||||||
|
<div id="description"></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -71,6 +71,7 @@ showRoute: function(response) {
|
|||||||
if(!response)
|
if(!response)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
OSRM.G.response = response;
|
||||||
OSRM.G.via_points = response.via_points.slice(0);
|
OSRM.G.via_points = response.via_points.slice(0);
|
||||||
if(response.status == 207) {
|
if(response.status == 207) {
|
||||||
OSRM.RoutingGeometry.showNA();
|
OSRM.RoutingGeometry.showNA();
|
||||||
|
Loading…
Reference in New Issue
Block a user