search widget does not work well for featureserver

572
2
07-11-2017 01:26 PM
lowolhar
New Contributor

it does not seem to find multiple features (in the same layer) based on the select. without any search-result event listening I will get a singular polygon highlighted (I don't really like the default color that much either)

seems like if I listen for search-results I can kind of get the index of the sources choice and the selected string somewhere down in there so I think I could then kick off a querytask or something and get an array of features returned that way that I could make my own graphic layer for and highlight them nicely but really is that the way its meant to work

was it only intended for point sources geocoder locate services etc.? I read you could have a combo mix: "The Search widget provides a way to perform search capabilities based on locator service(s) and/or map/feature service feature layer(s)." and I do and works well except for multiple polygon and line featureserver returns I think.   

Am I missing something with the search-results? There is only ever one object there.

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Lo,

    I am not sure I follow. When you configure multiple sources fro the search widget and those sources have the suggest ability then the search widget will present a list of suggestions and when you click one of those suggestions it will highlight and zoom to that result. If you are using an older ArcGIS Server that does not support suggestions then when you click enter (depending on how you have configured the search widget) it will present a list of search results or zoom and select the first returned result. If you have autoSelect true on the search widget it will 

Indicates whether to automatically select the first geocoded result.

That sounds like what you are running into. As far as the selection color that is configurable for each source:

https://developers.arcgis.com/javascript/3/jsapi/search-amd.html#sources  Look for the "highlightSymbol" 

0 Kudos
lowolhar
New Contributor

Humm...I am not sure what the autoSelect would do in this case. These are multiple polygons. In the list of choices (the suggests work fine) they show up like duplicates. For example a city limits layer where there is a large city polygon but then some smaller disjoint polygons are part of the same city as well. What I was trying to do is have the search in this case return all the features and zoom to the extent of all of them together. Which I think I can do its just additional code to querytask on the item they select. Trying to build a one stop search for points (I currently have these as geocodeserver locators), polyline layers and polygon layers (I currently have these as featureserver) items. 

I have one search blob in my javascript that reads all the locator/featureserver setups from a configuration file. So really don't want to have to have settings there for the different types...I think I was just led astray by the statement about "locator and/or map/feature server". They are really different sorts of returns tho...just will handle them differently with the search-results I think.  

0 Kudos