I\'m using Google\'s Geocoder to find lat lng coordinates for a given address.
var geocoder = new google.maps.Geocoder();
geocoder.geocode(
{
I prefer a hybrid approach.
If that doesn't yield enough results, search more broadly (and re-introduce bias if necessary)
function MyGeocoder(address,region)
{
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address, 'componentRestrictions': { 'country': region } }, function (r, s) {
if (r.length < 10) geocoder.geocode({ 'address': address /* could also bias here */ }, function (r2, s2) {
for (var j = 0; j < r2.length; j++) r.push(r2[j]);
DoSomethingWithResults(r);
});
else DoSomethingWithResults(r);
});
}
function DoSomethingWithResults(r)
{
// Remove Duplicates
var d = {};
r = r.filter(function (e) { var h = e.formatted_address.valueOf(); var isDup = d[h]; d[h] = true; return !isDup; });
// Do something with results
}