console.log("My query results:", featureSet.features); //returns an array of your query result's features console.log("My query results:", featureSet.features.length); //returns the length of the feature array
Thanks to all that helped, I'm going to consider this thread closed now.
<!DOCTYPE html> <html> <head> <title>Create a Map</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/dojo/dijit/themes/tundra/tundra.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"> <style> html, body, #mapDiv{ padding: 0; margin: 0; height: 100%; } </style> <script src="http://js.arcgis.com/3.8/"></script> <script> var map; require(["esri/map","esri/layers/ArcGISDynamicMapServiceLayer","esri/tasks/QueryTask","esri/tasks/query","esri/symbols/SimpleMarkerSymbol","esri/tasks/FeatureSet","dojo/domReady!"], function(Map,ArcGISDynamicMapServiceLayer,QueryTask,Query, SimpleMarkerSymbol,FeatureSet) { map = new Map("mapDiv", { center: [-56.049, 38.485], zoom: 3, basemap: "streets" }); var SunySchoolsLayer = new ArcGISDynamicMapServiceLayer("http://w7hp348/arcgis/rest/services/Testservice/XTest/MapServer"); map.addLayer(SunySchoolsLayer); var queryTask= new QueryTask("http://w7hp348/arcgis/rest/services/Testservice/XTest/MapServer/0"); var query = new Query(); query.where ="CampusName= 'Albany'"; //query.outSpatialReference = map.spatialReference; query.returnGeometry = true; query.outFields = ["CampusName"]; queryTask.execute(query,showResults); //console.log("My query results:", featureSet.features); var symbol = new SimpleMarkerSymbol(); symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE); symbol.setSize(50); var resultFeatures=FeatureSet.features; console.log("My query results:", FeatureSet.length); console.log("My query results:", FeatureSet.features); //returns an array of your query result's features function showResults(resultFeatures) { for(var i=0, i1=resultFeatures.features.length; i<i1; i++); { var graphic=resultFeatures; graphic.setSymbol(symbol); map.graphics.add(graphic); } } }); </script> </head> <body class="tundra"> <div id="mapDiv"></div>; </body> </html>
for(var i=0, i1=resultFeatures.features.length; i<i1; i++);
When you use console.log(), that means that you are sending a log message to the console window. So if you are testing your app in the Firefox browser, for example, you should see your log statements in Firebug's console tab, given that you've chosen the Firebug debugger. So for "console.log("My query results:", resultFeatures);" you should see in your debugger console panel the text 'My query reults:' followed by the FeatureSet object that was returned from your query task. You could further drill down and use:
If your debugger does not indicate that any features are getting returned, you should probably check to make sure there is nothing wrong with your feature layer or the way you're writing your query.
check out your debugger console to see what returned from your query
console.log("My query results:", resultFeatures);
Hi All: function executeQueryTask() { query.where = "CampusName = 'Albany' "; queryTask.execute(query,showResults); } function showResults(featureSet) { for(vari=0, i1=resultFeatures.length; i<i1; i++) { var graphic=resultFeatures; graphic.setSymbol(symbol); graphic.setInfoTEmplate(infoTemplate); map.graphics.add(graphic); } } });
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.