From: Richard Fairhurst Date: Thu, 23 Jan 2014 00:49:00 +0000 (+0000) Subject: Start work on drag-and-drop start/end markers X-Git-Tag: live~4842^2~50 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/08837b2f8b3a8434875682f8f18962a9bce73c46 Start work on drag-and-drop start/end markers --- diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 7369c0fb4..f3df5ae67 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -356,6 +356,8 @@ $(document).ready(function () { $(".search").hide(); $(".routing").show(); $(".query_wrapper.routing [name=route_from]").focus(); + $("#map").on('dragend dragover',function(e) { e.preventDefault(); }); + $("#map").on('drop',function(e) { OSM.routing.handleDrop(e); }); }); $(".close_directions").on("click",function(e) { @@ -363,6 +365,7 @@ $(document).ready(function () { $(".search").show(); $(".routing").hide(); OSM.routing.close(); + $("#map").off('dragend drop dragover'); $(".query_wrapper.search [name=query]").focus(); }); diff --git a/app/assets/javascripts/routing.js.erb b/app/assets/javascripts/routing.js.erb index 7837c5327..45ae08d81 100644 --- a/app/assets/javascripts/routing.js.erb +++ b/app/assets/javascripts/routing.js.erb @@ -88,6 +88,12 @@ OSM.Routing=function(map,name,jqSearch) { r.requestRoute(); } }; + + // Drag and drop markers + + r.handleDrop=function(e) { + console.log(r.map.mouseEventToLatLng(e.originalEvent)) + }; // Route-fetching UI diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index d0732de74..0f306b6d3 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -1024,6 +1024,8 @@ tr.turn { tr.turn:hover { background: lighten($green, 30%); } +.routing_engines, #route_from, #route_to { margin-left: 25px; } +.routing_marker { width: 15px; position: absolute; } /* Rules for entity history */ diff --git a/app/views/layouts/_search.html.erb b/app/views/layouts/_search.html.erb index bf734fce2..da0d0dcad 100644 --- a/app/views/layouts/_search.html.erb +++ b/app/views/layouts/_search.html.erb @@ -15,7 +15,9 @@
+ <%= image_tag "marker-green.png", :class => 'routing_marker', :draggable => 'true' %> <%= text_field_tag "route_from", params[:from], :placeholder => "From", :onchange=>"OSM.routing.geocode('route_from',event)" %> + <%= image_tag "marker-red.png" , :class => 'routing_marker', :draggable => 'true' %> <%= text_field_tag "route_to" , params[:to] , :placeholder => "To" , :onchange=>"OSM.routing.geocode('route_to' ,event)" %>