This is probably less a jQuery question, and more about how to request info from GeoNames. I have the following:
$(document).ready(function() {
$( "#city" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
style: "medium",
maxRows: 10,
//country: ["US","FR","DE","GB","IT"],
featureClass: "P",
//featureCode: "PPL",
continentCode: ["NA","SA","EU"],
name_startsWith: request.term
//name_startsWith: function () { return $("#city").val() }
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryCode,
value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryCode,
lat: item.lat,
lng: item.lng
}
}));
}
});
},
//Start Search after user types...
minLength: 2,
close: function() {
//UI plugin not removing loading gif, lets force it
$( '#city' ).removeClass( "ui-autocomplete-loading" );
}
});
});
Currently, when the user types what the prompt within the page suggests (City Name), the field returns a list of cities. However, if the user keeps typing to include their “state” or “country” the suggestion list is removed.
Is there a way with GeoNames to search both “city” and “state”, or “city” and “country”. I’ve dug thru their documentation and don’t see anything.
Just wondering if anyone has had experience using this service and tried to do something similar.
TY!