diff --git a/WebContent/base/OSRM.Geocoder.js b/WebContent/base/OSRM.Geocoder.js index 45c2659c5..183c0b5ce 100644 --- a/WebContent/base/OSRM.Geocoder.js +++ b/WebContent/base/OSRM.Geocoder.js @@ -43,7 +43,7 @@ call: function(marker_id, query) { } // build basic request for geocoder - var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json&json_callback=%jsonp" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&q=" + query; + var call = OSRM.DEFAULTS.HOST_GEOCODER_URL + "?format=json&json_callback=%jsonp" + OSRM.DEFAULTS.GEOCODER_BOUNDS + "&accept-language="+OSRM.Localization.current_language+"&limit=30&q=" + query; // prioritize results in currently shown mapview var bounds = OSRM.G.map.getBounds(); call += "&viewbox=" + bounds._southWest.lat + "," + bounds._northEast.lng + "," + bounds._northEast.lat + "," + bounds._southWest.lng; @@ -80,27 +80,42 @@ _showResults: function(response, parameters) { return; } + // filter/sort inputs + var filtered_response = []; + for(var i=0; i < response.length; i++){ + var result = response[i]; + if( OSRM.Geocoder._filterResult( result ) ) + continue; + filtered_response.push( result ); + } + filtered_response.sort( OSRM.Geocoder._compareResults ); + // show first result - OSRM.Geocoder._onclickResult(parameters.marker_id, response[0].lat, response[0].lon); + OSRM.Geocoder._onclickResult(parameters.marker_id, filtered_response[0].lat, filtered_response[0].lon); if( OSRM.G.markers.route.length > 1 ) // if a route is displayed, we don't need to show other possible geocoding results - return; + return; // show possible results for input var html = ""; html += '
| '+(i+1)+'. | '; + if(!result.icon) + result.icon = "http://nominatim.openstreetmap.org/images/mapicons/poi_point_of_interest.glow.12.png"; + html += '';
if(result.display_name){
- html += ' '+result.display_name+' ';
+ html += ''+result.display_name;
+ // debug output to show osm_type, class, type
+ // html += ' ';
}
html += "[osm_type: ' + result.osm_type + ', class: ' + result.class + ', type: ' + result.type + ']'; + html += ' |