Compare commits

...

79 Commits

Author SHA1 Message Date
DennisSchiefer 772ad0d618 added polnish and danish translation, minor version bump 2012-05-07 07:09:56 +01:00
DennisSchiefer e7bb320924 bugfix for displaying correct map tile layer when printing 2012-04-27 16:39:06 +01:00
DennisSchiefer 96e5c4b518 version bump 2012-04-27 16:10:03 +01:00
DennisSchiefer a3cfd49f97 shortener reply parameter name flexible,
check if reply is correct,
beautified continue marker
2012-04-27 12:13:27 +01:00
DennisSchiefer fbe722465d individual ids/classes for geocoder search results 2012-04-27 08:55:11 +01:00
DennisSchiefer 448e6cfdc7 gui handling now uses a main class in which all other gui classes plug
in
2012-04-27 08:40:18 +01:00
DennisSchiefer 8e79b29925 changed result-link to route-link 2012-04-27 07:02:37 +01:00
DennisSchiefer bd61494cf4 added authors 2012-04-27 07:01:33 +01:00
DennisSchiefer d33a75812d changed result-link to route-link 2012-04-27 07:01:19 +01:00
DennisSchiefer 9f5f6019bf changed language in html to English 2012-04-26 15:32:48 +01:00
DennisSchiefer aef70b832c josm request will also use only 6 digits precision 2012-04-26 13:45:54 +01:00
DennisSchiefer 611d265a27 corrected display of geocoder results 2012-04-26 13:45:23 +01:00
DennisSchiefer 635b13b61c all route/geocoder requests will only send 6 digits after the decimal
point.
2012-04-26 13:15:41 +01:00
DennisSchiefer a8a4f56292 printing support finalized (yeah!) 2012-04-26 12:49:30 +01:00
DennisSchiefer a0ceee732e added relative root url for Leaflet 2012-04-26 12:48:01 +01:00
DennisSchiefer 560ce74d06 printing window will now be loaded in IE and Chrome 2012-04-26 07:34:51 +01:00
DennisSchiefer d7ffb0d492 trying to get printing to act correctly with Chrome/IE 2012-04-25 16:36:53 +01:00
DennisSchiefer 369edbe9a7 opening josm will only load the current view if you are close enough,
opening josm will no longer trigger a constant loading symbol in
browsers
2012-04-25 15:01:20 +01:00
DennisSchiefer 94ca30c690 printing icon can now deactivates when there is no route 2012-04-25 12:17:36 +01:00
DennisSchiefer ab1e5255eb Merge branch 'trial/folders' into develop 2012-04-25 07:12:02 +01:00
shiin 0068d4062d changed header area for normal routes 2012-04-24 23:23:27 +02:00
shiin 04298b73f3 added image for "head on",
removed unneeded images
2012-04-24 23:06:19 +02:00
DennisSchiefer 7657f0de22 finished printing support (?) 2012-04-24 22:12:24 +02:00
DennisSchiefer 7cdeeb0723 continued work on printing header 2012-04-24 15:28:09 +01:00
DennisSchiefer c0b71cb62a restored large images 2012-04-24 15:24:42 +01:00
DennisSchiefer 253df58fdb beginning to restructure routing header area 2012-04-24 09:38:20 +01:00
DennisSchiefer cd3005f9fe corrected wrong name when querying layers 2012-04-24 09:35:13 +01:00
DennisSchiefer 94cf796ed2 refinement to French translation 2012-04-24 08:50:27 +01:00
DennisSchiefer 18995379ab added explanation for contributing 2012-04-24 07:42:03 +01:00
DennisSchiefer a5246cc8b8 added french to config 2012-04-24 07:41:44 +01:00
DennisSchiefer 3a7f527c68 french translation added, thanks to Nicolas belett VIGNERON,
Moyg, Jean-Frédéric
2012-04-24 07:25:22 +01:00
DennisSchiefer f404337383 Merge remote-tracking branch 'temp/master' into develop 2012-04-24 07:16:38 +01:00
shiin 7421117278 extended mapview to give information about the current visible tile
layer,
continued work on printing
2012-04-24 00:56:41 +02:00
JeanFred f6173b7a48 Add localisation in French 2012-04-23 22:14:27 +02:00
DennisSchiefer dffd67ef72 continued printing work 2012-04-23 17:30:09 +01:00
DennisSchiefer 3444499cf4 onload event can use a different window 2012-04-23 17:29:53 +01:00
DennisSchiefer 7241438502 corrected error ne instead of sw direction 2012-04-23 17:29:18 +01:00
DennisSchiefer 44c38146c9 enabled printing 2012-04-23 14:48:09 +01:00
DennisSchiefer 2060088c6b finished making jsonp parameter names interchangeable 2012-04-23 09:58:34 +01:00
shiin 38defe9629 some files weren't removed properly... 2012-04-23 00:09:22 +02:00
shiin 087bb12847 more file & folder restructuring 2012-04-23 00:08:02 +02:00
shiin c59a6f9444 reorganized folders 2012-04-22 23:48:43 +02:00
shiin 40c0222ffd better UI for route reversal (source/target are changed when response is
received/timeout)
2012-04-22 21:03:50 +02:00
shiin f763ec2664 work-around for invisible scrollbars in Chrome when usind webkit3d 2012-04-22 20:50:09 +02:00
DennisSchiefer 186f78f01e adapted printing to new geometry routines 2012-04-21 08:14:17 +01:00
DennisSchiefer 1da10942d5 changed jsonp call, so that position of the callback command has
to be given as "%jsonp" in the string
2012-04-21 08:13:42 +01:00
DennisSchiefer 7ad253732a link shortener parameters now changeable in config file 2012-04-21 08:11:57 +01:00
DennisSchiefer 4b1c4068f2 Merge branch 'trial/printing' into develop 2012-04-20 12:11:50 +01:00
DennisSchiefer 57ec4e5465 route geometry is requeried 2012-04-20 11:07:47 +01:00
DennisSchiefer f3290ab64b zooming/switching to show unnamed roads will not rebuild the complete
driving directions,
pending JSONP calls can be cleared
2012-04-20 07:37:26 +02:00
DennisSchiefer eb3c2f560e switched back to using normal images in route description (FF wasn't
actually faster, he just reported wrong numbers)
2012-04-19 21:32:07 +02:00
DennisSchiefer 869b13e9db init via_nodes with empty array 2012-04-19 12:59:31 +01:00
DennisSchiefer 57d9bc5bae route direction icons are now background images (which should be faster
in rendering)
2012-04-19 11:02:09 +01:00
DennisSchiefer 917ef160c5 delete route when reversing it 2012-04-19 11:01:18 +01:00
DennisSchiefer ae513dce5c corrected error with marking unnamed streets, introduced by speeding up
route geometry computation
2012-04-19 11:00:57 +01:00
DennisSchiefer 93b5ce2968 switched to small driving direction images 2012-04-19 09:59:36 +01:00
DennisSchiefer ba08d0b36c added road to first driving direction,
allow geographic direction in all driving directions
2012-04-19 09:57:15 +01:00
DennisSchiefer 2e60e92b31 added waiting message to route reversal,
moved reversal logic to OSRM.Markers
2012-04-19 09:48:32 +01:00
DennisSchiefer 5a9a55544b improved speed of decoding route geometry 2012-04-18 16:56:56 +01:00
DennisSchiefer ee7c79641a fixed bug in route reversal (source/target marker would switch colors
when dragged)
2012-04-18 16:55:56 +01:00
DennisSchiefer 6e57c31ec2 added localization to route link 2012-04-18 16:29:44 +01:00
DennisSchiefer 3d9d4f3764 geolocation will no longer interfer with initial position/route passed
to the website,
corrected centering offset of routes
2012-04-18 08:51:31 +01:00
DennisSchiefer 596e7fc60a added cross-browser support for onload event,
made IE8 work again
2012-04-18 07:46:04 +01:00
DennisSchiefer 8845c070a2 moved favicon handling to webserver 2012-04-18 06:56:17 +01:00
DennisSchiefer eaf5dd328f added finnish for overview map 2012-04-17 22:37:15 +02:00
DennisSchiefer 20a0a3b170 Merge remote-tracking branch 'origin/develop' into develop 2012-04-17 22:35:03 +02:00
DennisSchiefer 8d5d1a9400 Merge branch 'trial/printing' into develop 2012-04-17 22:34:18 +02:00
DennisSchiefer 572a306d6d Merge commit 'f2efcfc588f75c391946b1cf8d5600fcf849d3c9' into develop 2012-04-17 22:33:26 +02:00
DennisSchiefer 63a9e4c6c2 remove newline 2012-04-17 22:32:56 +02:00
DennisSchiefer c84d4b323e Merge commit '9bd4b772789b11ca085e7e7f052b410903cf2eb0' into develop 2012-04-17 22:30:28 +02:00
DennisSchiefer 46f717566d added finnish localization 2012-04-17 09:06:15 +01:00
DennisSchiefer 0199673d14 Merge remote-tracking branch 'temp/master' into develop 2012-04-17 09:03:16 +01:00
Teemu Koskinen 607d5408d3 Add Finnish translations 2012-04-16 21:01:40 +03:00
DennisSchiefer f6a3815e91 continued work on printing support 2012-04-16 16:04:36 +01:00
DennisSchiefer f2efcfc588 increased padding when centering on a route 2012-04-16 16:03:59 +01:00
DennisSchiefer 2bf573dbe1 bug in position of " in string 2012-04-16 12:28:51 +01:00
DennisSchiefer 9bd4b77278 use relative image locations 2012-04-16 12:28:16 +01:00
DennisSchiefer 0ba881c390 localization for printing 2012-04-15 23:12:17 +02:00
DennisSchiefer c7782b2776 more work on printing 2012-04-15 23:01:05 +02:00
53 changed files with 1764 additions and 910 deletions
+11
View File
@@ -0,0 +1,11 @@
The following people contributed code to the Open Source Routing Machine:
Dennis Schieferdecker
Dennis Luxen
Pascal Neis
Teemu Koskinen
Nicolas Belett Vigneron
Moyg
Jean-Frederic
Zbigniew Czernik
Jonas Häggqvist
+8
View File
@@ -26,6 +26,14 @@ Bugtracking
-----------
Please use the OSRM-Project bug tracker [(4)] for submitting any bug reports or feature requests.
Contribute
----------
If you like to contribute, you can simply fork the project and start coding.
When you are going to provide a more substantial addition, please create a new branch first.
For pull requests use the develop branch as target, never the master branch.
Integration into Project-OSRM repository
----------------------------------------
The Project-OSRM repository already contains the frontend repository as a submodule.
-42
View File
@@ -1,42 +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 old browser support
// [simple browser detection and routines to support some old browsers]
// browser detection (runs anonymous function to prevent local variables cluttering global namespace)
(function() {
var useragent = navigator.userAgent;
OSRM.Browser = {
FF3: useragent.search(/Firefox\/3/),
IE6_9: useragent.search(/MSIE (6|7|8|9)/)
};
}());
// compatibility tools for old browsers
function getElementsByClassName(node, classname) {
var a = [];
var re = new RegExp('(^| )'+classname+'( |$)');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}
document.head = document.head || document.getElementsByTagName('head')[0];
+2 -31
View File
@@ -19,39 +19,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
// [has to be loaded before all other OSRM classes]
var OSRM = {};
OSRM.VERSION = '0.1.4x';
OSRM.DATE = '120416';
OSRM.VERSION = '0.1.5.1';
OSRM.DATE = '120507';
OSRM.CONSTANTS = {};
OSRM.DEFAULTS = {};
OSRM.GLOBALS = {};
OSRM.G = OSRM.GLOBALS; // abbreviations
OSRM.C = OSRM.CONSTANTS;
// declare one class to be a subclass of another class
// (runs anonymous function to prevent local functions cluttering global namespace)
(function() {
var _inheritFromHelper = function() {};
OSRM.inheritFrom = function( sub_class, base_class ) {
_inheritFromHelper.prototype = base_class.prototype;
sub_class.prototype = new _inheritFromHelper();
sub_class.prototype.constructor = sub_class;
sub_class.prototype.base = base_class.prototype;
};
}());
// extend prototypes of a class -> used to add member values and functions
OSRM.extend = function( target_class, properties ) {
for( property in properties ) {
target_class.prototype[property] = properties[property];
}
};
// [usage of convenience functions]
// SubClass = function() {
// SubClass.prototype.base.constructor.apply(this, arguments);
// }
// OSRM.inheritFrom( SubClass, BaseClass );
// OSRM.extend( SubClass, { property:value } );
+9 -2
View File
@@ -35,12 +35,19 @@ OSRM.DEFAULTS = {
GEOCODER_BOUNDS: '', // the world is not enough!
//GEOCODER_BOUNDS: '&bounded=1&viewbox=-27.0,72.0,46.0,36.0', // bounds for Europe
SHORTENER_PARAMETERS: '%url&jsonp=%jsonp',
SHORTENER_REPLY_PARAMETER: 'ShortURL',
LANGUAGE: "en",
LANGUAGE_FILES_DIRECTORY: "localization/",
LANGUAGE_FILES_DIRECTORY: "localization/",
LANUGAGE_ONDEMAND_RELOADING: true,
LANGUAGE_SUPPORTED: [
{display_name:"en", encoding:"en"},
{display_name:"de", encoding:"de"}
{display_name:"da", encoding:"da"},
{display_name:"de", encoding:"de"},
{display_name:"fi", encoding:"fi"},
{display_name:"fr", encoding:"fr"},
{display_name:"pl", encoding:"pl"}
],
TILE_SERVERS: [
@@ -43,7 +43,7 @@ call: function(marker_id, query) {
}
//build request for geocoder
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query;
var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json&json_callback=%jsonp" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query;
OSRM.JSONP.call( call, OSRM.Geocoder._showResults, OSRM.Geocoder._showResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_"+marker_id, {marker_id:marker_id,query:query} );
},
@@ -84,20 +84,20 @@ _showResults: function(response, parameters) {
// show possible results for input
var html = "";
html += '<table class="results-table medium-font">';
html += '<table class="results medium-font">';
for(var i=0; i < response.length; i++){
var result = response[i];
//odd or even ?
var rowstyle='results-odd';
if(i%2==0) { rowstyle='results-even'; }
var rowstyle='results-body-odd';
if(i%2==0) { rowstyle='results-body-even'; }
html += '<tr class="'+rowstyle+'">';
html += '<td class="result-counter"><span">'+(i+1)+'.</span></td>';
html += '<td class="result-items">';
html += '<td class="results-body-counter"><span">'+(i+1)+'.</span></td>';
html += '<td class="results-body-items">';
if(result.display_name){
html += '<div class="result-item" onclick="OSRM.Geocoder._onclickResult(\''+parameters.marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
html += '<div class="results-body-item" onclick="OSRM.Geocoder._onclickResult(\''+parameters.marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
}
html += "</td></tr>";
}
@@ -148,14 +148,14 @@ updateAddress: function(marker_id, do_fallback_to_lat_lng) {
if(marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource()) {
lat = OSRM.G.markers.route[0].getLat();
lng = OSRM.G.markers.route[0].getLng();
lng = OSRM.G.markers.route[0].getLng();
} else if(marker_id == OSRM.C.TARGET_LABEL && OSRM.G.markers.hasTarget() ) {
lat = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLat();
lng = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng();
lng = OSRM.G.markers.route[OSRM.G.markers.route.length-1].getLng();
} else
return;
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json" + "&accept-language="+OSRM.Localization.current_language + "&lat=" + lat + "&lon=" + lng;
var call = OSRM.DEFAULTS.HOST_REVERSE_GEOCODER_URL + "?format=json&json_callback=%jsonp" + "&accept-language="+OSRM.Localization.current_language + "&lat=" + lat.toFixed(6) + "&lon=" + lng.toFixed(6);
OSRM.JSONP.call( call, OSRM.Geocoder._showReverseResults, OSRM.Geocoder._showReverseResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_"+marker_id, {marker_id:marker_id, do_fallback: do_fallback_to_lat_lng} );
},
@@ -22,45 +22,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
OSRM.GLOBALS.map = null;
// map view/model
// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility]
OSRM.MapView = L.Map.extend({
setViewUI: function(position, zoom) {
if( OSRM.GUI.visible == true ) {
var point = OSRM.G.map.project( position, zoom);
point.x-=OSRM.GUI.width/2;
position = OSRM.G.map.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);
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);
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) );
this.fitBounds( bounds );
},
getCenterUI: function(unbounded) {
var viewHalf = this.getSize();
if( OSRM.GUI.visible == true )
viewHalf.x += OSRM.GUI.width;
var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2));
return this.unproject(centerPoint, this._zoom, unbounded);
}
});
// map controller
// [map initialization, event handling]
OSRM.Map = {
@@ -89,18 +50,12 @@ init: function() {
});
// add layer control
var layersControl = new L.Control.Layers(base_maps, {});
OSRM.G.map.addControl(layersControl);
var layerControl = new L.Control.QueryableLayers(base_maps, {});
OSRM.G.map.addLayerControl(layerControl);
// move zoom markers
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
// initial correct map position and zoom (respect UI visibility, use browser position)
var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE);
OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ONLOAD_ZOOM_LEVEL);
if (navigator.geolocation && document.URL.indexOf("file://") == -1) // convenience during development, as FF doesn't save rights for local files
navigator.geolocation.getCurrentPosition(OSRM.Map.geolocationResponse);
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
// map events
OSRM.G.map.on('zoomend', OSRM.Map.zoomed );
@@ -109,8 +64,21 @@ init: function() {
OSRM.G.map.on('mousemove', OSRM.Map.mousemove );
},
// init map position and zoom (respect UI visibility / use browser geolocation)
initPosition: function() {
var position = new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE);
OSRM.G.map.setViewUI( position, OSRM.DEFAULTS.ONLOAD_ZOOM_LEVEL, true);
if (navigator.geolocation && document.URL.indexOf("file://") == -1) // convenience: FF does not save access rights for local files
navigator.geolocation.getCurrentPosition(OSRM.Map.geolocationResponse);
},
// map event handlers
zoomed: function(e) { OSRM.Routing.getRoute(); },
zoomed: function(e) {
if(OSRM.G.dragging)
OSRM.Routing.getDragRoute();
else
OSRM.Routing.getZoomRoute();
},
contextmenu: function(e) {;},
mousemove: function(e) { OSRM.Via.drawDragMarker(e); },
click: function(e) {
@@ -132,4 +100,4 @@ geolocationResponse: function(response) {
var latlng = new L.LatLng(response.coords.latitude, response.coords.longitude);
OSRM.G.map.setViewUI(latlng, OSRM.DEFAULTS.ZOOM_LEVEL );
}
};
};
+131
View File
@@ -0,0 +1,131 @@
/*
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 marker management (all route markers should only be set and deleted with these routines!)
// [this holds the vital information of the route]
OSRM.Markers = function() {
this.route = new Array();
this.highlight = new OSRM.DragMarker("highlight", {draggable:true,icon:OSRM.G.icons['marker-highlight'],dragicon:OSRM.G.icons['marker-highlight-drag']});;
this.dragger = new OSRM.DragMarker("drag", {draggable:true,icon:OSRM.G.icons['marker-drag'],dragicon:OSRM.G.icons['marker-drag']});;
};
OSRM.extend( OSRM.Markers,{
removeAll: function() {
for(var i=0; i<this.route.length;i++)
this.route[i].hide();
this.route.splice(0, this.route.length);
document.getElementById('gui-delete-source').style.visibility = "hidden";
document.getElementById('gui-delete-target').style.visibility = "hidden";
},
removeVias: function() {
// assert correct route array s - v - t
for(var i=1; i<this.route.length-1;i++)
this.route[i].hide();
this.route.splice(1, this.route.length-2);
},
setSource: function(position) {
// source node is always first node
if( this.route[0] && this.route[0].label == OSRM.C.SOURCE_LABEL )
this.route[0].setPosition(position);
else
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.C.SOURCE_LABEL, {draggable:true,icon:OSRM.G.icons['marker-source'],dragicon:OSRM.G.icons['marker-source-drag']}, position));
document.getElementById('gui-delete-source').style.visibility = "visible";
return 0;
},
setTarget: function(position) {
// target node is always last node
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL )
this.route[this.route.length-1].setPosition(position);
else
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.C.TARGET_LABEL, {draggable:true,icon:OSRM.G.icons['marker-target'],dragicon:OSRM.G.icons['marker-target-drag']}, position));
document.getElementById('gui-delete-target').style.visibility = "visible";
return this.route.length-1;
},
setVia: function(id, position) {
// via nodes only between source and target nodes
if( this.route.length<2 || id > this.route.length-2 )
return -1;
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, position));
return id+1;
},
removeMarker: function(id) {
if( id >= this.route.length )
return;
// also remove vias if source or target are removed
if( id==0 && this.route[0].label == OSRM.C.SOURCE_LABEL ) {
this.removeVias();
document.getElementById('gui-input-source').value = "";
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
document.getElementById('gui-delete-source').style.visibility = "hidden";
} else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL ) {
this.removeVias();
id = this.route.length-1;
document.getElementById('gui-input-target').value = "";
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
document.getElementById('gui-delete-target').style.visibility = "hidden";
}
this.route[id].hide();
this.route.splice(id, 1);
},
reverseMarkers: function() {
var size = this.route.length;
// invert route, if a route is shown
if( size > 1 ) {
// switch positions in nodes
var temp_position = this.route[0].getPosition();
this.route[0].setPosition( this.route[size-1].getPosition() );
OSRM.G.markers.route[size-1].setPosition( temp_position );
// switch nodes in array
var temp_node = OSRM.G.markers.route[0];
OSRM.G.markers.route[0] = OSRM.G.markers.route[size-1];
OSRM.G.markers.route[size-1] = temp_node;
// reverse route
OSRM.G.markers.route.reverse();
// clear information (both delete markers stay visible)
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
// invert marker, if only one marker is shown (implicit clear of information / delete markers)
} else if( size > 0 ) {
var position = this.route[0].getPosition();
var label = this.route[0].label;
this.removeMarker(0);
if( label == OSRM.C.TARGET_LABEL )
this.setSource( position );
else if( label == OSRM.C.SOURCE_LABEL )
this.setTarget( position );
this.route[0].show();
}
},
hasSource: function() {
if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL )
return true;
return false;
},
hasTarget: function() {
if( OSRM.G.markers.route[OSRM.G.markers.route.length-1] && OSRM.G.markers.route[OSRM.G.markers.route.length-1].label == OSRM.C.TARGET_LABEL )
return true;
return false;
}
});
@@ -15,91 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM routes
// [drawing of all types of route geometry]
// simple route class (wraps Leaflet Polyline)
OSRM.SimpleRoute = function (label, style) {
this.label = (label ? label : "route");
this.route = new L.DashedPolyline();
this.route.setLatLngs( [] );
if(style) this.route.setStyle( style );
this.shown = false;
};
OSRM.extend( OSRM.SimpleRoute,{
show: function() {
OSRM.G.map.addLayer(this.route);
this.shown = true;
},
hide: function() {
OSRM.G.map.removeLayer(this.route);
this.shown = false;
},
isShown: function() {
return this.shown;
},
getPoints: function() {
return this.route._originalPoints;
},
getPositions: function() {
return this.route.getLatLngs();
},
setPositions: function(positions) {
this.route.setLatLngs( positions );
},
setStyle: function(style) {
this.route.setStyle(style);
},
centerView: function() {
var bounds = new L.LatLngBounds( this.getPositions() );
OSRM.g.map.fitBoundsUI( bounds );
},
toString: function() {
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
}
});
// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes)
OSRM.MultiRoute = function (label) {
this.label = (label ? label : "multiroute");
this.route = new L.LayerGroup();
this.shown = false;
};
OSRM.extend( OSRM.MultiRoute,{
show: function() {
OSRM.G.map.addLayer(this.route);
this.shown = true;
},
hide: function() {
OSRM.G.map.removeLayer(this.route);
this.shown = false;
},
isShown: function() {
return this.shown;
},
addRoute: function(positions) {
var line = new L.DashedPolyline( positions );
line.on('click', function(e) { OSRM.G.route.fire('click',e); });
this.route.addLayer( line );
},
clearRoutes: function() {
this.route.clearLayers();
},
setStyle: function(style) {
this.route.invoke('setStyle', style);
},
toString: function() {
return "OSRM.MultiRoute("+ this.label + ")";
}
});
// route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets)
// OSRM route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets)
// [this holds the route geometry]
OSRM.Route = function() {
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
@@ -131,12 +49,16 @@ OSRM.extend( OSRM.Route,{
hideRoute: function() {
this._current_route.hide();
this._unnamed_route.hide();
// activate printing
OSRM.Printing.deactivate();
},
hideAll: function() {
this._current_route.hide();
this._unnamed_route.hide();
this._old_route.hide();
this._noroute = OSRM.Route.ROUTE;
// activate printing
OSRM.Printing.deactivate();
},
showUnnamedRoute: function(positions) {
@@ -19,7 +19,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
// [find correct position for a via marker]
// store location of via points returned by server
OSRM.GLOBALS.via_points = null;
OSRM.GLOBALS.via_points = [];
OSRM.Via = {
@@ -19,6 +19,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
// [assorted bugfixes to Leaflet functions we use]
// find relative leaflet URL
var i = 0;
while( L.ROOT_URL[i] == document.URL[i] ) { i++; }
L.RELATIVE_ROOT_URL = L.ROOT_URL.slice(i);
// return closest point on segment or distance to that point
L.LineUtil._sqClosestPointOnSegment = function (p, p1, p2, sqDist) {
var x = p1.x,
@@ -0,0 +1,34 @@
/*
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.
*/
// queryable Layers control
// [simply Control.Layers extended by query functions]
L.Control.QueryableLayers = L.Control.Layers.extend({
getActiveLayerName: function () {
var i, input, obj,
inputs = this._form.getElementsByTagName('input'),
inputsLen = inputs.length;
for (i = 0; i < inputsLen; i++) {
input = inputs[i];
obj = this._layers[input.layerId];
if (input.checked && !obj.overlay) {
return obj.name;
}
}
}
});
+83
View File
@@ -0,0 +1,83 @@
/*
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.
*/
// map view/model
// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility, better layerControl]
OSRM.MapView = L.Map.extend({
setViewUI: function(position, zoom, no_animation) {
if( OSRM.GUI.visible == true ) {
var point = this.project( position, zoom);
point.x-=OSRM.GUI.width/2;
position = this.unproject(point,zoom);
}
this.setView( position, zoom, no_animation);
},
fitBoundsUI: function(bounds) {
var southwest = bounds.getSouthWest();
var northeast = bounds.getNorthEast();
var zoom = this.getBoundsZoom(bounds);
var sw_point = this.project( southwest, zoom);
if( OSRM.GUI.visible == true )
sw_point.x-=OSRM.GUI.width+20;
else
sw_point.x-=20;
sw_point.y+=20;
var ne_point = this.project( northeast, zoom);
ne_point.y-=20;
ne_point.x+=20;
bounds.extend( this.unproject(sw_point,zoom) );
bounds.extend( this.unproject(ne_point,zoom) );
this.fitBounds( bounds );
},
getBoundsUI: function(unbounded) {
var bounds = this.getPixelBounds();
if( OSRM.GUI.visible == true )
bounds.min.x+=OSRM.GUI.width;
var sw = this.unproject(new L.Point(bounds.min.x, bounds.max.y), this._zoom, true),
ne = this.unproject(new L.Point(bounds.max.x, bounds.min.y), this._zoom, true);
return new L.LatLngBounds(sw, ne);
},
getCenterUI: function(unbounded) {
var viewHalf = this.getSize();
if( OSRM.GUI.visible == true )
viewHalf.x += OSRM.GUI.width;
var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2));
return this.unproject(centerPoint, this._zoom, unbounded);
},
addLayerControl: function( layerControl ) {
if( this.layerControl )
return;
this.layerControl = layerControl;
this.addControl(this.layerControl);
},
getActiveLayerId: function() {
var tile_server_id = 0;
var tile_servers = OSRM.DEFAULTS.TILE_SERVERS;
var tile_server_name = this.layerControl.getActiveLayerName();
for(var i=0, size=tile_servers.length; i<size; i++) {
if( tile_servers[i].display_name == tile_server_name ) {
tile_server_id = i;
break;
}
}
return tile_server_id;
}
});
@@ -16,7 +16,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM markers
// [base marker class, derived highlight marker and route marker classes, marker management]
// [base marker class, derived highlight marker and route marker classes]
// base marker class (wraps Leaflet markers)
@@ -164,86 +164,3 @@ toString: function() {
return "OSRM.DragMarker: \""+this.label+"\", "+this.position+")";
}
});
// marker management class (all route markers should only be set and deleted with these routines!)
// [this holds the vital information of the route]
OSRM.Markers = function() {
this.route = new Array();
this.highlight = new OSRM.DragMarker("highlight", {draggable:true,icon:OSRM.G.icons['marker-highlight'],dragicon:OSRM.G.icons['marker-highlight-drag']});;
this.dragger = new OSRM.DragMarker("drag", {draggable:true,icon:OSRM.G.icons['marker-drag'],dragicon:OSRM.G.icons['marker-drag']});;
};
OSRM.extend( OSRM.Markers,{
removeAll: function() {
for(var i=0; i<this.route.length;i++)
this.route[i].hide();
this.route.splice(0, this.route.length);
document.getElementById('gui-delete-source').style.visibility = "hidden";
document.getElementById('gui-delete-target').style.visibility = "hidden";
},
removeVias: function() {
// assert correct route array s - v - t
for(var i=1; i<this.route.length-1;i++)
this.route[i].hide();
this.route.splice(1, this.route.length-2);
},
setSource: function(position) {
// source node is always first node
if( this.route[0] && this.route[0].label == OSRM.C.SOURCE_LABEL )
this.route[0].setPosition(position);
else
this.route.splice(0,0, new OSRM.RouteMarker(OSRM.C.SOURCE_LABEL, {draggable:true,icon:OSRM.G.icons['marker-source'],dragicon:OSRM.G.icons['marker-source-drag']}, position));
document.getElementById('gui-delete-source').style.visibility = "visible";
return 0;
},
setTarget: function(position) {
// target node is always last node
if( this.route[this.route.length-1] && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL )
this.route[this.route.length-1].setPosition(position);
else
this.route.splice( this.route.length,0, new OSRM.RouteMarker(OSRM.C.TARGET_LABEL, {draggable:true,icon:OSRM.G.icons['marker-target'],dragicon:OSRM.G.icons['marker-target-drag']}, position));
document.getElementById('gui-delete-target').style.visibility = "visible";
return this.route.length-1;
},
setVia: function(id, position) {
// via nodes only between source and target nodes
if( this.route.length<2 || id > this.route.length-2 )
return -1;
this.route.splice(id+1,0, new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, position));
return id+1;
},
removeMarker: function(id) {
if( id >= this.route.length )
return;
// also remove vias if source or target are removed
if( id==0 && this.route[0].label == OSRM.C.SOURCE_LABEL ) {
this.removeVias();
document.getElementById('gui-input-source').value = "";
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
document.getElementById('gui-delete-source').style.visibility = "hidden";
} else if( id == this.route.length-1 && this.route[ this.route.length-1 ].label == OSRM.C.TARGET_LABEL ) {
this.removeVias();
id = this.route.length-1;
document.getElementById('gui-input-target').value = "";
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
document.getElementById('gui-delete-target').style.visibility = "hidden";
}
this.route[id].hide();
this.route.splice(id, 1);
},
hasSource: function() {
if( OSRM.G.markers.route[0] && OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL )
return true;
return false;
},
hasTarget: function() {
if( OSRM.G.markers.route[OSRM.G.markers.route.length-1] && OSRM.G.markers.route[OSRM.G.markers.route.length-1].label == OSRM.C.TARGET_LABEL )
return true;
return false;
}
});
+98
View File
@@ -0,0 +1,98 @@
/*
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 routes
// [drawing of all types of route geometry]
// simple route class (wraps Leaflet Polyline)
OSRM.SimpleRoute = function (label, style) {
this.label = (label ? label : "route");
this.route = new L.DashedPolyline();
this.route.setLatLngs( [] );
if(style) this.route.setStyle( style );
this.shown = false;
};
OSRM.extend( OSRM.SimpleRoute,{
show: function() {
OSRM.G.map.addLayer(this.route);
this.shown = true;
},
hide: function() {
OSRM.G.map.removeLayer(this.route);
this.shown = false;
},
isShown: function() {
return this.shown;
},
getPoints: function() {
return this.route._originalPoints;
},
getPositions: function() {
return this.route.getLatLngs();
},
setPositions: function(positions) {
this.route.setLatLngs( positions );
},
setStyle: function(style) {
this.route.setStyle(style);
},
centerView: function() {
var bounds = new L.LatLngBounds( this.getPositions() );
OSRM.g.map.fitBoundsUI( bounds );
},
toString: function() {
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
}
});
// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes)
OSRM.MultiRoute = function (label) {
this.label = (label ? label : "multiroute");
this.route = new L.LayerGroup();
this.shown = false;
};
OSRM.extend( OSRM.MultiRoute,{
show: function() {
OSRM.G.map.addLayer(this.route);
this.shown = true;
},
hide: function() {
OSRM.G.map.removeLayer(this.route);
this.shown = false;
},
isShown: function() {
return this.shown;
},
addRoute: function(positions) {
var line = new L.DashedPolyline( positions );
line.on('click', function(e) { OSRM.G.route.fire('click',e); });
this.route.addLayer( line );
},
clearRoutes: function() {
this.route.clearLayers();
},
setStyle: function(style) {
this.route.invoke('setStyle', style);
},
toString: function() {
return "OSRM.MultiRoute("+ this.label + ")";
}
});

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+44
View File
@@ -0,0 +1,44 @@
/*
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 GUI
// [base GUI class, all other GUI modules extend this class]
OSRM.GUI = {
// initialization functions of all GUI parts
init_functions: [],
// init GUI
init: function() {
for(var i=0, size=OSRM.GUI.init_functions.length; i<size; i++) {
OSRM.GUI.init_functions[i]();
}
},
//extend GUI class and add init functions to the array
extend: function( properties ) {
for( property in properties ) {
if( property == 'init' )
OSRM.GUI.init_functions.push( properties[property] );
else
OSRM.GUI[property] = properties[property];
}
}
};
@@ -15,11 +15,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM GUI functionality
// [responsible for all non-routing related GUI behaviour]
// OSRM MainGUI
// [handles all GUI events that interact with appearance of main window]
OSRM.GUI = {
OSRM.GUI.extend( {
// defaults
visible: null,
@@ -30,39 +30,20 @@ init: function() {
OSRM.GUI.visible = true;
OSRM.GUI.width = document.getElementById("main-wrapper").clientWidth;
// init favicon
document.getElementById('favicon').href=OSRM.G.images["favicon"].src;
// init starting source/target
document.getElementById('gui-input-source').value = OSRM.DEFAULTS.ONLOAD_SOURCE;
document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET;
// init events
// [TODO: switch to new event model]
document.getElementById("gui-toggle-in").onclick = OSRM.GUI.toggleMain;
document.getElementById("gui-toggle-out").onclick = OSRM.GUI.toggleMain;
document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-reset").onclick = OSRM.RoutingGUI.resetRouting;
document.getElementById("gui-reverse").onclick = OSRM.RoutingGUI.reverseRouting;
document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions;
document.getElementById("open-josm").onclick = OSRM.RoutingGUI.openJOSM;
document.getElementById("open-osmbugs").onclick = OSRM.RoutingGUI.openOSMBugs;
document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getRoute;
// gui after transition events
if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) {
document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI.onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("transitionend", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("webkitTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("oTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
document.getElementById('main-wrapper').addEventListener("MSTransitionEnd", OSRM.GUI._onMainTransitionEnd, false);
}
// set default language
@@ -85,44 +66,14 @@ setLabels: function() {
document.getElementById("gui-input-target").title = OSRM.loc("GUI_END_TOOLTIP");
document.getElementById("legal-notice").innerHTML = OSRM.loc("GUI_LEGAL_NOTICE");
},
// show/hide main-gui
toggleMain: function() {
// show main-gui
if( OSRM.GUI.visible == false ) {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";;
document.getElementById('blob-wrapper').style.visibility="hidden";
document.getElementById('main-wrapper').style.left="5px";
// hide main-gui
} else {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="30px";
document.getElementById('main-wrapper').style.left=-OSRM.GUI.width+"px";
}
// execute after animation (old browser support)
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 )
OSRM.GUI.onMainTransitionEnd();
//clear output area
clearResults: function() {
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
},
// do stuff after main-gui animation finished
onMainTransitionEnd: function() {
// after hiding main-gui
if( OSRM.GUI.visible == true ) {
document.getElementById('blob-wrapper').style.visibility="visible";
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = false;
// after showing main-gui
} else {
getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = true;
}
},
// show/hide small options bubble
//show/hide small options bubble
toggleOptions: function() {
if(document.getElementById('options-box').style.visibility=="visible") {
document.getElementById('options-box').style.visibility="hidden";
@@ -130,11 +81,41 @@ toggleOptions: function() {
document.getElementById('options-box').style.visibility="visible";
}
},
// show/hide main-gui
toggleMain: function() {
// show main-gui
if( OSRM.GUI.visible == false ) {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";;
document.getElementById('blob-wrapper').style.visibility="hidden";
document.getElementById('main-wrapper').style.left="5px";
// hide main-gui
} else {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="hidden";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="30px";
document.getElementById('main-wrapper').style.left=-OSRM.GUI.width+"px";
}
// clear output area
clearResults: function() {
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
// execute after animation (old browser support)
if( OSRM.Browser.FF3!=-1 || OSRM.Browser.IE6_9!=-1 )
OSRM.GUI._onMainTransitionEnd();
},
// do stuff after main-gui animation finished
_onMainTransitionEnd: function() {
// after hiding main-gui
if( OSRM.GUI.visible == true ) {
document.getElementById('blob-wrapper').style.visibility="visible";
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = false;
// after showing main-gui
} else {
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.visibility="visible";
OSRM.GUI.visible = true;
}
}
};
});
@@ -15,11 +15,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM routing
// [handles GUI events]
// OSRM RoutingGUI
// [handles all GUI events that interact with routing in main window]
OSRM.RoutingGUI = {
OSRM.GUI.extend( {
// init
init: function() {
// init events
document.getElementById("gui-input-source").onchange = function() {OSRM.GUI.inputChanged(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-delete-source").onclick = function() {OSRM.GUI.deleteMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-search-source").onclick = function() {OSRM.GUI.showMarker(OSRM.C.SOURCE_LABEL);};
document.getElementById("gui-input-target").onchange = function() {OSRM.GUI.inputChanged(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-delete-target").onclick = function() {OSRM.GUI.deleteMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-search-target").onclick = function() {OSRM.GUI.showMarker(OSRM.C.TARGET_LABEL);};
document.getElementById("gui-reset").onclick = OSRM.GUI.resetRouting;
document.getElementById("gui-reverse").onclick = OSRM.GUI.reverseRouting;
document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions;
document.getElementById("open-josm").onclick = OSRM.GUI.openJOSM;
document.getElementById("open-osmbugs").onclick = OSRM.GUI.openOSMBugs;
document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getZoomRoute;
},
// click: button "reset"
resetRouting: function() {
@@ -43,31 +62,17 @@ reverseRouting: function() {
document.getElementById("gui-input-source").value = document.getElementById("gui-input-target").value;
document.getElementById("gui-input-target").value = tmp;
// invert route
OSRM.G.markers.route.reverse();
if(OSRM.G.markers.route.length == 1) {
if(OSRM.G.markers.route[0].label == OSRM.C.TARGET_LABEL) {
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] );
} else if(OSRM.G.markers.route[0].label == OSRM.C.SOURCE_LABEL) {
OSRM.G.markers.route[0].label = OSRM.C.TARGET_LABEL;
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-target'] );
}
} else if(OSRM.G.markers.route.length > 1){
OSRM.G.markers.route[0].label = OSRM.C.SOURCE_LABEL;
OSRM.G.markers.route[0].marker.setIcon( OSRM.G.icons['marker-source'] );
OSRM.G.markers.route[OSRM.G.markers.route.length-1].label = OSRM.C.TARGET_LABEL;
OSRM.G.markers.route[OSRM.G.markers.route.length-1].marker.setIcon( OSRM.G.icons['marker-target'] );
}
// recompute route
// recompute route if needed
if( OSRM.G.route.isShown() ) {
OSRM.Routing.getRoute();
OSRM.G.markers.route.reverse();
OSRM.Routing.getRoute(); // temporary route reversal for query, actual reversal done after receiving response
OSRM.G.markers.route.reverse();
OSRM.G.markers.highlight.hide();
OSRM.RoutingDescription.showSimple( OSRM.G.response );
// simply reverse markers
} else {
document.getElementById('information-box').innerHTML = "";
document.getElementById('information-box-header').innerHTML = "";
OSRM.G.markers.reverseMarkers();
}
},
@@ -92,16 +97,22 @@ inputChanged: function(marker_id) {
// click: button "open JOSM"
openJOSM: function() {
var x = OSRM.G.map.getCenterUI();
var ydelta = 0.01;
var xdelta = ydelta * 2;
var p = [ 'left=' + (x.lng - xdelta), 'bottom=' + (x.lat - ydelta), 'right=' + (x.lng + xdelta), 'top=' + (x.lat + ydelta)];
var url = 'http://localhost:8111/load_and_zoom?' + p.join('&');
var center = OSRM.G.map.getCenterUI();
var bounds = OSRM.G.map.getBoundsUI();
var frame = L.DomUtil.create('iframe', null, document.body);
frame.style.width = frame.style.height = "0px";
var xdelta = Math.min(0.02, Math.abs(bounds.getSouthWest().lng - center.lng) );
var ydelta = Math.min(0.01, Math.abs(bounds.getSouthWest().lat - center.lat) );
var p = [ 'left=' + (center.lng - xdelta).toFixed(6), 'bottom=' + (center.lat - ydelta).toFixed(6), 'right=' + (center.lng + xdelta).toFixed(6), 'top=' + (center.lat + ydelta).toFixed(6)];
var url = 'http://127.0.0.1:8111/load_and_zoom?' + p.join('&');
var frame = document.getElementById('josm-frame');
if(!frame) {
frame = L.DomUtil.create('iframe', null, document.body);
frame.style.display = "none";
frame.id = 'josm-frame';
}
frame.src = url;
frame.onload = function(e) { document.body.removeChild(frame); };
},
//click: button "open OSM Bugs"
@@ -125,4 +136,4 @@ deleteMarker: function(marker_id) {
OSRM.G.markers.highlight.hide();
}
};
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 716 B

+94
View File
@@ -0,0 +1,94 @@
/*
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 localization
// [Danish language support]
OSRM.Localization["da"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Fejl",
"GUI_START": "Start",
"GUI_END": "Destination",
"GUI_RESET": "&nbsp;&nbsp;Nulstil&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Vis&nbsp;&nbsp;",
"GUI_REVERSE": "Omvendt",
"GUI_OPTIONS": "Kortlægnings værktøjer",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Fremhæv unavngivne veje",
"GUI_START_TOOLTIP": "Indtast start",
"GUI_END_TOOLTIP": "Indtast destination",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting af <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder af <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Søgeresultater",
"FOUND_X_RESULTS": "fandt %i resultater",
"TIMED_OUT": "Indtet svar",
"NO_RESULTS_FOUND": "Ingen resultater",
"NO_RESULTS_FOUND_SOURCE": "Ingen resultater for start",
"NO_RESULTS_FOUND_TARGET": "Ingen resultater for destination",
//routing
"ROUTE_DESCRIPTION": "Rutebeskrivelse",
"GET_LINK_TO_ROUTE": "Lav link",
"GENERATE_LINK_TO_ROUTE": "venter på link",
"LINK_TO_ROUTE_TIMEOUT": "ikke tilgængelig",
"GPX_FILE": "GPX Fil",
"DISTANCE": "Distance",
"DURATION": "Varighed",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Din rute bliver beregnet",
"NO_ROUTE_FOUND": "Ingen mulig rute fundet",
//printing
"OVERVIEW_MAP": "Oversigtskort",
"NO_ROUTE_SELECTED": "Ikke valgte rute",
// directions
"N": "nord",
"E": "øst",
"S": "syd",
"W": "vest",
"NE": "nordøst",
"SE": "sydøst",
"SW": "sydvest",
"NW": "nordvest",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Unknown instruction[ on <b>%s</b>]",
"DIRECTION_1":"Fortsæt [ ad <b>%s</b>]",
"DIRECTION_2":"Drej svagt til højre [ ad <b>%s</b>]",
"DIRECTION_3":"Drej til højre[ ad <b>%s</b>]",
"DIRECTION_4":"Drej skarpt til højre[ ad <b>%s</b>]",
"DIRECTION_5":"U-vending[ ad <b>%s</b>]",
"DIRECTION_6":"Drej svagt til venstre[ ad <b>%s</b>]",
"DIRECTION_7":"Drej til venstre[ ad <b>%s</b>]",
"DIRECTION_8":"Drej skarpt til venstre[ ad <b>%s</b>]",
"DIRECTION_10":"Kør mod <b>%d</b>[ ad <b>%s</b>]",
"DIRECTION_11-1":"Kør ind i rundkørslen og tag første udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-2":"Kør ind i rundkørslen og tag anden udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-3":"Kør ind i rundkørslen og tag tredje udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-4":"Kør ind i rundkørslen og tag fjerde udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-5":"Kør ind i rundkørslen og tag femte udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-6":"Kør ind i rundkørslen og tag sjette udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-7":"Kør ind i rundkørslen og tag syvende udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-8":"Kør ind i rundkørslen og tag ottende udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-9":"Kør ind i rundkørslen og tag niende udkørsel[ ad <b>%s</b>]",
"DIRECTION_11-x":"Kør ind i rundkørslen og tag en af de alt for mange udkørsler[ ad <b>%s</b>]",
"DIRECTION_15":"Du er ankommet til din destination"
};
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("da");
+5 -2
View File
@@ -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",
@@ -61,6 +63,7 @@ OSRM.Localization["de"] = {
"NW": "Nordwest",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Unbekannte Anweisung[ auf <b>%s</b>]",
"DIRECTION_1":"Geradeaus weiterfahren[ auf <b>%s</b>]",
@@ -71,7 +74,7 @@ OSRM.Localization["de"] = {
"DIRECTION_6":"Leicht links abbiegen[ auf <b>%s</b>]",
"DIRECTION_7":"Links abbiegen[ auf <b>%s</b>]",
"DIRECTION_8":"Scharf links abbiegen[ auf <b>%s</b>]",
"DIRECTION_10":"Fahren Sie Richtung <b>%s</b>",
"DIRECTION_10":"Fahren Sie Richtung <b>%d</b>[ auf <b>%s</b>]",
"DIRECTION_11-1":"In den Kreisverkehr einfahren und bei erster Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-2":"In den Kreisverkehr einfahren und bei zweiter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
"DIRECTION_11-3":"In den Kreisverkehr einfahren und bei dritter Möglichkeit[ in Richtung <b>%s</b>] verlassen",
@@ -87,4 +90,4 @@ OSRM.Localization["de"] = {
// set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING==true )
OSRM.Localization.setLanguage("de");
OSRM.Localization.setLanguage("de");
+5 -2
View File
@@ -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",
@@ -61,6 +63,7 @@ OSRM.Localization["en"] = {
"NW": "northwest",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Unknown instruction[ on <b>%s</b>]",
"DIRECTION_1":"Continue[ on <b>%s</b>]",
@@ -71,7 +74,7 @@ OSRM.Localization["en"] = {
"DIRECTION_6":"Turn slight left[ on <b>%s</b>]",
"DIRECTION_7":"Turn left[ on <b>%s</b>]",
"DIRECTION_8":"Turn sharp left[ on <b>%s</b>]",
"DIRECTION_10":"Head <b>%s</b>",
"DIRECTION_10":"Head <b>%d</b>[ on <b>%s</b>]",
"DIRECTION_11-1":"Enter roundabout and leave at first exit[ on <b>%s</b>]",
"DIRECTION_11-2":"Enter roundabout and leave at second exit[ on <b>%s</b>]",
"DIRECTION_11-3":"Enter roundabout and leave at third exit[ on <b>%s</b>]",
@@ -87,4 +90,4 @@ OSRM.Localization["en"] = {
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("en");
OSRM.Localization.setLanguage("en");
+93
View File
@@ -0,0 +1,93 @@
/*
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 localization
// [Finnish language support]
OSRM.Localization["fi"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Lähtöpaikka",
"GUI_END": "Määränpää",
"GUI_RESET": "&nbsp;&nbsp;Tyhjennä&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Etsi&nbsp;&nbsp;",
"GUI_REVERSE": "Käänteinen reitti",
"GUI_OPTIONS": "Kartoitustyökalut",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Korosta nimettömät tiet",
"GUI_START_TOOLTIP": "Syötä lähtöpaikka",
"GUI_END_TOOLTIP": "Syötä määränpää",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Haun tulokset",
"FOUND_X_RESULTS": "Löytyi %i vaihtoehtoa",
"TIMED_OUT": "Aikakatkaisu",
"NO_RESULTS_FOUND": "Ei hakutuloksia",
"NO_RESULTS_FOUND_SOURCE": "Ei hakutuloksia lähtöpaikka",
"NO_RESULTS_FOUND_TARGET": "Ei hakutuloksia määränpäälle",
//routing
"ROUTE_DESCRIPTION": "Reittiohjeet",
"GET_LINK_TO_ROUTE": "Luo linkki",
"GENERATE_LINK_TO_ROUTE": "odotetaan linkkiä",
"LINK_TO_ROUTE_TIMEOUT": "ei saatavilla",
"GPX_FILE": "GPX-tiedosto",
"DISTANCE": "Etäisyys",
"DURATION": "Aika",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Reittiä lasketaan",
"NO_ROUTE_FOUND": "Reittiä ei löytynyt",
//printing
"OVERVIEW_MAP": "Yleiskuvakartta",
// directions
"N": "pohjoiseen",
"E": "itään",
"S": "etelään",
"W": "länteen",
"NE": "koilliseen",
"SE": "kaakkoon",
"SW": "lounaaseen",
"NW": "luoteeseen",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Tuntematon ohje[ tielle <b>%s</b>]",
"DIRECTION_1":"Jatka[ tielle <b>%s</b>]",
"DIRECTION_2":"Käänny loivasti oikealle[ tielle <b>%s</b>]",
"DIRECTION_3":"Käänny oikealle[ tielle <b>%s</b>]",
"DIRECTION_4":"Käänny jyrkästi oikealle[ tielle <b>%s</b>]",
"DIRECTION_5":"Tee U-käännös[ tiellä <b>%s</b>]",
"DIRECTION_6":"Käänny loivasti vasemmalle[ tielle <b>%s</b>]",
"DIRECTION_7":"Käänny vasemmalle[ tielle <b>%s</b>]",
"DIRECTION_8":"Käänny jyrkästi vasemmalle [ tielle <b>%s</b>]",
"DIRECTION_10":"Aja <b>%d</b> [ tielle <b>%s</b>]",
"DIRECTION_11-1":"Aja liikenneympyrään ja poistu ensimmäisestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-2":"Aja liikenneympyrään ja poistu toisesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-3":"Aja liikenneympyrään ja poistu kolmannesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-4":"Aja liikenneympyrään ja poistu neljännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-5":"Aja liikenneympyrään ja poistu viidennestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-6":"Aja liikenneympyrään ja poistu kuudennesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-7":"Aja liikenneympyrään ja poistu seitsemännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-8":"Aja liikenneympyrään ja poistu kahdeksannesta haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-9":"Aja liikenneympyrään ja poistu yhdeksännestä haarasta[ tielle <b>%s</b>]",
"DIRECTION_11-x":"Aja liikenneympyrään ja poistu monen haaran jälkeen[ tielle <b>%s</b>]",
"DIRECTION_15":"Saavuit määränpäähän"
};
//set GUI language tielle load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("fi");
+92
View File
@@ -0,0 +1,92 @@
/*
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 localization
// [French language support]
OSRM.Localization["fr"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "Bugs OSM",
"GUI_START": "Départ",
"GUI_END": "Arrivée",
"GUI_RESET": "Réinitialiser",
"GUI_SEARCH": "Montrer",
"GUI_REVERSE": "Inverser",
"GUI_OPTIONS": "Outils de cartographie",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Surligner les rues sans nom",
"GUI_START_TOOLTIP": "Entrez le lieu de départ",
"GUI_END_TOOLTIP": "Entrez le lieu darrivée",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - hébergement par <a href='http://algo2.iti.kit.edu/'>KIT</a> - géocodage par <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Résultats de recherche",
"FOUND_X_RESULTS": "%i résultat(s)",
"TIMED_OUT": "La recherche na pas abouti",
"NO_RESULTS_FOUND": "Aucun résultat trouvé",
"NO_RESULTS_FOUND_SOURCE": "Aucun résultat pour le départ",
"NO_RESULTS_FOUND_TARGET": "Aucun résultat pour l'arrivée",
//routing
"ROUTE_DESCRIPTION": "Description de litinéraire",
"GET_LINK_TO_ROUTE": "Générer un lien",
"GENERATE_LINK_TO_ROUTE": "en attente du lien",
"LINK_TO_ROUTE_TIMEOUT": "indisponible",
"GPX_FILE": "Fichier GPX",
"DISTANCE": "Distance",
"DURATION": "Durée",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Votre itinéraire est en cours de calcul",
"NO_ROUTE_FOUND": "Pas ditinéraire possible",
//printing
"OVERVIEW_MAP": "Overview Map",
// directions
"N": "nord",
"E": "est",
"S": "sud",
"W": "ouest",
"NE": "nord-est",
"SE": "sud-est",
"SW": "sud-ouest",
"NW": "nord-ouest",
// driving directions
// %s: road name
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Instruction inconnue[ sur <b>%s</b>]",
"DIRECTION_1":"Continuez[ sur <b>%s</b>]",
"DIRECTION_2":"Tournez légèrement à droite[ sur <b>%s</b>]",
"DIRECTION_3":"Tournez à droite[ sur <b>%s</b>]",
"DIRECTION_4":"Tournez fortement à droite[ sur <b>%s</b>]",
"DIRECTION_5":"Faites demi-tour[ sur <b>%s</b>]",
"DIRECTION_6":"Tournez légèrement à gauche[ sur <b>%s</b>]",
"DIRECTION_7":"Tournez à gauche[ sur <b>%s</b>]",
"DIRECTION_8":"Tournez fortement à gauche[ sur <b>%s</b>]",
"DIRECTION_10":"Direction <b>%d</b>[ sur <b>%s</b>]",
"DIRECTION_11-1":"Au rond-point, prenez la première sortie[ sur <b>%s</b>]",
"DIRECTION_11-2":"Au rond-point, prenez la deuxième sortie[ sur <b>%s</b>]",
"DIRECTION_11-3":"Au rond-point, prenez la troisième sortie[ sur <b>%s</b>]",
"DIRECTION_11-4":"Au rond-point, prenez la quatrième sortie[ sur <b>%s</b>]",
"DIRECTION_11-5":"Au rond-point, prenez la cinquième sortie[ sur <b>%s</b>]",
"DIRECTION_11-6":"Au rond-point, prenez la sixième sortie[ sur <b>%s</b>]",
"DIRECTION_11-7":"Au rond-point, prenez la septième sortie[ sur <b>%s</b>]",
"DIRECTION_11-8":"Au rond-point, prenez la huitième sortie[ sur <b>%s</b>]",
"DIRECTION_11-9":"Au rond-point, prenez la neuvième sortie[ sur <b>%s</b>]",
"DIRECTION_11-x":"Au rond-point, prenez lune des trop nombreuses sorties[ sur <b>%s</b>]",
"DIRECTION_15":"Vous êtes arrivé"
};
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("fr");
+93
View File
@@ -0,0 +1,93 @@
/*
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 localization
// [Polish language support]
OSRM.Localization["pl"] = {
//gui
"OPEN_JOSM": "JOSM",
"OPEN_OSMBUGS": "OSM Bugs",
"GUI_START": "Początek",
"GUI_END": "Koniec",
"GUI_RESET": "&nbsp;&nbsp;Reset&nbsp;&nbsp;",
"GUI_SEARCH": "&nbsp;&nbsp;Pokaż&nbsp;&nbsp;",
"GUI_REVERSE": "Odwróć",
"GUI_OPTIONS": "Narzędzia",
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Zaznacz ulice bez nazwy",
"GUI_START_TOOLTIP": "Wprowadź początek",
"GUI_END_TOOLTIP": "Wprowadź koniec",
"GUI_LEGAL_NOTICE": "GUI2 v"+OSRM.VERSION+" "+OSRM.DATE+" - OSRM hosting: <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder: <a href='http://www.osm.org/'>OSM</a>",
// geocoder
"SEARCH_RESULTS": "Wyniki wyszukiwania",
"FOUND_X_RESULTS": "znaleziono %i wyników",
"TIMED_OUT": "Upłynął czas oczekiwania",
"NO_RESULTS_FOUND": "Brak wyników",
"NO_RESULTS_FOUND_SOURCE": "Brak wyników dla początku trasy",
"NO_RESULTS_FOUND_TARGET": "Brak wyników dla końca trasy",
//routing
"ROUTE_DESCRIPTION": "Opis trasy",
"GET_LINK_TO_ROUTE": "Generuj link",
"GENERATE_LINK_TO_ROUTE": "oczekiwanie na link",
"LINK_TO_ROUTE_TIMEOUT": "niedostępny",
"GPX_FILE": "Plik GPX",
"DISTANCE": "Dystans",
"DURATION": "Czas",
"YOUR_ROUTE_IS_BEING_COMPUTED": "Twoja trasa została wyznaczona",
"NO_ROUTE_FOUND": "Nie można wyznaczyć trasy",
//printing
"OVERVIEW_MAP": "Mapa poglądowa",
// directions
"N": "północ",
"E": "wschód",
"S": "południe",
"W": "zachód",
"NE": "północny wschód",
"SE": "południowy wschód",
"SW": "południowy zachód",
"NW": "połnocny zachód",
// driving directions
// %s: road name
// %d: direction
// [*]: will only be printed when there actually is a road name
"DIRECTION_0":"Nieznana instrukcja[ na <b>%s</b>]",
"DIRECTION_1":"Podążaj[ drogą <b>%s</b>]",
"DIRECTION_2":"Skręć lekko w prawo[ na drogę <b>%s</b>]",
"DIRECTION_3":"Skręć w prawo[ na drogę <b>%s</b>]",
"DIRECTION_4":"Skręć ostro w prawo[ na drogę <b>%s</b>]",
"DIRECTION_5":"Zawróć[ na drogę <b>%s</b>]",
"DIRECTION_6":"Skręć lekko w lewo[ na drogę <b>%s</b>]",
"DIRECTION_7":"Skręć w lewo[ na drogę <b>%s</b>]",
"DIRECTION_8":"Skręć ostro w lewo[ na drogę <b>%s</b>]",
"DIRECTION_10":"Podążaj <b>%d</b>[ drogą <b>%s</b>]",
"DIRECTION_11-1":"Wjedź na rondo, zjedź pierwszym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-2":"Wjedź na rondo, zjedź drugim zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-3":"Wjedź na rondo, zjedź trzecim zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-4":"Wjedź na rondo, zjedź czwartym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-5":"Wjedź na rondo, zjedź piątym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-6":"Wjedź na rondo, zjedź szóstym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-7":"Wjedź na rondo, zjedź siódmym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-8":"Wjedź na rondo, zjedź ósmym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-9":"Wjedź na rondo, zjedź dziewiątym zjazdem[ na drogę <b>%s</b>]",
"DIRECTION_11-x":"Wjedź na rondo, zjedź wybranym przez siebie zjazdem [ na drogę <b>%s</b>]",
"DIRECTION_15":"Cel został osiągnięty"
};
//set GUI language on load
if( OSRM.DEFAULTS.LANUGAGE_ONDEMAND_RELOADING == true )
OSRM.Localization.setLanguage("pl");
+98 -17
View File
@@ -220,82 +220,150 @@ html, body {
}
/* workaround for invisible scrollbars in Chrome */
#information-box::-webkit-scrollbar {
height: 10px;
width: 10px;
}
#information-box::-webkit-scrollbar-track {
background: #FFFFFF;
}
#information-box::-webkit-scrollbar-thumb {
min-height: 30px;
background: #EEEEEE;
border: 1px solid #999999;
-webkit-border-radius: 5ex;
}
#information-box::-webkit-scrollbar-thumb:hover {
background: #F9F9F9;
}
#information-box::-webkit-scrollbar-thumb:active {
background: #F4F4F4;
}
/* styles for information-box-header */
.header-title
{
font-weight:bold;
margin-bottom:10px;
}
.header-label
{
font-weight:normal;
padding:0px 5px 0px 0px;
}
.header-content
{
font-weight:normal;
}
.result-link
.route-link
{
color:#0000ff;
text-decoration:none;
cursor:pointer;
}
.result-link:hover
.route-link:hover
{
color:#ff0000;
}
/* style for information-box table (search results, driving directions) */
.results-table
/* style for information-box table (general) */
.no-results
{
text-align:center;
margin:28px;
}
/* style for information-box table (search results) */
.results
{
border-spacing:0px;
width:100%;
}
.results-odd
.results-body-odd
{
background-color: #FFFDE3;
}
.results-even
.results-body-even
{
background-color: #FFF9BB;
}
.result-counter
.results-body-counter
{
text-align:right;
vertical-align:top;
font-weight:bold;
padding:1px 5px 1px 5px;
}
.result-items
.results-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.result-directions
.results-body-item
{
cursor:pointer;
color:#000000
}
.results-body-item:hover
{
color:#ff0000
}
/* style for information-box table (driving directions) */
.description
{
border-spacing:0px;
width:100%;
}
.description-body-odd
{
background-color: #FFFDE3;
}
.description-body-even
{
background-color: #FFF9BB;
}
.description-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.description-body-directions
{
text-align:left;
vertical-align: middle;
padding:1px 5px 1px 5px;
}
.result-distance
.description-body-direction
{
width:18px;
height:18px;
}
.description-body-distance
{
text-align:right;
vertical-align: middle;
padding:1px 1px 1px 5px;
}
.result-item
.description-body-item
{
cursor:pointer;
color:#000000
}
.result-item:hover
.description-body-item:hover
{
color:#ff0000
}
.no-results
{
text-align:center;
margin:28px;
}
/* buttons */
@@ -366,6 +434,11 @@ html, body {
{
background-image:url("images/printer.png");
}
#gui-printer-inactive
{
cursor:default;
background-image:url("images/printer_inactive.png");
}
#gui-printer:hover
{
background-image:url("images/printer_hover.png");
@@ -447,6 +520,10 @@ html, body {
display:table;
width:100%;
}
.row
{
display:table-row;
}
.left
{
display:table-cell;
@@ -464,4 +541,8 @@ html, body {
display:table-cell;
text-align:center;
vertical-align:middle;
}
.stretch
{
width:100%;
}
+30 -26
View File
@@ -29,9 +29,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
<meta name="description" content="OSRM Website"/>
<meta name="author" content="Dennis Schieferdecker" />
<!-- favicon -->
<link rel="shortcut icon" href="" type="image/x-icon" id="favicon"/>
<!-- stylesheets -->
<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]-->
@@ -39,34 +36,41 @@ or see http://www.gnu.org/licenses/agpl.txt.
<!-- scripts -->
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
<script src="L.Bugfixes.js" type="text/javascript"></script>
<script src="L.DashedPolyline.js" type="text/javascript"></script>
<script src="L.MouseMarker.js" type="text/javascript"></script>
<script src="L.SwitchableIcon.js" type="text/javascript"></script>
<script src="base/leaflet/L.Bugfixes.js" type="text/javascript"></script>
<script src="base/leaflet/L.Control.QueryableLayers.js" type="text/javascript"></script>
<script src="base/leaflet/L.DashedPolyline.js" type="text/javascript"></script>
<script src="base/leaflet/L.MouseMarker.js" type="text/javascript"></script>
<script src="base/leaflet/L.SwitchableIcon.js" type="text/javascript"></script>
<script src="OSRM.base.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 src="utils/OSRM.browsers.js" type="text/javascript"></script>
<script src="utils/OSRM.classes.js" type="text/javascript"></script>
<script src="main.js" type="text/javascript"></script>
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
<script src="OSRM.Markers.js" type="text/javascript"></script>
<script src="OSRM.Route.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.MapView.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.Marker.js" type="text/javascript"></script>
<script src="base/osrm/OSRM.Route.js" type="text/javascript"></script>
<script src="OSRM.Map.js" type="text/javascript"></script>
<script src="OSRM.GUI.js" type="text/javascript"></script>
<script src="base/OSRM.Map.js" type="text/javascript"></script>
<script src="base/OSRM.Markers.js" type="text/javascript"></script>
<script src="base/OSRM.Routes.js" type="text/javascript"></script>
<script src="gui/OSRM.GUI.js" type="text/javascript"></script>
<script src="gui/OSRM.MainGUI.js" type="text/javascript"></script>
<script src="routing/OSRM.Routing.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingDescription.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingGeometry.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingGUI.js" type="text/javascript"></script>
<script src="gui/OSRM.RoutingGUI.js" type="text/javascript"></script>
<script src="routing/OSRM.RoutingNoNames.js" type="text/javascript"></script>
<script src="OSRM.Via.js" type="text/javascript"></script>
<script src="OSRM.Geocoder.js" type="text/javascript"></script>
<script src="base/OSRM.Via.js" type="text/javascript"></script>
<script src="base/OSRM.Geocoder.js" type="text/javascript"></script>
<script src="OSRM.Browser.js" type="text/javascript"></script>
<script src="OSRM.JSONP.js" type="text/javascript"></script>
<script src="utils/OSRM.JSONP.js" type="text/javascript"></script>
<script src="localization/OSRM.Localization.js" type="text/javascript"></script>
<script src="printing/OSRM.Printing.js" type="text/javascript"></script>
<script src="OSRM.Utils.js" type="text/javascript"></script>
<script src="utils/OSRM.Utils.js" type="text/javascript"></script>
</head>
@@ -100,15 +104,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
<div class="full">
<div id="input-source" class="input-marker">
<div class="left"><span id="gui-search-source-label" class="input-label">Start:</span></div>
<div class="center input-box"><input id="gui-input-source" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" /></div>
<div class="center input-box"><input id="gui-input-source" class="input-box" type="text" maxlength="200" value="" title="Enter start" /></div>
<div class="left"><div id="gui-delete-source" class="iconic-button delete-marker input-delete"></div></div>
<div class="right"><a class="button" id="gui-search-source">Zeigen</a></div>
<div class="right"><a class="button" id="gui-search-source">Show</a></div>
</div>
<div id="input-target" class="input-marker">
<div class="left"><span id="gui-search-target-label" class="input-label">Ende:</span></div>
<div class="center input-box"><input id="gui-input-target" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" /></div>
<div class="left"><span id="gui-search-target-label" class="input-label">End:</span></div>
<div class="center input-box"><input id="gui-input-target" class="input-box" type="text" maxlength="200" value="" title="Enter destination" /></div>
<div class="left"><div id="gui-delete-target" class="iconic-button delete-marker input-delete"></div></div>
<div class="right"><a class="button" id="gui-search-target">Zeigen</a></div>
<div class="right"><a class="button" id="gui-search-target">Show</a></div>
</div>
</div>
@@ -117,7 +121,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
<!-- action buttons -->
<div class="full">
<div class="left"><a class="button" id="gui-reset">Reset</a></div>
<div class="right"><a class="button" id="gui-reverse">Umdrehen</a></div>
<div class="right"><a class="button" id="gui-reverse">Reverse</a></div>
</div>
</div>
@@ -127,13 +131,13 @@ or see http://www.gnu.org/licenses/agpl.txt.
<div id="input-mask-options">
<!-- option toggle -->
<span id="gui-options-toggle" class="small-font">Kartenwerkzeuge</span>
<span id="gui-options-toggle" class="small-font">Mapping Tools</span>
<!-- actual options -->
<div id="options-box" class="full">
<div class="left">
<input type="checkbox" id="option-highlight-nonames" value="highlight-nonames" />
<span id="gui-option-highlight-nonames-label" class="checkbox-label small-font">Unbenannte Straßen hervorheben</span>
<span id="gui-option-highlight-nonames-label" class="checkbox-label small-font">Highlight unnamed streets</span>
</div>
<div class="right">
<a class="button" id="open-josm">JOSM</a>
+20 -13
View File
@@ -27,18 +27,22 @@ OSRM.init = function() {
OSRM.Localization.init();
OSRM.GUI.init();
OSRM.Map.init();
//OSRM.Printing.init();
OSRM.Printing.init();
OSRM.Routing.init();
// check if the URL contains some GET parameter, e.g. for showing a route
OSRM.parseParameters();
// only init default position / geolocation position if GET parameters do not specify a different one
if( OSRM.G.initial_position_override == false )
OSRM.Map.initPosition();
};
// prefetch images
OSRM.GLOBALS.images = {};
OSRM.prefetchImages = function() {
var image_list = [ {id:'marker-shadow', url:L.ROOT_URL + 'images/marker-shadow.png'},
var image_list = [ {id:'marker-shadow', url:L.RELATIVE_ROOT_URL + 'images/marker-shadow.png'},
{id:'marker-source', url:'images/marker-source.png'},
{id:'marker-target', url:'images/marker-target.png'},
{id:'marker-via', url:'images/marker-via.png'},
@@ -67,9 +71,9 @@ OSRM.prefetchImages = function() {
{id:'direction_6', url:'images/slight-left.png'},
{id:'direction_7', url:'images/turn-left.png'},
{id:'direction_8', url:'images/sharp-left.png'},
{id:'direction_10', url:'images/head.png'},
{id:'direction_11', url:'images/round-about.png'},
{id:'direction_15', url:'images/target.png'},
{id:'favicon', url:'images/osrm-favicon.ico'}
{id:'direction_15', url:'images/target.png'}
];
for(var i=0; i<image_list.length; i++) {
@@ -95,15 +99,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) } );
};
@@ -111,7 +115,10 @@ OSRM.prefetchIcons = function() {
OSRM.parseParameters = function(){
var called_url = document.location.search.substr(1,document.location.search.length);
// reject messages that are clearly too long or too small
// state, if GET parameters specify a different initial position
OSRM.G.initial_position_override = false;
// reject messages that are clearly too long or too small
if( called_url.length > 1000 || called_url.length == 0)
return;
@@ -167,6 +174,7 @@ OSRM.parseParameters = function(){
OSRM.Geocoder.updateAddress( OSRM.C.TARGET_LABEL, OSRM.C.DO_FALLBACK_TO_LAT_LNG );
OSRM.G.markers.route[index].show();
OSRM.G.markers.route[index].centerView();
OSRM.G.initial_position_override = true;
return;
}
@@ -196,15 +204,14 @@ OSRM.parseParameters = function(){
// compute route
OSRM.Routing.getRoute();
OSRM.G.initial_position_override = true;
return;
}
// default case: do nothing
// default case: do nothing
return;
};
// onload event
if(document.addEventListener) // FF, CH
document.addEventListener("DOMContentLoaded", OSRM.init, false);
else if(document.attachEvent)
document.attachEvent("onreadystatechange", function() { if ( document.readyState === "interactive" ) OSRM.init(); });
OSRM.Browser.onLoadHandler( OSRM.init );
+124 -62
View File
@@ -15,14 +15,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
// OSRM printer
// OSRM printing
// [printing support]
OSRM.Printing = {
// create UI for printing in mainwindow
init: function() {
var icon = document.createElement('div');
icon.id = "gui-printer";
icon.id = "gui-printer-inactive";
icon.className = "iconic-button top-right-button";
var spacer = document.createElement('div');
@@ -32,91 +34,151 @@ init: function() {
input_mask_header.appendChild(spacer,input_mask_header.lastChild);
input_mask_header.appendChild(icon,input_mask_header.lastChild);
document.getElementById("gui-printer").onclick = OSRM.Printing.print;
document.getElementById("gui-printer-inactive").onclick = OSRM.Printing.openPrintWindow;
},
windowLoaded: function(){
OSRM.Printing.show( OSRM.G.response );
OSRM.printwindow.focus();
},
// switch printer button on/off
activate: function() { // use showing route description as trigger
if( document.getElementById("gui-printer-inactive") )
document.getElementById("gui-printer-inactive").id = "gui-printer";
},
deactivate: function() { // use hide route as trigger
if( document.getElementById("gui-printer") )
document.getElementById("gui-printer").id = "gui-printer-inactive";
},
// create UI in printwindow
show: function(response) {
// create header
header =
var header =
'<thead class="description-header"><tr><td colspan="3">' +
'<div class="full">' +
'<div class="left">' +
'<div class="header-title base-font">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="header-content">' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
'<div class="header-content">' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
'<div class="row">' +
'<div class="left stretch">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("GUI_START")+ ': </div>' +
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-source").value + '</div>' +
'</div>' +
'<div class="right">' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("GUI_END")+ ': </div>' +
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-target").value + '</div>' +
'</div>' +
'</div>';
// create route description
var route_desc = '';
route_desc += '<table id="thetable" class="results-table medium-font">';
route_desc += '<thead style="display:table-header-group;"><tr><td colspan="3">'+header+'</td></tr></thead>';
route_desc += '</thead>';
route_desc += '<tbody stlye="display:table-row-group">';
'</div>' +
'</div>' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("DISTANCE")+': </div>' +
'<div class="left description-header-content">' + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="left description-header-label">' + OSRM.loc("DURATION")+': </div>' +
'<div class="left description-header-content">' + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="quad"></div>' +
'</td></tr></thead>';
// create route description
var body = '<tbody class="description-body">';
for(var i=0; i < response.route_instructions.length; i++){
//odd or even ?
var rowstyle='results-odd';
if(i%2==0) { rowstyle='results-even'; }
var rowstyle='description-body-odd';
if(i%2==0) { rowstyle='description-body-even'; }
route_desc += '<tr class="'+rowstyle+'">';
body += '<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 += "</td>";
route_desc += '<td class="result-items">';
route_desc += '<div class="result-item">';
body += '<td class="description-body-directions">';
body += '<img class="description-body-direction" src="../'+OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
body += "</td>";
// build route description
if( i == 0 )
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, OSRM.loc(response.route_instructions[i][6]) );
else if( response.route_instructions[i][1] != "" )
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]);
body += '<td class="description-body-items">';
if( response.route_instructions[i][1] != "" )
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
else
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"");
route_desc += '</div>';
route_desc += "</td>";
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
body += "</td>";
route_desc += '<td class="result-distance">';
body += '<td class="description-body-distance">';
if( i != response.route_instructions.length-1 )
route_desc += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
route_desc += "</td>";
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
body += "</td>";
route_desc += "</tr>";
body += "</tr>";
}
route_desc += '</tbody>';
route_desc += '</table>';
body += '</tbody>';
// put everything in DOM
OSRM.printwindow.document.getElementById('description').innerHTML = route_desc;
var print_window = OSRM.G.printwindow;
print_window.document.getElementById('description').innerHTML = '<table class="description medium-font">' + header + body + '</table>';
print_window.document.getElementById('overview-map-description').innerHTML = '<table class="description medium-font">' + header + '</table>';
// init map
var map = OSRM.printwindow.initialize();
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++)
map.addLayer( new L.MouseMarker( markers[i].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-via']} ) );
map.addLayer( new L.MouseMarker( markers[markers.length-1].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-target']} ));
var route = new L.DashedPolyline();
route.setLatLngs( OSRM.G.route.getPositions() );
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 );
// draw map
var positions = OSRM.G.route.getPositions();
var tile_server_id = OSRM.G.map.getActiveLayerId();
var zoom = print_window.drawMap( OSRM.DEFAULTS.TILE_SERVERS[tile_server_id], new L.LatLngBounds( positions ) );
// draw markers
print_window.prefetchIcons( OSRM.G.images );
print_window.drawMarkers( OSRM.G.markers.route );
// draw route & query for better geometry
print_window.drawRoute( positions );
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&z='+zoom+'&instructions=false', OSRM.Printing.drawRoute, OSRM.Printing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'print');
},
timeoutRoute: function() {},
drawRoute: function(response) {
if(!response)
return;
var positions = OSRM.RoutingGeometry._decode(response.route_geometry, 5);
OSRM.G.printwindow.drawRoute( positions );
},
// react to click
print: function() {
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);
// opens the print window and closes old instances
openPrintWindow: 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.G.printwindow )
OSRM.G.printwindow.close();
// generate a new window and wait till it has finished loading
OSRM.G.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");
},
// add content to printwindow after it has finished loading
printWindowLoaded: function(){
var print_window = OSRM.G.printwindow;
var print_document = print_window.document;
// add events
print_document.getElementById('gui-printer').onclick = print_window.printWindow;
// localization
print_document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" );
print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" );
// add routing content
OSRM.Printing.show( OSRM.G.response );
// finally, focus on printwindow
print_window.focus();
}
};
+168 -138
View File
@@ -24,97 +24,6 @@ body
}
/* route description box */
#description
{
width:500px;
margin:5px;
}
/* route map box */
#map
{
width:500px;
height:500px;
margin:5px;
}
/* styles for information-box-header */
div.header-title
{
font-weight:bold;
margin-bottom:10px;
}
.header-content
{
font-weight:normal;
}
.result-link
{
color:#0000ff;
text-decoration:none;
cursor:pointer;
}
.result-link:hover
{
color:#ff0000;
}
/* style for information-box table (search results, driving directions) */
.results-table
{
border-spacing:0px;
width:100%;
}
.results-odd
{
background-color: #FFFDE3;
}
.results-even
{
background-color: #FFF9BB;
}
.result-counter
{
text-align:right;
vertical-align:top;
font-weight:bold;
padding:1px 5px 1px 5px;
}
.result-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.result-directions
{
text-align:left;
vertical-align: middle;
padding:1px 5px 1px 5px;
}
.result-distance
{
text-align:right;
vertical-align: middle;
padding:1px 1px 1px 5px;
}
.result-item
{
cursor:pointer;
color:#000000
}
.no-results
{
text-align:center;
margin:28px;
}
/* header area */
#printing-header
{
@@ -133,19 +42,156 @@ div.header-title
}
/* utility styles */
@media print {
.quad
/* content area */
div.label
{
page-break-before:always;
font-weight:bold;
margin-bottom:10px;
}
.box
{
width:500px;
margin:5px;
}
#overview-map
{
width:500px;
height:500px;
margin:5px;
}
/* description content */
.description
{
border-spacing:0px;
width:100%;
}
/* styles for description header */
.description-header
{
display:table-header-group;
}
.description-header-label
{
padding:0px 5px 0px 0px;
}
.description-header-content
{
font-weight:bold;
}
/* styles for description body */
.description-body
{
display:table-row-group;
}
.description-body-odd
{
background-color: #FFFDE3;
}
.description-body-even
{
background-color: #FFF9BB;
}
.description-body-items
{
text-align:left;
vertical-align: middle;
width:100%;
padding:1px;
}
.description-body-directions
{
text-align:left;
vertical-align: middle;
padding:1px 5px 1px 5px;
}
.description-body-direction
{
height:36px;
width:36px;
}
.description-body-distance
{
text-align:right;
vertical-align: middle;
padding:1px 1px 1px 5px;
}
@media print {
.description-body-even > td,
.description-body-odd > td
{
border-bottom: 1px solid black;
}
}
@media screen {
/* utility styles */
.quad
{
min-width:10px;
min-height:10px;
}
@media print {
.pagebreak
{
page-break-before:always;
}
.noprint
{
display:none;
}
}
/* fonts */
@media print {
.base-font {
font-family: Times New Roman, Times, serif;
font-size: 16px;
font-weight: normal;
}
.big-font {
font-family: Times New Roman, Times, serif;
font-size: 18px;
font-weight: bold;
}
.medium-font {
font-family: Times New Roman, Times, serif;
font-size: 14px;
font-weight: normal;
}
.small-font {
font-family: Times New Roman, Times, serif;
font-size: 12px;
font-weight: normal;
}
}
@media screen {
.base-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
.big-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.medium-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10.5px;
font-weight: normal;
}
.small-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: normal;
}
}
@@ -173,51 +219,35 @@ div.header-title
}
/* fonts */
@media print {
.base-font {
font-family: Times New Roman, Times, serif;
font-size: 16px;
font-weight: normal;
/* table */
.full
{
display:table;
width:100%;
}
.big-font {
font-family: Times New Roman, Times, serif;
font-size: 18px;
font-weight: bold;
.row
{
display:table-row;
}
.medium-font {
font-family: Times New Roman, Times, serif;
font-size: 14px;
font-weight: normal;
.left
{
display:table-cell;
text-align:left;
vertical-align:top;
}
.small-font {
font-family: Times New Roman, Times, serif;
font-size: 12px;
font-weight: normal;
.right
{
display:table-cell;
text-align:right;
vertical-align:top;
}
.center
{
display:table-cell;
text-align:center;
vertical-align:top;
}
@media screen {
.base-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
}
.big-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.medium-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10.5px;
font-weight: normal;
}
.small-font {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: normal;
}
.stretch
{
width:100%;
}
+14 -39
View File
@@ -29,47 +29,18 @@ or see http://www.gnu.org/licenses/agpl.txt.
<meta name="description" content="OSRM Website"/>
<meta name="author" content="Dennis Schieferdecker" />
<!-- favicon -->
<link rel="shortcut icon" href="../images/osrm-favicon.ico" type="image/x-icon" />
<!-- stylesheets -->
<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]-->
<link rel="stylesheet" href="printing.css" type="text/css"/>
<!-- scripts -->
<script src="printing.js" type="text/javascript"></script>
<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="../base/leaflet/L.DashedPolyline.js" type="text/javascript"></script>
<script src="../base/leaflet/L.MouseMarker.js" type="text/javascript"></script>
<script src="../base/leaflet/L.SwitchableIcon.js" type="text/javascript"></script>
<script src="../base/osrm/OSRM.MapView.js" type="text/javascript"></script>
</head>
@@ -77,17 +48,21 @@ function printsite() {
<body class="base-font">
<!-- header -->
<div id="printing-header">
<div id="printing-header" class="noprint">
<div id="gui-printer" class="iconic-button top-right-button"></div>
</div>
<!--description-->
<div id="description"></div>
<div id="description-label" class="label">Route Description</div>
<div id="description" class="box"></div>
<!--map-->
<div class="quad"></div>
<div class="header-title">Übersichtskarte</div>
<div id="map"></div>
<div class="pagebreak"></div>
<div class="quad noprint"></div>
<div class="quad noprint"></div>
<div id="overview-map-label" class="label">Overview Map</div>
<div id="overview-map-description" class="box"></div>
<div id="overview-map"></div>
</body>
</html>
+98
View File
@@ -0,0 +1,98 @@
/*
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;
//print the window
function printWindow() {
window.print();
}
//prefetch icons
OSRM.GLOBALS.icons = {};
prefetchIcons = function(images_list) {
var icon_list = [ {id:'marker-source', image_id:'marker-source'},
{id:'marker-target', image_id:'marker-target'},
{id:'marker-via', image_id:'marker-via'},
{id:'marker-highlight', image_id:'marker-highlight'}
];
for(var i=0; i<icon_list.length; i++) {
var icon = {
iconUrl: "../"+images_list[icon_list[i].image_id].getAttribute("src"), iconSize: new L.Point(25, 41), iconAnchor: new L.Point(13, 41),
shadowUrl: "../"+images_list["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);
}
};
// function to initialize a map in the new window
function drawMap(tile_server, bounds) {
// 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(48.84, 10.10),
zoom: 13,
zoomAnimation: false,
fadeAnimation: false,
layers: [tile_layer],
attributionControl: false,
zoomControl: false,
dragging:false,
scrollWheelZoom:false,
touchZoom:false,
doubleClickZoom:false
});
OSRM.G.map.fitBoundsUI(bounds);
return OSRM.G.map.getBoundsZoom(bounds);
}
// manage makers
function drawMarkers( markers ) {
OSRM.G.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++)
OSRM.G.map.addLayer( new L.MouseMarker( markers[i].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-via']} ) );
OSRM.G.map.addLayer( new L.MouseMarker( markers[markers.length-1].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-target']} ) );
}
// manage route
function drawRoute( positions ) {
OSRM.G.route = new L.DashedPolyline();
OSRM.G.route.setLatLngs( positions );
OSRM.G.route.setStyle( {dashed:false,clickable:false,color:'#0033FF', weight:5} );
OSRM.G.map.addLayer( OSRM.G.route );
}
function updateRoute( positions ) {
OSRM.G.route.setLatLngs( positions );
}
// start populating the window when it is fully loaded
window.opener.OSRM.Browser.onLoadHandler( window.opener.OSRM.Printing.printWindowLoaded, window );
-105
View File
@@ -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
}
+38 -6
View File
@@ -25,7 +25,6 @@ OSRM.GLOBALS.markers = null;
OSRM.GLOBALS.dragging = null;
OSRM.GLOBALS.dragid = null;
OSRM.GLOBALS.pending = false;
OSRM.GLOBALS.pendingTimer = null;
OSRM.Routing = {
@@ -50,10 +49,14 @@ timeoutRoute: function() {
OSRM.RoutingDescription.showNA( OSRM.loc("TIMED_OUT") );
OSRM.Routing._snapRoute();
},
timeoutRouteReverse: function() {
OSRM.G.markers.reverseMarkers();
timeoutRoute();
},
showRouteSimple: function(response) {
if(!response)
return;
if( !OSRM.G.dragging ) // prevent simple routing when no longer dragging
if( !OSRM.G.dragging ) // prevent simple routing when not dragging (required as there can be drag events after a dragstop event!)
return;
if( response.status == 207) {
@@ -66,7 +69,7 @@ showRouteSimple: function(response) {
OSRM.Routing._updateHints(response);
if(OSRM.G.pending)
OSRM.G.pendingTimer = setTimeout(OSRM.Routing.draggingTimeout,1);
setTimeout(OSRM.Routing.draggingTimeout,1);
},
showRoute: function(response) {
if(!response)
@@ -87,6 +90,16 @@ showRoute: function(response) {
}
OSRM.Routing._updateHints(response);
},
showRouteZooming: function(response) {
if(!response)
return;
if(response.status != 207) {
OSRM.RoutingGeometry.show(response);
OSRM.RoutingNoNames.show(response);
}
OSRM.Routing._updateHints(response);
},
@@ -100,12 +113,31 @@ getRoute: function() {
OSRM.G.route.hideRoute();
return;
}
OSRM.JSONP.clear('dragging');
OSRM.JSONP.clear('zooming');
OSRM.JSONP.clear('route');
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRoute, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'route');
},
getZoomRoute: function() {
if( OSRM.G.markers.route.length < 2 )
return;
OSRM.JSONP.clear('dragging');
OSRM.JSONP.clear('zooming');
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRouteZooming, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'zooming');
},
getDragRoute: function() {
OSRM.G.pending = !OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=false', OSRM.Routing.showRouteSimple, OSRM.Routing.timeoutRouteSimple, OSRM.DEFAULTS.JSONP_TIMEOUT, 'dragging');;
},
getReverseRoute: function() {
if( OSRM.G.markers.route.length < 2 )
return;
OSRM.JSONP.clear('dragging');
OSRM.JSONP.clear('zooming');
OSRM.JSONP.clear('route');
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRoute, OSRM.Routing.timeoutRouteReverse, OSRM.DEFAULTS.JSONP_TIMEOUT, 'route');
},
draggingTimeout: function() {
OSRM.G.markers.route[OSRM.G.dragid].hint = null;
OSRM.Routing.getDragRoute();
@@ -113,11 +145,11 @@ draggingTimeout: function() {
_buildCall: function() {
var source = OSRM.DEFAULTS.HOST_ROUTING_URL;
source += '?z=' + OSRM.G.map.getZoom() + '&output=json&geomformat=cmp';
source += '?z=' + OSRM.G.map.getZoom() + '&output=json&jsonp=%jsonp&geomformat=cmp';
if(OSRM.G.markers.checksum)
source += '&checksum=' + OSRM.G.markers.checksum;
for(var i=0,size=OSRM.G.markers.route.length; i<size; i++) {
source += '&loc=' + OSRM.G.markers.route[i].getLat() + ',' + OSRM.G.markers.route[i].getLng();
source += '&loc=' + OSRM.G.markers.route[i].getLat().toFixed(6) + ',' + OSRM.G.markers.route[i].getLng().toFixed(6);
if( OSRM.G.markers.route[i].hint)
source += '&hint=' + OSRM.G.markers.route[i].hint;
}
+98 -66
View File
@@ -31,11 +31,17 @@ onClickRouteDescription: function(geometry_index) {
},
onClickCreateShortcut: function(src){
src += '&z='+ OSRM.G.map.getZoom() + '&center=' + OSRM.G.map.getCenter().lat.toFixed(6) + ',' + OSRM.G.map.getCenter().lng.toFixed(6);
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src, OSRM.RoutingDescription.showRouteLink, OSRM.RoutingDescription.showRouteLink_TimeOut, OSRM.DEFAULTS.JSONP_TIMEOUT, 'shortener');
var source = OSRM.DEFAULTS.SHORTENER_PARAMETERS.replace(/%url/, OSRM.DEFAULTS.HOST_SHORTENER_URL+src);
OSRM.JSONP.call(source, OSRM.RoutingDescription.showRouteLink, OSRM.RoutingDescription.showRouteLink_TimeOut, OSRM.DEFAULTS.JSONP_TIMEOUT, 'shortener');
document.getElementById('route-link').innerHTML = '['+OSRM.loc("GENERATE_LINK_TO_ROUTE")+']';
},
showRouteLink: function(response){
document.getElementById('route-link').innerHTML = '[<a class="result-link text-selectable" href="' +response.ShortURL+ '">'+response.ShortURL+'</a>]';
if(!response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER])
OSRM.RoutingDescription.showRouteLink_TimeOut();
else
document.getElementById('route-link').innerHTML = '[<a class="route-link text-selectable" href="' +response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER]+ '">'+response[OSRM.DEFAULTS.SHORTENER_REPLY_PARAMETER]+'</a>]';
},
showRouteLink_TimeOut: function(){
document.getElementById('route-link').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
@@ -43,86 +49,68 @@ showRouteLink_TimeOut: function(){
// handling of routing description
show: function(response) {
// activate printing
OSRM.Printing.activate();
// compute query string
var query_string = '?rebuild=1';
var query_string = '?hl=' + OSRM.Localization.current_language;
for(var i=0; i<OSRM.G.markers.route.length; i++)
query_string += '&loc=' + OSRM.G.markers.route[i].getLat().toFixed(6) + ',' + OSRM.G.markers.route[i].getLng().toFixed(6);
// create link to the route
var route_link ='[<a class="result-link" onclick="OSRM.RoutingDescription.onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK_TO_ROUTE")+'</a>]';
var route_link ='[<a class="route-link" onclick="OSRM.RoutingDescription.onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK_TO_ROUTE")+'</a>]';
// create GPX link
var gpx_link = '[<a class="result-link" onClick="document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
var gpx_link = '[<a class="route-link" onClick="document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
// create route description
var route_desc = "";
route_desc += '<table class="results-table medium-font">';
var body = "";
body += '<table class="description medium-font">';
for(var i=0; i < response.route_instructions.length; i++){
//odd or even ?
var rowstyle='results-odd';
if(i%2==0) { rowstyle='results-even'; }
var rowstyle='description-body-odd';
if(i%2==0) { rowstyle='description-body-even'; }
route_desc += '<tr class="'+rowstyle+'">';
body += '<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 += "</td>";
body += '<td class="description-body-directions">';
body += '<img class="description-body-direction" src="'+ OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0]) + '" alt=""/>';
body += '</td>';
route_desc += '<td class="result-items">';
route_desc += '<div class="result-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
body += '<td class="description-body-items">';
body += '<div class="description-body-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
// build route description
if( i == 0 )
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, OSRM.loc(response.route_instructions[i][6]) );
else if( response.route_instructions[i][1] != "" )
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]);
if( response.route_instructions[i][1] != "" )
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
else
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"");
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
route_desc += '</div>';
route_desc += "</td>";
body += '</div>';
body += "</td>";
route_desc += '<td class="result-distance">';
body += '<td class="description-body-distance">';
if( i != response.route_instructions.length-1 )
route_desc += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
route_desc += "</td>";
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
body += "</td>";
route_desc += "</tr>";
body += "</tr>";
}
route_desc += '</table>';
body += '</table>';
// create header
header =
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="full">' +
'<div class="left">' +
'<div class="header-content">' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
'<div class="header-content">' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
'</div>' +
'<div class="right">' +
'<div id="route-link" class="header-content">' + route_link + '</div>' +
'<div class="header-content">' + gpx_link + '</div>' +
'</div>' +
'</div>';
// build header
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), route_link, gpx_link);
// update DOM
document.getElementById('information-box-header').innerHTML = header;
document.getElementById('information-box').innerHTML = route_desc;
document.getElementById('information-box').innerHTML = body;
},
// simple description
showSimple: function(response) {
header =
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="full">' +
'<div class="left">' +
'<div class="header-content">' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
'<div class="header-content">' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
'</div>' +
'<div class="right">' +
'</div>' +
'</div>';
// build header
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), "", "");
// update DOM
document.getElementById('information-box-header').innerHTML = header;
@@ -131,36 +119,80 @@ showSimple: function(response) {
// no description
showNA: function( display_text ) {
header =
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="full">' +
'<div class="left">' +
'<div class="header-content">' + OSRM.loc("DISTANCE")+": N/A" + '</div>' +
'<div class="header-content">' + OSRM.loc("DURATION")+": N/A" + '</div>' +
'</div>' +
'<div class="right">' +
'</div>' +
'</div>';
// build header
header = OSRM.RoutingDescription._buildHeader("N/A", "N/A", "", "");
// update DOM
document.getElementById('information-box-header').innerHTML = header;
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+display_text+"</div>";
},
// build header
_buildHeader: function(distance, duration, route_link, gpx_link) {
var temp =
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
'<div class="full">' +
'<div class="row">' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
'<div class="left header-content stretch">' + distance + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
'<div class="left header-content stretch">' + duration + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="left">' +
'<div class="full">' +
'<div class="row">' +
'<div class="right header-content" id="route-link">' + route_link + '</div>' +
'</div>' +
'<div class="row">' +
'<div class="right header-content">' + gpx_link + '</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
// '<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
// '<div class="full">' +
// '<div class="row">' +
// '<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
// '<div class="left header-content">' + distance + '</div>' +
// '<div class="right header-content" id="route-link">' + route_link + '</div>' +
// '</div>' +
// '<div class="row">' +
// '<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
// '<div class="left header-content">' + duration + '</div>' +
// '<div class="right header-content">' + gpx_link + '</div>' +
// '</div>' +
// '</div>';
return temp;
},
// retrieve driving instruction icon from instruction id
getDrivingInstructionIcon: function(server_instruction_id) {
_getDrivingInstructionIcon: function(server_instruction_id) {
var local_icon_id = "direction_";
server_instruction_id = server_instruction_id.replace(/^11-\d{1,}$/,"11"); // dumb check, if there is a roundabout (all have the same icon)
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
getDrivingInstruction: function(server_instruction_id) {
_getDrivingInstruction: function(server_instruction_id) {
var local_instruction_id = "DIRECTION_";
server_instruction_id = server_instruction_id.replace(/^11-\d{2,}$/,"11-x"); // dumb check, if there are 10+ exits on a roundabout (say the same for exit 10+)
local_instruction_id += server_instruction_id;
+2 -6
View File
@@ -25,11 +25,7 @@ OSRM.RoutingGeometry = {
show: function(response) {
var geometry = OSRM.RoutingGeometry._decode(response.route_geometry, 5);
var positions = [];
for( var i=0, size=geometry.length; i < size; i++)
positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
OSRM.G.route.showRoute(positions, OSRM.Route.ROUTE);
OSRM.G.route.showRoute(geometry, OSRM.Route.ROUTE);
},
//show route geometry - if there is no route
@@ -63,7 +59,7 @@ _decode: function(encoded, precision) {
} while (b >= 0x20);
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
lng += dlng;
array.push([lat * precision, lng * precision]);
array.push( {lat: lat * precision, lng: lng * precision} );
}
return array;
}
+2 -2
View File
@@ -44,7 +44,7 @@ show: function(response) {
var current_positions = [];
var all_positions = [];
for( var i=0; i < geometry.length; i++) {
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
current_positions.push( geometry[i] );
// still named/unnamed?
if( (named[i] == is_named || named[i] == undefined) && i != geometry.length-1 )
@@ -54,7 +54,7 @@ show: function(response) {
if(is_named == false)
all_positions.push( current_positions );
current_positions = [];
current_positions.push( new L.LatLng(geometry[i][0], geometry[i][1]) );
current_positions.push( geometry[i] );
is_named = named[i];
}
@@ -18,7 +18,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
// OSRM JSONP call wrapper
// [wrapper for JSONP calls with DOM cleaning, fencing, timout handling]
OSRM.JSONP = {
// storage to keep track of unfinished JSONP calls
@@ -29,8 +28,8 @@ OSRM.JSONP = {
// default callback routines
late: function() { /*OSRM.debug.log("[jsonp] reply too late");*/ },
empty: function() { /*OSRM.debug.log("[jsonp] empty callback");*/ },
late: function() {},
empty: function() {},
// init JSONP call
@@ -49,8 +48,6 @@ OSRM.JSONP = {
OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty;
OSRM.JSONP.fences[id] = undefined; // clean fence
}
// OSRM.debug.log("[jsonp] timout handling: "+id);
};
// wrap callback function
@@ -65,12 +62,9 @@ OSRM.JSONP = {
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
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) );
};
// clean DOM (unfortunately, script elements cannot be reused by all browsers)
// clean DOM
var jsonp = document.getElementById('jsonp_'+id);
if(jsonp)
jsonp.parentNode.removeChild(jsonp);
@@ -79,20 +73,26 @@ OSRM.JSONP = {
var script = document.createElement('script');
script.type = 'text/javascript';
script.id = 'jsonp_'+id;
script.src = source + "&json_callback=OSRM.JSONP.callbacks."+id + "&jsonp=OSRM.JSONP.callbacks."+id;
script.src = source.replace(/%jsonp/,"OSRM.JSONP.callbacks."+id);
document.head.appendChild(script);
// 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();
// OSRM.debug.log("[jsonp] init: "+id);
return true;
},
clear: function(id) {
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
OSRM.JSONP.callbacks[id] = OSRM.JSONP.empty; // clean functions
OSRM.JSONP.timeouts[id] = OSRM.JSONP.empty;
OSRM.JSONP.fences[id] = undefined; // clean fence
// clean DOM
var jsonp = document.getElementById('jsonp_'+id);
if(jsonp)
jsonp.parentNode.removeChild(jsonp);
},
// reset all data
reset: function() {
OSRM.JSONP.fences = {};
+70
View File
@@ -0,0 +1,70 @@
/*
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 old/cross browser support
// [browser detection and routines for old/cross browser support]
// browser detection (runs anonymous function to prevent local variables cluttering global namespace)
(function() {
var useragent = navigator.userAgent;
OSRM.Browser = {
FF3: useragent.search(/Firefox\/3/),
IE6_9: useragent.search(/MSIE (6|7|8|9)/)
};
}());
// compatibility tools
//add document.head reference for older browsers
document.head = document.head || document.getElementsByTagName('head')[0];
// supply getElementsByClassName method for older browser
OSRM.Browser.getElementsByClassName = function( node, classname ) {
var a = [];
var re = new RegExp('(^| )'+classname+'( |$)');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
};
// call a function when DOM has finished loading and remove event handler (optionally pass a different window object)
OSRM.Browser.onLoadHandler = function( function_pointer, the_window ) {
the_window = the_window || window; // default document
var the_document = the_window.document;
if(the_window.addEventListener) { // FF, CH, IE9+
var temp_function = function() {
the_window.removeEventListener("DOMContentLoaded", arguments.callee, false);
function_pointer.call();
};
the_window.addEventListener("DOMContentLoaded", temp_function, false);
}
else if(the_document.attachEvent) { // IE8-
var temp_function = function() {
if ( the_document.readyState === "interactive" || the_document.readyState === "complete" ) {
the_document.detachEvent("onreadystatechange", arguments.callee);
function_pointer.call();
}
};
the_document.attachEvent("onreadystatechange", temp_function);
}
};
+47
View File
@@ -0,0 +1,47 @@
/*
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 base class
// [support for inheritance]
// declare one class to be a subclass of another class
// (runs anonymous function to prevent local functions cluttering global namespace)
(function() {
var _inheritFromHelper = function() {};
OSRM.inheritFrom = function( sub_class, base_class ) {
_inheritFromHelper.prototype = base_class.prototype;
sub_class.prototype = new _inheritFromHelper();
sub_class.prototype.constructor = sub_class;
sub_class.prototype.base = base_class.prototype;
};
}());
// extend prototypes of a class -> used to add member values and functions
OSRM.extend = function( target_class, properties ) {
for( property in properties ) {
target_class.prototype[property] = properties[property];
}
};
// [usage of convenience functions]
// SubClass = function() {
// SubClass.prototype.base.constructor.apply(this, arguments);
// }
// OSRM.inheritFrom( SubClass, BaseClass );
// OSRM.extend( SubClass, { property:value } );
@@ -63,7 +63,4 @@ OSRM.debug.init = function() {
// onload event
if(document.addEventListener) // FF, CH
document.addEventListener("DOMContentLoaded", OSRM.debug.init, false);
else if(document.attachEvent) // IE
document.attachEvent("onreadystatechange", function() { if ( document.readyState === "interactive" ) OSRM.debug.init(); });
OSRM.Browser.onLoadHandler( OSRM.debug.init );