Geocoder Bug????

2650
5
10-13-2015 02:21 PM
by Anonymous User
Not applicable

so given the code snippet below, here's the behavior: When I "pick", with the mouse, the address offered by the autoComplete, the function "showResults" does not fire. However when I enter the same exact address and press Enter, the showResults function does fire. And.....after selecting a second address via pressing Enter, the following error message appears on the console: "Geocoder:: stop query" but after successfully finding and zooming to the address. This one has me baffled and it may just be code drunkedness. Thanks in advance, rGibson

<script src="http://js.arcgis.com/3.14/"></script>

    <script>

      var map;

      var geocoder;

      var locatorUrl = "http://gisapps.fortsmithar.gov/arcgis/rest/services/Locators/GISCREATOR_AddressPoints_CreateAddressL...";

      require([

        "esri/map", "esri/dijit/Geocoder", "dojo/domReady!"

      ], function(

        Map, Geocoder

      ) {

        map = new Map("map",{

          basemap: "topo",

          center: [-117.19,34.05], // lon, lat

          zoom: 13

        });

       

        var myGeocoders = [{

          url: locatorUrl,

          name: "myAddress",

   ////////very important when using custom geocoders

   singleLine: "Street"

   ////////

        }];

        geocoder = new Geocoder({

          map: map,

          autoComplete: true,

          arcgisGeocoder: false,

          geocoders: myGeocoders, 

          value: "8813 Meadow Dr"

        },"search");

        geocoder.startup();

        geocoder.on("find-results", showResults);

  function showResults(results) {

  var geom;               

            geom = results.results.results[0].feature.geometry; 

  alert(geom);           

  }   

      });

    </script>

0 Kudos
5 Replies
TracySchloss
Frequent Contributor

Does hitting 'Enter' on the suggested address instead of a mouse click work?  I have seen other circumstances where Enter worked, but a map click didn't.  It's not a solution, but it might be the difference between why one is working and the other isn't. 

0 Kudos
by Anonymous User
Not applicable

Yes, hitting Enter and clicking on the suggested address both find the correct location and address

Sent via the Samsung Galaxy Note® 4, an AT&T 4G LTE smartphone

0 Kudos
TracySchloss
Frequent Contributor

It looks like you have another thread that is the answer.  You should use the Search widget, since Geocoder is being deprecated and the appropriate event listener for it, as opposed to Geocoder events.

MichaelVolz
Esteemed Contributor

Tracy:

Can you show the link where it says that Geocoder is being deprecated?

0 Kudos
TracySchloss
Frequent Contributor

The is in the Geocoder API help:

"Starting with version 3.13, the Search Widget supersedes the Geocoder Widget and is deprecated."

Geocoder | API Reference | ArcGIS API for JavaScript

ESRI could have been a little clearer on how they phrased it. 

It's also mentioned in the What's New for version 3.13.

"The Search Widget supersedes the Geocoder Widget (now deprecated). It's been reimagined, renamed and redesigned to provide a single searching and suggestion experience. It allows you to search across multiple Locator and Feature Layer services from a simple interface."

Hopefully my older applications will continue to work, but for the new ones I'm developing, I swapped out Geocoder for Search,  just using the parameters for geocoding.  It looks very similar, the main issue I had was I needed to adjust the CSS, since the Search is slightly longer.

0 Kudos