Geocode and then do identify task - popup

Discussion created by map12 on Apr 14, 2012
Latest reply on Apr 2, 2014 by schlot
I have a project with a simple 'onclick' execute identify task taken/modified from this sample:

What I want to do now is have that same function happen after a user enters in an address using the locator sample:

Do I need to create a separate identify function that works with the geometry of the results from the locator task?

or can a get that execute identify task to fire after the geocode results get added to the map as an event?

// something like this ? ? ?
dojo.connect(map,"geocode results have been added to the map", executeIdentifyTask);
// or would i need to look for the geocode graphic (geo)?

Any help/direction would be appreciated.
My application can be found here:

Full source code is here:

Here's my locator code:
 function locate() {;
        var address = {"SingleLine":dojo.byId("address").value};
        locator.outSpatialReference= map.spatialReference;

      function showResults(candidates) {
        var candidate;
      var symbol = new esri.symbol.SimpleMarkerSymbol();
        var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}");
      //  var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}");
        symbol.setSize (8);
        symbol.setColor(new dojo.Color([153,0,51,0.75]));

        var geom;
          if (candidate.score > 80) {
      var attributes = { address: candidate.address};   
          //  var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name };   
            geom = candidate.location;
            var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate);
            //add a graphic to the map at the geocoded location
            //add a text symbol to the map listing the location of the matched address.
            var displayText = candidate.address;
            var font = new esri.symbol.Font("16pt",esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_NORMAL,esri.symbol.Font.WEIGHT_BOLD,"Helvetica");
            var textSymbol = new esri.symbol.TextSymbol(displayText,font,new dojo.Color("#666633"));
       // esri.Graphic(geom, textSymbol));
            return false; //break out of loop after one candidate with score greater  than 80 is found.
        if(geom !== undefined){