I have been searching through the forums and haven't been able to find anything that has helped me with my dilema.
I am attempting to make an autocomplete menu for city names/airport codes that duplicated the functionality of the autocomplete on this form http://laosparadisetravel.turbott.com/IndexVT.aspx I am using the jQeury UI autocomplete widget and started with a duplicate of their query of geonames. The test page I am working on is at http://laosparadisetravel.com/test/test4.php and the code is:
Code:
$(function() {
$( "#gsorigin" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
featureClass: "P",
//fcode: "AIRP",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.alternateName ? ", " + item.alternateName : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2,
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
});
If I use featureClass P the results are way to broad, including non-airport related locations. If I use use S and fcode AIRP I don't get city names. I know I don't know the full structure of the geonames data so I expect I am missing data somewhere. Any suggestions on how to get both city names AND airport codes?
Also, I understand from reading the forum that the free web service is strained. An autocomplete ajax function is going to call the web service several times per form submission so I expect it would be best if I just downloaded the data and ran it off our servers. Is there a way to just download the relevant city/airport data without having to get the whole geonames db?