Select to view content in your preferred language

SourceCountry parameter has no effect in Geocoder

542
1
08-21-2014 06:33 AM
JamesSampica
New Contributor

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?

0 Kudos
1 Reply
JoshHevenor
Occasional Contributor II

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.

0 Kudos