mcdade31

Search by Parcel and Address

Discussion created by mcdade31 on Oct 4, 2012
Latest reply on Oct 5, 2012 by JGravois-esristaff
I'd like to duplicate the search feature in the Parks Finder app, where there is a radio button to choose the type of search. I'd like to be able to search by parcel # or address. It looks like the applicable code is spread between a few of the files (utils.js, config, default) so that makes it a little tough for me to decipher how to put it together in one file (still a novice) to make it work. As my app stands now, I have a functional search feature (by address only), so I don't necessarily need to blow that up to create an exact duplicate, but I'm not sure how to go about adding the parcel search to what I have either.

For what its worth, here is the search code in my app currently:
//Create Search Function
   function locate() {
        map.graphics.clear();
        var address = {"SingleLine":dojo.byId("address").value};
        locator.outSpatialReference= map.spatialReference;
        var options = {
          address:address,
          outFields:["Loc_name"]
        }
        locator.addressToLocations(options);
      }

      function showResults(candidates) {
        var candidate;
        var symbol = new esri.symbol.SimpleMarkerSymbol();
        var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}");

        symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_ROUND);
        symbol.setColor(new dojo.Color([153,0,51,0.75]));

        var geom;
        
        dojo.every(candidates,function(candidate){
          console.log(candidate.score);
          if (candidate.score > 80) {
            console.log(candidate.location);
            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
            map.graphics.add(graphic);
    //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("#610B0B"));
            textSymbol.setOffset(0,8);
            map.graphics.add(new esri.Graphic(geom, textSymbol));
            return false; //break out of loop after one candidate with score greater  than 80 is found.
          }
        });
        if(geom !== undefined){
          map.centerAndZoom(geom,15);
        }
      }

Outcomes