added scale control
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);};
|
||||
|
||||
Reference in New Issue
Block a user