Start work on drag-and-drop start/end markers
authorRichard Fairhurst <richard@systemeD.net>
Thu, 23 Jan 2014 00:49:00 +0000 (00:49 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Thu, 23 Jan 2014 00:49:00 +0000 (00:49 +0000)
app/assets/javascripts/index.js
app/assets/javascripts/routing.js.erb
app/assets/stylesheets/common.css.scss
app/views/layouts/_search.html.erb

index 7369c0fb4c928fb3186570fea2df931a7fc03ccf..f3df5ae676955a1925eeedaeabf4a4c541e47cd5 100644 (file)
@@ -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();
   });
 
index 7837c532771d3af28b457847bcda10621afb1f01..45ae08d81cd7dbe8accf86f0d90397ff386252e0 100644 (file)
@@ -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
 
index d0732de746dc9732529d5cb3af3e340cc81d15c9..0f306b6d3036b865c9d679ef28a621a6bc06be6c 100644 (file)
@@ -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 */
 
index bf734fce28e0203b8974ac38f13ea8e65ce705ee..da0d0dcada492fa0e4c1d69ed498cfae7977c25f 100644 (file)
@@ -15,7 +15,9 @@
   </div>
 
   <div class='query_wrapper routing'>
+    <%= 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)" %>
     <select class='routing_engines' name='routing_engines' onchange="OSM.routing.selectEngine(event)"></select>
   </div>