From c7782b277696e91ac42d1226a0da35268ec0161b Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Sun, 15 Apr 2012 23:01:05 +0200 Subject: [PATCH 1/3] more work on printing --- WebContent/OSRM.Map.js | 14 ++-- WebContent/printing/OSRM.Printing.js | 36 +++++--- WebContent/printing/printing.html | 33 +------- WebContent/printing/printing.js | 49 +++++++++++ WebContent/printing/printing_screen.css | 105 ------------------------ 5 files changed, 82 insertions(+), 155 deletions(-) create mode 100644 WebContent/printing/printing.js delete mode 100644 WebContent/printing/printing_screen.css diff --git a/WebContent/OSRM.Map.js b/WebContent/OSRM.Map.js index aebb36466..78c4755a7 100644 --- a/WebContent/OSRM.Map.js +++ b/WebContent/OSRM.Map.js @@ -27,27 +27,27 @@ OSRM.GLOBALS.map = null; OSRM.MapView = L.Map.extend({ setViewUI: function(position, zoom) { if( OSRM.GUI.visible == true ) { - var point = OSRM.G.map.project( position, zoom); + var point = this.project( position, zoom); point.x-=OSRM.GUI.width/2; - position = OSRM.G.map.unproject(point,zoom); + position = this.unproject(point,zoom); } this.setView( position, zoom); }, fitBoundsUI: function(bounds) { var southwest = bounds.getSouthWest(); var northeast = bounds.getNorthEast(); - var zoom = OSRM.G.map.getBoundsZoom(bounds); - var sw_point = OSRM.G.map.project( southwest, zoom); + var zoom = this.getBoundsZoom(bounds); + var sw_point = this.project( southwest, zoom); if( OSRM.GUI.visible == true ) sw_point.x-=OSRM.GUI.width/2; else sw_point.x-=10; sw_point.y+=10; - var ne_point = OSRM.G.map.project( northeast, zoom); + var ne_point = this.project( northeast, zoom); ne_point.y-=10; sw_point.x+=10; - bounds.extend( OSRM.G.map.unproject(sw_point,zoom) ); - bounds.extend( OSRM.G.map.unproject(ne_point,zoom) ); + bounds.extend( this.unproject(sw_point,zoom) ); + bounds.extend( this.unproject(ne_point,zoom) ); this.fitBounds( bounds ); }, getCenterUI: function(unbounded) { diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 90974d988..16bef49ee 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -19,7 +19,8 @@ or see http://www.gnu.org/licenses/agpl.txt. // [printing support] OSRM.Printing = { - + +// create UI for printing in mainwindow init: function() { var icon = document.createElement('div'); icon.id = "gui-printer"; @@ -35,12 +36,11 @@ init: function() { document.getElementById("gui-printer").onclick = OSRM.Printing.print; }, -windowLoaded: function(){ - OSRM.Printing.show( OSRM.G.response ); - OSRM.printwindow.focus(); -}, - +// create UI in printwindow show: function(response) { + // add events + OSRM.printwindow.document.getElementById('gui-printer').onclick = OSRM.printwindow.printWindow; + // create header header = '
' + @@ -68,7 +68,7 @@ show: function(response) { route_desc += ''; route_desc += ''; - route_desc += ''; + route_desc += ''; route_desc += ""; route_desc += ''; @@ -99,7 +99,7 @@ show: function(response) { OSRM.printwindow.document.getElementById('description').innerHTML = route_desc; // init map - var map = OSRM.printwindow.initialize(); + var map = OSRM.printwindow.initialize( OSRM.DEFAULTS.TILE_SERVERS[0] ); var markers = OSRM.G.markers.route; map.addLayer( new L.MouseMarker( markers[0].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-source']} ) ); for(var i=1, size=markers.length-1; i - - - + + diff --git a/WebContent/printing/printing.js b/WebContent/printing/printing.js new file mode 100644 index 000000000..c5da44095 --- /dev/null +++ b/WebContent/printing/printing.js @@ -0,0 +1,49 @@ +/* +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 initialization +// [for printing window] + +OSRM = {}; +OSRM.GLOBALS = {}; +OSRM.GUI = { visible:false }; +OSRM.G = OSRM.GLOBALS; + +// function to initialize a map in the new window +function initialize(tile_server) { + // setup map + var tile_layer = new L.TileLayer(tile_server.url, tile_server.options); + OSRM.G.map = new OSRM.MapView("map", { + center: new L.LatLng(51.505, -0.09), + zoom: 13, + zoomAnimation: false, + fadeAnimation: false, + layers: [tile_layer], + attributionControl: false, + zoomControl: false, + dragging:false, + scrollWheelZoom:false, + touchZoom:false, + doubleClickZoom:false + }); + return OSRM.G.map; +} + +//print the window +function printWindow() { + window.print(); +} \ No newline at end of file diff --git a/WebContent/printing/printing_screen.css b/WebContent/printing/printing_screen.css deleted file mode 100644 index a1ae513f0..000000000 --- a/WebContent/printing/printing_screen.css +++ /dev/null @@ -1,105 +0,0 @@ -/* -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 -} From 0ba881c3909e5d5cf618f60d602ab7e32acda4c0 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Sun, 15 Apr 2012 23:12:17 +0200 Subject: [PATCH 2/3] localization for printing --- WebContent/localization/OSRM.Locale.de.js | 2 ++ WebContent/localization/OSRM.Locale.en.js | 2 ++ WebContent/printing/OSRM.Printing.js | 3 +++ WebContent/printing/printing.css | 2 +- WebContent/printing/printing.html | 4 ++-- WebContent/printing/printing.js | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/WebContent/localization/OSRM.Locale.de.js b/WebContent/localization/OSRM.Locale.de.js index 161fa9299..04fd23047 100644 --- a/WebContent/localization/OSRM.Locale.de.js +++ b/WebContent/localization/OSRM.Locale.de.js @@ -50,6 +50,8 @@ OSRM.Localization["de"] = { "DURATION": "Dauer", "YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet", "NO_ROUTE_FOUND": "Keine Route hierher möglich", +// printing +"OVERVIEW_MAP": "Übersichtskarte", // directions "N": "Norden", "E": "Ost", diff --git a/WebContent/localization/OSRM.Locale.en.js b/WebContent/localization/OSRM.Locale.en.js index a67d5bbf1..6164807dc 100644 --- a/WebContent/localization/OSRM.Locale.en.js +++ b/WebContent/localization/OSRM.Locale.en.js @@ -50,6 +50,8 @@ OSRM.Localization["en"] = { "DURATION": "Duration", "YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed", "NO_ROUTE_FOUND": "No route possible", +//printing +"OVERVIEW_MAP": "Overview Map", // directions "N": "north", "E": "east", diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 16bef49ee..784dd71d5 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -40,6 +40,9 @@ init: function() { show: function(response) { // add events OSRM.printwindow.document.getElementById('gui-printer').onclick = OSRM.printwindow.printWindow; + + // + OSRM.printwindow.document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" ); // create header header = diff --git a/WebContent/printing/printing.css b/WebContent/printing/printing.css index 06d7dbc9f..0cbadb27f 100644 --- a/WebContent/printing/printing.css +++ b/WebContent/printing/printing.css @@ -33,7 +33,7 @@ body /* route map box */ -#map +#overview-map { width:500px; height:500px; diff --git a/WebContent/printing/printing.html b/WebContent/printing/printing.html index c70415d53..4456fa752 100644 --- a/WebContent/printing/printing.html +++ b/WebContent/printing/printing.html @@ -57,8 +57,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
-
Übersichtskarte
-
+
Übersichtskarte
+
diff --git a/WebContent/printing/printing.js b/WebContent/printing/printing.js index c5da44095..8303bba42 100644 --- a/WebContent/printing/printing.js +++ b/WebContent/printing/printing.js @@ -27,7 +27,7 @@ OSRM.G = OSRM.GLOBALS; function initialize(tile_server) { // setup map var tile_layer = new L.TileLayer(tile_server.url, tile_server.options); - OSRM.G.map = new OSRM.MapView("map", { + OSRM.G.map = new OSRM.MapView("overview-map", { center: new L.LatLng(51.505, -0.09), zoom: 13, zoomAnimation: false, From 9bd4b772789b11ca085e7e7f052b410903cf2eb0 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Mon, 16 Apr 2012 12:28:16 +0100 Subject: [PATCH 3/3] use relative image locations --- WebContent/OSRM.GUI.js | 2 +- WebContent/main.js | 6 +++--- WebContent/routing/OSRM.RoutingDescription.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index 6d6389679..f3ff3c1d1 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -31,7 +31,7 @@ init: function() { OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth; // init favicon - document.getElementById('favicon').href=OSRM.G.images["favicon"].src; + document.getElementById('favicon').href=OSRM.G.images["favicon"].getAttribute("src"); // init starting source/target document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE; diff --git a/WebContent/main.js b/WebContent/main.js index 99ec8530e..92d03d444 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -95,15 +95,15 @@ OSRM.prefetchIcons = function() { for(var i=0; i