Is there any default search area?

22 views
Skip to first unread message

Alvin

unread,
Aug 3, 2011, 4:05:10 AM8/3/11
to google-map...@googlegroups.com
Hello,
I'm using the Google API but I got a strange result.
 
I just wanted to search '114 Baker Street' in Australia but my result got only one street record in USA.
So I searched again with '114 Baker Street, Australia' and got a good result I want.
 
I've tested with http://map.google.com.au and search '114 Baker St' and got a good record and marker is shown in Australia.
 
I'd like to search the location first in Australia. How can I do this?
 
Following is the code I'm using to initialize the map:
geocoder = new google.maps.Geocoder();
     var latlng = new google.maps.LatLng(Somewhere in Australia);
     var myOptions = {
            zoom: 12,
            center: latlng,
            disableDoubleClickZoom:true,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
 
Any hint would be very appreciated.
Thanks.
 
 

Esa

unread,
Aug 3, 2011, 5:54:10 AM8/3/11
to Google Maps JavaScript API v3
Adding the country name to the search string is the most powerful way
to bias geocoding. Country code will do as well.

Usually a single line will do it. Something like:

search += " au";

in a suitable position in your code.

Esa

unread,
Aug 3, 2011, 6:01:05 AM8/3/11
to Google Maps JavaScript API v3
There is also the documented Region Code Biasing
http://code.google.com/apis/maps/documentation/javascript/services.html#GeocodingRegionCodes
which brings the biased results first.

"Note that biasing only prefers results for a specific domain; if more
relevant results exist outside of this domain, they may be included."

If you include the country name to the search string, it is very
unlikely that results from other countries would be returned.

Alvin

unread,
Aug 3, 2011, 8:04:15 PM8/3/11
to google-map...@googlegroups.com
Thank you very much.
have a good day.
Reply all
Reply to author
Forward
0 new messages