In EXB get popup with layer attributes to display after using ArcGIS world geocoder address search?

566
1
05-13-2023 02:29 PM
johnbrosowsky
Occasional Contributor II

Hi all -

I am migrating a WAB app to EXB and have the following challenge: when using the search widget with the ArcGIS World geocoder, when the user types in and selects an address candidate I would like the map to zoom to the address location, display a marker, and then trigger a webmap popup showing attributes from a layer in the map for that location.  I think this is a common task - using the world geocoder to search for an address, and then showing some information in a popup about that location based on other layers in the map.

With EXB for arcgis online, I can get the map to zoom to the address location and show a marker in the map, but I can't find any actions to trigger to show a webmap popup at that location.  The user has to close the address search and manually click on the map to get the popup.  Am I missing something in EXB for online that would enable this?

If not, I can use EXB developer and modify a copy of the search widget, but looking for pointers if anyone has already done that for search, as this seems like a common workflow.  Any advice would be greatly appreciated!!

 

 

 

 

 

 

1 Reply
JeffreyThompson2
MVP Regular Contributor

I have been working on extending and improving the search widget for a week now and I have something that searches data from the map, adds a marker and shows a popup, so it can be done in the developer edition. There are a lot of pitfalls you will need to work through. Here are my top tips.

1. The best place to add your custom code is in the onSelectRecord function of /name-of-your-search-component/src/runtime/component/result-list.tsx.

2. In the typical behavior of the search widget this function will fire two or three times per search. I found a variable called 'version' in the code. It doesn't appear to do anything, it was likely a debugging variable that got left in the final code. I put my code inside an if statement based on this variable equaling 1 to prevent multiple triggers.

3. You will need to grab the mapView and you may want to load it into state. Code below:

import { JimuMapView, MapViewManager } from 'jimu-arcgis'

const viewManager = MapViewManager.getInstance()
const mapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])
const [jimuMapView, setJimuMapView] = React.useState<JimuMapView>(mapView)

You will also need to add  "dependency": [ "jimu-arcgis" ], to manifest.json.

4. From there, it should be mostly the same as adding layers and triggering popups in the Javascript API.

GIS Developer
City of Arlington, Texas
0 Kudos