Merge branch 'trial/folders' into develop
@ -26,32 +26,3 @@ OSRM.DEFAULTS = {};
|
||||
OSRM.GLOBALS = {};
|
||||
OSRM.G = OSRM.GLOBALS; // abbreviations
|
||||
OSRM.C = OSRM.CONSTANTS;
|
||||
|
||||
|
||||
// declare one class to be a subclass of another class
|
||||
// (runs anonymous function to prevent local functions cluttering global namespace)
|
||||
(function() {
|
||||
var _inheritFromHelper = function() {};
|
||||
OSRM.inheritFrom = function( sub_class, base_class ) {
|
||||
_inheritFromHelper.prototype = base_class.prototype;
|
||||
sub_class.prototype = new _inheritFromHelper();
|
||||
sub_class.prototype.constructor = sub_class;
|
||||
sub_class.prototype.base = base_class.prototype;
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
// extend prototypes of a class -> used to add member values and functions
|
||||
OSRM.extend = function( target_class, properties ) {
|
||||
for( property in properties ) {
|
||||
target_class.prototype[property] = properties[property];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// [usage of convenience functions]
|
||||
// SubClass = function() {
|
||||
// SubClass.prototype.base.constructor.apply(this, arguments);
|
||||
// }
|
||||
// OSRM.inheritFrom( SubClass, BaseClass );
|
||||
// OSRM.extend( SubClass, { property:value } );
|
||||
|
@ -22,45 +22,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
OSRM.GLOBALS.map = null;
|
||||
|
||||
|
||||
// map view/model
|
||||
// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility]
|
||||
OSRM.MapView = L.Map.extend({
|
||||
setViewUI: function(position, zoom, no_animation) {
|
||||
if( OSRM.GUI.visible == true ) {
|
||||
var point = this.project( position, zoom);
|
||||
point.x-=OSRM.GUI.width/2;
|
||||
position = this.unproject(point,zoom);
|
||||
}
|
||||
this.setView( position, zoom, no_animation);
|
||||
},
|
||||
fitBoundsUI: function(bounds) {
|
||||
var southwest = bounds.getSouthWest();
|
||||
var northeast = bounds.getNorthEast();
|
||||
var zoom = this.getBoundsZoom(bounds);
|
||||
var sw_point = this.project( southwest, zoom);
|
||||
if( OSRM.GUI.visible == true )
|
||||
sw_point.x-=OSRM.GUI.width+20;
|
||||
else
|
||||
sw_point.x-=20;
|
||||
sw_point.y+=20;
|
||||
var ne_point = this.project( northeast, zoom);
|
||||
ne_point.y-=20;
|
||||
sw_point.x+=20;
|
||||
bounds.extend( this.unproject(sw_point,zoom) );
|
||||
bounds.extend( this.unproject(ne_point,zoom) );
|
||||
this.fitBounds( bounds );
|
||||
},
|
||||
getCenterUI: function(unbounded) {
|
||||
var viewHalf = this.getSize();
|
||||
if( OSRM.GUI.visible == true )
|
||||
viewHalf.x += OSRM.GUI.width;
|
||||
var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2));
|
||||
|
||||
return this.unproject(centerPoint, this._zoom, unbounded);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// map controller
|
||||
// [map initialization, event handling]
|
||||
OSRM.Map = {
|
||||
@ -89,8 +50,8 @@ init: function() {
|
||||
});
|
||||
|
||||
// add layer control
|
||||
var layersControl = new L.Control.Layers(base_maps, {});
|
||||
OSRM.G.map.addControl(layersControl);
|
||||
var layerControl = new L.Control.QueryableLayers(base_maps, {});
|
||||
OSRM.G.map.addLayerControl(layerControl);
|
||||
|
||||
// move zoom markers
|
||||
OSRM.Browser.getElementsByClassName(document,'leaflet-control-zoom')[0].style.left=(OSRM.GUI.width+10)+"px";
|
@ -15,159 +15,9 @@ 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 marker class (wraps Leaflet markers)
|
||||
OSRM.Marker = function( label, style, position ) {
|
||||
this.label = label ? label : "marker";
|
||||
this.position = position ? position : new L.LatLng(0,0);
|
||||
|
||||
this.marker = new L.MouseMarker( this.position, style );
|
||||
this.marker.parent = this;
|
||||
|
||||
this.shown = false;
|
||||
this.hint = null;
|
||||
};
|
||||
OSRM.extend( OSRM.Marker,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.marker);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.marker);
|
||||
this.shown = false;
|
||||
},
|
||||
setPosition: function( position ) {
|
||||
this.position = position;
|
||||
this.marker.setLatLng( position );
|
||||
this.hint = null;
|
||||
},
|
||||
getPosition: function() {
|
||||
return this.position;
|
||||
},
|
||||
getLat: function() {
|
||||
return this.position.lat;
|
||||
},
|
||||
getLng: function() {
|
||||
return this.position.lng;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
centerView: function(zoom) {
|
||||
if( zoom == undefined )
|
||||
zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
|
||||
OSRM.G.map.setViewUI( this.position, zoom );
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// route marker class (draggable, invokes route drawing routines)
|
||||
OSRM.RouteMarker = function ( label, style, position ) {
|
||||
style.baseicon = style.icon;
|
||||
OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments );
|
||||
this.label = label ? label : "route_marker";
|
||||
|
||||
this.marker.on( 'click', this.onClick );
|
||||
this.marker.on( 'drag', this.onDrag );
|
||||
this.marker.on( 'dragstart', this.onDragStart );
|
||||
this.marker.on( 'dragend', this.onDragEnd );
|
||||
};
|
||||
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
||||
OSRM.extend( OSRM.RouteMarker, {
|
||||
onClick: function(e) {
|
||||
for( var i=0; i<OSRM.G.markers.route.length; i++) {
|
||||
if( OSRM.G.markers.route[i].marker === this ) {
|
||||
OSRM.G.markers.removeMarker( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OSRM.Routing.getRoute();
|
||||
OSRM.G.markers.highlight.hide();
|
||||
OSRM.G.markers.dragger.hide();
|
||||
},
|
||||
onDrag: function(e) {
|
||||
this.parent.setPosition( e.target.getLatLng() );
|
||||
if(OSRM.G.markers.route.length>1)
|
||||
OSRM.Routing.getDragRoute();
|
||||
OSRM.Geocoder.updateLocation( this.parent.label );
|
||||
},
|
||||
onDragStart: function(e) {
|
||||
OSRM.G.dragging = true;
|
||||
this.switchIcon(this.options.dragicon);
|
||||
|
||||
// store id of dragged marker
|
||||
for( var i=0; i<OSRM.G.markers.route.length; i++)
|
||||
if( OSRM.G.markers.route[i].marker === this ) {
|
||||
OSRM.G.dragid = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if( this.parent != OSRM.G.markers.highlight)
|
||||
OSRM.G.markers.highlight.hide();
|
||||
if( this.parent != OSRM.G.markers.dragger)
|
||||
OSRM.G.markers.dragger.hide();
|
||||
if (OSRM.G.route.isShown())
|
||||
OSRM.G.route.showOldRoute();
|
||||
},
|
||||
onDragEnd: function(e) {
|
||||
OSRM.G.dragging = false;
|
||||
this.switchIcon(this.options.baseicon);
|
||||
|
||||
this.parent.setPosition( e.target.getLatLng() );
|
||||
if (OSRM.G.route.isShown()) {
|
||||
OSRM.Routing.getRoute();
|
||||
OSRM.G.route.hideOldRoute();
|
||||
OSRM.G.route.hideUnnamedRoute();
|
||||
} else {
|
||||
OSRM.Geocoder.updateAddress(this.parent.label);
|
||||
OSRM.GUI.clearResults();
|
||||
}
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//drag marker class (draggable, invokes route drawing routines)
|
||||
OSRM.DragMarker = function ( label, style, position ) {
|
||||
OSRM.DragMarker.prototype.base.constructor.apply( this, arguments );
|
||||
this.label = label ? label : "drag_marker";
|
||||
};
|
||||
OSRM.inheritFrom( OSRM.DragMarker, OSRM.RouteMarker );
|
||||
OSRM.extend( OSRM.DragMarker, {
|
||||
onClick: function(e) {
|
||||
if( this.parent != OSRM.G.markers.dragger)
|
||||
this.parent.hide();
|
||||
},
|
||||
onDragStart: function(e) {
|
||||
var new_via_index = OSRM.Via.findViaIndex( e.target.getLatLng() );
|
||||
OSRM.G.markers.route.splice(new_via_index+1,0, this.parent );
|
||||
|
||||
OSRM.RouteMarker.prototype.onDragStart.call(this,e);
|
||||
},
|
||||
onDragEnd: function(e) {
|
||||
OSRM.G.markers.route[OSRM.G.dragid] = new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, e.target.getLatLng() );
|
||||
OSRM.G.markers.route[OSRM.G.dragid].show();
|
||||
|
||||
OSRM.RouteMarker.prototype.onDragEnd.call(this,e);
|
||||
this.parent.hide();
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.DragMarker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// marker management class (all route markers should only be set and deleted with these routines!)
|
||||
// OSRM marker management (all route markers should only be set and deleted with these routines!)
|
||||
// [this holds the vital information of the route]
|
||||
|
||||
OSRM.Markers = function() {
|
||||
this.route = new Array();
|
||||
this.highlight = new OSRM.DragMarker("highlight", {draggable:true,icon:OSRM.G.icons['marker-highlight'],dragicon:OSRM.G.icons['marker-highlight-drag']});;
|
@ -15,91 +15,9 @@ 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]
|
||||
|
||||
|
||||
// simple route class (wraps Leaflet Polyline)
|
||||
OSRM.SimpleRoute = function (label, style) {
|
||||
this.label = (label ? label : "route");
|
||||
this.route = new L.DashedPolyline();
|
||||
this.route.setLatLngs( [] );
|
||||
if(style) this.route.setStyle( style );
|
||||
|
||||
this.shown = false;
|
||||
};
|
||||
OSRM.extend( OSRM.SimpleRoute,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.route);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.route);
|
||||
this.shown = false;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
getPoints: function() {
|
||||
return this.route._originalPoints;
|
||||
},
|
||||
getPositions: function() {
|
||||
return this.route.getLatLngs();
|
||||
},
|
||||
setPositions: function(positions) {
|
||||
this.route.setLatLngs( positions );
|
||||
},
|
||||
setStyle: function(style) {
|
||||
this.route.setStyle(style);
|
||||
},
|
||||
centerView: function() {
|
||||
var bounds = new L.LatLngBounds( this.getPositions() );
|
||||
OSRM.g.map.fitBoundsUI( bounds );
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes)
|
||||
OSRM.MultiRoute = function (label) {
|
||||
this.label = (label ? label : "multiroute");
|
||||
this.route = new L.LayerGroup();
|
||||
|
||||
this.shown = false;
|
||||
};
|
||||
OSRM.extend( OSRM.MultiRoute,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.route);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.route);
|
||||
this.shown = false;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
addRoute: function(positions) {
|
||||
var line = new L.DashedPolyline( positions );
|
||||
line.on('click', function(e) { OSRM.G.route.fire('click',e); });
|
||||
this.route.addLayer( line );
|
||||
},
|
||||
clearRoutes: function() {
|
||||
this.route.clearLayers();
|
||||
},
|
||||
setStyle: function(style) {
|
||||
this.route.invoke('setStyle', style);
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.MultiRoute("+ this.label + ")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 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]
|
||||
|
||||
OSRM.Route = function() {
|
||||
this._current_route = new OSRM.SimpleRoute("current" , {dashed:false} );
|
||||
this._old_route = new OSRM.SimpleRoute("old", {dashed:false,color:"#123"} );
|
34
WebContent/base/leaflet/L.Control.QueryableLayers.js
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// queryable Layers control
|
||||
// [simply Control.Layers extended by query functions]
|
||||
L.Control.QueryableLayers = L.Control.Layers.extend({
|
||||
getActiveLayerName: function () {
|
||||
var i, input, obj,
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
inputsLen = inputs.length;
|
||||
|
||||
for (i = 0; i < inputsLen; i++) {
|
||||
input = inputs[i];
|
||||
obj = this._layers[input.layerId];
|
||||
if (input.checked && !obj.overlay) {
|
||||
return obj.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
74
WebContent/base/osrm/OSRM.MapView.js
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// map view/model
|
||||
// [extending Leaflet L.Map with setView/fitBounds methods that respect UI visibility, better layerControl]
|
||||
OSRM.MapView = L.Map.extend({
|
||||
setViewUI: function(position, zoom, no_animation) {
|
||||
if( OSRM.GUI.visible == true ) {
|
||||
var point = this.project( position, zoom);
|
||||
point.x-=OSRM.GUI.width/2;
|
||||
position = this.unproject(point,zoom);
|
||||
}
|
||||
this.setView( position, zoom, no_animation);
|
||||
},
|
||||
fitBoundsUI: function(bounds) {
|
||||
var southwest = bounds.getSouthWest();
|
||||
var northeast = bounds.getNorthEast();
|
||||
var zoom = this.getBoundsZoom(bounds);
|
||||
var sw_point = this.project( southwest, zoom);
|
||||
if( OSRM.GUI.visible == true )
|
||||
sw_point.x-=OSRM.GUI.width+20;
|
||||
else
|
||||
sw_point.x-=20;
|
||||
sw_point.y+=20;
|
||||
var ne_point = this.project( northeast, zoom);
|
||||
ne_point.y-=20;
|
||||
ne_point.x+=20;
|
||||
bounds.extend( this.unproject(sw_point,zoom) );
|
||||
bounds.extend( this.unproject(ne_point,zoom) );
|
||||
this.fitBounds( bounds );
|
||||
},
|
||||
getCenterUI: function(unbounded) {
|
||||
var viewHalf = this.getSize();
|
||||
if( OSRM.GUI.visible == true )
|
||||
viewHalf.x += OSRM.GUI.width;
|
||||
var centerPoint = this._getTopLeftPoint().add(viewHalf.divideBy(2));
|
||||
|
||||
return this.unproject(centerPoint, this._zoom, unbounded);
|
||||
},
|
||||
addLayerControl: function( layerControl ) {
|
||||
if( this.layerControl )
|
||||
return;
|
||||
|
||||
this.layerControl = layerControl;
|
||||
this.addControl(this.layerControl);
|
||||
},
|
||||
getActiveLayerId: function() {
|
||||
var tile_server_id = 0;
|
||||
|
||||
var tile_servers = OSRM.DEFAULTS.TILE_SERVERS;
|
||||
var tile_server_name = this.layerControl.getActiveLayerName();
|
||||
for(var i=0, size=tile_servers.length; i<size; i++)
|
||||
if( tile_servers[tile_server_id].display_name == tile_server_name ) {
|
||||
tile_server_id = i;
|
||||
break;
|
||||
}
|
||||
|
||||
return tile_server_id;
|
||||
}
|
||||
});
|
166
WebContent/base/osrm/OSRM.Marker.js
Normal file
@ -0,0 +1,166 @@
|
||||
/*
|
||||
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]
|
||||
|
||||
|
||||
// base marker class (wraps Leaflet markers)
|
||||
OSRM.Marker = function( label, style, position ) {
|
||||
this.label = label ? label : "marker";
|
||||
this.position = position ? position : new L.LatLng(0,0);
|
||||
|
||||
this.marker = new L.MouseMarker( this.position, style );
|
||||
this.marker.parent = this;
|
||||
|
||||
this.shown = false;
|
||||
this.hint = null;
|
||||
};
|
||||
OSRM.extend( OSRM.Marker,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.marker);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.marker);
|
||||
this.shown = false;
|
||||
},
|
||||
setPosition: function( position ) {
|
||||
this.position = position;
|
||||
this.marker.setLatLng( position );
|
||||
this.hint = null;
|
||||
},
|
||||
getPosition: function() {
|
||||
return this.position;
|
||||
},
|
||||
getLat: function() {
|
||||
return this.position.lat;
|
||||
},
|
||||
getLng: function() {
|
||||
return this.position.lng;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
centerView: function(zoom) {
|
||||
if( zoom == undefined )
|
||||
zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
|
||||
OSRM.G.map.setViewUI( this.position, zoom );
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// route marker class (draggable, invokes route drawing routines)
|
||||
OSRM.RouteMarker = function ( label, style, position ) {
|
||||
style.baseicon = style.icon;
|
||||
OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments );
|
||||
this.label = label ? label : "route_marker";
|
||||
|
||||
this.marker.on( 'click', this.onClick );
|
||||
this.marker.on( 'drag', this.onDrag );
|
||||
this.marker.on( 'dragstart', this.onDragStart );
|
||||
this.marker.on( 'dragend', this.onDragEnd );
|
||||
};
|
||||
OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker );
|
||||
OSRM.extend( OSRM.RouteMarker, {
|
||||
onClick: function(e) {
|
||||
for( var i=0; i<OSRM.G.markers.route.length; i++) {
|
||||
if( OSRM.G.markers.route[i].marker === this ) {
|
||||
OSRM.G.markers.removeMarker( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OSRM.Routing.getRoute();
|
||||
OSRM.G.markers.highlight.hide();
|
||||
OSRM.G.markers.dragger.hide();
|
||||
},
|
||||
onDrag: function(e) {
|
||||
this.parent.setPosition( e.target.getLatLng() );
|
||||
if(OSRM.G.markers.route.length>1)
|
||||
OSRM.Routing.getDragRoute();
|
||||
OSRM.Geocoder.updateLocation( this.parent.label );
|
||||
},
|
||||
onDragStart: function(e) {
|
||||
OSRM.G.dragging = true;
|
||||
this.switchIcon(this.options.dragicon);
|
||||
|
||||
// store id of dragged marker
|
||||
for( var i=0; i<OSRM.G.markers.route.length; i++)
|
||||
if( OSRM.G.markers.route[i].marker === this ) {
|
||||
OSRM.G.dragid = i;
|
||||
break;
|
||||
}
|
||||
|
||||
if( this.parent != OSRM.G.markers.highlight)
|
||||
OSRM.G.markers.highlight.hide();
|
||||
if( this.parent != OSRM.G.markers.dragger)
|
||||
OSRM.G.markers.dragger.hide();
|
||||
if (OSRM.G.route.isShown())
|
||||
OSRM.G.route.showOldRoute();
|
||||
},
|
||||
onDragEnd: function(e) {
|
||||
OSRM.G.dragging = false;
|
||||
this.switchIcon(this.options.baseicon);
|
||||
|
||||
this.parent.setPosition( e.target.getLatLng() );
|
||||
if (OSRM.G.route.isShown()) {
|
||||
OSRM.Routing.getRoute();
|
||||
OSRM.G.route.hideOldRoute();
|
||||
OSRM.G.route.hideUnnamedRoute();
|
||||
} else {
|
||||
OSRM.Geocoder.updateAddress(this.parent.label);
|
||||
OSRM.GUI.clearResults();
|
||||
}
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//drag marker class (draggable, invokes route drawing routines)
|
||||
OSRM.DragMarker = function ( label, style, position ) {
|
||||
OSRM.DragMarker.prototype.base.constructor.apply( this, arguments );
|
||||
this.label = label ? label : "drag_marker";
|
||||
};
|
||||
OSRM.inheritFrom( OSRM.DragMarker, OSRM.RouteMarker );
|
||||
OSRM.extend( OSRM.DragMarker, {
|
||||
onClick: function(e) {
|
||||
if( this.parent != OSRM.G.markers.dragger)
|
||||
this.parent.hide();
|
||||
},
|
||||
onDragStart: function(e) {
|
||||
var new_via_index = OSRM.Via.findViaIndex( e.target.getLatLng() );
|
||||
OSRM.G.markers.route.splice(new_via_index+1,0, this.parent );
|
||||
|
||||
OSRM.RouteMarker.prototype.onDragStart.call(this,e);
|
||||
},
|
||||
onDragEnd: function(e) {
|
||||
OSRM.G.markers.route[OSRM.G.dragid] = new OSRM.RouteMarker(OSRM.C.VIA_LABEL, {draggable:true,icon:OSRM.G.icons['marker-via'],dragicon:OSRM.G.icons['marker-via-drag']}, e.target.getLatLng() );
|
||||
OSRM.G.markers.route[OSRM.G.dragid].show();
|
||||
|
||||
OSRM.RouteMarker.prototype.onDragEnd.call(this,e);
|
||||
this.parent.hide();
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.DragMarker: \""+this.label+"\", "+this.position+")";
|
||||
}
|
||||
});
|
98
WebContent/base/osrm/OSRM.Route.js
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
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]
|
||||
|
||||
|
||||
// simple route class (wraps Leaflet Polyline)
|
||||
OSRM.SimpleRoute = function (label, style) {
|
||||
this.label = (label ? label : "route");
|
||||
this.route = new L.DashedPolyline();
|
||||
this.route.setLatLngs( [] );
|
||||
if(style) this.route.setStyle( style );
|
||||
|
||||
this.shown = false;
|
||||
};
|
||||
OSRM.extend( OSRM.SimpleRoute,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.route);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.route);
|
||||
this.shown = false;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
getPoints: function() {
|
||||
return this.route._originalPoints;
|
||||
},
|
||||
getPositions: function() {
|
||||
return this.route.getLatLngs();
|
||||
},
|
||||
setPositions: function(positions) {
|
||||
this.route.setLatLngs( positions );
|
||||
},
|
||||
setStyle: function(style) {
|
||||
this.route.setStyle(style);
|
||||
},
|
||||
centerView: function() {
|
||||
var bounds = new L.LatLngBounds( this.getPositions() );
|
||||
OSRM.g.map.fitBoundsUI( bounds );
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.Route("+ this.label + ", " + this.route.getLatLngs().length + " points)";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// multiroute class (wraps Leaflet LayerGroup to hold several disjoint routes)
|
||||
OSRM.MultiRoute = function (label) {
|
||||
this.label = (label ? label : "multiroute");
|
||||
this.route = new L.LayerGroup();
|
||||
|
||||
this.shown = false;
|
||||
};
|
||||
OSRM.extend( OSRM.MultiRoute,{
|
||||
show: function() {
|
||||
OSRM.G.map.addLayer(this.route);
|
||||
this.shown = true;
|
||||
},
|
||||
hide: function() {
|
||||
OSRM.G.map.removeLayer(this.route);
|
||||
this.shown = false;
|
||||
},
|
||||
isShown: function() {
|
||||
return this.shown;
|
||||
},
|
||||
addRoute: function(positions) {
|
||||
var line = new L.DashedPolyline( positions );
|
||||
line.on('click', function(e) { OSRM.G.route.fire('click',e); });
|
||||
this.route.addLayer( line );
|
||||
},
|
||||
clearRoutes: function() {
|
||||
this.route.clearLayers();
|
||||
},
|
||||
setStyle: function(style) {
|
||||
this.route.invoke('setStyle', style);
|
||||
},
|
||||
toString: function() {
|
||||
return "OSRM.MultiRoute("+ this.label + ")";
|
||||
}
|
||||
});
|
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 166 B After Width: | Height: | Size: 240 B |
BIN
WebContent/images/head.png
Normal file
After Width: | Height: | Size: 710 B |
Before Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 716 B |
Before Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 746 B |
Before Width: | Height: | Size: 635 B |
Before Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 489 B |
Before Width: | Height: | Size: 676 B |
Before Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 778 B |
Before Width: | Height: | Size: 669 B After Width: | Height: | Size: 716 B |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 746 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 635 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 607 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 489 B |
Before Width: | Height: | Size: 430 B After Width: | Height: | Size: 676 B |
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 778 B |
@ -248,6 +248,11 @@ html, body {
|
||||
font-weight:bold;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.header-label
|
||||
{
|
||||
font-weight:normal;
|
||||
padding:0px 5px 0px 0px;
|
||||
}
|
||||
.header-content
|
||||
{
|
||||
font-weight:normal;
|
||||
@ -265,57 +270,57 @@ html, body {
|
||||
|
||||
|
||||
/* style for information-box table (search results, driving directions) */
|
||||
.results-table
|
||||
.description
|
||||
{
|
||||
border-spacing:0px;
|
||||
width:100%;
|
||||
}
|
||||
.results-odd
|
||||
.description-body-odd
|
||||
{
|
||||
background-color: #FFFDE3;
|
||||
}
|
||||
.results-even
|
||||
.description-body-even
|
||||
{
|
||||
background-color: #FFF9BB;
|
||||
}
|
||||
.result-counter
|
||||
.description-body-counter
|
||||
{
|
||||
text-align:right;
|
||||
vertical-align:top;
|
||||
font-weight:bold;
|
||||
padding:1px 5px 1px 5px;
|
||||
}
|
||||
.result-items
|
||||
.description-body-items
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
width:100%;
|
||||
padding:1px;
|
||||
}
|
||||
.result-directions
|
||||
.description-body-directions
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
padding:1px 5px 1px 5px;
|
||||
}
|
||||
.result-direction
|
||||
.description-body-direction
|
||||
{
|
||||
width:18px;
|
||||
height:18px;
|
||||
}
|
||||
.result-distance
|
||||
.description-body-distance
|
||||
{
|
||||
text-align:right;
|
||||
vertical-align: middle;
|
||||
padding:1px 1px 1px 5px;
|
||||
|
||||
}
|
||||
.result-item
|
||||
.description-body-item
|
||||
{
|
||||
cursor:pointer;
|
||||
color:#000000
|
||||
}
|
||||
.result-item:hover
|
||||
.description-body-item:hover
|
||||
{
|
||||
color:#ff0000
|
||||
}
|
||||
@ -475,6 +480,10 @@ html, body {
|
||||
display:table;
|
||||
width:100%;
|
||||
}
|
||||
.row
|
||||
{
|
||||
display:table-row;
|
||||
}
|
||||
.left
|
||||
{
|
||||
display:table-cell;
|
||||
@ -492,4 +501,8 @@ html, body {
|
||||
display:table-cell;
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
}
|
||||
.stretch
|
||||
{
|
||||
width:100%;
|
||||
}
|
@ -36,35 +36,40 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
|
||||
<!-- scripts -->
|
||||
<script src="leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||
<script src="L.Bugfixes.js" type="text/javascript"></script>
|
||||
<script src="L.DashedPolyline.js" type="text/javascript"></script>
|
||||
<script src="L.MouseMarker.js" type="text/javascript"></script>
|
||||
<script src="L.SwitchableIcon.js" type="text/javascript"></script>
|
||||
<script src="base/leaflet/L.Bugfixes.js" type="text/javascript"></script>
|
||||
<script src="base/leaflet/L.Control.QueryableLayers.js" type="text/javascript"></script>
|
||||
<script src="base/leaflet/L.DashedPolyline.js" type="text/javascript"></script>
|
||||
<script src="base/leaflet/L.MouseMarker.js" type="text/javascript"></script>
|
||||
<script src="base/leaflet/L.SwitchableIcon.js" type="text/javascript"></script>
|
||||
|
||||
<script src="OSRM.base.js" type="text/javascript"></script>
|
||||
<script src="OSRM.config.js" type="text/javascript"></script>
|
||||
<script src="OSRM.browsers.js" type="text/javascript"></script>
|
||||
<script src="utils/OSRM.browsers.js" type="text/javascript"></script>
|
||||
<script src="utils/OSRM.classes.js" type="text/javascript"></script>
|
||||
|
||||
<script src="main.js" type="text/javascript"></script>
|
||||
<!-- <script defer="defer" src="OSRM.debug.js" type="text/javascript"></script> -->
|
||||
|
||||
<script src="OSRM.Markers.js" type="text/javascript"></script>
|
||||
<script src="OSRM.Route.js" type="text/javascript"></script>
|
||||
<script src="base/osrm/OSRM.MapView.js" type="text/javascript"></script>
|
||||
<script src="base/osrm/OSRM.Marker.js" type="text/javascript"></script>
|
||||
<script src="base/osrm/OSRM.Route.js" type="text/javascript"></script>
|
||||
|
||||
<script src="OSRM.Map.js" type="text/javascript"></script>
|
||||
<script src="OSRM.GUI.js" type="text/javascript"></script>
|
||||
<script src="base/OSRM.Map.js" type="text/javascript"></script>
|
||||
<script src="base/OSRM.Markers.js" type="text/javascript"></script>
|
||||
<script src="base/OSRM.Routes.js" type="text/javascript"></script>
|
||||
<script src="gui/OSRM.GUI.js" type="text/javascript"></script>
|
||||
<script src="routing/OSRM.Routing.js" type="text/javascript"></script>
|
||||
<script src="routing/OSRM.RoutingDescription.js" type="text/javascript"></script>
|
||||
<script src="routing/OSRM.RoutingGeometry.js" type="text/javascript"></script>
|
||||
<script src="routing/OSRM.RoutingGUI.js" type="text/javascript"></script>
|
||||
<script src="gui/OSRM.RoutingGUI.js" type="text/javascript"></script>
|
||||
<script src="routing/OSRM.RoutingNoNames.js" type="text/javascript"></script>
|
||||
<script src="OSRM.Via.js" type="text/javascript"></script>
|
||||
<script src="OSRM.Geocoder.js" type="text/javascript"></script>
|
||||
<script src="base/OSRM.Via.js" type="text/javascript"></script>
|
||||
<script src="base/OSRM.Geocoder.js" type="text/javascript"></script>
|
||||
|
||||
<script src="OSRM.JSONP.js" type="text/javascript"></script>
|
||||
<script src="utils/OSRM.JSONP.js" type="text/javascript"></script>
|
||||
<script src="localization/OSRM.Localization.js" type="text/javascript"></script>
|
||||
<script src="printing/OSRM.Printing.js" type="text/javascript"></script>
|
||||
<script src="OSRM.Utils.js" type="text/javascript"></script>
|
||||
<script src="utils/OSRM.Utils.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ OSRM.init = function() {
|
||||
OSRM.Localization.init();
|
||||
OSRM.GUI.init();
|
||||
OSRM.Map.init();
|
||||
//OSRM.Printing.init();
|
||||
OSRM.Printing.init();
|
||||
OSRM.Routing.init();
|
||||
|
||||
// check if the URL contains some GET parameter, e.g. for showing a route
|
||||
@ -71,6 +71,7 @@ OSRM.prefetchImages = function() {
|
||||
{id:'direction_6', url:'images/slight-left.png'},
|
||||
{id:'direction_7', url:'images/turn-left.png'},
|
||||
{id:'direction_8', url:'images/sharp-left.png'},
|
||||
{id:'direction_10', url:'images/head.png'},
|
||||
{id:'direction_11', url:'images/round-about.png'},
|
||||
{id:'direction_15', url:'images/target.png'}
|
||||
];
|
||||
|
@ -15,11 +15,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
or see http://www.gnu.org/licenses/agpl.txt.
|
||||
*/
|
||||
|
||||
// OSRM printer
|
||||
// OSRM printing
|
||||
// [printing support]
|
||||
|
||||
OSRM.Printing = {
|
||||
|
||||
OSRM.Printing = {
|
||||
|
||||
// create UI for printing in mainwindow
|
||||
init: function() {
|
||||
var icon = document.createElement('div');
|
||||
@ -36,103 +37,92 @@ init: function() {
|
||||
document.getElementById("gui-printer").onclick = OSRM.Printing.print;
|
||||
},
|
||||
|
||||
|
||||
// create UI in printwindow
|
||||
show: function(response) {
|
||||
// add events
|
||||
OSRM.printwindow.document.getElementById('gui-printer').onclick = OSRM.printwindow.printWindow;
|
||||
|
||||
// localization
|
||||
OSRM.printwindow.document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" );
|
||||
OSRM.printwindow.document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" );
|
||||
|
||||
// create header
|
||||
header =
|
||||
var header =
|
||||
'<thead class="description-header"><tr><td colspan="3">' +
|
||||
|
||||
'<div class="full">' +
|
||||
'<div style="display:table-row">' +
|
||||
'<div class="row">' +
|
||||
|
||||
'<div class="left">' +
|
||||
'<div class="header-content" style="margin:0px 2px 0px 0px;">' + OSRM.loc("GUI_START")+ ': </div>' +
|
||||
'<div class="header-content" style="margin:0px 2px 0px 0px;">' + OSRM.loc("GUI_END")+ ': </div>' +
|
||||
'<div class="left stretch">' +
|
||||
'<div class="full">' +
|
||||
'<div class="row">' +
|
||||
'<div class="left description-header-label">' + OSRM.loc("GUI_START")+ ': </div>' +
|
||||
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-source").value + '</div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="left" style="width:100%">' +
|
||||
'<div class="header-content" style="font-weight:bold;">' + document.getElementById("gui-input-source").value + '</div>' +
|
||||
'<div class="header-content" style="font-weight:bold;">' + document.getElementById("gui-input-target").value + '</div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="left">' +
|
||||
'<div class="header-content" style="margin:0px 2px 0px 0px;">' + OSRM.loc("DISTANCE")+': </div>' +
|
||||
'<div class="header-content" style="margin:0px 2px 0px 0px;">' + OSRM.loc("DURATION")+': </div>' +
|
||||
'<div class="row">' +
|
||||
'<div class="left description-header-label">' + OSRM.loc("GUI_END")+ ': </div>' +
|
||||
'<div class="left description-header-content stretch">' + document.getElementById("gui-input-target").value + '</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="left">' +
|
||||
'<div class="header-content" style="font-weight:bold;">' + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
|
||||
'<div class="header-content" style="font-weight:bold;">' + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
|
||||
'<div class="full">' +
|
||||
'<div class="row">' +
|
||||
'<div class="left description-header-label">' + OSRM.loc("DISTANCE")+': </div>' +
|
||||
'<div class="left description-header-content">' + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="row">' +
|
||||
'<div class="left description-header-label">' + OSRM.loc("DURATION")+': </div>' +
|
||||
'<div class="left description-header-content">' + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="quad"></div>';
|
||||
|
||||
'<div class="quad"></div>' +
|
||||
'</td></tr></thead>';
|
||||
|
||||
// create route description
|
||||
var route_desc = '';
|
||||
route_desc += '<table id="thetable" class="results-table medium-font">';
|
||||
route_desc += '<thead style="display:table-header-group;"><tr><td colspan="3">'+header+'</td></tr></thead>';
|
||||
route_desc += '<tbody stlye="display:table-row-group">';
|
||||
|
||||
var body = '<tbody class="description-body">';
|
||||
for(var i=0; i < response.route_instructions.length; i++){
|
||||
//odd or even ?
|
||||
var rowstyle='results-odd';
|
||||
if(i%2==0) { rowstyle='results-even'; }
|
||||
var rowstyle='description-body-odd';
|
||||
if(i%2==0) { rowstyle='description-body-even'; }
|
||||
|
||||
route_desc += '<tr class="'+rowstyle+'">';
|
||||
body += '<tr class="'+rowstyle+'">';
|
||||
|
||||
route_desc += '<td class="result-directions">';
|
||||
route_desc += '<img width="18px" src="../'+OSRM.RoutingDescription.getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||
route_desc += "</td>";
|
||||
|
||||
route_desc += '<td class="result-items">';
|
||||
route_desc += '<div class="result-item">';
|
||||
body += '<td class="description-body-directions">';
|
||||
body += '<img class="description-body-direction" src="../'+OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0])+'" alt="" />';
|
||||
body += "</td>";
|
||||
|
||||
// build route description
|
||||
if( i == 0 )
|
||||
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, OSRM.loc(response.route_instructions[i][6]) );
|
||||
else if( response.route_instructions[i][1] != "" )
|
||||
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]);
|
||||
body += '<td class="description-body-items">';
|
||||
if( response.route_instructions[i][1] != "" )
|
||||
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
else
|
||||
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"");
|
||||
|
||||
route_desc += '</div>';
|
||||
route_desc += "</td>";
|
||||
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
body += "</td>";
|
||||
|
||||
route_desc += '<td class="result-distance">';
|
||||
body += '<td class="description-body-distance">';
|
||||
if( i != response.route_instructions.length-1 )
|
||||
route_desc += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
|
||||
route_desc += "</td>";
|
||||
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
|
||||
body += "</td>";
|
||||
|
||||
route_desc += "</tr>";
|
||||
body += "</tr>";
|
||||
}
|
||||
route_desc += '</tbody>';
|
||||
route_desc += '</table>';
|
||||
|
||||
|
||||
body += '</tbody>';
|
||||
|
||||
// put everything in DOM
|
||||
OSRM.printwindow.document.getElementById('description').innerHTML = route_desc;
|
||||
OSRM.printwindow.document.getElementById('overview-description').innerHTML =
|
||||
'<table id="" class="results-table medium-font">' +
|
||||
'<thead style="display:table-header-group;"><tr><td colspan="3">'+header+'</td></tr></thead>'+
|
||||
'</table>';
|
||||
OSRM.G.printwindow.document.getElementById('description').innerHTML = '<table class="description medium-font">' + header + body + '</table>';
|
||||
OSRM.G.printwindow.document.getElementById('overview-map-description').innerHTML = '<table class="description medium-font">' + header + '</table>';
|
||||
|
||||
// init map
|
||||
OSRM.Printing.map = OSRM.printwindow.initialize( OSRM.DEFAULTS.TILE_SERVERS[0] );
|
||||
var map = OSRM.Printing.map;
|
||||
// draw map
|
||||
var tile_server_id = OSRM.G.map.getActiveLayerId();
|
||||
var map = OSRM.G.printwindow.initialize( OSRM.DEFAULTS.TILE_SERVERS[tile_server_id] );
|
||||
// draw markers
|
||||
var markers = OSRM.G.markers.route;
|
||||
map.addLayer( new L.MouseMarker( markers[0].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-source']} ) );
|
||||
for(var i=1, size=markers.length-1; i<size; i++)
|
||||
map.addLayer( new L.MouseMarker( markers[i].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-via']} ) );
|
||||
map.addLayer( new L.MouseMarker( markers[markers.length-1].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-target']} ));
|
||||
|
||||
// draw route
|
||||
OSRM.Printing.route = new L.DashedPolyline();
|
||||
var route = OSRM.Printing.route;
|
||||
route.setLatLngs( OSRM.G.route.getPositions() );
|
||||
@ -140,8 +130,7 @@ show: function(response) {
|
||||
map.addLayer( route );
|
||||
var bounds = new L.LatLngBounds( OSRM.G.route.getPositions() );
|
||||
map.fitBoundsUI( bounds );
|
||||
|
||||
// query better geometry
|
||||
// query for a better route geometry
|
||||
var zoom = map.getBoundsZoom(bounds);
|
||||
OSRM.JSONP.call(OSRM.Routing._buildCall()+'&z='+zoom+'&instructions=false', OSRM.Printing.drawRoute, OSRM.Printing.timeoutRoute, OSRM.DEFAULTS.JSONP_TIMEOUT, 'print');
|
||||
},
|
||||
@ -154,23 +143,39 @@ drawRoute: function(response) {
|
||||
},
|
||||
|
||||
|
||||
|
||||
// open printwindow
|
||||
//open printWindow
|
||||
print: function() {
|
||||
// do not open window if there is no route to draw
|
||||
if( !OSRM.G.route.isRoute() || !OSRM.G.route.isShown() )
|
||||
return;
|
||||
|
||||
// close old window (should we really do this?)
|
||||
if( OSRM.printwindow )
|
||||
OSRM.printwindow.close();
|
||||
OSRM.printwindow = window.open("printing/printing.html","","width=540,height=500,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
|
||||
OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.printwindowLoaded, false);
|
||||
if( OSRM.G.printwindow )
|
||||
OSRM.G.printwindow.close();
|
||||
|
||||
// generate a new window and wait till it has finished loading
|
||||
OSRM.G.printwindow = window.open("printing/printing.html","","width=540,height=500,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes");
|
||||
OSRM.Browser.onLoadHandler( OSRM.Printing.printwindowLoaded, OSRM.G.printwindow );
|
||||
},
|
||||
|
||||
// add content to printwindow after it has finished loading
|
||||
|
||||
//add content to printwindow after it has finished loading
|
||||
printwindowLoaded: function(){
|
||||
var print_window = OSRM.G.printwindow;
|
||||
var print_document = print_window.document;
|
||||
|
||||
// add events
|
||||
print_document.getElementById('gui-printer').onclick = print_window.printWindow;
|
||||
|
||||
// localization
|
||||
print_document.getElementById('description-label').innerHTML = OSRM.loc( "ROUTE_DESCRIPTION" );
|
||||
print_document.getElementById('overview-map-label').innerHTML = OSRM.loc( "OVERVIEW_MAP" );
|
||||
|
||||
// add routing content
|
||||
OSRM.Printing.show( OSRM.G.response );
|
||||
OSRM.printwindow.focus();
|
||||
|
||||
// finally, focus on printwindow
|
||||
print_window.focus();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
@ -24,104 +24,6 @@ body
|
||||
}
|
||||
|
||||
|
||||
/* route description box */
|
||||
#description
|
||||
{
|
||||
width:500px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
/* route description box */
|
||||
#overview-description
|
||||
{
|
||||
width:500px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
|
||||
/* route map box */
|
||||
#overview-map
|
||||
{
|
||||
width:500px;
|
||||
height:500px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
|
||||
/* styles for information-box-header */
|
||||
div.header-title
|
||||
{
|
||||
font-weight:bold;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.header-content
|
||||
{
|
||||
font-weight:normal;
|
||||
}
|
||||
.result-link
|
||||
{
|
||||
color:#0000ff;
|
||||
text-decoration:none;
|
||||
cursor:pointer;
|
||||
}
|
||||
.result-link:hover
|
||||
{
|
||||
color:#ff0000;
|
||||
}
|
||||
|
||||
|
||||
/* style for information-box table (search results, driving directions) */
|
||||
.results-table
|
||||
{
|
||||
border-spacing:0px;
|
||||
width:100%;
|
||||
}
|
||||
.results-odd
|
||||
{
|
||||
background-color: #FFFDE3;
|
||||
}
|
||||
.results-even
|
||||
{
|
||||
background-color: #FFF9BB;
|
||||
}
|
||||
.result-counter
|
||||
{
|
||||
text-align:right;
|
||||
vertical-align:top;
|
||||
font-weight:bold;
|
||||
padding:1px 5px 1px 5px;
|
||||
}
|
||||
.result-items
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
width:100%;
|
||||
padding:1px;
|
||||
}
|
||||
.result-directions
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
padding:1px 5px 1px 5px;
|
||||
}
|
||||
.result-distance
|
||||
{
|
||||
text-align:right;
|
||||
vertical-align: middle;
|
||||
padding:1px 1px 1px 5px;
|
||||
}
|
||||
.result-item
|
||||
{
|
||||
cursor:pointer;
|
||||
color:#000000
|
||||
}
|
||||
.no-results
|
||||
{
|
||||
text-align:center;
|
||||
margin:28px;
|
||||
}
|
||||
|
||||
|
||||
/* header area */
|
||||
#printing-header
|
||||
{
|
||||
@ -140,19 +42,156 @@ div.header-title
|
||||
}
|
||||
|
||||
|
||||
/* utility styles */
|
||||
@media print {
|
||||
.quad
|
||||
/* content area */
|
||||
div.label
|
||||
{
|
||||
page-break-before:always;
|
||||
font-weight:bold;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.box
|
||||
{
|
||||
width:500px;
|
||||
margin:5px;
|
||||
}
|
||||
#overview-map
|
||||
{
|
||||
width:500px;
|
||||
height:500px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
|
||||
/* description content */
|
||||
.description
|
||||
{
|
||||
border-spacing:0px;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
/* styles for description header */
|
||||
.description-header
|
||||
{
|
||||
display:table-header-group;
|
||||
}
|
||||
.description-header-label
|
||||
{
|
||||
padding:0px 5px 0px 0px;
|
||||
}
|
||||
.description-header-content
|
||||
{
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
|
||||
/* styles for description body */
|
||||
.description-body
|
||||
{
|
||||
display:table-row-group;
|
||||
}
|
||||
.description-body-odd
|
||||
{
|
||||
background-color: #FFFDE3;
|
||||
}
|
||||
.description-body-even
|
||||
{
|
||||
background-color: #FFF9BB;
|
||||
}
|
||||
.description-body-items
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
width:100%;
|
||||
padding:1px;
|
||||
}
|
||||
.description-body-directions
|
||||
{
|
||||
text-align:left;
|
||||
vertical-align: middle;
|
||||
padding:1px 5px 1px 5px;
|
||||
}
|
||||
.description-body-direction
|
||||
{
|
||||
height:36px;
|
||||
width:36px;
|
||||
}
|
||||
.description-body-distance
|
||||
{
|
||||
text-align:right;
|
||||
vertical-align: middle;
|
||||
padding:1px 1px 1px 5px;
|
||||
}
|
||||
@media print {
|
||||
.description-body-even > td,
|
||||
.description-body-odd > td
|
||||
{
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
}
|
||||
@media screen {
|
||||
|
||||
|
||||
/* utility styles */
|
||||
.quad
|
||||
{
|
||||
min-width:10px;
|
||||
min-height:10px;
|
||||
}
|
||||
@media print {
|
||||
.pagebreak
|
||||
{
|
||||
page-break-before:always;
|
||||
}
|
||||
.noprint
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* fonts */
|
||||
@media print {
|
||||
.base-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.big-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.medium-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.small-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen {
|
||||
.base-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.big-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.medium-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10.5px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.small-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 9px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -180,77 +219,35 @@ div.header-title
|
||||
}
|
||||
|
||||
|
||||
/* fonts */
|
||||
@media print {
|
||||
|
||||
.base-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.big-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.medium-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.small-font {
|
||||
font-family: Times New Roman, Times, serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media screen {
|
||||
.base-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.big-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.medium-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 10.5px;
|
||||
font-weight: normal;
|
||||
}
|
||||
.small-font {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 9px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* table */
|
||||
.full
|
||||
{
|
||||
display:table;
|
||||
width:100%;
|
||||
}
|
||||
.row
|
||||
{
|
||||
display:table-row;
|
||||
}
|
||||
.left
|
||||
{
|
||||
display:table-cell;
|
||||
text-align:left;
|
||||
vertical-align:middle;
|
||||
vertical-align:top;
|
||||
}
|
||||
.right
|
||||
{
|
||||
display:table-cell;
|
||||
text-align:right;
|
||||
vertical-align:middle;
|
||||
vertical-align:top;
|
||||
}
|
||||
.center
|
||||
{
|
||||
display:table-cell;
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
vertical-align:top;
|
||||
}
|
||||
.stretch
|
||||
{
|
||||
width:100%;
|
||||
}
|
@ -29,18 +29,15 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
<meta name="description" content="OSRM Website"/>
|
||||
<meta name="author" content="Dennis Schieferdecker" />
|
||||
|
||||
<!-- favicon -->
|
||||
<link rel="shortcut icon" href="../images/osrm-favicon.ico" type="image/x-icon" />
|
||||
|
||||
<!-- stylesheets -->
|
||||
<link rel="stylesheet" href="../leaflet/leaflet.css" type="text/css"/>
|
||||
<!--[if lte IE 8]><link rel="stylesheet" href="../leaflet/leaflet.ie.css" type="text/css"/><![endif]-->
|
||||
<link rel="stylesheet" href="printing.css" type="text/css"/>
|
||||
|
||||
<!-- scripts -->
|
||||
<script src="../leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||
<script src="printing.js" type="text/javascript"></script>
|
||||
<script src="../OSRM.Map.js" type="text/javascript"></script>
|
||||
<script src="../leaflet/leaflet-src.js" type="text/javascript"></script>
|
||||
<script src="../base/osrm/OSRM.MapView.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
||||
@ -48,18 +45,20 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
<body class="base-font">
|
||||
|
||||
<!-- header -->
|
||||
<div id="printing-header">
|
||||
<div id="printing-header" class="noprint">
|
||||
<div id="gui-printer" class="iconic-button top-right-button"></div>
|
||||
</div>
|
||||
|
||||
<!--description-->
|
||||
<div id="description-label" class="header-title">Routenbeschreibung</div>
|
||||
<div id="description"></div>
|
||||
<div id="description-label" class="label">Routenbeschreibung</div>
|
||||
<div id="description" class="box"></div>
|
||||
|
||||
<!--map-->
|
||||
<div class="quad"></div>
|
||||
<div id="overview-map-label" class="header-title">Übersichtskarte</div>
|
||||
<div id="overview-description" class="results-table medium-font"></div>
|
||||
<div class="pagebreak"></div>
|
||||
<div class="quad noprint"></div>
|
||||
<div class="quad noprint"></div>
|
||||
<div id="overview-map-label" class="label">Übersichtskarte</div>
|
||||
<div id="overview-map-description" class="box"></div>
|
||||
<div id="overview-map"></div>
|
||||
|
||||
</body>
|
||||
|
@ -28,7 +28,7 @@ function initialize(tile_server) {
|
||||
// setup map
|
||||
var tile_layer = new L.TileLayer(tile_server.url, tile_server.options);
|
||||
OSRM.G.map = new OSRM.MapView("overview-map", {
|
||||
center: new L.LatLng(51.505, -0.09),
|
||||
center: new L.LatLng(48.84, 10.10),
|
||||
zoom: 13,
|
||||
zoomAnimation: false,
|
||||
fadeAnimation: false,
|
||||
|
@ -58,72 +58,53 @@ show: function(response) {
|
||||
var gpx_link = '[<a class="result-link" onClick="document.location.href=\'' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx\';">'+OSRM.loc("GPX_FILE")+'</a>]';
|
||||
|
||||
// create route description
|
||||
var route_desc = "";
|
||||
route_desc += '<table class="results-table medium-font">';
|
||||
|
||||
var body = "";
|
||||
|
||||
body += '<table class="description medium-font">';
|
||||
for(var i=0; i < response.route_instructions.length; i++){
|
||||
//odd or even ?
|
||||
var rowstyle='results-odd';
|
||||
if(i%2==0) { rowstyle='results-even'; }
|
||||
var rowstyle='description-body-odd';
|
||||
if(i%2==0) { rowstyle='description-body-even'; }
|
||||
|
||||
route_desc += '<tr class="'+rowstyle+'">';
|
||||
body += '<tr class="'+rowstyle+'">';
|
||||
|
||||
route_desc += '<td class="result-directions">';
|
||||
route_desc += '<img class="result-direction" src="'+ OSRM.RoutingDescription.getDrivingInstructionIcon(response.route_instructions[i][0]) + '" alt=""/>';
|
||||
route_desc += '</td>';
|
||||
body += '<td class="description-body-directions">';
|
||||
body += '<img class="description-body-direction" src="'+ OSRM.RoutingDescription._getDrivingInstructionIcon(response.route_instructions[i][0]) + '" alt=""/>';
|
||||
body += '</td>';
|
||||
|
||||
route_desc += '<td class="result-items">';
|
||||
route_desc += '<div class="result-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
|
||||
body += '<td class="description-body-items">';
|
||||
body += '<div class="description-body-item" onclick="OSRM.RoutingDescription.onClickRouteDescription('+response.route_instructions[i][3]+')">';
|
||||
|
||||
// build route description
|
||||
if( response.route_instructions[i][1] != "" )
|
||||
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]).replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
else
|
||||
route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
body += OSRM.loc(OSRM.RoutingDescription._getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"").replace(/%d/, OSRM.loc(response.route_instructions[i][6]));
|
||||
|
||||
route_desc += '</div>';
|
||||
route_desc += "</td>";
|
||||
body += '</div>';
|
||||
body += "</td>";
|
||||
|
||||
route_desc += '<td class="result-distance">';
|
||||
body += '<td class="description-body-distance">';
|
||||
if( i != response.route_instructions.length-1 )
|
||||
route_desc += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
|
||||
route_desc += "</td>";
|
||||
body += '<b>'+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+'</b>';
|
||||
body += "</td>";
|
||||
|
||||
route_desc += "</tr>";
|
||||
body += "</tr>";
|
||||
}
|
||||
route_desc += '</table>';
|
||||
body += '</table>';
|
||||
|
||||
// create header
|
||||
header =
|
||||
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
|
||||
'<div class="full">' +
|
||||
'<div class="left">' +
|
||||
'<div class="header-content">' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
|
||||
'<div class="header-content">' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="right">' +
|
||||
'<div id="route-link" class="header-content">' + route_link + '</div>' +
|
||||
'<div class="header-content">' + gpx_link + '</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
// build header
|
||||
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), route_link, gpx_link);
|
||||
|
||||
// update DOM
|
||||
document.getElementById('information-box-header').innerHTML = header;
|
||||
document.getElementById('information-box').innerHTML = route_desc;
|
||||
document.getElementById('information-box').innerHTML = body;
|
||||
},
|
||||
|
||||
// simple description
|
||||
showSimple: function(response) {
|
||||
header =
|
||||
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
|
||||
'<div class="full">' +
|
||||
'<div class="left">' +
|
||||
'<div class="header-content">' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '</div>' +
|
||||
'<div class="header-content">' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="right">' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
// build header
|
||||
header = OSRM.RoutingDescription._buildHeader(OSRM.Utils.metersToDistance(response.route_summary.total_distance), OSRM.Utils.secondsToTime(response.route_summary.total_time), "", "");
|
||||
|
||||
// update DOM
|
||||
document.getElementById('information-box-header').innerHTML = header;
|
||||
@ -132,24 +113,68 @@ showSimple: function(response) {
|
||||
|
||||
// no description
|
||||
showNA: function( display_text ) {
|
||||
header =
|
||||
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
|
||||
'<div class="full">' +
|
||||
'<div class="left">' +
|
||||
'<div class="header-content">' + OSRM.loc("DISTANCE")+": N/A" + '</div>' +
|
||||
'<div class="header-content">' + OSRM.loc("DURATION")+": N/A" + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="right">' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
// build header
|
||||
header = OSRM.RoutingDescription._buildHeader("N/A", "N/A", "", "");
|
||||
|
||||
// update DOM
|
||||
document.getElementById('information-box-header').innerHTML = header;
|
||||
document.getElementById('information-box').innerHTML = "<div class='no-results big-font'>"+display_text+"</div>";
|
||||
},
|
||||
|
||||
// build header
|
||||
_buildHeader: function(distance, duration, route_link, gpx_link) {
|
||||
var temp =
|
||||
'<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
|
||||
|
||||
'<div class="full">' +
|
||||
'<div class="row">' +
|
||||
|
||||
'<div class="left">' +
|
||||
'<div class="full">' +
|
||||
'<div class="row">' +
|
||||
'<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
|
||||
'<div class="left header-content stretch">' + distance + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="row">' +
|
||||
'<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
|
||||
'<div class="left header-content stretch">' + duration + '</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="left">' +
|
||||
'<div class="full">' +
|
||||
'<div class="row">' +
|
||||
'<div class="right header-content" id="route-link">' + route_link + '</div>' +
|
||||
'</div>' +
|
||||
'<div class="row">' +
|
||||
'<div class="right header-content">' + gpx_link + '</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'</div>';
|
||||
// '<div class="header-title">' + OSRM.loc("ROUTE_DESCRIPTION") + '</div>' +
|
||||
// '<div class="full">' +
|
||||
// '<div class="row">' +
|
||||
// '<div class="left header-label">' + OSRM.loc("DISTANCE")+":" + '</div>' +
|
||||
// '<div class="left header-content">' + distance + '</div>' +
|
||||
// '<div class="right header-content" id="route-link">' + route_link + '</div>' +
|
||||
// '</div>' +
|
||||
// '<div class="row">' +
|
||||
// '<div class="left header-label">' + OSRM.loc("DURATION")+":" + '</div>' +
|
||||
// '<div class="left header-content">' + duration + '</div>' +
|
||||
// '<div class="right header-content">' + gpx_link + '</div>' +
|
||||
// '</div>' +
|
||||
// '</div>';
|
||||
return temp;
|
||||
},
|
||||
|
||||
// retrieve driving instruction icon from instruction id
|
||||
getDrivingInstructionIcon: function(server_instruction_id) {
|
||||
_getDrivingInstructionIcon: function(server_instruction_id) {
|
||||
var local_icon_id = "direction_";
|
||||
server_instruction_id = server_instruction_id.replace(/^11-\d{1,}$/,"11"); // dumb check, if there is a roundabout (all have the same icon)
|
||||
local_icon_id += server_instruction_id;
|
||||
@ -161,7 +186,7 @@ getDrivingInstructionIcon: function(server_instruction_id) {
|
||||
},
|
||||
|
||||
// retrieve driving instructions from instruction ids
|
||||
getDrivingInstruction: function(server_instruction_id) {
|
||||
_getDrivingInstruction: function(server_instruction_id) {
|
||||
var local_instruction_id = "DIRECTION_";
|
||||
server_instruction_id = server_instruction_id.replace(/^11-\d{2,}$/,"11-x"); // dumb check, if there are 10+ exits on a roundabout (say the same for exit 10+)
|
||||
local_instruction_id += server_instruction_id;
|
||||
|
@ -41,7 +41,6 @@ OSRM.JSONP = {
|
||||
|
||||
// wrap timeout function
|
||||
OSRM.JSONP.timeouts[id] = function(response) {
|
||||
console.log("timeout",id);
|
||||
try {
|
||||
timeout_function(response, parameters);
|
||||
} finally {
|
@ -45,22 +45,25 @@ OSRM.Browser.getElementsByClassName = function( node, classname ) {
|
||||
return a;
|
||||
};
|
||||
|
||||
// call a function when DOM has finished loading and remove event handler
|
||||
OSRM.Browser.onLoadHandler = function( function_pointer ) {
|
||||
if(document.addEventListener) { // FF, CH, IE9+
|
||||
// call a function when DOM has finished loading and remove event handler (optionally pass a different window object)
|
||||
OSRM.Browser.onLoadHandler = function( function_pointer, the_document ) {
|
||||
the_document = the_document || document; // default document
|
||||
|
||||
if(the_document.addEventListener) { // FF, CH, IE9+
|
||||
var temp_function = function() {
|
||||
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
the_document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
function_pointer.call();
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", temp_function, false);
|
||||
the_document.addEventListener("DOMContentLoaded", temp_function, false);
|
||||
}
|
||||
else if(document.attachEvent) { // IE8-
|
||||
|
||||
else if(the_document.attachEvent) { // IE8-
|
||||
var temp_function = function() {
|
||||
if ( document.readyState === "interactive" || document.readyState === "complete" ) {
|
||||
document.detachEvent("onreadystatechange", arguments.callee);
|
||||
if ( the_document.readyState === "interactive" || the_document.readyState === "complete" ) {
|
||||
the_document.detachEvent("onreadystatechange", arguments.callee);
|
||||
function_pointer.call();
|
||||
}
|
||||
};
|
||||
document.attachEvent("onreadystatechange", temp_function);
|
||||
the_document.attachEvent("onreadystatechange", temp_function);
|
||||
}
|
||||
};
|
47
WebContent/utils/OSRM.classes.js
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
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
|
||||
// [support for inheritance]
|
||||
|
||||
// declare one class to be a subclass of another class
|
||||
// (runs anonymous function to prevent local functions cluttering global namespace)
|
||||
(function() {
|
||||
var _inheritFromHelper = function() {};
|
||||
OSRM.inheritFrom = function( sub_class, base_class ) {
|
||||
_inheritFromHelper.prototype = base_class.prototype;
|
||||
sub_class.prototype = new _inheritFromHelper();
|
||||
sub_class.prototype.constructor = sub_class;
|
||||
sub_class.prototype.base = base_class.prototype;
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
// extend prototypes of a class -> used to add member values and functions
|
||||
OSRM.extend = function( target_class, properties ) {
|
||||
for( property in properties ) {
|
||||
target_class.prototype[property] = properties[property];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// [usage of convenience functions]
|
||||
// SubClass = function() {
|
||||
// SubClass.prototype.base.constructor.apply(this, arguments);
|
||||
// }
|
||||
// OSRM.inheritFrom( SubClass, BaseClass );
|
||||
// OSRM.extend( SubClass, { property:value } );
|