The Identify Features sample has the code if you click on the map.In one of my applications, I have a datagrid containing polylines of ROV transects. When you click on one of the items in the datagrid, an InfoWindow is placed at the midpoint of the transect. This function (the click event on the datagrid rovGrid) is how I did it.
private function rovGrid_Click():void
{
var obj:Object = rovGrid.selectedItem;
if (obj != null)
{
MainMap.infoWindow.hide();
var graphic:Graphic = findGraphicByAttribute(obj, layerROVGraphics);
var path:Polyline = graphic.geometry as Polyline;
var halfway:int = path.paths[0].length/2;
var mapPoint:MapPoint = path.getPoint(0,halfway);
if (graphic == null)
{
Alert.show ("This transect cannot be found");
return;
}
if (chkROVZoom.selected)
{
MainMap.extent = graphic.geometry.extent;
if (!MainMap.extent.containsExtent(graphic.geometry.extent)) {MainMap.level--;}
}
//I didn't include the function to fill the content of the infoWindow
MainMap.infoWindow.content = Functions.createVideoWindow(graphic);
MainMap.infoWindow.label = "Transect: " + graphic.attributes.Name;
MainMap.infoWindow.show(mapPoint);
}
}
private function findGraphicByAttribute(attributes:Object, graphicLayer:GraphicsLayer):Graphic
{
for each (var graphic:Graphic in graphicLayer.graphicProvider)
{
if (graphic.attributes["OBJECTID"] == attributes["OBJECTID"])
{
return graphic;
}
}
return null;
}