I would like to remove the default symbology of the polygon selection result of the Search widget. I'm doing this within some custom code utilizing the aspect.around module accessing the _onSearchResults function of the Search widget.js file; however, I'm unable to get this to fully work. Below is my aspect.around module which is within a function where the widget gets passed in.
Any help or thoughts would be appreciated.
aspect.around(widget, '_onSearchResults', lang.hitch(this, function(originalMethod) {
return lang.hitch(this, function() {
var features, feature, layer, queryLayer, queryLayerUrl, queryTask, query, pt;
features = [];
feature = null;
if (arguments) {
features = arguments[0].results[0];
array.forEach(features, function (feature){
// Search for Intersection
if (feature.feature.attributes.Loc_name === 'Streets' && feature.feature.attributes.Addr_type === 'StreetInt'){
originalMethod.apply(widget, arguments);
}else{
// Search for Owner, Address, PID, or S-T-R
if (feature.feature.attributes.Loc_name === "Parcels" || feature.feature.attributes.Loc_name === "Owner" || feature.feature.attributes.Loc_name === "AddressPoints" || feature.feature.attributes.Loc_name === "PID") {
queryLayerUrl = this.queryParcelUrl;
layer = this.qlayer;
} else if (feature.feature.attributes.Loc_name === 'STR') {
queryLayerUrl = this.querySectionUrl;
layer = this.qlayer;
}
query = new EsriQuery();
query.outSpatialReference = this.map.spatialReference;
query.returnGeometry = true;
query.outFields = this.queryLayerOutFields;
pt = feature.feature.geometry;
query.geometry = pt;
// parcel selection symbol - only for Search tool
this.parcelSelSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_NULL));
queryTask = new QueryTask(queryLayerUrl);
queryTask.execute(query, lang.hitch(this, function(result) {
this.map.graphics.clear();
var selfeature, graphic, poly, point;
if (result.features.length > 0){
selfeature = result.features[0];
graphic = selfeature;
poly = selfeature.geometry.getExtent();
point = selfeature.geometry.getCentroid();
graphic.setSymbol(this.parcelSelSymbol);
this.map.graphics.add(graphic);
this.map.setExtent(poly.expand(2));
this.map.infoWindow.hide();
this.map.infoWindow.clearFeatures();
this.map.infoWindow.setFeatures([selfeature]);
}
}));
}
}, this);
Solved! Go to Solution.
Robert,
I actually figured it out. It does exactly as you describe but what I wanted it to do was not show the selection, just zoom to the parcel. All I had to do was not add the graphic to the map! Ugh... Thanks for the response.
Douglas,
So what is it not doing? I added your code in the search widget in one of my apps and made some code adjustments for my data and requires and it took my county locator and selected the parcel that the locator point intersected.
Robert,
I actually figured it out. It does exactly as you describe but what I wanted it to do was not show the selection, just zoom to the parcel. All I had to do was not add the graphic to the map! Ugh... Thanks for the response.