3

I have developed a application using the ESRI JS API to allow users to create and edit features in a web map. I have used the QueryTask to create summary statistics to report back to the user on total length and such. To create this report back, I am using .innerHTML, which works great, but the statistic is not refreshed when a change is made to the feature. Thus in order for a user to see updated statistics they need to refresh the page. This is not ideal - can I add a listener or other technique to automatically update the statistics generated with the Query Task?

The Query and Query Task is:

queryTask = new QueryTask("URL");
    query = new Query();
    statisticDefinition = new StatisticDefinition();
    statisticDefinition.statisticType = "sum";
    statisticDefinition.onStatisticField = "SHAPE.STArea()";
    statisticDefinition.outStatisticFieldName = "total_area";
    query.outStatistics = [statisticDefinition];
    queryTask.execute(query, function (result) {
        total_area = result.features[0].attributes;
        postExecute();

    });

and the postExecute Function that gives the statistic to the DIV:

function postExecute() {
    var roadLength = (total['total'])";
    document.getElementById("length").innerHTML = roadLength;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.