Events for Global search
Hi.
I'm trying to get the global search to automatically zoom to the selected/found feature. I've tried to configure the result -> search parameters in desktop.json.js to use the function ZoomToFeature, but this doesn't work. I've read several of the forum treads and I can't see any solution to this problem. So I thought of creating a custom module that zooms to the searchresults, but I'm having a few problems. Are there any events for the global search? The module would listen for an event (like seachcompleted?) and use the result. I've found the searchProgressEventArgs, but I'm not sure how to bind this to the existing global search in the viewer. I think that developing an custom searchprovider is a bit overkill for this purpose.
Does anyone have any suggestions or examples of searchProgressEventArgs?
0
-
Hi Torbjørn,
Search modules emit a SearchProgressEvent (as you've found) which provides a SearchProgressEventArgs object that contains information about the progress. Each type of provider that accepts input from the global search box may generate these events.
To zoom to the extent of selected/found feature(s), you could listen for the SearchProgressEvent, and when an Event occurs that matches up to what you want to observe, you can get the results attribute which references a FeatureSetCollection. FeatureSetCollection objects have a member featureSets that is a reference to the features returned.
Alternatively, you could add a command to the Results module configuration, in the resultMappings section. These commands accept a FeatureSetCollectionID argument (a string), and would then be able to obtain the feature set collection by its ID and get the extent of all featuresets from that.
Either way you will be creating some custom client code, but neither method would require you to create a custom search provider.
The SDK Samples viewer provided in the Viewer for HTML5 download has a sample of handling map events (under Mapping -> Map Event Handling). Changing the event from MapClickedEvent to SearchProgressEvent will help you get on your way!
Regards,
-Malcolm1 -
This post is a bit old now but could someone (Malcolm?) provide an example of how to actually get the results attribute? I have a custom module that is subscribed properly to the SearchProgressEvent but I'm not sure what to do from there.
I'm trying to accomplish exactly what Torbjørn described - zooming to the results of a global search. My thinking was to have my custom component listen for the SearchProgressEvent (as indicated by Malcolm) and have it determine the extent of the feature(s) and zoom to it.0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer