AnsweredAssumed Answered

eSearch : URL Parameters not working with custom code

Question asked by bokeefe on Oct 14, 2016
Latest reply on Oct 14, 2016 by bokeefe

Robert Scheitlin, GISP has created the eSearch widget. It has URL parameters. With this ability I can generate a URL that allows my clients / customers to visit a webmap that is cued up to exactly what I want them to see. Except I need to offer them a 'current year' URL and that wasn't an option with eSearch "out-of-the-box" so after working with Robert I was able to introduce some modified code that gave me what I wanted.

 

//now check if there is a url search to do
var myObject = this.getUrlParams();
if (myObject.esearch) {
if(myObject.esearch === "curmonth"){
var today = new Date();
today.setDate(1);
var thisMonthStr = this._formatDate(today.getTime(), 'yyyy/MM/dd');
myObject.esearch = thisMonthStr + "~" + this._formatDate(new Date().getTime(), 'yyyy/MM/dd');
console.info(myObject.esearch);
}
if(myObject.esearch === "curyear"){
var today = new Date();
today.setDate(1);
var thisYearStr = this._formatDate(today.getTime(), 'yyyy');
myObject.esearch = this._formatDate(Date(thisYearStr), 'yyyy');
console.info(myObject.esearch);
}
if(this.config.layers[myObject.slayer].expressions.expression.length > 0){
var valuesObj1 = lang.clone(this.config.layers[myObject.slayer].expressions.expression[myObject.exprnum].values.value);
var values = myObject.esearch.split("|");
array.forEach(values, lang.hitch(this, function(val, index){
if (val.indexOf('~') > -1){
var ranges = val.split("~");
valuesObj1[index].valueObj.value1 = ranges[0];
valuesObj1[index].valueObj.value2 = ranges[1];
}else{
valuesObj1[index].valueObj.value = val;
}
}));
html.empty(this.textsearchlabel);
html.place(html.toDom(this.config.layers[myObject.slayer].expressions.expression[myObject.exprnum].textsearchlabel), this.textsearchlabel);
this.paramsDijit.build(valuesObj1, this.resultLayers[myObject.slayer], this.config.layers[myObject.slayer].url,
this.config.layers[myObject.slayer].definitionexpression);
this.selectLayerAttribute.set('value', myObject.slayer);
on.once(this.paramsDijit, 'param-ready', lang.hitch(this, function () {
this._queryFromURL(myObject.esearch, myObject.slayer, myObject.exprnum, myObject.close || false);
}));
}

This adds a 'Current Month' (curmonth) option and a 'Current Year' (curyear) option to the URL Parameters.

 

However, it just stopped working and I wonder if anyone has any ideas?

 

The map can be viewed at the custom URL: City of Tulsa, Tulsa Police Department, Methlabs Web Map  

 

This map is in our sandbox area so it won't be there once I get this figured out. But for now, I'm getting zilch returns on the custom URL.

Outcomes