Select to view content in your preferred language

How to automatically load popup when layer loads?

517
3
04-13-2022 12:03 AM
YogeshSwami
Emerging Contributor

When we load a feature layer on map, user needs to click on some graphic of that feature to get it highlighted and open the feature. How can we pass the particular object id to that layer so that the graphic automatically gets highlighted as soon as the feature loads, without user interaction?

Can someone please help?

 

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

You can use the popup's open method by passing in the feature you want to highlight.

view.popup.open({
    features: [pointGraphic],
    location: pointGraphic.geometry
});
YogeshSwami
Emerging Contributor

Actually this is my feature I am retrieving:

YogeshSwami_0-1649922800944.png

and then when I try this:

view.popup.open({

    features:feature,

    location:feature.geometry

})

I am getting this error: 

YogeshSwami_1-1649922942276.png

Please help me with this.

0 Kudos
YObaidat
Occasional Contributor

you need here to pass "centroid" to the location property

view.popup.open({

    features:feature,

    location:feature.geometry.centroid

})
0 Kudos