Hi,
Version 3.17.
We surprised that FeatureLayer selectFeatures() method does not return "features" and "method" - just Array of objects.
And help is not correct
FeatureLayer | API Reference | ArcGIS API for JavaScript 3.18
That means there is a difference to use QueryTask.execute() or FeatureLayer.selectFeatures().
Should we use 3.18?
Any help please.
Piterson,
That was in my very first reply:
censusBlockPointsLayer<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit; font-size: 14px;">on</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">"selection-complete"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">,</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">function</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>evt<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN> <SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">{</SPAN> console<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit; font-size: 14px;">info</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>evt<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">;</SPAN> <SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>
You are right.
Could we do it in
function initFunctionality() { var query2 = new Query(); query2.outFields = ["*"]; query2.where = "OBJECTID < 5";
censusBlockPointsLayer.selectFeatures(query2, FeatureLayer.SELECTION_NEW, function (featureSet) { console.info(featureSet); });
...
};
The print in console is the same: Array of Objects
What is the point in doing a selection inside the response of another selection. Also by adding that, you would be creating an infinite loop in your code, because you are executing a selection inside the selection complete handler event.
Robert,
Thank you for the response.
I see.
Please try this
censusBlockPointsLayer.on("selection-complete", function(evt) { var query = new Query(); query.outFields = ["*"]; query.where = "OBJECTID < 5";
censusBlockPointsLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (featureSet) { console.info(featureSet); }); //console.info(evt); var totalPopulation = sumPopulation(censusBlockPointsLayer.getSelectedFeatures()); var r = ""; r = "<b>The total Census Block population within the drive time polygon is <i>" + totalPopulation + "</i>.</b>"; dom.byId('messages').innerHTML = r; });
Not sure how your code is handling the FeatureLayer.selectFeatures but this sample does return feature and method just fine (I just added a console.info(evt)):
ArcGIS API for JavaScript Sandbox
censusBlockPointsLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">on</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"selection-complete"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>evt<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">info</SPAN><SPAN class="punctuation token">(</SPAN>evt<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.