Select to view content in your preferred language

Feature Layer Query Error

4271
1
Jump to solution
10-13-2014 05:06 PM
joepublic
Deactivated User

I'm trying to understand how to query a feature layer and getting the following error:

 

 

ReferenceError {stack: "ReferenceError: Query is not defined↵    at http:/…  at d (http://js.arcgis.com/3.10/init.js:74:10)",

message: "Unable to draw graphic (geometry:null, symbol:null): Query is not defined"}

message: "Unable to draw graphic (geometry:null, symbol:null):

Query is not defined" stack: "ReferenceError: Query is not defined↵    at http://tobagoborn.com/esri/examples/exam1.html:40:24↵    at null. (http://js.arcgis.com/3.10/init.js:777:175)↵    at h.(anonymous function).g

[as onLoad] (http://js.arcgis.com/3.10/init.js:239:390)↵    at v (http://js.arcgis.com/3.10/js/esri/layers/FeatureLayer.js:24:225)↵   

at S._forceIdentity (http://js.arcgis.com/3.10/js/esri/layers/FeatureLayer.js:50:338)↵    at S._initLayer (http://js.arcgis.com/3.10/js/esri/layers/FeatureLayer.js:25:72)↵   

at Object. (http://js.arcgis.com/3.10/init.js:174:23)↵    at http://js.arcgis.com/3.10/init.js:630:478↵  

at c (http://js.arcgis.com/3.10/init.js:74:221)↵    at d (http://js.arcgis.com/3.10/init.js:74:10)"

 

Script below:......

 

<html>

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

  <title>Basic Example 1</title>

  <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">

  <script src="http://js.arcgis.com/3.10/"></script>

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>

 

 

  <script type="text/javascript">

  var countries;

  var buttonPicked;

  var buttonType;

  var countryCode = [];

  var map, featureLayer, relatedTable;

  var featureURL = "http://dev.consciousglobalchange.org/arcgis/rest/services/MEP/webmap_catalog/FeatureServer/0";

  var relatedURL = "http://dev.consciousglobalchange.org/arcgis/rest/services/MEP/webmap_catalog/FeatureServer/1";

 

 

  function countries()

  {

  require(["esri/map",

  "esri/layers/FeatureLayer",

  "esri/tasks/query",

  "dojo/domReady!"

  ], function(Map,FeatureLayer)

  {

  map = new Map("mapDiv",

  {

  center: [-56.049, 38.485],

  zoom: 3,

  basemap: "streets"

  });

  var featureLayer = new FeatureLayer(featureURL,

  {

  outFields: ["*"]

  });

  featureLayer.on("load", function ()

  {

  var cntryq = new Query();

  cntryq.outFields = ["*"];

  cntryq.where = "UN = " + 840; //332

 

 

  countries.queryFeatures(cntryq, function(featureSet)

  {

  var data = featureSet.features;

  console.log(data);

  });

  }); //end of on

  //map.addLayer(featureLayer);

  }); //end require

  }

  countries();

  </script>

  </head>

 

  <body>

  <div id="mapDiv"></div>

 

</body>

</html>

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
joepublic
Deactivated User

Figured it out!!

Needed to include the Query keyword in the function after the require array

View solution in original post

0 Kudos
1 Reply
joepublic
Deactivated User

Figured it out!!

Needed to include the Query keyword in the function after the require array

0 Kudos