Select to view content in your preferred language

Problem Find task

1353
8
06-21-2012 07:08 PM
DaiDai1
Deactivated User
Im Problem findtask need help:
do not show results it is empty
DataMAp: http://www.mediafire.com/download.php?qyg3b97pzpngcqb


Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Find</title>
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/1.6/arcgis/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://localhost/arcgis_js_api/library/1.6/arcgis/"></script>
    <script type="text/javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.find");

      var find, params;
      function init() {
        find = new esri.tasks.FindTask("http://localhost/ArcGIS/rest/services/gisDuLich/DuLich/MapServer");
        params = new esri.tasks.FindParameters();
        params.contains=true;
        params.returnGeometry=true;
        params.layerIds = [0,1,2,3,4,5,6,7,8];
     
        params.searchFields = ['maDoiTuong','danhTuChung','diaDanh','diaChi','doiTuong','maNhanDang','ngayThuNhan','ngayCapNhat','maDoiTuong','maDonViHanhChinh','danhTuChung','diaDanh','dienTich','nhandang','ten'];
      }

      function doFind() {
        params.searchText = dojo.byId("searchText1").value;
        find.execute(params, showResults);
      }

      function showResults(results) {
      alert("Don't shows results "+results);
        var result, attribs;
        var s = ["<table border=\"1\"><thead><tr style=\"background-color:#ccc;\"><td>OBJECTID</td><td>Dia Danh</td></tr></thead><tbody id=\"states\">"];
        dojo.forEach(results,function(result){
          attribs = result.feature.attributes;
          alert(result.feature.attributes);
          for (j in result.feature.attributes) {
          alert(j);
            if (j.toUpperCase() != "OBJECTID" && j.toUpperCase() != "SHAPE")
                if (result.feature.attributes.toUpperCase() != "NULL")               
                s.push("<tr><td>" + j + "</td><td>" + result.feature.attributes+ "</td></tr>");
        }
          
        });
        s.push("</tbody></table>");
        dojo.byId("tbl").innerHTML = s.join("");
      }

      dojo.addOnLoad(init);
    </script>

  </head>
  <body class="claro">
    Dia Danh: <input type="text" id="searchText1" size="40" value="Trường" />
    <input type="button" value="Find" onclick="doFind()" />

    <div id="tbl"></div>

  </body>
</html>
0 Kudos
8 Replies
DaiDai1
Deactivated User
Im Problem findtask need help:
do not show results it is empty
DataMAp: http://www.mediafire.com/download.php?qyg3b97pzpngcqb


Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Find</title>
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/1.6/arcgis/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://localhost/arcgis_js_api/library/1.6/arcgis/"></script>
    <script type="text/javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.find");

      var find, params;
      function init() {
        find = new esri.tasks.FindTask("http://localhost/ArcGIS/rest/services/gisDuLich/DuLich/MapServer");
        params = new esri.tasks.FindParameters();
        params.contains=true;
        params.returnGeometry=true;
        params.layerIds = [0,1,2,3,4,5,6,7,8];
     
        params.searchFields = ['maDoiTuong','danhTuChung','diaDanh','diaChi','doiTuong','maNhanDang','ngayThuNhan','ngayCapNhat','maDoiTuong','maDonViHanhChinh','danhTuChung','diaDanh','dienTich','nhandang','ten'];
      }

      function doFind() {
        params.searchText = dojo.byId("searchText1").value;
        find.execute(params, showResults);
      }

      function showResults(results) {
      alert("Don't shows results "+results);
        var result, attribs;
        var s = ["<table border=\"1\"><thead><tr style=\"background-color:#ccc;\"><td>OBJECTID</td><td>Dia Danh</td></tr></thead><tbody id=\"states\">"];
        dojo.forEach(results,function(result){
          attribs = result.feature.attributes;
          alert(result.feature.attributes);
          for (j in result.feature.attributes) {
          alert(j);
            if (j.toUpperCase() != "OBJECTID" && j.toUpperCase() != "SHAPE")
                if (result.feature.attributes.toUpperCase() != "NULL")               
                s.push("<tr><td>" + j + "</td><td>" + result.feature.attributes+ "</td></tr>");
        }
          
        });
        s.push("</tbody></table>");
        dojo.byId("tbl").innerHTML = s.join("");
      }

      dojo.addOnLoad(init);
    </script>

  </head>
  <body class="claro">
    Dia Danh: <input type="text" id="searchText1" size="40" value="Trường" />
    <input type="button" value="Find" onclick="doFind()" />

    <div id="tbl"></div>

  </body>
