autocomplete GeoNames

Questionsautocomplete GeoNames
Cristi Gradinaru asked 11 years ago

Hi,

Is it possible to implement autocomplete feature using GeoNames database in edit / add form?

Actually, GeoNames provides a function that will perform the autocomplete using the id of an inputbox.

$(function()
{
function log( message )
{
}
$( "#city" ).autocomplete(
{
source: function( request, response )
{
$.ajax(
{
//url: "http://api.geonames.org/searchJSON",
url: "http://api.geonames.org/searchJSON?&username=yourusername&q=",
dataType: "jsonp",
data:
{
featureClass: "P",
style: "FULL",
maxRows: 12,
name_startsWith: request.term
},
success: function( data )
{
response( $.map( data.geonames, function( item )
{
return {label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,value: item.countryname}
}
)
);
}
}
);
},
}
);
}
);

#city is the id of the inputbox where the autocomplete is implemented

3 Answers
Abu Ghufran answered 11 years ago

This is doable and i just tested it now.

<script src="http://tompi.github.io/jeoquery/jeoquery.js&quot; type="text/javascript"></script>

Simple include above lib .. and use dataInit property.

$col = array();
$col["title"] = "Name";
$col["name"] = "name";
$col["editable"] = true;
$col["width"] = "40";
$col["editoptions"]["dataInit"] = "function(o){ jQuery(o).jeoCityAutoComplete(); }";
$cols[] = $col;

Cristi Gradinaru answered 11 years ago

Hi,

Thanks for your answer, but this is not working for me. It only inhibits the edit option and nothing more… After including the above lib and using dataInit property like in your example the edit is no longer working (the edit form is not showing up).

Is it because I'm using the free version of phpgrid?

Abu Ghufran answered 11 years ago

Yes, this could be the reason. I've verified it on full version.

Your Answer

8 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?