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

4320
1
06-24-2011 02:02 PM
DavidBrown6
New Contributor
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.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
0 Kudos
1 Reply
SiqiLi
by Esri Contributor
Esri Contributor
Here is what you need to modify in the code:

Comment out the following code in the init() function:
//query.geometry = (geometry, sourcewkid);

In the execute() function, add the following codes:
function execute(geometry) {

var mySplitResult = geometry.split(",");
var mapPoint = new esri.geometry.Point([parseFloat(mySplitResult[0]), parseFloat(mySplitResult[1])],new esri.SpatialReference({ wkid:2965 }));  
query.geometry = mapPoint;

queryTask.execute(query,showResults);
}
0 Kudos