Is it possible to have a pop up for my search widget to display information?

333
1
05-10-2023 10:09 AM
ChesouyeCoye
New Contributor III

I would like a search widget that onclick displays something similar to the screenshot attached. I would only want it on one of my feature layers. How do I go about doing so? 

 

Please see my codepen: 

https://codepen.io/chesouye/pen/poxVyXJ

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

This is my understanding of your question. I apologize if I did not understand the question. I think you are asking to run search when user clicks on features of a given feature layer and show a popupTemplate using results of the search. This codepen app shows a proof of concept for how it can be done: https://codepen.io/U_B_U/pen/oNaMVoe?editors=100

Essentially, you want to use MapView.hittest() to return a result only when user clicks on the featurelayer of your choice by setting includes parameter. If the hittest returns results then you can call search widget's search method using either attribute, geometry or long,lat. Once the search returns the result, then you can show the popup by calling view.popup.open() method. You can setup the action, content and title of the popup as needed. 

 

Hope this helps,

0 Kudos