Composite Locator Geocode Service & Search Widget

487
3
06-08-2023 02:16 PM
Labels (1)
JonathanKressin
New Contributor III

In my Experience Builder mapping app (Developer 1.11), now that we are live, we are finding a problem with the search widget.

In some address searches for valid addresses, the suggestion is providing good results, but clicking on them indicate that the address is not found.  If you just type the address and press enter, the address is found just fine. 

Looking at the rest services being called, everything looks to be working right.  Where things seem to be failing is with the 'magic key' being passed from the suggestion.  I can reproduce the behavior from the rest endpoints by first using the suggest endpoint, getting the suggestions, and then pasting the address and magic key into the 'find address candidates' endpoint.  If I remove the magic key, the find endpoint has no problem providing a geocoded result.

Has anyone else had this problem?  I am suspecting this is due to our using a composite locator and the magic key somehow not being matched up correctly.  

Thanks!

Jonathan

 

0 Kudos
3 Replies
JeffreyThompson2
MVP Regular Contributor

Do you have the "Auto select the first result" option turned on?

JeffreyThompson2_0-1686312910236.png

I have discovered that when this box is checked the search widget will ignore the user's chosen data source and return data from the first data source with a valid response.

I got around this problem by capturing the click event in the suggestion-list.tsx, passing it to result-list.tsx and overwriting the dsId and configId in onSelectRecord

GIS Developer
City of Arlington, Texas
0 Kudos
JonathanKressin
New Contributor III

I do have this selected, but unfortunately, I am looking at a different issue.  We only have a single locator added to the search widget (the composite locator), so there aren't multiple sources it could be selecting from there.  Turning off that checkbox doesn't affect this specific problem.

This morning, I think I'm going to duplicate the search widget and set the magic key to be blank when sent to the 'find address candidates' to see if this provides a workaround on the issue (without introducing new problems).

Thanks!

Jonathan

0 Kudos
JonathanKressin
New Contributor III

Just as a quick follow-up, modifying the search widget to set the magic key to an empty string appears to have resolved the issue.  I'm going to put the updated app into dev for our internal users to test and make sure this doesn't cause any new issues.  

If anyone else has problems with composite locators, the fix is fairly easy.  In the search.tsx component for the search widget, you just need to update the following lines:

const initResultServiceList = (newServiceList: ServiceList, initResultServiceListOption?: InitResultServiceListOption) => {
    const { configId, isFromSuggestion } = initResultServiceListOption || {}
    const magicKey = ""
 
0 Kudos