Region Biasing: Region Codes equal to ccTLD or ISO 3166-1?

113 views
Skip to first unread message

24/7

unread,
Dec 15, 2011, 9:54:55 PM12/15/11
to google-map...@googlegroups.com
Hi,

I'm trying to "filter" the search results. In other words: Bind geocoding query results to only one ex. country. 

Q: When I'd make an initial query through ex. Geocoder for a country, would the "result.address_components.{$country}.short_name" hold the required country short code? I'm trying to find out - without having a list of ccTLD names/shorts - if I can first query for a country and, in a 2nd step, query for addresses only in this country.

Thanks!
K.

24/7

unread,
Dec 15, 2011, 10:14:44 PM12/15/11
to google-map...@googlegroups.com
To (not) answer my Q myself: After some tests with _safe_ ccTLD codes, I found no proof that the geocoder really cares about the region. For ccTLD of AT (austria), I go "Ma" I got "Massachusetts, United States.." as answer and similar... Btw: I tried it in combination with viewport biasing (and without: same result).

I really wonder what algorithm (or idea) is behind building the actual response for suggestions. Can't get rid of the feeling that there's just a big encyclopedia that contains _all_ names of every address component in the world and has alphabetic ordering and therefore throws every result back at you that appears to be the first match. When trying "hungary" (country), I get "Buda, Nigeria" before "Budapest, Hungary" (the capitol)...

Rossko

unread,
Dec 16, 2011, 4:44:33 AM12/16/11
to Google Maps JavaScript API v3
It's an address geocoder, it tries to find you an address. It's not
so good at finding countries or capital cities because it's not
purposed for that. You might find that something like Geonames works
better.

24/7

unread,
Dec 18, 2011, 10:06:57 AM12/18/11
to google-map...@googlegroups.com
Geonames doesn't solve the problem. I need lat/lng as result. Even if I'd use the Geonames DB, I'd have to get the rest (route/street, house nr, etc.) from google maps. And the Problem is that the geocoder doesn't deliver all results that would be matching. If that would be the case, I could pre-filter the autocomplete result. I still wonder why geocoder got 'region' and 'bounds' are args for the geocoder, as both don't seem to actually work. I can't see any impact on the results.

Rossko

unread,
Dec 18, 2011, 3:32:16 PM12/18/11
to Google Maps JavaScript API v3
Can you give a clear example of your problem? Clearly "Ma" isn't a
complete address.

> I still wonder why geocoder got
> 'region' and 'bounds' are args for the geocoder, as both don't seem to
> actually work. I can't see any impact on the results.

The documentation does say these should only bias the results ; it
does specifically say it will not exclude results outside of the
expected area. I think it will just promote a result from within the
expected region whem there might be some equally likely looking match
from outside the region. If the "best" match is outside of the
region, it will still be the best match and be the first suggestion.

You'd have to do your own filtering for that, by bounds or by some bit
of text you'd like to see in the result.

24/7

unread,
Dec 19, 2011, 6:55:44 AM12/19/11
to google-map...@googlegroups.com
Can you give a clear example of your problem?  Clearly "Ma" isn't a complete address

It's about incomplete addresses. I'm using a jQuery UI autocomplete powered form that populates a list that shows the suggestions. The user than click-selects what she/he needs.

You'd have to do your own filtering for that, by bounds or by some bit
> of text you'd like to see in the result.

Yeah, but what should I filter if the results contain only stuff that's far out of the bouds and region? If my bounds are for e.g. the borders of hungary and the results only contain "Buda, Nigeria", then I can't filter anything, so I'll have to wait until the result matches. And they start matching with "Budap", which then gives me two results (one has `sublocality` as additional address_component) that are both "Budapest, Hungary". If I try "do", I'll get "Dör, Hungary" as result/suggestion. Even if the bounds are far away from that and the region isn't matching (neither is the input string).

Rossko

unread,
Dec 19, 2011, 3:51:48 PM12/19/11
to Google Maps JavaScript API v3
> Yeah, but what should I filter if the results contain only stuff that's far
> out of the bouds and region? If my bounds are for e.g. the borders of
> hungary and the results only contain "Buda, Nigeria", then I can't filter
> anything

I don't understand this difficulty. If the lat/long for "Buda,
Nigeria" is outside of your region of interest's bounds, you discard
it and don't use it.

You probably won't get "Budapest" as a possible match, since "Buda" is
a much better match. The geocoder is purposed to give you the best
match or matches to whatever user-generated garbage it is fed. It is
not purposed for autocomplete applications because that is something
different (the matching you need would not be for the 'whole thing'
but fof 'starting with'), and it isn't ever going to return the kind
of data you need.

This post might be of interest
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/7198aa6036cbcb91/14406a782853c6b5

It's rather likely to fall foul of the request rate limiting too?

24/7

unread,
Dec 20, 2011, 5:00:45 AM12/20/11
to google-map...@googlegroups.com
First: Thanks for the link. I didn't intend to double post & discuss this issue. Just haven't stumbled upon this before.

It's rather likely to fall foul of the request rate limiting too?

Fair point. I guess I'll take a look at the JQuery plugin you linked and leave it away.

Best wishes and thanks for taking the time to discuss this,
Kaiser.
Reply all
Reply to author
Forward
0 new messages