Select to view content in your preferred language

Popup graphic polygon not getting focused

755
2
Jump to solution
04-26-2022 12:44 AM
YogeshSwami
Emerging Contributor

Hello

I am using this code to open the popup at some location:

layer.queryFeatures().then((results: any) => {
                        const features = results.features;
                        features.forEach((result: any) => {
                            const oid = result.attributes.OBJECTID;
                            if (oid == this.selectedWindFarmId) {
                                    view.popup.open({
                                        features:result,
                                        location: result.geometry.centroid,
                                        title:result.attributes.Name,
                                        updateLocationEnabled:true,
                                        shouldFocus: true,
                                    });
                                    view.popup.viewModel.includeDefaultActions = false;
                                    view.popup.viewModel.highlightEnabled=true;
                                    view.zoom=12;
                            }
                        });
                    });
 
Here I am using shouldFocus also and highlightEnabled also. The popup is opening fine but not highlighting the selected feature. Please help
0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi @YogeshSwami -

Did you try setting the features property of the open method to the array of features returned from the query? It's expecting an array of graphics, not just one individual graphic. This sample highlights the feature returned from the query successfully: https://codepen.io/laurenb14/pen/xxpozMp?editors=1000

The shouldFocus option for the Popup open method provides a way to set focus to the popup itself automatically as it opens, not the feature.

Lauren

View solution in original post

0 Kudos
2 Replies
LaurenBoyd
Esri Contributor

Hi @YogeshSwami -

Did you try setting the features property of the open method to the array of features returned from the query? It's expecting an array of graphics, not just one individual graphic. This sample highlights the feature returned from the query successfully: https://codepen.io/laurenb14/pen/xxpozMp?editors=1000

The shouldFocus option for the Popup open method provides a way to set focus to the popup itself automatically as it opens, not the feature.

Lauren
0 Kudos
YogeshSwami
Emerging Contributor

Hello @LaurenBoyd,

Thanks for the reply.

It really helped. I replaced features:result by features:[result] and it is working fine.

0 Kudos