AnsweredAssumed Answered

Getting CodedValueDomain from QueryTask result.

Question asked by salihyalcin89 on Jul 7, 2015
Latest reply on Aug 10, 2015 by WCrick-esristaff

Hello everyone,

I am developing an app that uses QueryTask feature of Esri Android SDK. Evertyhing is perfect except one thing. QueryTask results return Attribute Values and I am displaying this values at Popup. Let me explain deeply. Results have district field. I use district_name with coded value. For example; When value 1 district name display Green, when value 2 district name display Blue. At the SDK side, I am able to show district name =1 or district name=2. I want to show real district name with CodedValueDomain.

 

I showed like left popup my attributes but I want to show like right popup. I dont know how to access codedValueDomains. I've read API documentation, samples etc.

test.png

 

Here is my code approach;

 

private class AsyncQueryTask extends AsyncTask<String, Void, FeatureResult> {

@Override
protected void onPreExecute() {
progress = new ProgressDialog(MainActivity.this);
progress = ProgressDialog.show(MainActivity.this, "",
"Please wait....query task is executing");
}
/**
* First member in string array is the query URL; second member is the
* where clause.
*/
@Override
protected FeatureResult doInBackground(String... queryArray) {
if (queryArray == null || queryArray.length <= 1)
return null;
String url = "http://company.gov.tr/arcgis/rest/services/GIS/Parcel/MapServer/1"
QueryParameters qParameters = new QueryParameters();
String whereClause = queryArray[1];
SpatialReference sr = SpatialReference.create(102100);
qParameters.setGeometry(mMapView.getExtent());
qParameters.setOutSpatialReference(sr);
qParameters.setReturnGeometry(true);
qParameters.setWhere(whereClause);
QueryTask qTask = new QueryTask(url);
try {
FeatureResult results = qTask.execute(qParameters);
return results;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(FeatureResult results) {
String message = "No result comes back";
if (results != null) {
int size = (int) results.featureCount();
for (Object element : results) {
progress.incrementProgressBy(size / 100);
if (element instanceof Feature) {
Feature feature = (Feature) element;
// turn feature into graphic
Graphic graphic = new Graphic(feature.getGeometry(),
feature.getSymbol(), feature.getAttributes());
// add graphic to layer
graphicsLayer.addGraphic(graphic);
}
}
// update message with results
message = String.valueOf(results.featureCount())
+ " results have returned from query.";
}
progress.dismiss();
Toast toast = Toast.makeText(MainActivity.this, message,
Toast.LENGTH_LONG);
toast.show();
boolQuery = false;
}
}

 

 

Dan O'Neill

Will Crick

Outcomes