</html>


Newbie please help!
Thanks
0 Kudos
DaiDai1
Deactivated User
Im Problem findtask need help:
do not show results it is empty
DataMAp: http://www.mediafire.com/download.php?qyg3b97pzpngcqb


Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Find</title>
    <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/1.6/arcgis/js/dojo/dijit/themes/claro/claro.css">
    <script type="text/javascript" src="http://localhost/arcgis_js_api/library/1.6/arcgis/"></script>
    <script type="text/javascript">
      dojo.require("esri.map");
      dojo.require("esri.tasks.find");

      var find, params;
      function init() {
        find = new esri.tasks.FindTask("http://localhost/ArcGIS/rest/services/gisDuLich/DuLich/MapServer");
        params = new esri.tasks.FindParameters();
        params.contains=true;
        params.returnGeometry=true;
        params.layerIds = [0,1,2,3,4,5,6,7,8];
     
        params.searchFields = ['maDoiTuong','danhTuChung','diaDanh','diaChi','doiTuong','maNhanDang','ngayThuNhan','ngayCapNhat','maDoiTuong','maDonViHanhChinh','danhTuChung','diaDanh','dienTich','nhandang','ten'];
      }

      function doFind() {
        params.searchText = dojo.byId("searchText1").value;
        find.execute(params, showResults);
      }

      function showResults(results) {
      alert("Don't shows results "+results);
        var result, attribs;
        var s = ["<table border=\"1\"><thead><tr style=\"background-color:#ccc;\"><td>OBJECTID</td><td>Dia Danh</td></tr></thead><tbody id=\"states\">"];
        dojo.forEach(results,function(result){
          attribs = result.feature.attributes;
          alert(result.feature.attributes);
          for (j in result.feature.attributes) {
          alert(j);
            if (j.toUpperCase() != "OBJECTID" && j.toUpperCase() != "SHAPE")
                if (result.feature.attributes.toUpperCase() != "NULL")               
                s.push("<tr><td>" + j + "</td><td>" + result.feature.attributes+ "</td></tr>");
        }
          
        });
        s.push("</tbody></table>");
        dojo.byId("tbl").innerHTML = s.join("");
      }

      dojo.addOnLoad(init);
    </script>

  </head>
  <body class="claro">
    Dia Danh: <input type="text" id="searchText1" size="40" value="Trường" />
    <input type="button" value="Find" onclick="doFind()" />

    <div id="tbl"></div>

  </body>
</html>


HELP ME PLEASE!
0 Kudos
JessicaKnight1
Occasional Contributor
I'm having issues as well!
0 Kudos
DaiDai1
Deactivated User
HELP ME PLEASE!

PLEASE
HELP ME
0 Kudos
derekswingley1
Deactivated User
What have you tried?

What errors are you seeing?

Do you see the request going to the layer in your map service?

Consider using 3.0 as it is the latest version of the API.
0 Kudos
DaiDai1
Deactivated User
What have you tried?

What errors are you seeing?

Do you see the request going to the layer in your map service?

Consider using 3.0 as it is the latest version of the API.


Further explanation? Please!
Thanks
0 Kudos
TimCollyer
Regular Contributor
I've had problems with the FindTask on layers that contain joins.

Try using the QueryTask and see what happens.
0 Kudos
ReneeMaxwell
Regular Contributor
I am also having a problem with the find task for a particular map service. I'm using version 3.1 of the API. There are no errors, just an empty result set. I have tested this task in versions 2.8 and 3.0 and experienced the exact same problem.

When I change the map service URL to query a different service, the find task works. Both of the layers that I'm searching in each service are built from an SDE View in Oracle (they are building layers) but only one of them fails. When I use the Find task via the REST directory it also returns empty for this particular map service only.

I've tried renaming and republishing the map service, but the find task still fails regardless. It is an MSD map service. I'm using ArcGIS 10.0 SP3.
0 Kudos