OSM.Routing -> OSM.Directions
Too close of a name collision to OSM.Router.
This commit is contained in:
parent
ed75d4710b
commit
be79156f43
6 changed files with 21 additions and 23 deletions
|
@ -13,9 +13,8 @@
|
|||
//= require index/history
|
||||
//= require index/note
|
||||
//= require index/new_note
|
||||
//= require index/directions
|
||||
//= require router
|
||||
//= require routing
|
||||
//= require_tree ./routing_engines
|
||||
|
||||
(function() {
|
||||
var loaderTimeout;
|
||||
|
@ -326,8 +325,8 @@ $(document).ready(function () {
|
|||
$(".search_form").on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
if ($(".query_wrapper.routing").is(":visible")) {
|
||||
// Routing
|
||||
OSM.routing.requestRoute(true, true);
|
||||
// Directions
|
||||
OSM.directions.requestRoute(true, true);
|
||||
} else {
|
||||
// Search
|
||||
$("header").addClass("closed");
|
||||
|
@ -348,8 +347,8 @@ $(document).ready(function () {
|
|||
map.getCenter().lng.toFixed(precision)));
|
||||
});
|
||||
|
||||
OSM.routing = OSM.Routing(map,'OSM.routing',$('.query_wrapper.routing'));
|
||||
OSM.routing.chooseEngine('javascripts.directions.engines.osrm_car');
|
||||
OSM.directions = OSM.Directions(map, 'OSM.directions', $('.query_wrapper.routing'));
|
||||
OSM.directions.chooseEngine('javascripts.directions.engines.osrm_car');
|
||||
|
||||
$(".get_directions").on("click",function(e) {
|
||||
e.preventDefault();
|
||||
|
@ -358,7 +357,7 @@ $(document).ready(function () {
|
|||
$(".search_form input[type='submit']").addClass("routing_submit");
|
||||
$(".query_wrapper.routing [name=route_from]").focus();
|
||||
$("#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) {
|
||||
e.originalEvent.dataTransfer.effectAllowed = 'move';
|
||||
e.originalEvent.dataTransfer.setData('id', this.id);
|
||||
|
@ -374,7 +373,7 @@ $(document).ready(function () {
|
|||
$(".search").show();
|
||||
$(".routing").hide();
|
||||
$(".search_form input[type='submit']").removeClass("routing_submit");
|
||||
OSM.routing.close();
|
||||
OSM.directions.close();
|
||||
$("#map").off('dragend drop dragover');
|
||||
$(".routing_marker").off('dragstart');
|
||||
$(".query_wrapper.search [name=query]").focus();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
osm.org routing interface
|
||||
*/
|
||||
//= require_self
|
||||
//= require_tree ./directions_engines
|
||||
|
||||
var TURN_INSTRUCTIONS = [];
|
||||
|
||||
|
@ -16,14 +15,14 @@ var ROUTING_POLYLINE_HIGHLIGHT = {
|
|||
weight: 12
|
||||
};
|
||||
|
||||
OSM.RoutingEngines = {
|
||||
OSM.DirectionsEngines = {
|
||||
list: [],
|
||||
add: function (supportsHTTPS, 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 = {};
|
||||
|
||||
TURN_INSTRUCTIONS = [
|
||||
|
@ -298,7 +297,7 @@ OSM.Routing = function (map, name, jqSearch) {
|
|||
// Routing engine handling
|
||||
|
||||
// Add all engines
|
||||
var list = OSM.RoutingEngines.list;
|
||||
var list = OSM.DirectionsEngines.list;
|
||||
list.sort(function (a, b) {
|
||||
return I18n.t(a.name) > I18n.t(b.name);
|
||||
});
|
|
@ -77,5 +77,5 @@ GraphHopperEngine.prototype.createConfig = function () {
|
|||
};
|
||||
};
|
||||
|
||||
OSM.RoutingEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig());
|
||||
OSM.RoutingEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig());
|
||||
OSM.DirectionsEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig());
|
||||
OSM.DirectionsEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig());
|
|
@ -92,7 +92,7 @@ MapQuestEngine.prototype.createConfig = function () {
|
|||
};
|
||||
};
|
||||
|
||||
OSM.RoutingEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig());
|
||||
OSM.RoutingEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig());
|
||||
OSM.RoutingEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig());
|
||||
OSM.DirectionsEngines.add(true, new MapQuestEngine("Bicycle", "routeType=bicycle").createConfig());
|
||||
OSM.DirectionsEngines.add(true, new MapQuestEngine("Foot", "routeType=pedestrian").createConfig());
|
||||
OSM.DirectionsEngines.add(true, new MapQuestEngine("Car", "routeType=fastest").createConfig());
|
||||
// can be: routeType=fastest|shortest|pedestrian|multimodal|bicycle
|
|
@ -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());
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
<div class='query_wrapper routing'>
|
||||
<%= 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' %>
|
||||
<%= text_field_tag "route_to" , params[:to] , :placeholder => t('site.search.to') , :onchange=>"OSM.routing.geocode('route_to' ,event)" %>
|
||||
<select class='routing_engines' name='routing_engines' onchange="OSM.routing.selectEngine(event)"></select>
|
||||
<%= 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.directions.selectEngine(event)"></select>
|
||||
<%= image_tag "searching-small.gif", :class => 'spinner', :style => "vertical-align: middle; display: none;" %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue