Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d86eaa00a0 | |||
| 54c0d50b68 | |||
| 204189c326 | |||
| acdfa546a8 | |||
| 6a9216d6e4 | |||
| 9c2a1dc37f | |||
| 26c9d357f0 | |||
| 879d73c629 | |||
| 441146eeae | |||
| d453cadc8c | |||
| 74188206e8 | |||
| 700206099b | |||
| aa952df541 | |||
| b8944da9dc | |||
| 22dda2b285 | |||
| 0ee469c4e0 | |||
| a7eef27e99 | |||
| 4b40f1253f |
@@ -1,4 +1,25 @@
|
|||||||
// dashed polyline
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Leaflet extension: Dashed Polyline
|
||||||
|
// [adds dashed optionally dashed lines when using SVG or VML rendering]
|
||||||
|
|
||||||
|
|
||||||
|
// dashed polyline class
|
||||||
L.DashedPolyline = L.Polyline.extend({
|
L.DashedPolyline = L.Polyline.extend({
|
||||||
initialize: function(latlngs, options) {
|
initialize: function(latlngs, options) {
|
||||||
L.Polyline.prototype.initialize.call(this, latlngs, options);
|
L.Polyline.prototype.initialize.call(this, latlngs, options);
|
||||||
@@ -6,7 +27,7 @@ L.DashedPolyline = L.Polyline.extend({
|
|||||||
|
|
||||||
options: {
|
options: {
|
||||||
dashed: true
|
dashed: true
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +41,7 @@ L.DashedPolyline = !L.Browser.svg ? L.DashedPolyline : L.DashedPolyline.extend({
|
|||||||
else
|
else
|
||||||
this._path.setAttribute('stroke-dasharray', '');
|
this._path.setAttribute('stroke-dasharray', '');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -34,6 +55,6 @@ L.DashedPolyline = L.Browser.svg || !L.Browser.vml ? L.DashedPolyline : L.Dashed
|
|||||||
else
|
else
|
||||||
this._stroke.dashstyle = "solid";
|
this._stroke.dashstyle = "solid";
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Leaflet extension: MouseMarker
|
||||||
|
// [marker class that propagates modifier and button presses]
|
||||||
|
// [currently deactivated: propagation mousemove events]
|
||||||
|
|
||||||
|
|
||||||
|
// extended marker class
|
||||||
L.MouseMarker = L.Marker.extend({
|
L.MouseMarker = L.Marker.extend({
|
||||||
initialize: function (latlng, options) {
|
initialize: function (latlng, options) {
|
||||||
L.Marker.prototype.initialize.apply(this, arguments);
|
L.Marker.prototype.initialize.apply(this, arguments);
|
||||||
@@ -26,5 +49,5 @@ L.MouseMarker = L.Marker.extend({
|
|||||||
shiftKey: e.shiftKey,
|
shiftKey: e.shiftKey,
|
||||||
button: e.button
|
button: e.button
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
@@ -1,4 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 browser detection
|
// OSRM browser detection
|
||||||
|
// [simple detection routines to respect some browser peculiarities]
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
@@ -6,7 +24,7 @@
|
|||||||
|
|
||||||
OSRM.Browser = {
|
OSRM.Browser = {
|
||||||
FF3: useragent.search(/Firefox\/3/),
|
FF3: useragent.search(/Firefox\/3/),
|
||||||
IE6_9: useragent.search(/MSIE (6|7|8|9)/),
|
IE6_9: useragent.search(/MSIE (6|7|8|9)/)
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
// GUI functionality
|
/*
|
||||||
|
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 functionality
|
||||||
|
// [responsible for all non-routing related GUI behaviour]
|
||||||
|
|
||||||
|
|
||||||
OSRM.GUI = {
|
OSRM.GUI = {
|
||||||
@@ -57,6 +75,6 @@ toggleOptions: function() {
|
|||||||
} else {
|
} else {
|
||||||
document.getElementById('options-box').style.visibility="visible";
|
document.getElementById('options-box').style.visibility="visible";
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -1,39 +1,54 @@
|
|||||||
|
/*
|
||||||
|
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 JSONP call wrapper
|
// OSRM JSONP call wrapper
|
||||||
// w/ DOM cleaning, fencing, timout handling
|
// [wrapper for JSONP calls with DOM cleaning, fencing, timout handling]
|
||||||
|
|
||||||
|
|
||||||
OSRM.JSONP = {
|
OSRM.JSONP = {
|
||||||
|
|
||||||
|
// storage to keep track of unfinished JSONP calls
|
||||||
fences: {},
|
fences: {},
|
||||||
callbacks: {},
|
callbacks: {},
|
||||||
timeouts: {},
|
timeouts: {},
|
||||||
timers: {},
|
timers: {},
|
||||||
|
|
||||||
TIMEOUT: OSRM.DEFAULTS.JSONP_TIMEOUT,
|
|
||||||
|
|
||||||
late: function() { },//console.log("reply too late");},
|
// default callback routines
|
||||||
empty: function() { },//console.log("empty callback");},
|
late: function() { /*OSRM.debug.log("[jsonp] reply too late");*/ },
|
||||||
|
empty: function() { /*OSRM.debug.log("[jsonp] empty callback");*/ },
|
||||||
|
|
||||||
|
|
||||||
|
// init JSONP call
|
||||||
call: function(source, callback_function, timeout_function, timeout, id) {
|
call: function(source, callback_function, timeout_function, timeout, id) {
|
||||||
// only one active JSONP call per id
|
// only one active JSONP call per id
|
||||||
if (OSRM.JSONP.fences[id] == true)
|
if (OSRM.JSONP.fences[id] == true)
|
||||||
return false;
|
return false;
|
||||||
OSRM.JSONP.fences[id] = true;
|
OSRM.JSONP.fences[id] = true;
|
||||||
|
|
||||||
// console.log("[status] jsonp init for "+id);
|
|
||||||
// console.log("[status] jsonp request ",source);
|
|
||||||
|
|
||||||
// wrap timeout function
|
// wrap timeout function
|
||||||
OSRM.JSONP.timeouts[id] = function(response) {
|
OSRM.JSONP.timeouts[id] = function(response) {
|
||||||
timeout_function(response);
|
timeout_function(response);
|
||||||
|
|
||||||
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
|
||||||
// if(jsonp)
|
|
||||||
// jsonp.parentNode.removeChild(jsonp);
|
|
||||||
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
||||||
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
||||||
OSRM.JSONP.fences[id] = undefined; // clean fence
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
|
||||||
// console.log("timeout: "+id); // at the end - otherwise racing conditions may happen
|
// OSRM.debug.log("[jsonp] timout handling: "+id);
|
||||||
// document.getElementById('information-box').innerHTML += "timeout:" + id + "<br>";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// wrap callback function
|
// wrap callback function
|
||||||
@@ -41,26 +56,19 @@ OSRM.JSONP = {
|
|||||||
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
clearTimeout(OSRM.JSONP.timers[id]); // clear timeout timer
|
||||||
OSRM.JSONP.timers[id] = undefined;
|
OSRM.JSONP.timers[id] = undefined;
|
||||||
|
|
||||||
if( OSRM.JSONP.fences[id] == undefined ) // fence to prevent execution after timeout function (when precompiled!)
|
|
||||||
return;
|
|
||||||
|
|
||||||
callback_function(response); // actual wrapped callback
|
callback_function(response); // actual wrapped callback
|
||||||
|
|
||||||
// var jsonp = document.getElementById('jsonp_'+id); // clean DOM
|
|
||||||
// if(jsonp)
|
|
||||||
// jsonp.parentNode.removeChild(jsonp);
|
|
||||||
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
OSRM.JSONP.callbacks[id] = OSRM.JSONP.late; // clean functions
|
||||||
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
OSRM.JSONP.timeouts[id] = OSRM.JSONP.late;
|
||||||
OSRM.JSONP.fences[id] = undefined; // clean fence
|
OSRM.JSONP.fences[id] = undefined; // clean fence
|
||||||
|
|
||||||
// console.log("[status] jsonp response for "+id); // at the end - otherwise racing conditions may happen
|
// OSRM.debug.log("[jsonp] response handling: "+id);
|
||||||
// document.getElementById('information-box').innerHTML += "callback:" + id + "<br>";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// clean DOM (cannot reuse script element with all browsers, unfortunately)
|
// clean DOM (unfortunately, script elements cannot be reused by all browsers)
|
||||||
var jsonp = document.getElementById('jsonp_'+id);
|
var jsonp = document.getElementById('jsonp_'+id);
|
||||||
if(jsonp)
|
if(jsonp)
|
||||||
jsonp.parentNode.removeChild(jsonp);
|
jsonp.parentNode.removeChild(jsonp);
|
||||||
|
|
||||||
// add script to DOM
|
// add script to DOM
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
@@ -71,7 +79,16 @@ OSRM.JSONP = {
|
|||||||
|
|
||||||
// start timeout timer
|
// start timeout timer
|
||||||
OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout);
|
OSRM.JSONP.timers[id] = setTimeout(OSRM.JSONP.timeouts[id], timeout);
|
||||||
|
|
||||||
|
// OSRM.debug.log("[jsonp] init: "+id);
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
// reset all data
|
||||||
|
reset: function() {
|
||||||
|
OSRM.JSONP.fences = {};
|
||||||
|
OSRM.JSONP.callbacks = {};
|
||||||
|
OSRM.JSONP.timeouts = {};
|
||||||
|
OSRM.JSONP.timers = {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,73 +1,116 @@
|
|||||||
// localization
|
/*
|
||||||
|
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
|
||||||
|
// [basic localization options]
|
||||||
|
|
||||||
|
|
||||||
OSRM.Localization = {
|
OSRM.Localization = {
|
||||||
language: "en",
|
|
||||||
|
// if existing, return localized string -> English string -> input string
|
||||||
translate: function(text) {
|
translate: function(text) {
|
||||||
if( OSRM.Localization[OSRM.Localization.language][text] )
|
if( OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text] )
|
||||||
return OSRM.Localization[OSRM.Localization.language][text];
|
return OSRM.Localization[OSRM.DEFAULTS.LANGUAGE][text];
|
||||||
else if( OSRM.Localization[OSRM.Localization.language][text] )
|
else if( OSRM.Localization["en"][text] )
|
||||||
return OSRM.Localization[OSRM.Localization.language][text];
|
return OSRM.Localization["en"][text];
|
||||||
else
|
else
|
||||||
return text;
|
return text;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// shorter call to translate function
|
||||||
OSRM.loc = OSRM.Localization.translate;
|
OSRM.loc = OSRM.Localization.translate;
|
||||||
|
|
||||||
|
|
||||||
|
// German language support
|
||||||
OSRM.Localization["de"] = {
|
OSRM.Localization["de"] = {
|
||||||
//gui
|
//gui
|
||||||
"GUI_START": "Start",
|
"GUI_START": "Start",
|
||||||
"GUI_END": "Ende",
|
"GUI_END": "Ziel",
|
||||||
"GUI_RESET": "Reset",
|
"GUI_RESET": "Reset",
|
||||||
"GUI_SEARCH": "Suchen",
|
"GUI_SEARCH": "Zeigen",
|
||||||
"GUI_ROUTE": "Route",
|
|
||||||
"GUI_REVERSE": "Umdrehen",
|
"GUI_REVERSE": "Umdrehen",
|
||||||
"GUI_OPTIONS": "Optionen",
|
"GUI_OPTIONS": "Optionen",
|
||||||
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Stra�en hervorheben",
|
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben",
|
||||||
"GUI_START_TOOLTIP": "Startposition eingeben",
|
"GUI_START_TOOLTIP": "Startposition eingeben",
|
||||||
"GUI_END_TOOLTIP": "Zielposition eingeben",
|
"GUI_END_TOOLTIP": "Zielposition eingeben",
|
||||||
"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
"GUI_LEGAL_NOTICE": "GUI2 v0.1.1 120316 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
||||||
// geocoder
|
// geocoder
|
||||||
"SEARCH_RESULTS": "Suchergebnisse",
|
"SEARCH_RESULTS": "Suchergebnisse",
|
||||||
"TIMED_OUT": "Zeit�berschreitung",
|
"TIMED_OUT": "Zeitüberschreitung",
|
||||||
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
|
"NO_RESULTS_FOUND": "Keine Ergebnisse gefunden",
|
||||||
|
"NO_RESULTS_FOUND_SOURCE": "Keine Ergebnisse gefunden für Start",
|
||||||
|
"NO_RESULTS_FOUND_TARGET": "Keine Ergebnisse gefunden für Ziel",
|
||||||
// routing
|
// routing
|
||||||
"ROUTE_DESCRIPTION": "Routenbeschreibung",
|
"ROUTE_DESCRIPTION": "Routenbeschreibung",
|
||||||
"GET_LINK": "Generiere Link",
|
"GET_LINK": "Generiere Link",
|
||||||
"LINK_TO_ROUTE": "Link zur Route",
|
|
||||||
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
|
"LINK_TO_ROUTE_TIMEOUT": "nicht möglich",
|
||||||
"GPX_FILE": "GPX Datei",
|
"GPX_FILE": "GPX Datei",
|
||||||
"DISTANCE": "Distanz",
|
"DISTANCE": "Distanz",
|
||||||
"DURATION": "Dauer",
|
"DURATION": "Dauer",
|
||||||
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
|
"YOUR_ROUTE_IS_BEING_COMPUTED": "Ihre Route wird berechnet",
|
||||||
"NO_ROUTE_FOUND": "Keine Route hierher m�glich",
|
"NO_ROUTE_FOUND": "Keine Route hierher möglich",
|
||||||
|
// directions
|
||||||
|
"N": "Norden",
|
||||||
|
"O": "Ost",
|
||||||
|
"S": "Süden",
|
||||||
|
"W": "Westen",
|
||||||
|
"NO": "Nordost",
|
||||||
|
"SO": "Südost",
|
||||||
|
"SW": "Südwest",
|
||||||
|
"NW": "Nordwest"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// English language support
|
||||||
OSRM.Localization["en"] = {
|
OSRM.Localization["en"] = {
|
||||||
//gui
|
//gui
|
||||||
"GUI_START": "Start",
|
"GUI_START": "Start",
|
||||||
"GUI_END": "End",
|
"GUI_END": "End",
|
||||||
"GUI_RESET": "Reset",
|
"GUI_RESET": " Reset ",
|
||||||
"GUI_SEARCH": "Search",
|
"GUI_SEARCH": " Show ",
|
||||||
"GUI_ROUTE": "Route",
|
|
||||||
"GUI_REVERSE": "Reverse",
|
"GUI_REVERSE": "Reverse",
|
||||||
"GUI_OPTIONS": "Options",
|
"GUI_OPTIONS": "Options",
|
||||||
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets",
|
"GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets",
|
||||||
"GUI_START_TOOLTIP": "Enter start",
|
"GUI_START_TOOLTIP": "Enter start",
|
||||||
"GUI_END_TOOLTIP": "Enter destination",
|
"GUI_END_TOOLTIP": "Enter destination",
|
||||||
"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
"GUI_LEGAL_NOTICE": "GUI2 v0.1.1 120316 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a>",
|
||||||
// geocoder
|
// geocoder
|
||||||
"SEARCH_RESULTS": "Search Results",
|
"SEARCH_RESULTS": "Search Results",
|
||||||
"TIMED_OUT": "Timed Out",
|
"TIMED_OUT": "Timed Out",
|
||||||
"NO_RESULTS_FOUND": "No results found",
|
"NO_RESULTS_FOUND": "No results found",
|
||||||
|
"NO_RESULTS_FOUND_SOURCE": "No results found for start",
|
||||||
|
"NO_RESULTS_FOUND_TARGET": "No results found for end",
|
||||||
//routing
|
//routing
|
||||||
"ROUTE_DESCRIPTION": "Route Description",
|
"ROUTE_DESCRIPTION": "Route Description",
|
||||||
"GET_LINK": "Generate Link",
|
"GET_LINK": "Generate Link",
|
||||||
"LINK_TO_ROUTE": "Route Link",
|
|
||||||
"LINK_TO_ROUTE_TIMEOUT": "not available",
|
"LINK_TO_ROUTE_TIMEOUT": "not available",
|
||||||
"GPX_FILE": "GPX File",
|
"GPX_FILE": "GPX File",
|
||||||
"DISTANCE": "Distance",
|
"DISTANCE": "Distance",
|
||||||
"DURATION": "Duration",
|
"DURATION": "Duration",
|
||||||
"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed",
|
"YOUR_ROUTE_IS_BEING_COMPUTED": "Your route is being computed",
|
||||||
"NO_ROUTE_FOUND": "No route possible",
|
"NO_ROUTE_FOUND": "No route possible",
|
||||||
|
// directions
|
||||||
|
"N": "north",
|
||||||
|
"E": "east",
|
||||||
|
"S": "south",
|
||||||
|
"W": "west",
|
||||||
|
"NE": "northeast",
|
||||||
|
"SE": "southeast",
|
||||||
|
"SW": "southwest",
|
||||||
|
"NW": "northwest"
|
||||||
};
|
};
|
||||||
@@ -1,14 +1,33 @@
|
|||||||
// OSRM.Marker class
|
/*
|
||||||
// + sub-classes
|
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 markers
|
||||||
|
// [base marker class, derived highlight marker and route marker classes, marker management]
|
||||||
|
|
||||||
|
|
||||||
// base class
|
// base marker class (wraps Leaflet markers)
|
||||||
OSRM.Marker = function( label, style, position ) {
|
OSRM.Marker = function( label, style, position ) {
|
||||||
this.label = label ? label : "marker";
|
this.label = label ? label : "marker";
|
||||||
this.position = position ? position : new L.LatLng(0,0);
|
this.position = position ? position : new L.LatLng(0,0);
|
||||||
|
|
||||||
this.marker = new L.MouseMarker( this.position, style );
|
this.marker = new L.MouseMarker( this.position, style );
|
||||||
this.marker.parent = this;
|
this.marker.parent = this;
|
||||||
|
this.dirty_move = true;
|
||||||
|
this.dirty_type = true;
|
||||||
|
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
this.hint = undefined;
|
this.hint = undefined;
|
||||||
@@ -48,24 +67,29 @@ centerView: function(zooming) {
|
|||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// highlight marker
|
// highlight marker class (cannot be dragged)
|
||||||
OSRM.HighlightMarker = function( label, style, position) {
|
OSRM.HighlightMarker = function( label, style, position) {
|
||||||
OSRM.HighlightMarker.prototype.base.constructor.apply( this, arguments );
|
OSRM.HighlightMarker.prototype.base.constructor.apply( this, arguments );
|
||||||
this.label = label ? label : "highlight_marker";
|
this.label = label ? label : "highlight_marker";
|
||||||
|
|
||||||
|
this.marker.on( 'click', this.onClick );
|
||||||
};
|
};
|
||||||
OSRM.inheritFrom( OSRM.HighlightMarker, OSRM.Marker );
|
OSRM.inheritFrom( OSRM.HighlightMarker, OSRM.Marker );
|
||||||
OSRM.extend( OSRM.HighlightMarker, {
|
OSRM.extend( OSRM.HighlightMarker, {
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "OSRM.HighlightMarker: \""+this.label+"\", "+this.position+")";
|
return "OSRM.HighlightMarker: \""+this.label+"\", "+this.position+")";
|
||||||
},
|
},
|
||||||
|
onClick: function(e) {
|
||||||
|
this.parent.hide();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// route marker
|
// route marker class (draggable, invokes route drawing routines)
|
||||||
OSRM.RouteMarker = function ( label, style, position ) {
|
OSRM.RouteMarker = function ( label, style, position ) {
|
||||||
OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments );
|
OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments );
|
||||||
this.label = label ? label : "route_marker";
|
this.label = label ? label : "route_marker";
|
||||||
@@ -78,8 +102,6 @@ OSRM.RouteMarker = function ( label, style, position ) {
|
|||||||
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
||||||
OSRM.extend( OSRM.RouteMarker, {
|
OSRM.extend( OSRM.RouteMarker, {
|
||||||
onClick: function(e) {
|
onClick: function(e) {
|
||||||
// if(!e.ctrlKey)
|
|
||||||
// return;
|
|
||||||
for( var i=0; i<my_markers.route.length; i++) {
|
for( var i=0; i<my_markers.route.length; i++) {
|
||||||
if( my_markers.route[i].marker === this ) {
|
if( my_markers.route[i].marker === this ) {
|
||||||
my_markers.removeMarker( i );
|
my_markers.removeMarker( i );
|
||||||
@@ -91,9 +113,9 @@ onClick: function(e) {
|
|||||||
my_markers.highlight.hide();
|
my_markers.highlight.hide();
|
||||||
},
|
},
|
||||||
onDrag: function(e) {
|
onDrag: function(e) {
|
||||||
// OSRM.debug.log("[event] drag event");
|
this.parent.dirty_move = true;
|
||||||
this.parent.setPosition( e.target.getLatLng() );
|
this.parent.setPosition( e.target.getLatLng() );
|
||||||
if(OSRM.dragging == true) // TODO: hack to deal with drag events after dragend event
|
if(OSRM.dragging == true) // TODO: hack that deals with drag events after dragend event
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
else
|
else
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
@@ -101,7 +123,6 @@ onDrag: function(e) {
|
|||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragStart: function(e) {
|
onDragStart: function(e) {
|
||||||
// OSRM.debug.log("[event] dragstart event");
|
|
||||||
OSRM.dragging = true;
|
OSRM.dragging = true;
|
||||||
|
|
||||||
// hack to store id of dragged marker
|
// hack to store id of dragged marker
|
||||||
@@ -119,23 +140,29 @@ onDragStart: function(e) {
|
|||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
},
|
},
|
||||||
onDragEnd: function(e) {
|
onDragEnd: function(e) {
|
||||||
// OSRM.debug.log("[event] dragend event");
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
if (my_route.isShown()) {
|
if (my_route.isShown()) {
|
||||||
my_route.hideOldRoute();
|
my_route.hideOldRoute();
|
||||||
my_route.hideUnnamedRoute(); // provides better visuals
|
my_route.hideUnnamedRoute();
|
||||||
}
|
}
|
||||||
OSRM.dragging = false;
|
OSRM.dragging = false;
|
||||||
|
|
||||||
updateLocation( this.parent.label );
|
updateLocation( this.parent.label );
|
||||||
|
if(my_route.isShown()==false) {
|
||||||
|
if(this.parent.label == "source")
|
||||||
|
updateReverseGeocoder("source");
|
||||||
|
else if(this.parent.label == "target")
|
||||||
|
updateReverseGeocoder("target");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
|
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//marker array class
|
// 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() {
|
OSRM.Markers = function() {
|
||||||
this.route = new Array();
|
this.route = new Array();
|
||||||
this.highlight = new OSRM.HighlightMarker("highlight", {draggable:false,icon:OSRM.icons['marker-highlight']});;
|
this.highlight = new OSRM.HighlightMarker("highlight", {draggable:false,icon:OSRM.icons['marker-highlight']});;
|
||||||
@@ -190,5 +217,15 @@ removeMarker: function(id) {
|
|||||||
|
|
||||||
this.route[id].hide();
|
this.route[id].hide();
|
||||||
this.route.splice(id, 1);
|
this.route.splice(id, 1);
|
||||||
|
},
|
||||||
|
hasSource: function() {
|
||||||
|
if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
hasTarget: function() {
|
||||||
|
if( my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,25 @@
|
|||||||
// OSRM route classes
|
/*
|
||||||
|
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]
|
||||||
|
|
||||||
|
|
||||||
// base route class
|
// simple route class (wraps Leaflet Polyline)
|
||||||
OSRM.SimpleRoute = function (label, style) {
|
OSRM.SimpleRoute = function (label, style) {
|
||||||
this.label = (label ? label : "route");
|
this.label = (label ? label : "route");
|
||||||
this.route = new L.DashedPolyline();
|
this.route = new L.DashedPolyline();
|
||||||
@@ -35,7 +53,6 @@ setStyle: function(style) {
|
|||||||
},
|
},
|
||||||
centerView: function() {
|
centerView: function() {
|
||||||
var bounds = new L.LatLngBounds( this.getPositions() );
|
var bounds = new L.LatLngBounds( this.getPositions() );
|
||||||
bounds._southWest.lng-=1.02; // dirty hack
|
|
||||||
map.fitBounds( bounds );
|
map.fitBounds( bounds );
|
||||||
},
|
},
|
||||||
onClick: function(e) {
|
onClick: function(e) {
|
||||||
@@ -44,11 +61,11 @@ onClick: function(e) {
|
|||||||
},
|
},
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
|
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// multiroute class (several separate route parts)
|
// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes)
|
||||||
OSRM.MultiRoute = function (label) {
|
OSRM.MultiRoute = function (label) {
|
||||||
this.label = (label ? label : "multiroute");
|
this.label = (label ? label : "multiroute");
|
||||||
this.route = new L.LayerGroup();
|
this.route = new L.LayerGroup();
|
||||||
@@ -84,7 +101,8 @@ toString: function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// main route class
|
// route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets)
|
||||||
|
// [this holds the route geometry]
|
||||||
OSRM.Route = function() {
|
OSRM.Route = function() {
|
||||||
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
|
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
|
||||||
this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
|
this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
|
||||||
@@ -117,6 +135,12 @@ OSRM.extend( OSRM.Route,{
|
|||||||
this._current_route.hide();
|
this._current_route.hide();
|
||||||
this._unnamed_route.hide();
|
this._unnamed_route.hide();
|
||||||
},
|
},
|
||||||
|
hideAll: function() {
|
||||||
|
this._current_route.hide();
|
||||||
|
this._unnamed_route.hide();
|
||||||
|
this._old_route.hide();
|
||||||
|
this._noroute = OSRM.Route.ROUTE;
|
||||||
|
},
|
||||||
|
|
||||||
showUnnamedRoute: function(positions) {
|
showUnnamedRoute: function(positions) {
|
||||||
this._unnamed_route.clearRoutes();
|
this._unnamed_route.clearRoutes();
|
||||||
@@ -129,7 +153,7 @@ OSRM.extend( OSRM.Route,{
|
|||||||
hideUnnamedRoute: function() {
|
hideUnnamedRoute: function() {
|
||||||
this._unnamed_route.hide();
|
this._unnamed_route.hide();
|
||||||
},
|
},
|
||||||
// TODO: hack to put unnamed_route above old_route -> easier way in Leaglet 0.4+
|
// TODO: hack to put unnamed_route above old_route -> easier way in will be available Leaflet 0.4
|
||||||
_raiseUnnamedRoute: function() {
|
_raiseUnnamedRoute: function() {
|
||||||
if(this._unnamed_route.isShown()) {
|
if(this._unnamed_route.isShown()) {
|
||||||
this._unnamed_route.hide();
|
this._unnamed_route.hide();
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
// OSRM route class
|
|
||||||
|
|
||||||
|
|
||||||
OSRM.TheRoute = {
|
|
||||||
|
|
||||||
};
|
|
||||||
OSRM.extend( OSRM.TheRoute, {
|
|
||||||
|
|
||||||
show: function() {},
|
|
||||||
hide: function() {},
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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
|
// OSRM base class
|
||||||
|
// [has to loaded before all other OSRM classes]
|
||||||
|
|
||||||
OSRM = {};
|
OSRM = {};
|
||||||
OSRM.VERSION = '0.1';
|
OSRM.VERSION = '0.1.1';
|
||||||
|
|
||||||
|
|
||||||
// inheritance helper function (convenience function)
|
// inheritance helper function (convenience function)
|
||||||
OSRM._inheritFromHelper = function() {};
|
OSRM._inheritFromHelper = function() {};
|
||||||
@@ -12,6 +31,7 @@ OSRM.inheritFrom = function( sub_class, base_class ) {
|
|||||||
sub_class.prototype.base = base_class.prototype;
|
sub_class.prototype.base = base_class.prototype;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// class prototype extending helper function (convenience function)
|
// class prototype extending helper function (convenience function)
|
||||||
OSRM.extend = function( target_class, properties ) {
|
OSRM.extend = function( target_class, properties ) {
|
||||||
for( property in properties ) {
|
for( property in properties ) {
|
||||||
@@ -19,6 +39,7 @@ OSRM.extend = function( target_class, properties ) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// usage:
|
// usage:
|
||||||
// SubClass = function() {
|
// SubClass = function() {
|
||||||
// SubClass.prototype.base.constructor.apply(this, arguments);
|
// SubClass.prototype.base.constructor.apply(this, arguments);
|
||||||
|
|||||||
@@ -1,14 +1,32 @@
|
|||||||
|
/*
|
||||||
|
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 config file
|
// OSRM config file
|
||||||
// (has to be loaded directly after OSRM.base!)
|
// [has to be loaded directly after OSRM.base]
|
||||||
|
|
||||||
OSRM.DEFAULTS = {
|
OSRM.DEFAULTS = {
|
||||||
HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute',
|
HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute',
|
||||||
HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/',
|
HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/',
|
||||||
WEBSITE_URL: 'http://map.project-osrm.org/',
|
WEBSITE_URL: document.URL.replace(/#*\?.*/i,""),
|
||||||
JSONP_TIMEOUT: 2000,
|
JSONP_TIMEOUT: 5000,
|
||||||
ZOOM_LEVEL: 14,
|
ZOOM_LEVEL: 14,
|
||||||
ONLOAD_LATITUDE: 48.84,
|
ONLOAD_LATITUDE: 48.84,
|
||||||
ONLOAD_LONGITUDE: 10.10,
|
ONLOAD_LONGITUDE: 10.10,
|
||||||
ONLOAD_SOURCE: "",
|
ONLOAD_SOURCE: "",
|
||||||
ONLOAD_TARGET: "",
|
ONLOAD_TARGET: "",
|
||||||
};
|
LANGUAGE: "en"
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
// debug code for OSRM
|
// debug code for OSRM
|
||||||
// (works faster than console.log in time-critical events)
|
// [works better than console.log in older browsers and for logging event handling]
|
||||||
|
|
||||||
OSRM.debug = {};
|
OSRM.debug = {};
|
||||||
|
|
||||||
|
|||||||
@@ -1,133 +1,102 @@
|
|||||||
|
/*
|
||||||
|
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 geocoding routines
|
||||||
|
// [geocoder query, management and display of geocoder results]
|
||||||
|
// [TODO: better separation of GUI and geocoding routines, reverse geocoding]
|
||||||
|
|
||||||
// some constants
|
// some constants
|
||||||
OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json';
|
OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0';
|
||||||
OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json';
|
|
||||||
OSRM.SOURCE_MARKER_LABEL = "source";
|
OSRM.SOURCE_MARKER_LABEL = "source";
|
||||||
OSRM.TARGET_MARKER_LABEL = "target";
|
OSRM.TARGET_MARKER_LABEL = "target";
|
||||||
|
|
||||||
|
|
||||||
// update locations in input boxes
|
// update geo coordinates in input boxes
|
||||||
function updateLocation(marker_id) {
|
function updateLocation(marker_id) {
|
||||||
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0].dirty_move == true ) {
|
||||||
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1].dirty_move == true) {
|
||||||
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function updateReverseGeocoder(marker_id) {
|
|
||||||
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
|
||||||
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
|
||||||
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
|
||||||
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
|
||||||
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
|
||||||
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function updateLocations() {
|
|
||||||
if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
|
||||||
document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
|
||||||
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
|
||||||
//OSRM.debug.log("[call1] reverse geocoder");
|
|
||||||
}
|
|
||||||
|
|
||||||
if( my_markers.route[my_markers.route.length-1] && my_markers.route[ my_markers.route.length-1 ].label == OSRM.TARGET_MARKER_LABEL) {
|
|
||||||
document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
|
||||||
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function timeout_ReverseGeocoder() {
|
// process input request and call geocoder if needed
|
||||||
//OSRM.debug.log("[timeout] reverse geocoder");
|
|
||||||
}
|
|
||||||
|
|
||||||
//prepare request and call reverse geocoder
|
|
||||||
function callReverseGeocoder(marker_id, lat, lon) {
|
|
||||||
//build request
|
|
||||||
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
|
||||||
var src= OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
|
||||||
OSRM.JSONP.call( src, showReverseGeocoderResults_Source, timeout_ReverseGeocoder, OSRM.JSONP.TIMEOUT, "reverse_geocoder_source" );
|
|
||||||
//OSRM.debug.log("[call2] reverse geocoder");
|
|
||||||
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
|
||||||
var src = OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
|
||||||
OSRM.JSONP.call( src, showReverseGeocoderResults_Target, timeout_ReverseGeocoder, OSRM.JSONP.TIMEOUT, "reverse_geocoder_target" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//processing JSONP response of reverse geocoder
|
|
||||||
//(with wrapper functions for source/target jsonp)
|
|
||||||
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
|
||||||
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
|
||||||
function showReverseGeocoderResults(marker_id, response) {
|
|
||||||
//OSRM.debug.log("[inner] reverse geocoder");
|
|
||||||
if(response){
|
|
||||||
if(response.address == undefined)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var address = "";
|
|
||||||
if( response.address.road)
|
|
||||||
address += response.address.road;
|
|
||||||
if( response.address.city) {
|
|
||||||
if( response.address.road)
|
|
||||||
address += ", ";
|
|
||||||
address += response.address.city;
|
|
||||||
}
|
|
||||||
if( address == "" )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(marker_id == OSRM.SOURCE_MARKER_LABEL)
|
|
||||||
document.getElementById("input-source-name").value = address;
|
|
||||||
else if(marker_id == OSRM.TARGET_MARKER_LABEL)
|
|
||||||
document.getElementById("input-target-name").value = address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// prepare request and call geocoder
|
|
||||||
function callGeocoder(marker_id, query) {
|
function callGeocoder(marker_id, query) {
|
||||||
//geo coordinate given?
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0].dirty_move == false && my_markers.route[0].dirty_type == false)
|
||||||
|
return;
|
||||||
|
if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1].dirty_move == false && my_markers.route[my_markers.route.length-1].dirty_type == false)
|
||||||
|
return;
|
||||||
|
if(query=="")
|
||||||
|
return;
|
||||||
|
|
||||||
|
//geo coordinates given -> go directly to drawing results
|
||||||
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
|
if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){
|
||||||
var coord = query.split(/[,;]/);
|
var coord = query.split(/[,;]/);
|
||||||
onclickGeocoderResult(marker_id, coord[0], coord[1]);
|
onclickGeocoderResult(marker_id, coord[0], coord[1], true);
|
||||||
// updateReverseGeocoder(marker_id);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//build request
|
//build request
|
||||||
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
var src= OSRM.GEOCODE_POST + "&q=" + query;
|
var src= OSRM.GEOCODE_POST + "&q=" + query;
|
||||||
OSRM.JSONP.call( src, showGeocoderResults_Source, showGeocoderResults_Timeout, OSRM.JSONP.TIMEOUT, "geocoder_source" );
|
OSRM.JSONP.call( src, showGeocoderResults_Source, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_source" );
|
||||||
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
var src = OSRM.GEOCODE_POST + "&q=" + query;
|
var src = OSRM.GEOCODE_POST + "&q=" + query;
|
||||||
OSRM.JSONP.call( src, showGeocoderResults_Target, showGeocoderResults_Timeout, OSRM.JSONP.TIMEOUT, "geocoder_target" );
|
OSRM.JSONP.call( src, showGeocoderResults_Target, showGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "geocoder_target" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// helper function for clicks on geocoder search results
|
// helper function for clicks on geocoder search results
|
||||||
function onclickGeocoderResult(marker_id, lat, lon) {
|
function onclickGeocoderResult(marker_id, lat, lon, do_reverse_geocode, zoom ) {
|
||||||
var index;
|
var index;
|
||||||
if( marker_id == OSRM.SOURCE_MARKER_LABEL )
|
if( marker_id == OSRM.SOURCE_MARKER_LABEL )
|
||||||
index = my_markers.setSource( new L.LatLng(lat, lon) );
|
index = my_markers.setSource( new L.LatLng(lat, lon) );
|
||||||
else if( marker_id == OSRM.TARGET_MARKER_LABEL )
|
else if( marker_id == OSRM.TARGET_MARKER_LABEL )
|
||||||
index = my_markers.setTarget( new L.LatLng(lat, lon) );
|
index = my_markers.setTarget( new L.LatLng(lat, lon) );
|
||||||
else
|
else
|
||||||
index = -1; // search via positions not yet implemented
|
index = -1; // via nodes not yet implemented
|
||||||
|
|
||||||
|
if( do_reverse_geocode == true )
|
||||||
|
updateReverseGeocoder(marker_id);
|
||||||
|
if( zoom == undefined )
|
||||||
|
zoom = true;
|
||||||
|
|
||||||
my_markers.route[index].show();
|
my_markers.route[index].show();
|
||||||
my_markers.route[index].centerView();
|
if( !my_markers.route[index].dirty_move || my_markers.route[index].dirty_type )
|
||||||
|
my_markers.route[index].centerView(zoom);
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
|
my_markers.route[index].dirty_move = false;
|
||||||
|
my_markers.route[index].dirty_type = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// processing JSONP response of geocoder
|
// process JSONP response of geocoder
|
||||||
// (with wrapper functions for source/target jsonp)
|
// (with wrapper functions for source/target jsonp)
|
||||||
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
function showGeocoderResults_Source(response) { showGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
||||||
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
function showGeocoderResults_Target(response) { showGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
||||||
function showGeocoderResults(marker_id, response) {
|
function showGeocoderResults(marker_id, response) {
|
||||||
if(response){
|
if(response){
|
||||||
if(response.length == 0) {
|
if(response.length == 0) {
|
||||||
showGeocoderResults_Empty();
|
showGeocoderResults_Empty(marker_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = "";
|
var html = "";
|
||||||
html += '<table class="results-table">';
|
html += '<table class="results-table">';
|
||||||
for(var i=0; i < response.length; i++){
|
for(var i=0; i < response.length; i++){
|
||||||
@@ -154,11 +123,83 @@ function showGeocoderResults(marker_id, response) {
|
|||||||
onclickGeocoderResult(marker_id, response[0].lat, response[0].lon);
|
onclickGeocoderResult(marker_id, response[0].lat, response[0].lon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showGeocoderResults_Empty() {
|
function showGeocoderResults_Empty(marker_id) {
|
||||||
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+".<p>";
|
if(marker_id == OSRM.SOURCE_MARKER_LABEL)
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_SOURCE")+".<p>";
|
||||||
|
else if(marker_id == OSRM.TARGET_MARKER_LABEL)
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND_TARGET")+".<p>";
|
||||||
|
else
|
||||||
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("NO_RESULTS_FOUND")+".<p>";
|
||||||
}
|
}
|
||||||
function showGeocoderResults_Timeout() {
|
function showGeocoderResults_Timeout() {
|
||||||
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
document.getElementById('information-box-headline').innerHTML = OSRM.loc("SEARCH_RESULTS")+":";
|
||||||
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("TIMED_OUT")+".<p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// - [upcoming feature: reverse geocoding (untested) ] -
|
||||||
|
OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0';
|
||||||
|
|
||||||
|
//update reverse geocoder informatiopn in input boxes
|
||||||
|
function updateReverseGeocoder(marker_id) {
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.hasSource()==true) { //&& my_markers.route[0].dirty == true ) {
|
||||||
|
//document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng);
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.hasTarget()==true) { //&& my_markers.route[my_markers.route.length-1].dirty == true) {
|
||||||
|
//document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
||||||
|
callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//prepare request and call reverse geocoder
|
||||||
|
function callReverseGeocoder(marker_id, lat, lon) {
|
||||||
|
//build request
|
||||||
|
if (marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
var src= OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
||||||
|
OSRM.JSONP.call( src, showReverseGeocoderResults_Source, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_source" );
|
||||||
|
} else if (marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
var src = OSRM.REVERSE_GEOCODE_POST + "&lat=" + lat + "&lon=" + lon;
|
||||||
|
OSRM.JSONP.call( src, showReverseGeocoderResults_Target, showReverseGeocoderResults_Timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, "reverse_geocoder_target" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//processing JSONP response of reverse geocoder
|
||||||
|
//(with wrapper functions for source/target jsonp)
|
||||||
|
function showReverseGeocoderResults_Timeout() {}
|
||||||
|
function showReverseGeocoderResults_Source(response) { showReverseGeocoderResults(OSRM.SOURCE_MARKER_LABEL, response); }
|
||||||
|
function showReverseGeocoderResults_Target(response) { showReverseGeocoderResults(OSRM.TARGET_MARKER_LABEL, response); }
|
||||||
|
function showReverseGeocoderResults(marker_id, response) {
|
||||||
|
//OSRM.debug.log("[inner] reverse geocoder");
|
||||||
|
if(response){
|
||||||
|
if(response.address == undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var address = "";
|
||||||
|
if( response.address.road)
|
||||||
|
address += response.address.road;
|
||||||
|
if( response.address.city ) {
|
||||||
|
if( address != "" )
|
||||||
|
address += ", ";
|
||||||
|
address += response.address.city;
|
||||||
|
} else if( response.address.village ) {
|
||||||
|
if( address != "" )
|
||||||
|
address += ", ";
|
||||||
|
address += response.address.village;
|
||||||
|
}
|
||||||
|
if( address == "" && response.address.country )
|
||||||
|
address += response.address.country;
|
||||||
|
if( address == "" )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(marker_id == OSRM.SOURCE_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-source-name").value = address;
|
||||||
|
my_markers.route[0].dirty_move = false;
|
||||||
|
my_markers.route[0].dirty_type = false;
|
||||||
|
} else if(marker_id == OSRM.TARGET_MARKER_LABEL) {
|
||||||
|
document.getElementById("input-target-name").value = address;
|
||||||
|
my_markers.route[my_markers.route.length-1].dirty_move = false;
|
||||||
|
my_markers.route[my_markers.route.length-1].dirty_type = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 483 B |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 477 B |
|
After Width: | Height: | Size: 480 B |
|
After Width: | Height: | Size: 488 B |
|
After Width: | Height: | Size: 489 B |
@@ -1,4 +1,24 @@
|
|||||||
/* styles for map */
|
/*
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
/* map -> fullscreen */
|
||||||
body {
|
body {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -89,7 +109,7 @@ html, body, #map {
|
|||||||
padding:0px;
|
padding:0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-toggle
|
.main-toggle-out
|
||||||
{
|
{
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
@@ -99,14 +119,32 @@ html, body, #map {
|
|||||||
height:16px;
|
height:16px;
|
||||||
background-image:url("images/cancel.png");
|
background-image:url("images/cancel.png");
|
||||||
}
|
}
|
||||||
.main-toggle:hover
|
.main-toggle-out:hover
|
||||||
{
|
{
|
||||||
background-image:url("images/cancel_hover.png");
|
background-image:url("images/cancel_hover.png");
|
||||||
}
|
}
|
||||||
.main-toggle:active
|
.main-toggle-out:active
|
||||||
{
|
{
|
||||||
background-image:url("images/cancel_active.png");
|
background-image:url("images/cancel_active.png");
|
||||||
}
|
}
|
||||||
|
.main-toggle-in
|
||||||
|
{
|
||||||
|
cursor:pointer;
|
||||||
|
position:absolute;
|
||||||
|
right:5px;
|
||||||
|
top:5px;
|
||||||
|
width:16px;
|
||||||
|
height:16px;
|
||||||
|
background-image:url("images/restore.png");
|
||||||
|
}
|
||||||
|
.main-toggle-in:hover
|
||||||
|
{
|
||||||
|
background-image:url("images/restore_hover.png");
|
||||||
|
}
|
||||||
|
.main-toggle-in:active
|
||||||
|
{
|
||||||
|
background-image:url("images/restore_active.png");
|
||||||
|
}
|
||||||
|
|
||||||
.main-options
|
.main-options
|
||||||
{
|
{
|
||||||
@@ -222,6 +260,16 @@ html, body, #map {
|
|||||||
padding-top:1px;
|
padding-top:1px;
|
||||||
padding-bottom: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
|
.result-item
|
||||||
{
|
{
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
@@ -241,7 +289,8 @@ html, body, #map {
|
|||||||
font-size:10px;
|
font-size:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generally useful styles (above buttons, so that they get their special cursor!)*/
|
|
||||||
|
/* utility styles (defined above buttons, so that buttons retain cursor:pointer)*/
|
||||||
.not-selectable
|
.not-selectable
|
||||||
{
|
{
|
||||||
cursor:default;
|
cursor:default;
|
||||||
@@ -260,6 +309,7 @@ html, body, #map {
|
|||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* buttons */
|
/* buttons */
|
||||||
.button
|
.button
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
|
|
||||||
@@ -11,6 +29,9 @@
|
|||||||
<meta name="description" content="OSRM Website"/>
|
<meta name="description" content="OSRM Website"/>
|
||||||
<meta name="author" content="Dennis Schieferdecker" />
|
<meta name="author" content="Dennis Schieferdecker" />
|
||||||
|
|
||||||
|
<!-- favicon -->
|
||||||
|
<link rel="shortcut icon" href="images/osrm-favicon.ico" type="image/x-icon" />
|
||||||
|
|
||||||
<!-- stylesheets -->
|
<!-- stylesheets -->
|
||||||
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
|
<link rel="stylesheet" href="leaflet/leaflet.css" type="text/css"/>
|
||||||
<link rel="stylesheet" href="main.css" type="text/css"/>
|
<link rel="stylesheet" href="main.css" type="text/css"/>
|
||||||
@@ -51,7 +72,7 @@
|
|||||||
<!-- show ui blob -->
|
<!-- show ui blob -->
|
||||||
<div id="blob-wrapper" class="gui-wrapper">
|
<div id="blob-wrapper" class="gui-wrapper">
|
||||||
<div id="blob-input" class="gui-box">
|
<div id="blob-input" class="gui-box">
|
||||||
<div class="main-toggle" onclick="OSRM.GUI.toggleMain()"></div>
|
<div class="main-toggle-in" onclick="OSRM.GUI.toggleMain()"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -60,23 +81,21 @@
|
|||||||
|
|
||||||
<!-- input box -->
|
<!-- input box -->
|
||||||
<div class="gui-box not-selectable" id="main-input">
|
<div class="gui-box not-selectable" id="main-input">
|
||||||
<div class="main-toggle" onclick="OSRM.GUI.toggleMain()"></div>
|
<div class="main-toggle-out" onclick="OSRM.GUI.toggleMain()"></div>
|
||||||
<img id="osrm-logo" alt="OSRM Logo" src="images/osrm-logo.png" />
|
<img id="osrm-logo" alt="OSRM Logo" src="images/osrm-logo.png" />
|
||||||
|
|
||||||
<!-- source/target input -->
|
<!-- source/target input -->
|
||||||
<table class="full">
|
<table class="full">
|
||||||
<tr>
|
<tr>
|
||||||
<td id="gui-search-source-label">Start:</td>
|
<td id="gui-search-source-label">Start:</td>
|
||||||
<td><input id="input-source-name" class="input-box" type="text" value="" title="Startposition eingeben" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);}" /></td>
|
<td><input id="input-source-name" class="input-box" type="text" maxlength="200" value="" title="Startposition eingeben" onchange="if( my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) my_markers.route[0].dirty_type = true;" onblur="callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);}" /></td>
|
||||||
<!-- <td class="right"><a class="button not-selectable" id="gui-here-target" onclick="">i</a></td> -->
|
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="centerMarker('source')">Zeigen</a></td>
|
||||||
<td class="right"><a class="button not-selectable" id="gui-search-source" onclick="callGeocoder(OSRM.SOURCE_MARKER_LABEL, document.getElementById('input-source-name').value);">Suchen</a></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td id="gui-search-target-label">Ende:</td>
|
<td id="gui-search-target-label">Ende:</td>
|
||||||
<td><input id="input-target-name" class="input-box" type="text" value="" title="Zielposition eingeben" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);}" /></td>
|
<td><input id="input-target-name" class="input-box" type="text" maxlength="200" value="" title="Zielposition eingeben" onchange="if( my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL) my_markers.route[my_markers.route.length-1].dirty_type = true;" onblur="callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);" onkeypress="if(event.keyCode==13) {callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);}" /></td>
|
||||||
<!-- <td class="right"><a class="button not-selectable" id="gui-here-target" onclick="">i</a></td> -->
|
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="centerMarker('target');">Zeigen</a></td>
|
||||||
<td class="right"><a class="button not-selectable" id="gui-search-target" onclick="callGeocoder(OSRM.TARGET_MARKER_LABEL, document.getElementById('input-target-name').value);">Suchen</a></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -85,8 +104,7 @@
|
|||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td> <a class="button not-selectable" id="gui-reset" onclick="resetRouting();">Reset</a></td>
|
<td> <a class="button not-selectable" id="gui-reset" onclick="resetRouting();">Reset</a></td>
|
||||||
<td class="center"> <a class="button not-selectable" id="gui-reverse" onclick="reverseRouting();">Reverse</a></td>
|
<td class="right"> <a class="button not-selectable" id="gui-reverse" onclick="reverseRouting();">Umdrehen</a></td>
|
||||||
<td class="right"> <a class="button not-selectable" id="gui-route" onclick="startRouting();">Route</a></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -102,7 +120,7 @@
|
|||||||
<div class="gui-box not-selectable" id="main-output">
|
<div class="gui-box not-selectable" id="main-output">
|
||||||
<div id="information-box-headline"></div>
|
<div id="information-box-headline"></div>
|
||||||
<div id="information-box"></div>
|
<div id="information-box"></div>
|
||||||
<div id="legal-notice">GUI2 v0.1 120313 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a></div>
|
<div id="legal-notice">GUI2 v0.1.1 120316 - OSRM hosting by <a href='http://algo2.iti.kit.edu/'>KIT</a> - Geocoder by <a href='http://www.osm.org/'>OSM</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
|
/*
|
||||||
|
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
|
||||||
|
// [initialization of maps, local strings, image prefetching]
|
||||||
|
|
||||||
var map;
|
var map;
|
||||||
|
|
||||||
|
|
||||||
|
// onload initialization routine
|
||||||
function init() {
|
function init() {
|
||||||
prefetchImages();
|
prefetchImages();
|
||||||
prefetchIcons();
|
prefetchIcons();
|
||||||
@@ -20,9 +41,15 @@ function prefetchImages() {
|
|||||||
var images = [ 'images/marker-source.png',
|
var images = [ 'images/marker-source.png',
|
||||||
'images/marker-target.png',
|
'images/marker-target.png',
|
||||||
'images/marker-via.png',
|
'images/marker-via.png',
|
||||||
'images/marker-highlight.png'
|
'images/marker-highlight.png',
|
||||||
|
'images/cancel.png',
|
||||||
|
'images/cancel_active.png',
|
||||||
|
'images/cancel_hover.png',
|
||||||
|
'images/restore.png',
|
||||||
|
'images/restore_active.png',
|
||||||
|
'images/restore_hover.png'
|
||||||
];
|
];
|
||||||
|
|
||||||
for(var i=0; i<images.length; i++) {
|
for(var i=0; i<images.length; i++) {
|
||||||
OSRM.images[i] = new Image();
|
OSRM.images[i] = new Image();
|
||||||
OSRM.images[i].src = images[i];
|
OSRM.images[i].src = images[i];
|
||||||
@@ -46,7 +73,6 @@ function prefetchIcons() {
|
|||||||
|
|
||||||
// init localization
|
// init localization
|
||||||
function initLocale() {
|
function initLocale() {
|
||||||
document.getElementById("gui-route").innerHTML = OSRM.loc("GUI_ROUTE");
|
|
||||||
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");
|
document.getElementById("gui-reset").innerHTML = OSRM.loc("GUI_RESET");
|
||||||
document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE");
|
document.getElementById("gui-reverse").innerHTML = OSRM.loc("GUI_REVERSE");
|
||||||
document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS");
|
document.getElementById("gui-option-highlight-nonames-label").innerHTML = OSRM.loc("GUI_HIGHLIGHT_UNNAMED_ROADS");
|
||||||
@@ -76,6 +102,7 @@ function centerOnGeolocation() {
|
|||||||
|
|
||||||
// init map
|
// init map
|
||||||
function initMap() {
|
function initMap() {
|
||||||
|
// setup tile servers
|
||||||
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
var osmorgURL = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
osmorgAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 Mapnik',
|
osmorgAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 Mapnik',
|
||||||
osmorgOptions = {maxZoom: 18, attribution: osmorgAttribution};
|
osmorgOptions = {maxZoom: 18, attribution: osmorgAttribution};
|
||||||
@@ -97,14 +124,16 @@ function initMap() {
|
|||||||
mapquest = new L.TileLayer(mapquestURL, mapquestOptions),
|
mapquest = new L.TileLayer(mapquestURL, mapquestOptions),
|
||||||
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
|
cloudmade = new L.TileLayer(cloudmadeURL, cloudmadeOptions);
|
||||||
|
|
||||||
|
// setup map
|
||||||
map = new L.Map('map', {
|
map = new L.Map('map', {
|
||||||
center: new L.LatLng(51.505, -0.09),
|
center: new L.LatLng(51.505, -0.09),
|
||||||
zoom: 13,
|
zoom: 13,
|
||||||
zoomAnimation: false, // uncomment to remove animations and hiding of routes during zoom
|
zoomAnimation: false, // false: removes animations and hiding of routes during zoom
|
||||||
fadeAnimation: false,
|
fadeAnimation: false,
|
||||||
layers: [osmorg]
|
layers: [osmorg]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add tileservers
|
||||||
var baseMaps = {
|
var baseMaps = {
|
||||||
"osm.org": osmorg,
|
"osm.org": osmorg,
|
||||||
"osm.de": osmde,
|
"osm.de": osmde,
|
||||||
@@ -116,99 +145,93 @@ function initMap() {
|
|||||||
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
var layersControl = new L.Control.Layers(baseMaps, overlayMaps);
|
||||||
map.addControl(layersControl);
|
map.addControl(layersControl);
|
||||||
|
|
||||||
|
// move zoom markers
|
||||||
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.left="420px";
|
||||||
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
getElementsByClassName(document,'leaflet-control-zoom')[0].style.top="5px";
|
||||||
|
|
||||||
map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
|
// initial map position and zoom
|
||||||
map.on('zoomend', function(e) { getRoute(OSRM.FULL_DESCRIPTION); });
|
map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE), OSRM.DEFAULTS.ZOOM_LEVEL);
|
||||||
|
map.on('zoomend', function(e) { getRoute(OSRM.FULL_DESCRIPTION); });
|
||||||
|
map.on('contextmenu', function(e) {});
|
||||||
|
|
||||||
|
// click on map to set source and target nodes
|
||||||
map.on('click', function(e) {
|
map.on('click', function(e) {
|
||||||
if( !my_markers.route[0] || my_markers.route[0].label != OSRM.SOURCE_MARKER_LABEL) {
|
if( !my_markers.route[0] || my_markers.route[0].label != OSRM.SOURCE_MARKER_LABEL) {
|
||||||
index = my_markers.setSource( e.latlng );
|
onclickGeocoderResult("source", e.latlng.lat, e.latlng.lng, true, false );
|
||||||
my_markers.route[index].show();
|
|
||||||
my_markers.route[index].centerView(false);
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
|
||||||
updateLocation("source");
|
|
||||||
// updateReverseGeocoder("source");
|
|
||||||
}
|
}
|
||||||
else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
|
else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
|
||||||
index = my_markers.setTarget( e.latlng );
|
onclickGeocoderResult("target", e.latlng.lat, e.latlng.lng, true, false );
|
||||||
my_markers.route[index].show();
|
|
||||||
my_markers.route[index].centerView(false);
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
|
||||||
updateLocation("target");
|
|
||||||
// updateReverseGeocoder("target");
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
// onmousemove test
|
|
||||||
// map.on('mousemove', function(e) { console.log("pos: " + e.latlng); });
|
|
||||||
// map.on('mousemove', function(e) {
|
|
||||||
// var objs = new Array;
|
|
||||||
// var obj = null;
|
|
||||||
// do {
|
|
||||||
// obj = document.elementFromPoint(e.layerPoint.x, e.layerPoint.y);
|
|
||||||
//
|
|
||||||
// if (obj == null)
|
|
||||||
// break;
|
|
||||||
// if (obj == document.body)
|
|
||||||
// break;
|
|
||||||
// if (obj instanceof SVGPathElement)
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// objs.push(obj);
|
|
||||||
// obj.style.display = 'none';
|
|
||||||
// } while(true);
|
|
||||||
// for(var i=0; i<objs.length; ++i)
|
|
||||||
// objs[i].style.display ='';
|
|
||||||
//
|
|
||||||
// if (obj == null)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// if (obj instanceof SVGPathElement)
|
|
||||||
// xroute.route.fire('mousemove',e);
|
|
||||||
// else
|
|
||||||
// xroute.route.fire('mouseout',e);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// parse URL GET parameters if existing
|
// parse URL GET parameters if any exist
|
||||||
function checkURL(){
|
function checkURL(){
|
||||||
var called_url = document.location.search.substr(1,document.location.search.length);
|
var called_url = document.location.search.substr(1,document.location.search.length);
|
||||||
if( called_url != '') {
|
|
||||||
var positions = [];
|
// reject messages that are clearly too long or too small
|
||||||
|
if( called_url.length > 1000 || called_url.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// storage for parameter values
|
||||||
|
var positions = [];
|
||||||
|
var destination = undefined;
|
||||||
|
var destination_name = undefined;
|
||||||
|
|
||||||
// parse input (currently only parses start, dest, via)
|
// parse input
|
||||||
var splitted_url = called_url.split('&');
|
var splitted_url = called_url.split('&');
|
||||||
for(var i=0; i<splitted_url.length; i++) {
|
for(var i=0; i<splitted_url.length; i++) {
|
||||||
var name_val = splitted_url[i].split('=');
|
var name_val = splitted_url[i].split('=');
|
||||||
if(name_val.length!=2)
|
if(name_val.length!=2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(name_val[0] == 'loc') {
|
||||||
var coordinates = unescape(name_val[1]).split(',');
|
var coordinates = unescape(name_val[1]).split(',');
|
||||||
if(coordinates.length!=2)
|
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
|
||||||
continue;
|
return;
|
||||||
|
positions.push ( new L.LatLng( coordinates[0], coordinates[1]) );
|
||||||
if(name_val[0] == 'loc')
|
|
||||||
positions.push ( new L.LatLng( coordinates[0], coordinates[1]) );
|
|
||||||
}
|
}
|
||||||
|
else if(name_val[0] == 'dest') {
|
||||||
|
var coordinates = unescape(name_val[1]).split(',');
|
||||||
|
if(coordinates.length!=2 || !isLatitude(coordinates[0]) || !isLongitude(coordinates[1]) )
|
||||||
|
return;
|
||||||
|
destination = new L.LatLng( coordinates[0], coordinates[1]);
|
||||||
|
}
|
||||||
|
else if(name_val[0] == 'destname') {
|
||||||
|
destination_name = decodeURI(name_val[1]).replace(/<\/?[^>]+(>|$)/g ,""); // discard tags
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// case 1: destination given
|
||||||
|
if( destination != undefined ) {
|
||||||
|
onclickGeocoderResult("target", destination.lat, destination.lng, (destination_name == undefined) );
|
||||||
|
if( destination_name != undefined )
|
||||||
|
document.getElementById("input-target-name").value = destination_name;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// case 2: locations given
|
||||||
|
if( positions != []) {
|
||||||
// draw via points
|
// draw via points
|
||||||
if( positions.length > 0)
|
if( positions.length > 0) {
|
||||||
my_markers.setSource( positions[0] );
|
onclickGeocoderResult("source", positions[0].lat, positions[0].lng, true, false );
|
||||||
|
//my_markers.setSource( positions[0] );
|
||||||
|
}
|
||||||
|
if(positions.length > 1) {
|
||||||
|
onclickGeocoderResult("target", positions[positions.length-1].lat, positions[positions.length-1].lng, true, false );
|
||||||
|
//my_markers.setTarget( positions[positions.length-1] );
|
||||||
|
}
|
||||||
for(var i=1; i<positions.length-1;i++)
|
for(var i=1; i<positions.length-1;i++)
|
||||||
my_markers.setVia( i-1, positions[i] );
|
my_markers.setVia( i-1, positions[i] );
|
||||||
if(positions.length > 1)
|
|
||||||
my_markers.setTarget( positions[positions.length-1] );
|
|
||||||
for(var i=0; i<my_markers.route.length;i++)
|
for(var i=0; i<my_markers.route.length;i++)
|
||||||
my_markers.route[i].show();
|
my_markers.route[i].show();
|
||||||
|
|
||||||
|
// center on route
|
||||||
|
var bounds = new L.LatLngBounds( positions );
|
||||||
|
map.fitBounds( bounds );
|
||||||
|
|
||||||
// compute route
|
// compute route
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
|
||||||
var bounds = new L.LatLngBounds( positions );
|
|
||||||
//bounds._southWest.lng-=1.02; // dirty hacks
|
|
||||||
map.fitBounds( bounds );
|
|
||||||
//my_route.centerView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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 routing routines
|
||||||
|
// [management of routing/direction requests and processing of responses]
|
||||||
|
// [TODO: major refactoring scheduled]
|
||||||
|
|
||||||
|
// some variables
|
||||||
var my_route = undefined;
|
var my_route = undefined;
|
||||||
var my_markers = undefined;
|
var my_markers = undefined;
|
||||||
|
|
||||||
@@ -7,40 +29,17 @@ OSRM.dragging = false;
|
|||||||
OSRM.pending = false;
|
OSRM.pending = false;
|
||||||
OSRM.pendingTimer = undefined;
|
OSRM.pendingTimer = undefined;
|
||||||
|
|
||||||
// init data
|
|
||||||
|
// init routing data structures
|
||||||
function initRouting() {
|
function initRouting() {
|
||||||
my_route = new OSRM.Route();
|
my_route = new OSRM.Route();
|
||||||
my_markers = new OSRM.Markers();
|
my_markers = new OSRM.Markers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode compressed route geometry
|
|
||||||
function decodeRouteGeometry(encoded, precision) {
|
|
||||||
precision = Math.pow(10, -precision);
|
|
||||||
var len = encoded.length, index=0, lat=0, lng = 0, array = [];
|
|
||||||
while (index < len) {
|
|
||||||
var b, shift = 0, result = 0;
|
|
||||||
do {
|
|
||||||
b = encoded.charCodeAt(index++) - 63;
|
|
||||||
result |= (b & 0x1f) << shift;
|
|
||||||
shift += 5;
|
|
||||||
} while (b >= 0x20);
|
|
||||||
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
|
||||||
lat += dlat;
|
|
||||||
shift = 0;
|
|
||||||
result = 0;
|
|
||||||
do {
|
|
||||||
b = encoded.charCodeAt(index++) - 63;
|
|
||||||
result |= (b & 0x1f) << shift;
|
|
||||||
shift += 5;
|
|
||||||
} while (b >= 0x20);
|
|
||||||
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
|
||||||
lng += dlng;
|
|
||||||
array.push([lat * precision, lng * precision]);
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
// display a transmitted route
|
// -- JSONP processing --
|
||||||
|
|
||||||
|
// process JSONP response of routing server
|
||||||
function timeoutRouteSimple() {
|
function timeoutRouteSimple() {
|
||||||
showNoRouteGeometry();
|
showNoRouteGeometry();
|
||||||
showNoRouteDescription();
|
showNoRouteDescription();
|
||||||
@@ -68,10 +67,11 @@ function showRouteSimple(response) {
|
|||||||
showRouteDescriptionSimple(response);
|
showRouteDescriptionSimple(response);
|
||||||
}
|
}
|
||||||
updateHints(response);
|
updateHints(response);
|
||||||
|
|
||||||
|
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
||||||
// if(OSRM.pending) {
|
// if(OSRM.pending) {
|
||||||
// clearTimeout(OSRM.pendingTimer);
|
// clearTimeout(OSRM.pendingTimer);
|
||||||
// OSRM.pendingTimer = setTimeout(timeoutDrag,100); // dirty dirty!
|
// OSRM.pendingTimer = setTimeout(timeoutDrag,100);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
function showRoute(response) {
|
function showRoute(response) {
|
||||||
@@ -92,6 +92,8 @@ function showRoute(response) {
|
|||||||
updateHints(response);
|
updateHints(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// show route geometry
|
||||||
function showNoRouteGeometry() {
|
function showNoRouteGeometry() {
|
||||||
var positions = [];
|
var positions = [];
|
||||||
for(var i=0; i<my_markers.route.length;i++)
|
for(var i=0; i<my_markers.route.length;i++)
|
||||||
@@ -111,6 +113,8 @@ function showRouteGeometry(response) {
|
|||||||
my_route.showRoute(points, OSRM.Route.ROUTE);
|
my_route.showRoute(points, OSRM.Route.ROUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// route description display (and helper functions)
|
||||||
function onClickRouteDescription(geometry_index) {
|
function onClickRouteDescription(geometry_index) {
|
||||||
var positions = my_route.getPositions();
|
var positions = my_route.getPositions();
|
||||||
|
|
||||||
@@ -122,10 +126,10 @@ function onClickCreateShortcut(src){
|
|||||||
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src+'&jsonp=showRouteLink', showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
|
OSRM.JSONP.call(OSRM.DEFAULTS.HOST_SHORTENER_URL+src+'&jsonp=showRouteLink', showRouteLink, showRouteLink_TimeOut, 2000, 'shortener');
|
||||||
}
|
}
|
||||||
function showRouteLink(response){
|
function showRouteLink(response){
|
||||||
document.getElementById('route-link').innerHTML = '[<a id="gpx-link" href="' +response.ShortURL+ '">'+OSRM.loc("LINK_TO_ROUTE")+'</a>]';
|
document.getElementById('route-prelink').innerHTML = '[<a id="gpx-link" class = "text-selectable" href="' +response.ShortURL+ '">'+response.ShortURL+'</a>]';
|
||||||
}
|
}
|
||||||
function showRouteLink_TimeOut(){
|
function showRouteLink_TimeOut(){
|
||||||
document.getElementById('route-link').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
|
document.getElementById('route-prelink').innerHTML = '['+OSRM.loc("LINK_TO_ROUTE_TIMEOUT")+']';
|
||||||
}
|
}
|
||||||
function showRouteDescription(response) {
|
function showRouteDescription(response) {
|
||||||
// compute query string
|
// compute query string
|
||||||
@@ -134,8 +138,7 @@ function showRouteDescription(response) {
|
|||||||
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
query_string += '&loc=' + my_markers.route[i].getLat() + ',' + my_markers.route[i].getLng();
|
||||||
|
|
||||||
// create link to the route
|
// create link to the route
|
||||||
var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
var route_link ='<span class="route-summary" id="route-prelink">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
||||||
//var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + document.URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
|
|
||||||
|
|
||||||
// create GPX link
|
// create GPX link
|
||||||
var gpx_link = '<span class="route-summary">[<a id="gpx-link" onClick="javascript: document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]</span>';
|
var gpx_link = '<span class="route-summary">[<a id="gpx-link" onClick="javascript: document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]</span>';
|
||||||
@@ -155,31 +158,38 @@ function showRouteDescription(response) {
|
|||||||
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'"/>';
|
route_desc += '<img width="18px" src="images/'+getDirectionIcon(response.route_instructions[i][0])+'"/>';
|
||||||
route_desc += "</td>";
|
route_desc += "</td>";
|
||||||
|
|
||||||
//route_desc += '<td class="result-counter"><span">'+(i+1)+'.</span></td>';
|
|
||||||
|
|
||||||
route_desc += '<td class="result-items">';
|
route_desc += '<td class="result-items">';
|
||||||
route_desc += '<span class="result-item" onclick="onClickRouteDescription('+response.route_instructions[i][3]+')">'
|
route_desc += '<span class="result-item" onclick="onClickRouteDescription('+response.route_instructions[i][3]+')">';
|
||||||
+ response.route_instructions[i][0] + ' on ';
|
route_desc += response.route_instructions[i][0];
|
||||||
if( response.route_instructions[i][2] > 0 )
|
if( i == 0 )
|
||||||
route_desc += response.route_instructions[i][1] + ' for '
|
route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] );
|
||||||
+ getDistanceWithUnit(response.route_instructions[i][2])
|
if( response.route_instructions[i][1] != "" ) {
|
||||||
+ '</span>';
|
route_desc += ' on ';
|
||||||
|
route_desc += '<b>' + response.route_instructions[i][1] + '</b>';
|
||||||
|
}
|
||||||
|
//route_desc += ' for ';
|
||||||
|
route_desc += '</span>';
|
||||||
|
route_desc += "</td>";
|
||||||
|
|
||||||
|
route_desc += '<td class="result-distance">';
|
||||||
|
if( i != response.route_instructions.length-1 )
|
||||||
|
route_desc += '<b>'+getDistanceWithUnit(response.route_instructions[i][2])+'</b>';
|
||||||
route_desc += "</td>";
|
route_desc += "</td>";
|
||||||
|
|
||||||
route_desc += "</tr>";
|
route_desc += "</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
route_desc += '</table>';
|
route_desc += '</table>';
|
||||||
headline = "";
|
headline = "";
|
||||||
headline += OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
headline += OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
headline += '<div style="float:left;width:70%">';
|
headline += '<div style="float:left;width:40%">';
|
||||||
headline += "<span class='route-summary'>"
|
headline += "<span class='route-summary'>"
|
||||||
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
||||||
+ " - "
|
+ "<br>"
|
||||||
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
||||||
+ "</span>";
|
+ "</span>";
|
||||||
headline += '</div>';
|
headline += '</div>';
|
||||||
headline += '<div style="float:left;text-align:right;width:30%;">'+route_link+'<br>'+gpx_link+'</div>';
|
headline += '<div style="float:left;text-align:right;width:60%;">'+route_link+'<br>'+gpx_link+'</div>';
|
||||||
|
|
||||||
var output = "";
|
var output = "";
|
||||||
output += route_desc;
|
output += route_desc;
|
||||||
@@ -191,7 +201,7 @@ function showRouteDescriptionSimple(response) {
|
|||||||
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
headline += "<span class='route-summary'>"
|
headline += "<span class='route-summary'>"
|
||||||
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
+ OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance)
|
||||||
+ " - "
|
+ "<br>"
|
||||||
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
+ OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time)
|
||||||
+ "</span>";
|
+ "</span>";
|
||||||
headline += '<br><br>';
|
headline += '<br><br>';
|
||||||
@@ -203,7 +213,7 @@ function showNoRouteDescription() {
|
|||||||
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
headline = OSRM.loc("ROUTE_DESCRIPTION")+":<br>";
|
||||||
headline += "<span class='route-summary'>"
|
headline += "<span class='route-summary'>"
|
||||||
+ OSRM.loc("DISTANCE")+": N/A"
|
+ OSRM.loc("DISTANCE")+": N/A"
|
||||||
+ " - "
|
+ "<br>"
|
||||||
+ OSRM.loc("DURATION")+": N/A"
|
+ OSRM.loc("DURATION")+": N/A"
|
||||||
+ "</span>";
|
+ "</span>";
|
||||||
headline += '<br><br>';
|
headline += '<br><br>';
|
||||||
@@ -212,6 +222,8 @@ function showNoRouteDescription() {
|
|||||||
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
|
document.getElementById('information-box').innerHTML = "<br><p style='font-size:14px;font-weight:bold;text-align:center;'>"+OSRM.loc("YOUR_ROUTE_IS_BEING_COMPUTED")+".<p>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unnamed streets display
|
||||||
function showRouteNonames(response) {
|
function showRouteNonames(response) {
|
||||||
// do not display unnamed streets?
|
// do not display unnamed streets?
|
||||||
if( document.getElementById('option-highlight-nonames').checked == false) {
|
if( document.getElementById('option-highlight-nonames').checked == false) {
|
||||||
@@ -252,14 +264,15 @@ function showRouteNonames(response) {
|
|||||||
my_route.showUnnamedRoute(all_positions);
|
my_route.showUnnamedRoute(all_positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function for dragging and drawing routes
|
|
||||||
|
//-- main function --
|
||||||
|
|
||||||
|
// generate server calls to query routes
|
||||||
function getRoute(do_description) {
|
function getRoute(do_description) {
|
||||||
|
|
||||||
// if source or target are not set -> hide route
|
// if source or target are not set -> hide route
|
||||||
if( my_markers.route.length < 2 ) {
|
if( my_markers.route.length < 2 ) {
|
||||||
my_route.hideRoute();
|
my_route.hideRoute();
|
||||||
//my_markers.removeVias(); // TODO: do I need this?
|
|
||||||
//my_markers.highlight.hide();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,16 +305,17 @@ function getRoute(do_description) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do call
|
// do call
|
||||||
var called = OSRM.JSONP.call(source, callback, timeout, OSRM.JSONP.TIMEOUT, type);
|
var called = OSRM.JSONP.call(source, callback, timeout, OSRM.DEFAULTS.JSONP_TIMEOUT, type);
|
||||||
|
|
||||||
// TODO: guarantee to do last drag
|
// TODO: hack to process final drag event, if it was fenced, but we are still dragging
|
||||||
if(called == false && !do_description) {
|
if(called == false && !do_description) {
|
||||||
clearTimeout(OSRM.pendingTimer);
|
clearTimeout(OSRM.pendingTimer);
|
||||||
OSRM.pendingTimer = setTimeout(timeoutDrag,OSRM.JSONP.TIMEOUT);
|
OSRM.pendingTimer = setTimeout(timeoutDrag,OSRM.DEFAULTS.JSONP_TIMEOUT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clearTimeout(OSRM.pendingTimer);
|
clearTimeout(OSRM.pendingTimer);
|
||||||
}
|
}
|
||||||
|
// // TODO: hack to process final drag event, if it was fenced, but we are still dragging (alternative approach)
|
||||||
// if(called == false && !do_description) {
|
// if(called == false && !do_description) {
|
||||||
// OSRM.pending = true;
|
// OSRM.pending = true;
|
||||||
// } else {
|
// } else {
|
||||||
@@ -309,28 +323,42 @@ function getRoute(do_description) {
|
|||||||
// OSRM.pending = false;
|
// OSRM.pending = false;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeoutDrag() {
|
function timeoutDrag() {
|
||||||
my_markers.route[OSRM.dragid].hint = undefined;
|
my_markers.route[OSRM.dragid].hint = undefined;
|
||||||
getRoute(OSRM.NO_DESCRIPTION);
|
getRoute(OSRM.NO_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startRouting() {
|
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
//-- helper functions --
|
||||||
}
|
|
||||||
|
//decode compressed route geometry
|
||||||
function resetRouting() {
|
function decodeRouteGeometry(encoded, precision) {
|
||||||
document.getElementById('input-source-name').value = "";
|
precision = Math.pow(10, -precision);
|
||||||
document.getElementById('input-target-name').value = "";
|
var len = encoded.length, index=0, lat=0, lng = 0, array = [];
|
||||||
|
while (index < len) {
|
||||||
my_route.hideRoute();
|
var b, shift = 0, result = 0;
|
||||||
my_markers.removeAll();
|
do {
|
||||||
my_markers.highlight.hide();
|
b = encoded.charCodeAt(index++) - 63;
|
||||||
|
result |= (b & 0x1f) << shift;
|
||||||
document.getElementById('information-box').innerHTML = "";
|
shift += 5;
|
||||||
document.getElementById('information-box-headline').innerHTML = "";
|
} while (b >= 0x20);
|
||||||
|
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
||||||
|
lat += dlat;
|
||||||
|
shift = 0;
|
||||||
|
result = 0;
|
||||||
|
do {
|
||||||
|
b = encoded.charCodeAt(index++) - 63;
|
||||||
|
result |= (b & 0x1f) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (b >= 0x20);
|
||||||
|
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
|
||||||
|
lng += dlng;
|
||||||
|
array.push([lat * precision, lng * precision]);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update hints of all markers
|
||||||
function updateHints(response) {
|
function updateHints(response) {
|
||||||
var hint_locations = response.hint_data.locations;
|
var hint_locations = response.hint_data.locations;
|
||||||
my_markers.checksum = response.hint_data.checksum;
|
my_markers.checksum = response.hint_data.checksum;
|
||||||
@@ -338,6 +366,7 @@ function updateHints(response) {
|
|||||||
my_markers.route[i].hint = hint_locations[i];
|
my_markers.route[i].hint = hint_locations[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// snap all markers to the received route
|
||||||
function snapRoute() {
|
function snapRoute() {
|
||||||
var positions = my_route.getPositions();
|
var positions = my_route.getPositions();
|
||||||
|
|
||||||
@@ -346,19 +375,67 @@ function snapRoute() {
|
|||||||
for(var i=0; i<via_points.length; i++)
|
for(var i=0; i<via_points.length; i++)
|
||||||
my_markers.route[i+1].setPosition( new L.LatLng(via_points[i][0], via_points[i][1]) );
|
my_markers.route[i+1].setPosition( new L.LatLng(via_points[i][0], via_points[i][1]) );
|
||||||
|
|
||||||
updateLocation( "source" );
|
// updateLocation( "source" );
|
||||||
updateLocation( "target" );
|
// updateLocation( "target" );
|
||||||
|
|
||||||
|
//if(OSRM.dragid == 0 && my_markers.hasSource()==true)
|
||||||
|
updateReverseGeocoder("source");
|
||||||
|
//else if(OSRM.dragid == my_markers.route.length-1 && my_markers.hasTarget()==true)
|
||||||
|
updateReverseGeocoder("target");
|
||||||
}
|
}
|
||||||
|
|
||||||
function positionsToInput() {
|
// map driving instructions to icons
|
||||||
if(my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL) {
|
// [TODO: better implementation, language-safe]
|
||||||
document.getElementById('input-source-name').value = my_markers.route[0].getPosition().lat.toFixed(6)+","+my_markers.route[0].getPosition().lng.toFixed(6);
|
function getDirectionIcon(name) {
|
||||||
}
|
var directions = {
|
||||||
if(my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL) {
|
"Turn left":"turn-left.png",
|
||||||
document.getElementById('input-target-name').value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6)+","+my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6);
|
"Turn right":"turn-right.png",
|
||||||
}
|
"U-Turn":"u-turn.png",
|
||||||
|
"Head":"continue.png",
|
||||||
|
"Continue":"continue.png",
|
||||||
|
"Turn slight left":"slight-left.png",
|
||||||
|
"Turn slight right":"slight-right.png",
|
||||||
|
"Turn sharp left":"sharp-left.png",
|
||||||
|
"Turn sharp right":"sharp-right.png",
|
||||||
|
"Enter roundabout and leave at first exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at second exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at third exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at forth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at fifth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at sixth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at seventh exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at eighth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at nineth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at tenth exit":"round-about.png",
|
||||||
|
"Enter roundabout and leave at one of the too many exit":"round-about.png",
|
||||||
|
"You have reached your destination":"target.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
if( directions[name] )
|
||||||
|
return directions[name];
|
||||||
|
else
|
||||||
|
return "default.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -- gui functions --
|
||||||
|
|
||||||
|
// click: button "reset"
|
||||||
|
function resetRouting() {
|
||||||
|
document.getElementById('input-source-name').value = "";
|
||||||
|
document.getElementById('input-target-name').value = "";
|
||||||
|
|
||||||
|
my_route.hideAll();
|
||||||
|
my_markers.removeAll();
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
|
||||||
|
document.getElementById('information-box').innerHTML = "";
|
||||||
|
document.getElementById('information-box-headline').innerHTML = "";
|
||||||
|
|
||||||
|
OSRM.JSONP.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// click: button "reverse"
|
||||||
function reverseRouting() {
|
function reverseRouting() {
|
||||||
// invert input boxes
|
// invert input boxes
|
||||||
var tmp = document.getElementById("input-source-name").value;
|
var tmp = document.getElementById("input-source-name").value;
|
||||||
@@ -384,40 +461,20 @@ function reverseRouting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recompute route
|
// recompute route
|
||||||
getRoute(OSRM.FULL_DESCRIPTION);
|
if( my_route.isShown() ) {
|
||||||
my_markers.highlight.hide();
|
getRoute(OSRM.FULL_DESCRIPTION);
|
||||||
|
my_markers.highlight.hide();
|
||||||
|
} else {
|
||||||
|
document.getElementById('information-box').innerHTML = "";
|
||||||
|
document.getElementById('information-box-headline').innerHTML = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// click: button "show"
|
||||||
|
function centerMarker(marker_id) {
|
||||||
|
if( marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL && !my_markers.route[0].dirty_type ) {
|
||||||
//--------------------
|
my_markers.route[0].centerView();
|
||||||
function getDirectionIcon(name) {
|
} else if( marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL && !my_markers.route[my_markers.route.length-1].dirty_type) {
|
||||||
var directions = {
|
my_markers.route[my_markers.route.length-1].centerView();
|
||||||
"Turn left":"turn-left.png",
|
}
|
||||||
"Turn right":"turn-right.png",
|
}
|
||||||
"U-Turn":"u-turn.png",
|
|
||||||
"Head":"continue.png",
|
|
||||||
"Continue":"continue.png",
|
|
||||||
"Turn slight left":"slight-left.png",
|
|
||||||
"Turn slight right":"slight-right.png",
|
|
||||||
"Turn sharp left":"sharp-left.png",
|
|
||||||
"Turn sharp right":"sharp-right.png",
|
|
||||||
"Enter round-about and leave at first exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at second exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at third exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at forth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at fifth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at sixth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at seventh exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at eighth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at nineth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at tenth exit":"round-about.png",
|
|
||||||
"Enter round-about and leave at one of the too many exit":"round-about.png",
|
|
||||||
};
|
|
||||||
|
|
||||||
if( directions[name] )
|
|
||||||
return directions[name];
|
|
||||||
else
|
|
||||||
return "default.png";
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<script src="leaflet/leaflet-src.js"></script>
|
|
||||||
<script src="OSRM.js"></script>
|
|
||||||
<script src="OSRM.Markers.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
function testSnippet()
|
|
||||||
{
|
|
||||||
var marker = new OSRM.RouteMarker("source",undefined,new L.Icon('images/marker-source.png'));
|
|
||||||
marker.yyy();
|
|
||||||
for(a in marker)
|
|
||||||
alert(a);
|
|
||||||
alert(marker);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>Test Javascript Snippets</h1>
|
|
||||||
<p id="output">This could be your output.</p>
|
|
||||||
|
|
||||||
<button type="button" onclick="testSnippet()">Run Snippet</button>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,4 +1,21 @@
|
|||||||
// compatibility mode for old browser
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// compatibility tools for old browsers
|
||||||
function getElementsByClassName(node, classname) {
|
function getElementsByClassName(node, classname) {
|
||||||
var a = [];
|
var a = [];
|
||||||
var re = new RegExp('(^| )'+classname+'( |$)');
|
var re = new RegExp('(^| )'+classname+'( |$)');
|
||||||
@@ -19,18 +36,37 @@ function secondsToTime(seconds){
|
|||||||
hours = parseInt(minutes/60);
|
hours = parseInt(minutes/60);
|
||||||
minutes = minutes%60;
|
minutes = minutes%60;
|
||||||
if(hours==0){
|
if(hours==0){
|
||||||
return minutes+' min';
|
return minutes + ' ' + 'min';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return hours+' h '+minutes+' min';
|
return hours + ' ' + 'h' + ' ' + minutes + ' ' + 'min';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// human readable distance
|
// human readable distance
|
||||||
function getDistanceWithUnit(distance){
|
function getDistanceWithUnit(distance){
|
||||||
distance = parseInt(distance);
|
distance = parseInt(distance);
|
||||||
if(distance >= 1000){ return (parseInt(distance/1000))+' km'; }
|
|
||||||
else{ return distance+' m'; }
|
if(distance >= 100000){ return (parseInt(distance/1000))+' ' + 'km'; }
|
||||||
|
else if(distance >= 10000){ return (parseInt(distance/1000).toFixed(1))+' ' + 'km'; }
|
||||||
|
else if(distance >= 1000){ return (parseFloat(distance/1000).toFixed(2))+' ' + 'km'; }
|
||||||
|
else{ return distance+' ' + 'm'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------
|
||||||
|
|
||||||
|
// verify angles
|
||||||
|
function isLatitude(value) {
|
||||||
|
if( value >=-90 && value <=90)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
function isLongitude(value) {
|
||||||
|
if( value >=-180 && value <=180)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// store location of via points returned by server
|
||||||
var via_points;
|
var via_points;
|
||||||
|
|
||||||
|
|
||||||
|
// find route segment of current route geometry that is closest to the new via node (marked by index of its endpoint)
|
||||||
function findNearestRouteSegment( new_via ) {
|
function findNearestRouteSegment( new_via ) {
|
||||||
var min_dist = Number.MAX_VALUE;
|
var min_dist = Number.MAX_VALUE;
|
||||||
var min_index = undefined;
|
var min_index = undefined;
|
||||||
@@ -17,6 +37,7 @@ function findNearestRouteSegment( new_via ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// find the correct index among all via nodes to insert the new via node, and insert it
|
||||||
function findViaPosition( new_via_position ) {
|
function findViaPosition( new_via_position ) {
|
||||||
// find route segment that is closest to click position (marked by last index)
|
// find route segment that is closest to click position (marked by last index)
|
||||||
var nearest_index = findNearestRouteSegment( new_via_position );
|
var nearest_index = findNearestRouteSegment( new_via_position );
|
||||||
|
|||||||