// Initialize query task queryTask = new QueryTask('http://myurl'); // Initialize query query = new Query(); query.returnGeometry = true; query.outFields = ['PIND']; // Initialize info template infoTemplate = new InfoTemplate('${PIND}', 'PIND: ${PIND}'); // Initialize symbol symbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255.0, 0.0, 0.0]) ), new Color([255.0, 0.0, 0.0, 0.25]) );
function drawFeatureSet(featureSet) { try { // Clear graphics map.graphics.clear(); // Loop through features for (feature in featureSet.features) { feature.symbol = symbol; feature.infoTemplate = infoTemplate; map.graphics.add(feature); } } catch(e) { console.log(e.message); } }
Solved! Go to Solution.
function showResults(featureSet) { //remove all graphics on the maps graphics layer map.graphics.clear(); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = featureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; graphic.setSymbol(symbol); //Set the infoTemplate. graphic.setInfoTemplate(infoTemplate); //Add graphic to the map graphics layer. map.graphics.add(graphic); } }
function showResults(featureSet) { //remove all graphics on the maps graphics layer map.graphics.clear(); //Performance enhancer - assign featureSet array to a single variable. var resultFeatures = featureSet.features; //Loop through each feature returned for (var i=0, il=resultFeatures.length; i<il; i++) { //Get the current feature from the featureSet. //Feature is a graphic var graphic = resultFeatures; graphic.setSymbol(symbol); //Set the infoTemplate. graphic.setInfoTemplate(infoTemplate); //Add graphic to the map graphics layer. map.graphics.add(graphic); } }