From 204189c3262675e7fbb0690aec92d9d65bfb6929 Mon Sep 17 00:00:00 2001 From: DennisSchiefer Date: Fri, 16 Mar 2012 15:06:43 +0100 Subject: [PATCH] - version bump to v0.1.1 - restructured buttons (route is gone, search is show) - added prefetching gui hide/show buttons - increased timeout to 5000ms - click highlight marker to hide it - boundary box on Europe when querying geocoder - added "reached your destination" display in route instructions - improved visual for route summary - when loading a stored route, source and target are named and the route is zoomed correctly - improved display results of reverse geocoder (ues village/country tags) - more consistent behaviour when displaying reverse geocoder results or geocoordinates - reverse geocoder now works at dragend - more consistent behaviour when leaving an input box - reversing a route when only one marker is set empties the result box --- WebContent/OSRM.Localization.js | 12 ++++---- WebContent/OSRM.Markers.js | 11 +++++++ WebContent/OSRM.base.js | 2 +- WebContent/OSRM.config.js | 2 +- WebContent/geocoder.js | 32 +++++++++++++------- WebContent/images/markers.pdf | Bin 10861 -> 11596 bytes WebContent/images/target.png | Bin 0 -> 721 bytes WebContent/main.html | 13 +++----- WebContent/main.js | 45 +++++++++++++--------------- WebContent/routing.js | 51 +++++++++++++------------------- 10 files changed, 84 insertions(+), 84 deletions(-) create mode 100644 WebContent/images/target.png diff --git a/WebContent/OSRM.Localization.js b/WebContent/OSRM.Localization.js index 1fa979c9c..52cb267be 100644 --- a/WebContent/OSRM.Localization.js +++ b/WebContent/OSRM.Localization.js @@ -42,14 +42,13 @@ OSRM.Localization["de"] = { "GUI_START": "Start", "GUI_END": "Ziel", "GUI_RESET": "Reset", -"GUI_SEARCH": "Suchen", -"GUI_ROUTE": "Route", +"GUI_SEARCH": "Zeigen", "GUI_REVERSE": "Umdrehen", "GUI_OPTIONS": "Optionen", "GUI_HIGHLIGHT_UNNAMED_ROADS": "Unbenannte Straßen hervorheben", "GUI_START_TOOLTIP": "Startposition eingeben", "GUI_END_TOOLTIP": "Zielposition eingeben", -"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by KIT - Geocoder by OSM", +"GUI_LEGAL_NOTICE": "GUI2 v0.1.1 120316 - OSRM hosting by KIT - Geocoder by OSM", // geocoder "SEARCH_RESULTS": "Suchergebnisse", "TIMED_OUT": "Zeitüberschreitung", @@ -82,15 +81,14 @@ OSRM.Localization["en"] = { //gui "GUI_START": "Start", "GUI_END": "End", -"GUI_RESET": "Reset", -"GUI_SEARCH": "Search", -"GUI_ROUTE": "Route", +"GUI_RESET": "  Reset  ", +"GUI_SEARCH": "  Show  ", "GUI_REVERSE": "Reverse", "GUI_OPTIONS": "Options", "GUI_HIGHLIGHT_UNNAMED_ROADS": "Highlight unnamed streets", "GUI_START_TOOLTIP": "Enter start", "GUI_END_TOOLTIP": "Enter destination", -"GUI_LEGAL_NOTICE": "GUI2 v0.1 120313 - OSRM hosting by KIT - Geocoder by OSM", +"GUI_LEGAL_NOTICE": "GUI2 v0.1.1 120316 - OSRM hosting by KIT - Geocoder by OSM", // geocoder "SEARCH_RESULTS": "Search Results", "TIMED_OUT": "Timed Out", diff --git a/WebContent/OSRM.Markers.js b/WebContent/OSRM.Markers.js index 8cca3c3d5..a4c42d8ed 100644 --- a/WebContent/OSRM.Markers.js +++ b/WebContent/OSRM.Markers.js @@ -75,11 +75,16 @@ toString: function() { OSRM.HighlightMarker = function( label, style, position) { OSRM.HighlightMarker.prototype.base.constructor.apply( this, arguments ); this.label = label ? label : "highlight_marker"; + + this.marker.on( 'click', this.onClick ); }; OSRM.inheritFrom( OSRM.HighlightMarker, OSRM.Marker ); OSRM.extend( OSRM.HighlightMarker, { toString: function() { return "OSRM.HighlightMarker: \""+this.label+"\", "+this.position+")"; +}, +onClick: function(e) { + this.parent.hide(); } }); @@ -143,6 +148,12 @@ onDragEnd: function(e) { OSRM.dragging = false; updateLocation( this.parent.label ); + if(my_route.isShown()==false) { + if(this.parent.label == "source") + updateReverseGeocoder("source"); + else if(this.parent.label == "target") + updateReverseGeocoder("target"); + } }, toString: function() { return "OSRM.RouteMarker: \""+this.label+"\", "+this.position+")"; diff --git a/WebContent/OSRM.base.js b/WebContent/OSRM.base.js index 61ed2caf3..35f2cd60d 100644 --- a/WebContent/OSRM.base.js +++ b/WebContent/OSRM.base.js @@ -19,7 +19,7 @@ or see http://www.gnu.org/licenses/agpl.txt. // [has to loaded before all other OSRM classes] OSRM = {}; -OSRM.VERSION = '0.1'; +OSRM.VERSION = '0.1.1'; // inheritance helper function (convenience function) diff --git a/WebContent/OSRM.config.js b/WebContent/OSRM.config.js index e6ca44af3..4c3adc09b 100644 --- a/WebContent/OSRM.config.js +++ b/WebContent/OSRM.config.js @@ -22,7 +22,7 @@ OSRM.DEFAULTS = { HOST_ROUTING_URL: 'http://router.project-osrm.org/viaroute', HOST_SHORTENER_URL: 'http://map.project-osrm.org/shorten/', WEBSITE_URL: document.URL.replace(/#*\?.*/i,""), - JSONP_TIMEOUT: 2000, + JSONP_TIMEOUT: 5000, ZOOM_LEVEL: 14, ONLOAD_LATITUDE: 48.84, ONLOAD_LONGITUDE: 10.10, diff --git a/WebContent/geocoder.js b/WebContent/geocoder.js index 47fdd7242..a145524dd 100644 --- a/WebContent/geocoder.js +++ b/WebContent/geocoder.js @@ -20,7 +20,7 @@ or see http://www.gnu.org/licenses/agpl.txt. // [TODO: better separation of GUI and geocoding routines, reverse geocoding] // some constants -OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json'; +OSRM.GEOCODE_POST = 'http://nominatim.openstreetmap.org/search?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0'; OSRM.SOURCE_MARKER_LABEL = "source"; OSRM.TARGET_MARKER_LABEL = "target"; @@ -40,7 +40,9 @@ function callGeocoder(marker_id, query) { if (marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0] && my_markers.route[0].label == OSRM.SOURCE_MARKER_LABEL && my_markers.route[0].dirty_move == false && my_markers.route[0].dirty_type == false) return; if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1] && my_markers.route[my_markers.route.length-1].label == OSRM.TARGET_MARKER_LABEL && my_markers.route[my_markers.route.length-1].dirty_move == false && my_markers.route[my_markers.route.length-1].dirty_type == false) - return; + return; + if(query=="") + return; //geo coordinates given -> go directly to drawing results if(query.match(/^\s*[-+]?[0-9]*\.?[0-9]+\s*[,;]\s*[-+]?[0-9]*\.?[0-9]+\s*$/)){ @@ -137,15 +139,15 @@ function showGeocoderResults_Timeout() { // - [upcoming feature: reverse geocoding (untested) ] - -OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json'; +OSRM.REVERSE_GEOCODE_POST = 'http://nominatim.openstreetmap.org/reverse?format=json&bounded=1&viewbox=-27.0,72.0,46.0,36.0'; //update reverse geocoder informatiopn in input boxes function updateReverseGeocoder(marker_id) { - if (marker_id == OSRM.SOURCE_MARKER_LABEL ) { //&& my_markers.route[0].dirty == true ) { - document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6); + if (marker_id == OSRM.SOURCE_MARKER_LABEL && my_markers.hasSource()==true) { //&& my_markers.route[0].dirty == true ) { + //document.getElementById("input-source-name").value = my_markers.route[0].getPosition().lat.toFixed(6) + ", " + my_markers.route[0].getPosition().lng.toFixed(6); callReverseGeocoder("source", my_markers.route[0].getPosition().lat, my_markers.route[0].getPosition().lng); - } else if (marker_id == OSRM.TARGET_MARKER_LABEL ) { //&& my_markers.route[my_markers.route.length-1].dirty == true) { - document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6); + } else if (marker_id == OSRM.TARGET_MARKER_LABEL && my_markers.hasTarget()==true) { //&& my_markers.route[my_markers.route.length-1].dirty == true) { + //document.getElementById("input-target-name").value = my_markers.route[my_markers.route.length-1].getPosition().lat.toFixed(6) + ", " + my_markers.route[my_markers.route.length-1].getPosition().lng.toFixed(6); callReverseGeocoder("target", my_markers.route[my_markers.route.length-1].getPosition().lat, my_markers.route[my_markers.route.length-1].getPosition().lng); } } @@ -175,20 +177,28 @@ function showReverseGeocoderResults(marker_id, response) { var address = ""; if( response.address.road) address += response.address.road; - if( response.address.city) { - if( response.address.road) + if( response.address.city ) { + if( address != "" ) address += ", "; address += response.address.city; + } else if( response.address.village ) { + if( address != "" ) + address += ", "; + address += response.address.village; } + if( address == "" && response.address.country ) + address += response.address.country; if( address == "" ) return; if(marker_id == OSRM.SOURCE_MARKER_LABEL) { document.getElementById("input-source-name").value = address; - //my_markers.route[0].dirty = false; + my_markers.route[0].dirty_move = false; + my_markers.route[0].dirty_type = false; } else if(marker_id == OSRM.TARGET_MARKER_LABEL) { document.getElementById("input-target-name").value = address; - //my_markers.route[my_markers.route.length-1].dirty = false; + my_markers.route[my_markers.route.length-1].dirty_move = false; + my_markers.route[my_markers.route.length-1].dirty_type = false; } } diff --git a/WebContent/images/markers.pdf b/WebContent/images/markers.pdf index 94c2def87ab7c28412c280b0f22f58e850a85dc7..4cf60451a93852234158ec1a77f77060c5005cd4 100644 GIT binary patch delta 2445 zcmZWrX*d)L7j8_lBnD$=OkF!Mn=u(9WXY0!5QdOF46+-OvLtFS7-Pwr?1WG^OWCts zEyRpOlr3wcuaNK7ulwA4ex3K6_nhY}KhF7LJL1@AAq7OBHKbEw=+Dh`i37a8!3$gcXGJF@^dlQ+mHKg?p7^Fd8*+VHYkzRuB?8J@3qdS>t-vH~ z8^&-%`0Tegwy7j1O|(iX7_Rk(Zf=L{fOnWD@5mhAKT*EFk30FIV`6{i5Lgj??>&`Y zQn2~Cln8(gp+Ut-B~UNR^H8;TgnmJOE*5nf0s&$WsNZ8-avTr+Ck6i zk1Y&MUopeZj;&WsRdDp>1YEj0q&#HIEZhs)1j>lXfU#ZS)Qvtqh%|*V@Db2@zJhUl zR?ah9_4Z08iZ$CcF@TaK?0QmYE5A2Snk%N2*@x;ryHz zpZ{`)-+5!w_izD)4vq@dwiu4eDZuLh-+C6<50guoz3M8CVQ~B%vnkCS;N~%YHT_I8 zWx>B14SU2#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yd@t-M0 zl{$J8vwKcI`uFm`&!^W4Qx*g?1vEKve)|3H!-@T&v(6orsPH==_rUYb#D7V3OqZQ= WzR%lcGXa?P7(8A5T-G@yGywoR`a*jE literal 0 HcmV?d00001 diff --git a/WebContent/main.html b/WebContent/main.html index c18c49644..412766365 100644 --- a/WebContent/main.html +++ b/WebContent/main.html @@ -89,17 +89,13 @@ or see http://www.gnu.org/licenses/agpl.txt. Start: - - - Suchen + Zeigen Ende: - - - Suchen + Zeigen @@ -108,8 +104,7 @@ or see http://www.gnu.org/licenses/agpl.txt. - - +
Reset Reverse Route Umdrehen
@@ -125,7 +120,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
- +
diff --git a/WebContent/main.js b/WebContent/main.js index d4d97836d..b5bd0fbdb 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -41,9 +41,15 @@ function prefetchImages() { var images = [ 'images/marker-source.png', 'images/marker-target.png', 'images/marker-via.png', - 'images/marker-highlight.png' + 'images/marker-highlight.png', + 'images/cancel.png', + 'images/cancel_active.png', + 'images/cancel_hover.png', + 'images/restore.png', + 'images/restore_active.png', + 'images/restore_hover.png' ]; - + for(var i=0; i 0) - my_markers.setSource( positions[0] ); - if(positions.length > 1) - my_markers.setTarget( positions[positions.length-1] ); + if( positions.length > 0) { + onclickGeocoderResult("source", positions[0].lat, positions[0].lng, true, false ); + //my_markers.setSource( positions[0] ); + } + if(positions.length > 1) { + onclickGeocoderResult("target", positions[positions.length-1].lat, positions[positions.length-1].lng, true, false ); + //my_markers.setTarget( positions[positions.length-1] ); + } for(var i=1; i'; route_desc += ""; @@ -200,7 +201,7 @@ function showRouteDescriptionSimple(response) { headline = OSRM.loc("ROUTE_DESCRIPTION")+":
"; headline += "" + OSRM.loc("DISTANCE")+": " + getDistanceWithUnit(response.route_summary.total_distance) - + " - " + + "
" + OSRM.loc("DURATION")+": " + secondsToTime(response.route_summary.total_time) + "
"; headline += '

'; @@ -212,7 +213,7 @@ function showNoRouteDescription() { headline = OSRM.loc("ROUTE_DESCRIPTION")+":
"; headline += "" + OSRM.loc("DISTANCE")+": N/A" - + " - " + + "
" + OSRM.loc("DURATION")+": N/A" + "
"; headline += '

'; @@ -374,8 +375,13 @@ function snapRoute() { for(var i=0; i