diff --git a/WebContent/base/OSRM.Routes.js b/WebContent/base/OSRM.Routes.js
index e03d8fe75..48acba14d 100644
--- a/WebContent/base/OSRM.Routes.js
+++ b/WebContent/base/OSRM.Routes.js
@@ -20,9 +20,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
OSRM.Route = function() {
- this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
- this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
- this._unnamed_route = new OSRM.MultiRoute("unnamed");
+ this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
+ this._alternative_route = new OSRM.SimpleRoute("alternative" , {dashed:false} );
+ this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
+ this._unnamed_route = new OSRM.MultiRoute("unnamed");
this._current_route_style = {dashed:false,color:'#0033FF', weight:5};
this._current_noroute_style = {dashed:true, color:'#222222', weight:2};
@@ -30,6 +31,7 @@ OSRM.Route = function() {
this._old_noroute_style = {dashed:true, color:'#000000', weight:2};
this._unnamed_route_style = {dashed:false, color:'#FF00FF', weight:10};
this._old_unnamed_route_style = {dashed:false, color:'#990099', weight:10};
+ this._alternative_route_style = {dashed:false,color:'#FF3300', weight:5};
this._noroute = OSRM.Route.ROUTE;
this._history = new OSRM.HistoryRoute();
@@ -99,6 +101,16 @@ OSRM.extend( OSRM.Route,{
this._old_route.hide();
},
+ // show/hide alternative route
+ showAlternativeRoute: function(positions) {
+ this._alternative_route.setPositions( positions );
+ this._alternative_route.setStyle( this._alternative_route_style );
+ this._alternative_route.show();
+ },
+ hideAlternativeRoute: function() {
+ this._alternative_route.hide();
+ },
+
// query routines
isShown: function() {
return this._current_route.isShown();
diff --git a/WebContent/main.css b/WebContent/main.css
index 2b61e5071..219dcd911 100644
--- a/WebContent/main.css
+++ b/WebContent/main.css
@@ -532,6 +532,21 @@ html, body {
outline-style:none;
vertical-align:1px;
}
+.button-pressed
+{
+ cursor:pointer;
+ padding:2px 10px 2px 10px;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ background-color:#DDDDDD;
+ border:1px solid #999999;
+ color:#000000;
+ text-decoration:none;
+ font-size:9px;
+ outline-style:none;
+ vertical-align:1px;
+}
/* iconic buttons */
diff --git a/WebContent/routing/OSRM.Routing.js b/WebContent/routing/OSRM.Routing.js
index 8dccb7f63..e11be5906 100644
--- a/WebContent/routing/OSRM.Routing.js
+++ b/WebContent/routing/OSRM.Routing.js
@@ -68,6 +68,7 @@ showRoute: function(response) {
OSRM.RoutingGeometry.show(response);
OSRM.RoutingNoNames.show(response);
OSRM.RoutingDescription.show(response);
+ OSRM.RoutingAlternatives.prepare(response);
OSRM.Routing._snapRoute();
}
OSRM.Routing._updateHints(response);
diff --git a/WebContent/routing/OSRM.RoutingAlternatives.js b/WebContent/routing/OSRM.RoutingAlternatives.js
new file mode 100644
index 000000000..23f88dcee
--- /dev/null
+++ b/WebContent/routing/OSRM.RoutingAlternatives.js
@@ -0,0 +1,92 @@
+/*
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU AFFERO General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+or see http://www.gnu.org/licenses/agpl.txt.
+*/
+
+// OSRM routing alternatives
+// [everything about handling alternatives]
+
+
+OSRM.RoutingAlternatives = {
+
+// prepare response
+prepare: function() {
+ OSRM.RoutingAlternatives._buildAlternatives();
+},
+
+// add alternatives
+_buildAlternatives: function() {
+ var data =
+ 'B' +
+ 'A';
+ document.getElementById('information-box-header').innerHTML = data + document.getElementById('information-box-header').innerHTML;
+ OSRM.G.response.active = 0;
+
+ document.getElementById("gui-a").onclick = function () {
+ if( OSRM.G.response.active == 0 )
+ return;
+ document.getElementById("gui-a").className = "button-pressed top-right-button";
+ document.getElementById("gui-b").className = "button top-right-button";
+ OSRM.G.route.hideAlternativeRoute();
+ OSRM.G.response.active = 0;
+ // switch data
+ //OSRM.Routing.showRoute(OSRM.G.response);
+ console.log("click a");
+ };
+ document.getElementById("gui-a").onmouseover = function () {
+ if( OSRM.G.response.active == 0 )
+ return;
+
+ var geometry = OSRM.RoutingGeometry._decode(OSRM.G.response.route_geometry, 5);
+ OSRM.G.route.showAlternativeRoute(geometry);
+ console.log("over a");
+ };
+ document.getElementById("gui-a").onmouseout = function () {
+ if( OSRM.G.response.active == 0 )
+ return;
+
+ OSRM.G.route.hideAlternativeRoute();
+ console.log("out a");
+ };
+
+ document.getElementById("gui-b").onclick = function () {
+ if( OSRM.G.response.active == 1 )
+ return;
+ document.getElementById("gui-a").className = "button top-right-button";
+ document.getElementById("gui-b").className = "button-pressed top-right-button";
+ OSRM.G.route.hideAlternativeRoute();
+ OSRM.G.response.active = 1;
+ // switch data
+ //OSRM.Routing.showRoute(OSRM.G.response);
+ console.log("click b");
+ };
+ document.getElementById("gui-b").onmouseover = function () {
+ if( OSRM.G.response.active == 1 )
+ return;
+
+ var geometry = OSRM.RoutingGeometry._decode(OSRM.G.response.route_geometry, 5);
+ OSRM.G.route.showAlternativeRoute(geometry);
+ console.log("over b");
+ };
+ document.getElementById("gui-b").onmouseout = function () {
+ if( OSRM.G.response.active == 1 )
+ return;
+
+ OSRM.G.route.hideAlternativeRoute();
+ console.log("out b");
+ };
+}
+
+};
\ No newline at end of file