seeking samples or documentation on using multiple geocoders and geocoderMenu

661
3
08-14-2013 01:08 PM
PatKeegan
Occasional Contributor
Hi All,

Looking for a sample or documentation on how to configure the geocoder digit to use multiple custom locators.

I am trying to construct my geocoder with multiple geocoding service and allow users to change between them via the geocoderMenu.

I found this very cool working example but it was a bit more complex than i was looking for: https://github.com/Esri/geocoder-search-widget-js

my code (which does not show the geocoderMenu) is something like this

  var geocoder [];
                 var custom1 = {
   url : "some url for a locator",
   name : "Address",
   outFields : "*",
   singleLineFieldName : "Address"
  };
  geocoder.push(custom1)

  var custom2 = {
   url: "some url for a locator",
   name: "Name",
   outFields : "*",   
   singleLineFieldName: "PlaceName"
  };  
  geocoder.push(custom2)


 var geocoder = new esri.dijit.Geocoder({
  map : map,
  geocoders : geocoder,
  autoComplete: true,
  theme : "simpleGeocoder",
  geocoderMenu: true,
  arcgisGeocoder : false
 }, "webmap-toolbar-right");
 geocoder.startup();

0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor
Here's a fiddle showing an example of the geocoder using multiple locators:

http://jsfiddle.net/DC2g2/
0 Kudos
JohnGravois
Frequent Contributor
its probably causing problems that you use the same variable name for your array of locators and the widget itself.

you also need to use an equal sign when instantiating an empty array.

so...
//was
var geocoder []

//should be
var geocoderz = [];
0 Kudos
PatKeegan
Occasional Contributor
Thanks for fiddle, I was using api version 3.5. Upgrade is in order.
0 Kudos