Merge commit '9bd4b772789b11ca085e7e7f052b410903cf2eb0' into develop
This commit is contained in:
commit
c84d4b323e
@ -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;
|
||||
|
@ -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) {
|
||||
@ -132,4 +132,4 @@ geolocationResponse: function(response) {
|
||||
var latlng = new L.LatLng(response.coords.latitude, response.coords.longitude);
|
||||
OSRM.G.map.setViewUI(latlng, OSRM.DEFAULTS.ZOOM_LEVEL );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -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",
|
||||
@ -87,4 +89,4 @@ OSRM.Localization["de"] = {
|
||||
|
||||
// set GUI language on load
|
||||
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING==true )
|
||||
OSRM.Localization.setLanguage("de");
|
||||
OSRM.Localization.setLanguage("de");
|
||||
|
@ -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",
|
||||
@ -87,4 +89,4 @@ OSRM.Localization["en"] = {
|
||||
|
||||
//set GUI language on load
|
||||
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
|
||||
OSRM.Localization.setLanguage("en");
|
||||
OSRM.Localization.setLanguage("en");
|
||||
|
@ -95,15 +95,15 @@ OSRM.prefetchIcons = function() {
|
||||
|
||||
for(var i=0; i<icon_list.length; i++) {
|
||||
var icon = {
|
||||
iconUrl: OSRM.G.images[icon_list[i].image_id].src, iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
|
||||
shadowUrl: OSRM.G.images["marker-shadow"].src, shadowSize: new L.Point(41, 41),
|
||||
iconUrl: OSRM.G.images[icon_list[i].image_id].getAttribute("src"), iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
|
||||
shadowUrl: OSRM.G.images["marker-shadow"].getAttribute("src"), shadowSize: new L.Point(41, 41),
|
||||
popupAnchor: new L.Point(0, -33)
|
||||
};
|
||||
OSRM.G.icons[icon_list[i].id] = new L.SwitchableIcon(icon);
|
||||
}
|
||||
|
||||
// special values for drag marker
|
||||
OSRM.G.icons['marker-drag'] = new L.SwitchableIcon( {iconUrl: OSRM.G.images["marker-drag"].src, iconSize: new L.Point(18, 18) } );
|
||||
OSRM.G.icons['marker-drag'] = new L.SwitchableIcon( {iconUrl: OSRM.G.images["marker-drag"].getAttribute("src"), iconSize: new L.Point(18, 18) } );
|
||||
};
|
||||
|
||||
|
||||
|
@ -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,14 @@ 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;
|
||||
|
||||
//
|
||||
OSRM.printwindow.document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" );
|
||||
|
||||
// create header
|
||||
header =
|
||||
'<div class="full">' +
|
||||
@ -68,7 +71,7 @@ show: function(response) {
|
||||
route_desc += '<tr class="'+rowstyle+'">';
|
||||
|
||||
route_desc += '<td class="result-directions">';
|
||||
route_desc += '<img width="18px" src="'+OSRM.RoutingDescription.getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||
route_desc += '<img width="18px" src=../"'+OSRM.RoutingDescription.getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||
route_desc += "</td>";
|
||||
|
||||
route_desc += '<td class="result-items">';
|
||||
@ -99,7 +102,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<size; i++)
|
||||
@ -110,13 +113,25 @@ show: function(response) {
|
||||
route.setStyle( {dashed:false,clickable:false,color:'#0033FF', weight:5} );
|
||||
map.addLayer( route );
|
||||
var bounds = new L.LatLngBounds( OSRM.G.route.getPositions() );
|
||||
map.fitBounds( bounds );
|
||||
map.fitBoundsUI( bounds );
|
||||
},
|
||||
|
||||
// react to click
|
||||
// open printwindow
|
||||
print: function() {
|
||||
// do not open window if there is no route to draw
|
||||
if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() )
|
||||
return;
|
||||
// close old window (should we really do this?)
|
||||
if( OSRM.printwindow )
|
||||
OSRM.printwindow.close();
|
||||
OSRM.printwindow = window.open("printing/printing.html","","width=540,height=500,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
|
||||
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.windowLoaded, false);
|
||||
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.printwindowLoaded, false);
|
||||
},
|
||||
|
||||
// add content to printwindow after it has finished loading
|
||||
printwindowLoaded: function(){
|
||||
OSRM.Printing.show( OSRM.G.response );
|
||||
OSRM.printwindow.focus();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ body
|
||||
|
||||
|
||||
/* route map box */
|
||||
#map
|
||||
#overview-map
|
||||
{
|
||||
width:500px;
|
||||
height:500px;
|
||||
|
@ -39,37 +39,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
<!-- scripts -->
|
||||
<script src="../leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
function initialize() {
|
||||
// setup events
|
||||
document.getElementById('gui-printer').onclick= printsite;
|
||||
|
||||
// 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 L.Map("map", {
|
||||
center: new L.LatLng(51.505, -0.09),
|
||||
zoom: 13,
|
||||
zoomAnimation: false,
|
||||
fadeAnimation: false,
|
||||
layers: [osmorg],
|
||||
attributionControl: false,
|
||||
zoomControl: false,
|
||||
dragging:false,
|
||||
scrollWheelZoom:false,
|
||||
touchZoom:false,
|
||||
doubleClickZoom:false
|
||||
});
|
||||
return temp1;
|
||||
}
|
||||
|
||||
function printsite() {
|
||||
window.print();
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="printing.js" type="text/javascript"></script>
|
||||
<script src="../OSRM.Map.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
||||
@ -86,8 +57,8 @@ function printsite() {
|
||||
|
||||
<!--map-->
|
||||
<div class="quad"></div>
|
||||
<div class="header-title">Übersichtskarte</div>
|
||||
<div id="map"></div>
|
||||
<div id="overview-map-label" class="header-title">Übersichtskarte</div>
|
||||
<div id="overview-map"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
49
WebContent/printing/printing.js
Normal file
49
WebContent/printing/printing.js
Normal file
@ -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("overview-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();
|
||||
}
|
@ -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
|
||||
}
|
@ -154,9 +154,9 @@ getDrivingInstructionIcon: function(server_instruction_id) {
|
||||
local_icon_id += server_instruction_id;
|
||||
|
||||
if( OSRM.G.images[local_icon_id] )
|
||||
return OSRM.G.images[local_icon_id].src;
|
||||
return OSRM.G.images[local_icon_id].getAttribute("src");
|
||||
else
|
||||
return OSRM.G.images["direction_0"].src;
|
||||
return OSRM.G.images["direction_0"].getAttribute("src");
|
||||
},
|
||||
|
||||
// retrieve driving instructions from instruction ids
|
||||
|
Loading…
Reference in New Issue
Block a user