Open Popup after adding client-side feature

279
2
Jump to solution
02-21-2024 06:38 AM
DavinShokes1
Occasional Contributor II

In my app:

  • The user searches for an address
  • A graphic is created for the search result
  • External API request data is added to graphic attributes
  • The graphic is added to a client side feature layer
  • The popup can be opened by clicking the new feature. However,
  • I'm trying to programmatically update/replace the existing popup with the popup for the new feature (Around line 283-316).

I can't figure out the correct code to show the popup. I've tried the advice from https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFea... and https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#querying but I don't think I'm making the correct function.

 

Any advice? Thank you.

0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi @DavinShokes1 -

You could try passing in the graphic that is added to the feature layer to the features property in the MapView's openPopup() method after the query/external API call completes. Here's a simple example showing how to use that property: https://codepen.io/laurenb14/pen/ZEPNpXG?editors=1000 

You'll have to make sure the MapView popupEnabled property is set to false to manually open the popup as well.

Hope this helps!

Lauren

View solution in original post

2 Replies
LaurenBoyd
Esri Contributor

Hi @DavinShokes1 -

You could try passing in the graphic that is added to the feature layer to the features property in the MapView's openPopup() method after the query/external API call completes. Here's a simple example showing how to use that property: https://codepen.io/laurenb14/pen/ZEPNpXG?editors=1000 

You'll have to make sure the MapView popupEnabled property is set to false to manually open the popup as well.

Hope this helps!

Lauren
DavinShokes1
Occasional Contributor II

Thanks, that got me on the right path and my misunderstanding of the popupTemplate.

 

 

0 Kudos