Using this sample...
ArcGIS API for JavaScript Sandbox
change the geocoder as follows...
geocoder = new Geocoder({
autoComplete: true,
map: map ,
arcgisGeocoder: {
sourceCountry: "USA"
}
}, "search");
typing anything into the geocoder still causes it to match addresses from other countries.
Is there a workaround for this?
This has kind of worked for me (taken from an older forum post by Joanne McGraw that I can't find):
var geocoders = [{
url: "some/geocoder",
name: "EC Geocoder",
singleLineFieldName: "SingleLine",
suffix: ", CA" // Canada <-------------------------
}];
var geocoder = new Geocoder({
map: map,
geocoders: geocoders,
arcgisGeocoder: false,
autoComplete: true
}, dojo.create('div'));
I've also have tried keeping a polygon of the country of origin handy, and filtering the Geocoder results using Polygon.contains(point) for a client-side check.