commented out route history

This commit is contained in:
DennisSchiefer 2012-05-11 15:08:04 +01:00
parent c0e86c47c2
commit e7b3590352
4 changed files with 58 additions and 54 deletions

View File

@ -78,7 +78,7 @@ zoomed: function(e) {
OSRM.Routing.getRoute_Dragging(); OSRM.Routing.getRoute_Dragging();
else else
OSRM.Routing.getRoute_Redraw(); OSRM.Routing.getRoute_Redraw();
// OSRM.Routing.getRoute_History(); // OSRM.Routing.getRoute_RedrawHistory();
}, },
contextmenu: function(e) {;}, contextmenu: function(e) {;},
mousemove: function(e) { OSRM.Via.drawDragMarker(e); }, mousemove: function(e) { OSRM.Via.drawDragMarker(e); },

View File

@ -18,16 +18,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
// OSRM route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets) // OSRM route management (handles drawing of route geometry - current route, old route, unnamed route, highlight unnamed streets)
// [this holds the route geometry] // [this holds the route geometry]
//OSRM.SimplePosition = function(lat, lng, hint) {
// this.lat = lat;
// this.lng = lng;
// this.hint = hint;
//};
//OSRM.extend( OSRM.SimplePosition,{
//getLat: function() { return this.lat; },
//getLng: function() { return this.lng; }
//});
OSRM.Route = function() { OSRM.Route = function() {
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} ); this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
@ -67,7 +57,7 @@ OSRM.Route.ROUTE = false;
OSRM.extend( OSRM.Route,{ OSRM.extend( OSRM.Route,{
showRoute: function(positions, noroute) { showRoute: function(positions, noroute) {
this.showHistoryRoutes(); // this.showHistoryRoutes();
this._noroute = noroute; this._noroute = noroute;
this._current_route.setPositions( positions ); this._current_route.setPositions( positions );
if ( this._noroute == OSRM.Route.NOROUTE ) if ( this._noroute == OSRM.Route.NOROUTE )
@ -78,7 +68,8 @@ OSRM.extend( OSRM.Route,{
//this._raiseUnnamedRoute(); //this._raiseUnnamedRoute();
}, },
hideRoute: function() { hideRoute: function() {
this.showHistoryRoutes(); // this.fetchHistoryRoute();
// this.showHistoryRoutes();
this._current_route.hide(); this._current_route.hide();
this._unnamed_route.hide(); this._unnamed_route.hide();
// deactivate printing // deactivate printing
@ -88,7 +79,7 @@ OSRM.extend( OSRM.Route,{
this.hideRoute(); this.hideRoute();
this._old_route.hide(); this._old_route.hide();
this._noroute = OSRM.Route.ROUTE; this._noroute = OSRM.Route.ROUTE;
this.clearHistoryRoutes(); // this.clearHistoryRoutes();
}, },
showUnnamedRoute: function(positions) { showUnnamedRoute: function(positions) {
@ -145,41 +136,54 @@ OSRM.extend( OSRM.Route,{
// history route handling // history route handling
storeHistoryRoute: function() { storeHistoryRoute: function() {
// if( document.getElementById('option-show-previous-routes').checked == false) if( document.getElementById('option-show-previous-routes').checked == false)
// return; return;
// if(this.isShown() && this.isRoute()) { console.log("store");
// // move route and positions this.fetchHistoryRoute();
// for(var i=this._history_routes-1; i>0; i--) { if(this.isShown() && this.isRoute()) {
// this._history_route[i].setPositions( this._history_route[i-1].getPositions() ); // store new route and positions in staging spot
// this._history_data[i] = this._history_data[i-1]; this._history_route[0].setPositions( this._current_route.getPositions() );
// } this._history_data[0] = [];
// // store new route and positions var markers = OSRM.G.markers.route;
// this._history_route[0].setPositions( this._current_route.getPositions() ); for(var i=0,size=markers.length; i<size; i++) {
// this._history_data[0] = []; var position = {
// var markers = OSRM.G.markers.route; lat:markers[i].getLat(),
// for(var i=0,size=markers.length; i<size; i++) { lng:markers[i].getLng(),
// var position = new OSRM.SimplePosition(markers[i].getLat(), markers[i].getLng(), markers[i].hint); hint:markers[i].hint
//// lat:markers[i].getLat(), };
//// lng:markers[i].getLng(), this._history_data[0].push(position);
//// hint:markers[i].hint }
//// }; }
// this._history_data[0].push(position);
// }
// }
}, },
showHistoryRoutes: function() { showHistoryRoutes: function() {
// if( document.getElementById('option-show-previous-routes').checked == false) if( document.getElementById('option-show-previous-routes').checked == false)
// return; return;
// for(var i=1,size=this._history_routes; i<size; i++) { console.log("show");
// this._history_route[i].setStyle( this._history_styles[i] ); for(var i=1,size=this._history_routes; i<size; i++) {
// this._history_route[i].show(); this._history_route[i].setStyle( this._history_styles[i] );
// } this._history_route[i].show();
}
}, },
clearHistoryRoutes: function() { clearHistoryRoutes: function() {
// for(var i=0,size=this._history_route.length; i<size; i++) { for(var i=0,size=this._history_route.length; i<size; i++) {
// this._history_route[i].hide(); this._history_route[i].hide();
// this._history_route[i].setPositions( [] ); this._history_route[i].setPositions( [] );
// this._history_data[i] = []; this._history_data[i] = [];
// } }
},
fetchHistoryRoute: function() {
if( document.getElementById('option-show-previous-routes').checked == false)
return;
if( this._history_data[0].length == 0)
return;
console.log("fetch");
// move route and positions
for(var i=this._history_routes-1; i>0; i--) {
this._history_route[i].setPositions( this._history_route[i-1].getPositions() );
this._history_data[i] = this._history_data[i-1];
}
// reset staging spot
this._history_route[0].setPositions( [] );
this._history_data[0] = [];
} }
}); });

View File

@ -80,7 +80,7 @@ reverseRouting: function() {
// click: button "show" // click: button "show"
showMarker: function(marker_id) { showMarker: function(marker_id) {
if( OSRM.JSONP.fences["geocoder_source"] || OSRM.JSONP.fences["geocoder_target"] ) if( OSRM.JSONP.fences["geocoder_source"] || OSRM.JSONP.fences["geocoder_target"] ) // needed when focus was on input box and user clicked on button
return; return;
if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() ) if( marker_id == OSRM.C.SOURCE_LABEL && OSRM.G.markers.hasSource() )
@ -140,10 +140,10 @@ deleteMarker: function(marker_id) {
//click: checkbox "show previous routes" //click: checkbox "show previous routes"
showPreviousRoutes: function(value) { showPreviousRoutes: function(value) {
if( document.getElementById('option-show-previous-routes').checked == false) // if( document.getElementById('option-show-previous-routes').checked == false)
OSRM.G.route.clearHistoryRoutes(); // OSRM.G.route.clearHistoryRoutes();
else // else
OSRM.G.route.storeHistoryRoute(); // OSRM.G.route.storeHistoryRoute();
} }
}); });

View File

@ -65,7 +65,7 @@ showRouteSimple: function(response) {
} else { } else {
OSRM.RoutingGeometry.show(response); OSRM.RoutingGeometry.show(response);
OSRM.RoutingDescription.showSimple(response); OSRM.RoutingDescription.showSimple(response);
OSRM.G.route.storeHistoryRoute(); // OSRM.G.route.storeHistoryRoute();
} }
OSRM.Routing._updateHints(response); OSRM.Routing._updateHints(response);
@ -88,7 +88,7 @@ showRoute: function(response) {
OSRM.RoutingNoNames.show(response); OSRM.RoutingNoNames.show(response);
OSRM.RoutingDescription.show(response); OSRM.RoutingDescription.show(response);
OSRM.Routing._snapRoute(); OSRM.Routing._snapRoute();
OSRM.G.route.storeHistoryRoute(); // OSRM.G.route.storeHistoryRoute();
} }
OSRM.Routing._updateHints(response); OSRM.Routing._updateHints(response);
}, },
@ -146,7 +146,7 @@ getRoute_Redraw: function() {
OSRM.JSONP.clear('redraw'); OSRM.JSONP.clear('redraw');
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRouteRedraw, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'redraw'); OSRM.JSONP.call(OSRM.Routing._buildCall()+'&instructions=true', OSRM.Routing.showRouteRedraw, OSRM.Routing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'redraw');
}, },
getRoute_History: function() { getRoute_RedrawHistory: function() {
for(var i=0; i<10; i++) for(var i=0; i<10; i++)
if( OSRM.G.route._history_data[i].length > 0 ) { if( OSRM.G.route._history_data[i].length > 0 ) {
OSRM.JSONP.clear('history'+i); OSRM.JSONP.clear('history'+i);