Select to view content in your preferred language

Esri 4.31 | MapView.popup.open() is not a function error (until map is focused)

244
1
Jump to solution
11-12-2024 06:21 AM
orahlagi
Occasional Contributor

Hi, So I had previously 4.30 and everything was working well.

Upon 4.31 upgrade, When initialize a session, I have a function that upon hovering on either FeatureLayer or StreamLayer, opens a popup via MapView.popup.open() and close it via popup.close().

however, I receive the following error:

mapView?.popup?.open is not a function

mapView.popup.close is not a function

 

Now, When I click on anywhere on the map (even blank spots), these functions suddenly become available, and everything works.

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

Because the Popup is now lazily loaded, it's not a full Popup instance until a feature with a popup template is clicked.

To interact with the popup manually, there are two methods on the view you an use.

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#openPopup

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#closePopup

This should get you the behavior you are looking for.

View solution in original post

0 Kudos
1 Reply
ReneRubalcava
Honored Contributor

Because the Popup is now lazily loaded, it's not a full Popup instance until a feature with a popup template is clicked.

To interact with the popup manually, there are two methods on the view you an use.

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#openPopup

https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#closePopup

This should get you the behavior you are looking for.

0 Kudos