[GIS] Arcgis SDK for Android – Query multiple feature layers

androidarcgis-runtimefeature-layerlayerssdk

I'm developing a android application with arcgis sdk.
I have a basemap and then 4 different feature layers on top of it.
I began with the arcgis sample "attribute editor" and removed the edit functioncs because I just want to view the features of the clicked point.

I had a little issue with querying a point or a 1px line on the touchscreen but I solved it with creating an envelope around the clicked point and then query the envelope.

So far so good! But my problem now is, that I can only query one feature layer at a time. I want to click on the map and then it queryies the layer 1, layer 2, layer 3, and finally layer 4. How can you do this? I was just able to query layer 1 OR 2 OR 3 OR 4…

I have this code sections:

featureLayerDefault.selectFeatures(query,
ArcGISFeatureLayer.SELECTION_METHOD.NEW,
new CallbackListener<FeatureSet>() {
    // handle any errors
    public void onError(Throwable e) {
    Log.d(TAG, "Select Features Error" + e.getLocalizedMessage());
    }

if (queryResults.getGraphics().length > 0) {
Log.d(TAG, "Feature found id=" + queryResults.getGraphics()[0].getAttributeValue(featureLayerDefault.getObjectIdField()));
// set new data and notify adapter that data has changed
listAdapter.setFeatureSet(queryResults);
listAdapter.notifyDataSetChanged();

Best Answer

A QueryTask is the right approach for getting features from a single layer in a map service. If you want to query all layers in a map service you should use the IdentifyTask. Otherwise, you need to use multiple QueryTasks to query different layers.

Related Question