added scale control

This commit is contained in:
DennisSchiefer
2012-08-14 16:51:24 +01:00
parent 320bbcfb20
commit 71399daf00
7 changed files with 50 additions and 22 deletions
+21 -2
View File
@@ -100,11 +100,30 @@ afterMainTransition: function() {
},
// toggle distance units
onUnitsChanged: function(value) {
OSRM.Utils.setToHumanDistanceFunction(value);
onUnitsChanged: function(type) {
OSRM.GUI.changeDistanceFormat(type);
OSRM.Routing.getRoute({keepAlternative:true});
},
// change distance format
changeDistanceFormat: function(type) {
OSRM.G.DISTANCE_FORMAT = type;
// change scale control
if(OSRM.G.map) {
OSRM.G.map.scaleControl.removeFrom(OSRM.G.map);
OSRM.G.map.scaleControl.options.metric = (type != 1);
OSRM.G.map.scaleControl.options.imperial = (type == 1);
OSRM.G.map.scaleControl.addTo(OSRM.G.map);
}
// change converter
if( type == 1 )
OSRM.Utils.toHumanDistance = OSRM.Utils.toHumanDistanceMiles;
else
OSRM.Utils.toHumanDistance = OSRM.Utils.toHumanDistanceMeters;
},
// set timestamp of data
setDataTimestamp: function(response) {
if(!response)
+1 -1
View File
@@ -24,7 +24,7 @@ OSRM.GUI.extend( {
// init
init: function() {
// init variables
OSRM.Utils.setToHumanDistanceFunction(OSRM.DEFAULTS.DISTANCE_FORMAT);
OSRM.GUI.changeDistanceFormat(OSRM.DEFAULTS.DISTANCE_FORMAT);
// init events
document.getElementById("gui-input-source").onchange = function() {OSRM.GUI.inputChanged(OSRM.C.SOURCE_LABEL);};