AnsweredAssumed Answered

ArcGIS JavaScript API: Zoom to point feature using FindTask

Question asked by Geohab on Oct 1, 2014
Latest reply on Oct 1, 2014 by jskinner-esristaff

Hi All,


I am using the FindTask in my web map (Note: I have point and polygon layers) and it is working fine. When I search using a keyword from the polygon layer it zooms to the polygon and selects the polygon/s using graphics which is what I wanted. However, when I search using a keyword from the point layer, it pans to the center of the selected point/s and doesn't show any graphics. So what I want is, when I search using a point key word, to zoom to the selected point/s and show a circle or square graphics. Below is the code I'm using (Note: I have changed my server name to "myserver:6080").



findTask = new FindTask("http://myserver:6080/arcgis/rest/services/gisdata/webmap/MapServer/");   
      map.on("load", function () {   
          //Create the find parameters   
          findParams = new FindParameters();   
          findParams.returnGeometry = true;   
          findParams.layerIds = [0, 1, 2];   
          findParams.searchFields = ["IDNO", "RESID", "INT", "FTNM"];   
          findParams.outSpatialReference = map.spatialReference;   
          console.log("find sr: ", findParams.outSpatialReference);   
        function doFind() {   
          //Set the search text to the value in the box   
          findParams.searchText = dom.byId("SEARCH").value;   
          findTask.execute(findParams, showResults);   
        function showResults(results) {   
          //This function works with an array of FindResult that the task returns
        var markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1.5), new Color([255, 0, 0, 0.5]));
        var polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 0, 0, 0.5]));

          //create array of attributes   
          var items =, function (result) {   
            var graphic = result.feature;   
            return result.feature;  
          var myFeatureExtent = graphicsUtils.graphicsExtent(items);  
          map.setExtent(myFeatureExtent, true);