I am somewhat new to WAB developer and am trying to accomplish what I would think would be a fairly simple task. I would like for the user to be able to use the Search widget to search by address (using either our locator or an address point layer, either are available) and for the results to return attributes from certain polygons that the point falls within. So for instance, searching by address returns attributes from parcel and zoning, two separate layers. Somewhat similar
I feel like this functionality is available somewhere, however I'm just missing it. I don't necessarily want the user to have to place a point on a map for the attributes from the two layers to be returned, I'd like for the point that is created by way of the Search widget to "trigger" the identify widget (or eSearch widget if appropriate.)
There is similar functionality with the NearMe widget, however what I really want is to intersect any polygons that the point falls inside of rather than a buffer distance from a point.
Thanks for any suggestions or help!
Andrew,
I do this with my eSearch widget on my parcel viewer site. The changes are simple. In the Search Widget.js
At the end of the _onSelectResult method I add:
_onSelectResult: function(e) {
...
// publish select result to other widgets
this.publishData({
'selectResult': e
});
//Dispatch event to have eSearch search for this geometry.
this.publishData({
'target': 'eSearch',
'feature': result.feature
});
},
In my eSearch widget.js I have
onReceiveData: function(name, widgetId, data) {
if(data.message && data.message === "Deactivate_DrawTool"){
this.drawBox.deactivate();
}
if(data && data.target && data.target === 'eSearch'){
if(data.feature.geometry.type === "polygon"){
//Ensure a point inside the polygon. The centroid is not gauranteed to be inside the poly
esriConfig.defaults.geometryService.labelPoints([data.feature.geometry], lang.hitch(this, function(labelPoint) {
this.search(labelPoint[0], 0);
}));
}else{
this.search(data.feature.geometry, 0);
}
}
},
Thank you so much Robert! That seems to have worked.
Is there a setting within eSearch that will allow for search results from multiple layers to be displayed in the results window? So for instance, I am searching against Parcels and Zoning Districts (two polygon layers) and when the search is conducted only the Parcels layer is appearing in the results window:
If I change the order of the search layers, the Zoning Districts layer is returned in the results window:
Andrew,
Nope the eSearch is only designed to search one specified layer at a time.
To do this in the Identify widget in the widget.js change the onReceiveData function to:
onReceiveData: function(name, widgetId, data) {
if(data.message && data.message === "Deactivate_DrawTool"){
this.drawBox.deactivate();
}
if(data.selectResult){
this.identifyFeatures(data.selectResult.result.feature.geometry);
}
},