HI, very confused about this dojo API and widget stuff. I want to add a button click event in the QueryTask _showResults() function so zooming to a feature is triggered ONLY when a button gets clicked. The following codes automatically trigger the button click event after the query finishes which is not what i want. Please help!
_query: function(){
var query = new Query();
query.where = "1=1";
query.outFields = ["ID", "Name"];
query.returnGeometry = true;
var queryTask = new QueryTask("http://......");
queryTask.execute(query, lang.hitch(this, this._showResults));
},
_showResults: function(featureSet){
this.own(on(this.btnZoomTo, "click", lang.hitch(this, this.map.centerAndZoom(featureSet.features[0].geometry, 10))));
},
Solved! Go to Solution.
Alex,
The issue is that you are not assigning a function to the click, you were just assigning code:
_showResults: function(featureSet){ this.own(on(this.btnZoomTo, "click", lang.hitch(this, function{ this.map.centerAndZoom(featureSet.features[0].geometry, 10) }))); },
Alex,
The issue is that you are not assigning a function to the click, you were just assigning code:
_showResults: function(featureSet){ this.own(on(this.btnZoomTo, "click", lang.hitch(this, function{ this.map.centerAndZoom(featureSet.features[0].geometry, 10) }))); },
Thanks Robert. so if understood it correctly, my way will fire this.map.centerAndZoom() automatically without clicking while your version assigns a function to the click event and fire only when user clicks the button, correct? Thanks so much for your help!
Alex,
That is correct.
this is my first WAB and widget project. lots of stuff to learn. thanks so much for your help. you made my life easier! t