select feature based on geocoder results problem

Discussion created by bagpipemike on Apr 24, 2014
Latest reply on Jul 30, 2014 by bagpipemike

I'm trying to take the geometry of a geocoder search result and use that as the input geometry to query against a feature layer. If the geometry returned by the geocoder search result intersects a polygon in the feature layer, then a popup appears to display some of the attributes of the layer.

This works fine for one-off address searches. It also works fine if I search for a new address after finding the first address and the new address is in a different polygon in the feature layer to the previous polygon that was selected in the first address search. However in the scenario where the first search is completed and a second address is searched and that second address intersects the same polygon as was selected by the first search, I'm having some problems.

In this scenario the map first starts to recentre on the second address but then quickly zooms back to the location of the first address. In the console the following error messages appear:

"exception in animation handler for: onAnimate

TypeError: d is undefined
.cache["esri/dijit/Popup"]/</e<._onPan()/3.8compact/ (line 543)
.cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 173)
.cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238)
.cache["esri/_coremap"]/</p<._panningHandler()/3.8compact/ (line 828)
.cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 173)
.cache["dojo/aspect"]/</n/</h.around.advice()/3.8compact/ (line 238)
.cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238)
.cache["dojo/_base/fx"]/</<._fire()/3.8compact/ (line 44)
.cache["dojo/_base/fx"]/</<._cycle()/3.8compact/ (line 48)
.cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 172)
.cache["dojo/aspect"]/</n/</h()/3.8compact/ (line 238)
.cache["dojo/_base/lang"]/</g.hitch/<()/3.8compact/ (line 172)

Reload the page to get source for:"

These error messages appear 4 times in a row.

Here is my code:

     function startGeocoder() {
      geocoder = new Geocoder({
       map : map,
       arcgisGeocoder : {
        placeholder : "Address search",
        sourceCountry : "GBR"
      }, "search");
      geocoder.autoComplete = true;
      geocoder.on("select", queryLayer);      
     function queryLayer(evt){
      var point = evt.result.feature.geometry;

      var query = Query();
      query.geometry = point;
      selectTariffLayer.selectFeatures(query, selectTariffLayer.SELECTION_NEW, function(results){
       var charge = results[0].attributes["Charge"];
       var price = results[0].attributes["Cost"];

                popup.setTitle("Parking tariffs");
                popup.setContent(charge + "<br/>" + price); 


Any suggestions where I'm going wrong?