rocksolid311

''wkid' undefined' error message for simple query (NOVICE SHOULD BE EASY TO ANSWER!!)

Discussion created by rocksolid311 on Jun 24, 2011
Latest reply on Jun 27, 2011 by sli-esristaff
Hi guys,

I am very new to ArcGIS server (2 days!). I am trying to create a simple query based on the geometry (I am just passing coordinates) passed to a MapServer. I am just trying to return tabular results and I am not concerned about using a map. I keep running into this error message:

[52 Uncaught TypeError: Cannot read property 'wkid' of undefined]

When you run the query straight from the browser, you don't have to define this parameter.

Here is the html:

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>Query State Info without Map</title>
    <link rel="stylesheet" type="text/css"

href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css

">
    <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?

v=1.6"></script>
    <script type="text/javascript" language="Javascript">
      dojo.require("esri.tasks.query");

      var queryTask, query;
   var sourcewkid = new esri.SpatialReference({"wkid":2965});
      function init() {
        //build query
        queryTask = new esri.tasks.QueryTask("http://gis.hamiltoncounty.in.gov/ArcGIS/rest/services/Parcel-Lines/MapServer/0");
        dojo.connect(queryTask, "onComplete", showResults);
        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = true;
  query.geometry = (geometry, sourcewkid);
  query.geometryType = "esriGeometryPoint";
  query.spatialRel = "esriSpatialRelIntersects";
  query.outSpatialReference = 2965;
  query.inSpatialReference = 2965;
        query.outFields =["OBJECTID", "FMTPRCLNO", "DEEDEDOWNR", "LOCADDRESS", "LOCHSENUMR", "LOCCITY", "LOCZIP", "SUBDIVNAME", "SUBDIVSEC", "CONDOUNIT", "PROPCLASS", "PROPUSE", "TAXDISTNAM", "PARCELNO", "COMMON_ARE", "SUBDIV_COD", "STPRCLNO", "SHAPE"];
      }

      function execute(geometry) {
        debugger;
        //execute query
        queryTask.execute(query,showResults);
      }

      function showResults(results) {

        var s = "";
        for (var i=0, il=results.features.length; i<il; i++) {
          var featureAttributes = results.features[i].attributes;
          for (att in featureAttributes) {
            s = s + "<b>" + att + ":</b>  " + featureAttributes[att] + "<br />";
          }
        }
        dojo.byId("info").innerHTML = s;
      }

      dojo.addOnLoad(init);
    </script>
  </head>
  <body>
    Coordinate : <input type="text" id="geometry" value="198538.360028002, 1718163.919889" />
    <input type="button" value="Get Details" onclick="execute(dojo.byId('geometry').value);"
/>
    <br />
    <br />
    <div id="info" style="padding:5px; margin:5px; background-color:#eee;">
    </div>
  </body>
</html>

Thanks,

Dave

Outcomes