From 213bb71b35bbfb6b83ab4ba64984f69e27a919ec Mon Sep 17 00:00:00 2001 From: shiin Date: Mon, 9 Apr 2012 11:59:32 +0200 Subject: [PATCH] changed behaviour of geocoder (return always triggers geocoder, moving a single marker clears search results) --- WebContent/OSRM.GUI.js | 3 +++ WebContent/OSRM.Geocoder.js | 10 +++++++--- WebContent/OSRM.Markers.js | 9 +++++---- WebContent/main.html | 6 +++--- WebContent/routing/OSRM.RoutingGUI.js | 11 ++++++++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/WebContent/OSRM.GUI.js b/WebContent/OSRM.GUI.js index f47b548ad..bd367daf0 100644 --- a/WebContent/OSRM.GUI.js +++ b/WebContent/OSRM.GUI.js @@ -37,10 +37,12 @@ init: function() { document.getElementById("gui-printer").onclick = OSRM.Printing.print; document.getElementById("gui-input-source").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.SOURCE_LABEL);}; + document.getElementById("gui-input-source").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-delete-source").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-search-source").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.SOURCE_LABEL);}; document.getElementById("gui-input-target").onchange = function() {OSRM.RoutingGUI.inputChanged(OSRM.C.TARGET_LABEL);}; + document.getElementById("gui-input-target").onkeyup = function(e) {OSRM.RoutingGUI.keyUp(e,OSRM.C.TARGET_LABEL);}; document.getElementById("gui-delete-target").onclick = function() {OSRM.RoutingGUI.deleteMarker(OSRM.C.TARGET_LABEL);}; document.getElementById("gui-search-target").onclick = function() {OSRM.RoutingGUI.showMarker(OSRM.C.TARGET_LABEL);}; @@ -49,6 +51,7 @@ init: function() { document.getElementById("gui-options-toggle").onclick = OSRM.GUI.toggleOptions; document.getElementById("open-josm").onclick = OSRM.RoutingGUI.openJOSM; document.getElementById("open-osmbugs").onclick = OSRM.RoutingGUI.openOSMBugs; + document.getElementById("option-highlight-nonames").onclick = OSRM.Routing.getRoute; // gui after transition events if( OSRM.Browser.FF3==-1 && OSRM.Browser.IE6_9==-1 ) { diff --git a/WebContent/OSRM.Geocoder.js b/WebContent/OSRM.Geocoder.js index 80f302995..4331b3e9a 100644 --- a/WebContent/OSRM.Geocoder.js +++ b/WebContent/OSRM.Geocoder.js @@ -60,7 +60,8 @@ _onclickResult: function(marker_id, lat, lon) { OSRM.G.markers.route[index].show(); OSRM.G.markers.route[index].centerView(); - OSRM.Routing.getRoute(); + if( OSRM.G.markers.route.length > 1 ) + OSRM.Routing.getRoute(); }, @@ -76,6 +77,11 @@ _showResults: function(response, parameters) { return; } + // show first result + OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); + if( OSRM.G.markers.route.length > 1 ) + return; + // show possible results for input var html = ""; html += ''; @@ -101,8 +107,6 @@ _showResults: function(response, parameters) { "
"+OSRM.loc("SEARCH_RESULTS")+"
" + "
(found "+response.length+" results)"+"
"; document.getElementById('information-box').innerHTML = html; - - OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); }, _showResults_Empty: function(parameters) { document.getElementById('information-box-header').innerHTML = diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index 8858a8ba1..a86e4853f 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -118,14 +118,15 @@ onDragEnd: function(e) { this.switchIcon(this.options.baseicon); this.parent.setPosition( e.target.getLatLng() ); - OSRM.Routing.getRoute(); if (OSRM.G.route.isShown()) { + OSRM.Routing.getRoute(); OSRM.G.route.hideOldRoute(); OSRM.G.route.hideUnnamedRoute(); - } - - if(OSRM.G.route.isShown()==false) + } else { OSRM.Geocoder.updateAddress(this.parent.label); + document.getElementById('information-box').innerHTML = ""; // do we want this? + document.getElementById('information-box-header').innerHTML = ""; + } }, toString: function() { return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")"; diff --git a/WebContent/main.html b/WebContent/main.html index 20a9d6e3e..171fc9da3 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -109,7 +109,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
Ende:
-
+
@@ -129,12 +129,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
- Kartenwerkzeuge + Kartenwerkzeuge
- + Unbenannte Straßen hervorheben
diff --git a/WebContent/routing/OSRM.RoutingGUI.js b/WebContent/routing/OSRM.RoutingGUI.js index a7fa509cb..e549b1a0a 100644 --- a/WebContent/routing/OSRM.RoutingGUI.js +++ b/WebContent/routing/OSRM.RoutingGUI.js @@ -83,7 +83,16 @@ showMarker: function(marker_id) { }, -// changed: any inputbox (is called when return is pressed [after] or focus is lost [before]) +// keyup: force geocoder when enter is pressed +// (change event can be triggered, too; second call to geocoder gets fenced by JSONP) +// (alternative: track changes manually and only permit keyup event, if there was no change) +// do we want this? +keyUp: function(e, marker_id) { + if(e.keyCode==13) + OSRM.RoutingGUI.inputChanged(marker_id); +}, + +// changed: any inputbox (is called when enter is pressed [after] or focus is lost [before]) inputChanged: function(marker_id) { if( marker_id == OSRM.C.SOURCE_LABEL) OSRM.Geocoder.call(OSRM.C.SOURCE_LABEL, document.getElementById('gui-input-source').value);