1

I am trying to query an ArcGIS Online feature layer using arcgis-java (ArcGIS Runtime) as below:

ServiceFeatureTable featureTable = new ServiceFeatureTable(this.SERVICE_FEATURE_URL);
QueryParameters query = new QueryParameters();
query.setWhereClause("1=1");
query.setReturnGeometry(true);
ListenableFuture<FeatureQueryResult> queryFeaturesAsync = featureTable.queryFeaturesAsync(query);
try {
    FeatureQueryResult result = queryFeaturesAsync.get();
    Iterator<Feature> iterator = result.iterator();
    if (iterator.hasNext()) {
        Feature feature = iterator.next();
        System.out.println(feature.getAttributes());
        System.out.println(feature.getGeometry());
    }
} catch (Exception e) {
    e.printStackTrace();
}

But always it returns only one feature even though the layer has more than 1 feature. How can I get more than one feature?

Also I tried by setting the setMaxFeatures also but there is no effect.

The main thing is I am not creating the FeatureLayer and MapView objects and not adding the FeatureLayer on MapView. I just want to query the ServiceFeatureTable.

Gary Sheppard
  • 4,764
  • 3
  • 25
  • 35
Naveen Kumar H S
  • 1,304
  • 16
  • 30

1 Answers1

1

I think it's returning all the features, but you're only looking at the first one. Try changing if:

if (iterator.hasNext()) {

to while:

while (iterator.hasNext()) {
Gary Sheppard
  • 4,764
  • 3
  • 25
  • 35