Created by
Piotr Szrajber
| function QueryExecutor(queryObject, callback) {
this.index = 0;
this.name = queryObject.name;
this.values = queryObject.values;
this.callback = callback;
this.interval = null;
}
QueryExecutor.prototype.startShow = function () {
var me = this;
this.interval = setInterval(function () {
me.execute();
}, 3000);
};
QueryExecutor.prototype.stopShow = function () {
clearInterval(this.interval);
};
QueryExecutor.prototype.execute = function () {
var me = this,
value = me.values[me.index];
console.log(value);
$GP.queries.add({
featureClassId: "{http://www.intergraph.com/geomedia/gml}OM_USA_STATES",
url: "http://demo.hexagongeospatial.com/GWM_WFS_NonTransactional/service.svc/get",
definitionName: "WFS",
queryName: me.name,
addToLegend: false,
filters: [{
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", value]
}]
}, function (result) {
me.index = (me.index + 1) % me.values.length;
if (result.updated) {
$GP.ui.info(`Analysis '${me.name}' updated to 'STATE_NAME = ${value}'`);
return;
}
$GP.queries.find({
analysisId: result.analysisId,
}, function (result2) {
result2.analysis.addToLegend(function () {
//$GP.legend.find({
// name: queryName
//}, function (ret){ret.legendItems[0].fitLayer();});
});
});
});
};
[{
name: "AroundNevada",
values: [
"Nevada", "California", "Oregon", "Idaho", "Utah", "Arizona"
]
}, /*{ // uncomment to see bug
name: "AroundKansas",
values: [
"Colorado", "Nebraska", "Iowa", "Missouri", "Oklahoma"
]
}*/].map(function (queryObject){
return new QueryExecutor(queryObject);
}).forEach(function(executor){
setTimeout(function () {
executor.startShow();
}, 1500);
});
|