Select to view content in your preferred language

Programmatically set selected graphic/feature

1289
2
Jump to solution
04-29-2014 06:57 AM
JamesSampica
Deactivated User
I add a graphic to the map through code and want to automatically show the infowindow without the user having to click on the graphic. With the code below it just shows an empty infowindow since nothing is selected on the map.

How can I programmatically set the selected feature or graphic?

map.graphics.add(graphic); map.centerAndZoom(graphic.geometry.getCentroid(), 6);  //What I want to do //map.setSelectedGraphic(graphic)  map.infoWindow.show(graphic.geometry.getCentroid());
0 Kudos
1 Solution

Accepted Solutions
JonathanUihlein
Esri Regular Contributor
Something like:

                 map.infoWindow.setFeatures(result);                 map.infoWindow.show(center);

View solution in original post

0 Kudos
2 Replies
JonathanUihlein
Esri Regular Contributor
Something like:

                 map.infoWindow.setFeatures(result);                 map.infoWindow.show(center);
0 Kudos
JamesSampica
Deactivated User
Something like:


                map.infoWindow.setFeatures(result);
                map.infoWindow.show(center);


Great, thank you.

I had to change it to an array since the setFeatures method accepts an array of graphics or deferreds.

map.infoWindow.setFeatures([graphic]);
0 Kudos