OSM.Routing -> OSM.Directions

Too close of a name collision to OSM.Router.
This commit is contained in:
John Firebaugh 2014-05-12 12:34:34 -07:00
parent ed75d4710b
commit be79156f43
6 changed files with 21 additions and 23 deletions

View file

@ -13,9 +13,8 @@
//= require index/history //= require index/history
//= require index/note //= require index/note
//= require index/new_note //= require index/new_note
//= require index/directions
//= require router //= require router
//= require routing
//= require_tree ./routing_engines
(function() { (function() {
var loaderTimeout; var loaderTimeout;
@ -326,8 +325,8 @@ $(document).ready(function () {
$(".search_form").on("submit", function(e) { $(".search_form").on("submit", function(e) {
e.preventDefault(); e.preventDefault();
if ($(".query_wrapper.routing").is(":visible")) { if ($(".query_wrapper.routing").is(":visible")) {
// Routing // Directions
OSM.routing.requestRoute(true, true); OSM.directions.requestRoute(true, true);
} else { } else {
// Search // Search
$("header").addClass("closed"); $("header").addClass("closed");
@ -348,8 +347,8 @@ $(document).ready(function () {
map.getCenter().lng.toFixed(precision))); map.getCenter().lng.toFixed(precision)));
}); });
OSM.routing = OSM.Routing(map,'OSM.routing',$('.query_wrapper.routing')); OSM.directions = OSM.Directions(map, 'OSM.directions', $('.query_wrapper.routing'));
OSM.routing.chooseEngine('javascripts.directions.engines.osrm_car'); OSM.directions.chooseEngine('javascripts.directions.engines.osrm_car');
$(".get_directions").on("click",function(e) { $(".get_directions").on("click",function(e) {
e.preventDefault(); e.preventDefault();
@ -358,7 +357,7 @@ $(document).ready(function () {
$(".search_form input[type='submit']").addClass("routing_submit"); $(".search_form input[type='submit']").addClass("routing_submit");
$(".query_wrapper.routing [name=route_from]").focus(); $(".query_wrapper.routing [name=route_from]").focus();
$("#map").on('dragend dragover',function(e) { e.preventDefault(); }); $("#map").on('dragend dragover',function(e) { e.preventDefault(); });
$("#map").on('drop',function(e) { OSM.routing.handleDrop(e); e.preventDefault(); }); $("#map").on('drop',function(e) { OSM.directions.handleDrop(e); e.preventDefault(); });
$(".routing_marker").on('dragstart',function(e) { $(".routing_marker").on('dragstart',function(e) {
e.originalEvent.dataTransfer.effectAllowed = 'move'; e.originalEvent.dataTransfer.effectAllowed = 'move';
e.originalEvent.dataTransfer.setData('id', this.id); e.originalEvent.dataTransfer.setData('id', this.id);
@ -374,7 +373,7 @@ $(document).ready(function () {
$(".search").show(); $(".search").show();
$(".routing").hide(); $(".routing").hide();
$(".search_form input[type='submit']").removeClass("routing_submit"); $(".search_form input[type='submit']").removeClass("routing_submit");
OSM.routing.close(); OSM.directions.close();
$("#map").off('dragend drop dragover'); $("#map").off('dragend drop dragover');
$(".routing_marker").off('dragstart'); $(".routing_marker").off('dragstart');
$(".query_wrapper.search [name=query]").focus(); $(".query_wrapper.search [name=query]").focus();

View file

@ -1,6 +1,5 @@
/* //= require_self
osm.org routing interface //= require_tree ./directions_engines
*/
var TURN_INSTRUCTIONS = []; var TURN_INSTRUCTIONS = [];
@ -16,14 +15,14 @@ var ROUTING_POLYLINE_HIGHLIGHT = {
weight: 12 weight: 12
}; };
OSM.RoutingEngines = { OSM.DirectionsEngines = {
list: [], list: [],
add: function (supportsHTTPS, engine) { add: function (supportsHTTPS, engine) {
if (document.location.protocol == "http:" || supportsHTTPS) this.list.push(engine); if (document.location.protocol == "http:" || supportsHTTPS) this.list.push(engine);
} }
}; };
OSM.Routing = function (map, name, jqSearch) { OSM.Directions = function (map, name, jqSearch) {
var r = {}; var r = {};
TURN_INSTRUCTIONS = [ TURN_INSTRUCTIONS = [
@ -298,7 +297,7 @@ OSM.Routing = function (map, name, jqSearch) {
// Routing engine handling // Routing engine handling
// Add all engines // Add all engines
var list = OSM.RoutingEngines.list; var list = OSM.DirectionsEngines.list;
list.sort(function (a, b) { list.sort(function (a, b) {
return I18n.t(a.name) > I18n.t(b.name); return I18n.t(a.name) > I18n.t(b.name);
}); });

View file

@ -77,5 +77,5 @@ GraphHopperEngine.prototype.createConfig = function () {
}; };
}; };
OSM.RoutingEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); OSM.DirectionsEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig());
OSM.RoutingEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); OSM.DirectionsEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig());

View file

@ -92,7 +92,7 @@ MapQuestEngine.prototype.createConfig = function () {
}; };
}; };
OSM.RoutingEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig()); OSM.DirectionsEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig());
OSM.RoutingEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig()); OSM.DirectionsEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig());
OSM.RoutingEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig()); OSM.DirectionsEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig());
// can be: routeType=fastest|shortest|pedestrian|multimodal|bicycle // can be: routeType=fastest|shortest|pedestrian|multimodal|bicycle

View file

@ -66,4 +66,4 @@ OSRMEngine.prototype.createConfig = function () {
}; };
}; };
OSM.RoutingEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig()); OSM.DirectionsEngines.add(false, new OSRMEngine("Car", "http://router.project-osrm.org/viaroute").createConfig());

View file

@ -18,10 +18,10 @@
<div class='query_wrapper routing'> <div class='query_wrapper routing'>
<%= image_tag "marker-green.png", :class => 'routing_marker', :id => 'marker_from', :draggable => 'true' %> <%= image_tag "marker-green.png", :class => 'routing_marker', :id => 'marker_from', :draggable => 'true' %>
<%= text_field_tag "route_from", params[:from], :placeholder => t('site.search.from'), :onchange=>"OSM.routing.geocode('route_from',event)" %> <%= text_field_tag "route_from", params[:from], :placeholder => t('site.search.from'), :onchange=>"OSM.directions.geocode('route_from',event)" %>
<%= image_tag "marker-red.png" , :class => 'routing_marker', :id => 'marker_to' , :draggable => 'true' %> <%= image_tag "marker-red.png" , :class => 'routing_marker', :id => 'marker_to' , :draggable => 'true' %>
<%= text_field_tag "route_to" , params[:to] , :placeholder => t('site.search.to') , :onchange=>"OSM.routing.geocode('route_to' ,event)" %> <%= text_field_tag "route_to" , params[:to] , :placeholder => t('site.search.to') , :onchange=>"OSM.directions.geocode('route_to' ,event)" %>
<select class='routing_engines' name='routing_engines' onchange="OSM.routing.selectEngine(event)"></select> <select class='routing_engines' name='routing_engines' onchange="OSM.directions.selectEngine(event)"></select>
<%= image_tag "searching-small.gif", :class => 'spinner', :style => "vertical-align: middle; display: none;" %> <%= image_tag "searching-small.gif", :class => 'spinner', :style => "vertical-align: middle; display: none;" %>
</div> </div>