venugopal24 / geo-autocomplete

Automatically exported from code.google.com/p/geo-autocomplete
0 stars 0 forks source link

How do I filter geo-autocomplete to show only my country? #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using geo-autocomplete javascript plugin and want to filter the
autocomplete to show only one country.

Original issue reported on code.google.com by rbeaur...@gmail.com on 12 Feb 2010 at 7:24

GoogleCodeExporter commented 8 years ago
easy!

open up jquery.autocomplete_geomod.js

change line 355 from:

var _query = lastWord(term);

to:

var _query = lastWord(term) + 'Australia';

Let me know how you go ;)

Adski.

Original comment by adamkirk...@gmail.com on 19 Feb 2010 at 8:51

GoogleCodeExporter commented 8 years ago
Thanks! It works nicely, is there a way to filter out street names and only 
search
suburbs etc. ?

Original comment by rbeaur...@gmail.com on 19 Feb 2010 at 9:57

GoogleCodeExporter commented 8 years ago
i am sure there is a way..just have not figured it out yet :(

if you change line 52 of geo_autocomplete.js from:

return '<img src="' + _src + '" width="' + options.mapwidth + '" height="' +
options.mapheight + '" /> ' + _place + '<br clear="both"/>';

to:

return '<img src="' + _src + '" width="' + options.mapwidth + '" height="' +
options.mapheight + '" /> ' + _data.types + ': ' + _place +
_data.geometry.viewport.getCenter().toUrlValue()  + '<br clear="both"/>';

it will show the data type & the lat/long of the location you are searching for.

see: http://code.google.com/apis/maps/documentation/v3/services.html#Types

and: 
http://code.google.com/apis/maps/documentation/v3/services.html#GeocodingRespons
es

if you work out how please post the solution for everyone else :)

Original comment by adamkirk...@gmail.com on 19 Feb 2010 at 11:12

GoogleCodeExporter commented 8 years ago
yes you need to check in the types array and exclude any "route".  try changing 
line
29 from

if (_result.geometry && _result.geometry.viewport) {

to

if ($.inArray("route", _result.types) == -1 && _result.geometry &&
_result.geometry.viewport) {

let me know how you go -

cheers, bob

Original comment by hitch...@gmail.com on 19 Feb 2010 at 11:35

GoogleCodeExporter commented 8 years ago
thanks bob.. you have created a very nice autocomplete.

I will try this now & let you know how I go.

Adski.

Original comment by adamkirk...@gmail.com on 19 Feb 2010 at 11:51

GoogleCodeExporter commented 8 years ago
I modified line 356 instead from

options.geocoder.geocode({'address': _query},...

and replaced it with this

options.geocoder.geocode({
                'address': _query,
                'region': 'CA'
                },
This will restrict the handling to the Canadian region. "CA" was picked up from 
the region Database at this link:

http://www.iana.org/assignments/language-subtag-registry

Original comment by pierrebe...@gmail.com on 3 Sep 2010 at 6:58

GoogleCodeExporter commented 8 years ago
I still cannot work out how to only show only results found in Australia. I 
have tried both bob's & pierre's code without success. Any ideas?

Original comment by adamkirk...@gmail.com on 5 Sep 2010 at 1:33

GoogleCodeExporter commented 8 years ago
@adam the plugin gets results using the Google Geocoding Service as documented 
here;

http://code.google.com/apis/maps/documentation/javascript/services.html#Geocodin
gRequests

...so Pierre's solution is a good one.  did you try the region code 'AU' for 
Australia?

Original comment by hitch...@gmail.com on 5 Sep 2010 at 9:19

GoogleCodeExporter commented 8 years ago
@bob, yes I tried using 'AU' in Pierre's mod but still have no luck :(

SEE: http://www.agedcarefinder.com.au/AgedCareJobFinder.aspx

if you search for "rosebud" you get results from all around the world

Original comment by adamkirk...@gmail.com on 7 Sep 2010 at 11:47

GoogleCodeExporter commented 8 years ago
I was able to limit the results to the us by making line 356 in geomod: 
options.geocoder.geocode({'address': _query + ", US"}, function(_results, 
_status) {

You have to add the country to the address part since the geocoder uses the 
address parameter 'OR' the region and other parameters.

Also, you can limit it to just cities by changing line 29 in geo_ to:
if ($.inArray("locality", _result.types) >=0  && _result.geometry && 
_result.geometry.viewport) {

Original comment by randy.ra...@gmail.com on 25 Sep 2010 at 2:10

GoogleCodeExporter commented 8 years ago
I changed line 356 in the geomod to read my other forms with data of zip, 
state, city, and of always limits to the USA:

var zip = document.getElementById('contZip'); 
var state = document.getElementById('contState'); 
var city = document.getElementById('contCity'); 
var extra_query = ", " + city.value + ", " + state.value + " " + zip.value + ", 
USA";

options.geocoder.geocode({'address': _query + extra_query}, function(_results, 
_status) { 

Original comment by Jonathan...@gmail.com on 5 Nov 2010 at 7:35

GoogleCodeExporter commented 8 years ago
marking as Done because v2.1 supports this option now.  any more feature 
requests; keep 'em coming.

Original comment by hitch...@gmail.com on 21 Nov 2010 at 12:17

GoogleCodeExporter commented 8 years ago
is it possible to order results be country, province?
I have filtered results to two countries.

thanks.

Original comment by wwwdev....@gmail.com on 18 Aug 2011 at 4:00