Hi, I 'm trying to add a ROLL_OVER function on mouseovergraphic
I added this line on createQueryResults..
graphic.addEventListener(MouseEvent.ROLL_OVER, mouseOverGraphic);
and the function:
private function mouseOverGraphic(event:MouseEvent):void
{
var gra:Graphic = event.currentTarget as Graphic;
var infoData:Object = gra.attributes;
clearTimeout(hitimer);
var queryResult:ResultItem = gra.attributes as ResultItem;
if (map.extent.containsXY(queryResult.center.x, queryResult.center.y))
// only show infowindow if query result in contained within map extent
{
hitimer = setTimeout(showHighlight, 300, [ queryResult ]);
}
else
{
hideInfoWindow();
}
}
What I'm wronging?
Naty
Solved! Go to Solution.
Naty,
It is because the graphics attributes are not a ResultItem.
Here is the fix:
import mx.collections.ArrayList;
import com.esri.ags.components.ContentNavigator;
private var contentNavigator:ContentNavigator = new ContentNavigator();
private function mouseOverGraphic(event:MouseEvent):void
{
var currentGraphic:Graphic = event.currentTarget as Graphic;
var mapPoint:MapPoint = (currentGraphic.geometry.type == Geometry.MAPPOINT)? (currentGraphic.geometry as MapPoint) : currentGraphic.geometry.extent.center;
contentNavigator.dataProvider = new ArrayList([ currentGraphic ]);
// Put the ContentNavigator in the info window.
map.infoWindowContent = contentNavigator;
map.zoomTo(currentGraphic.geometry);
map.infoWindow.show(mapPoint);
}
Naty,
It is because the graphics attributes are not a ResultItem.
Here is the fix:
import mx.collections.ArrayList;
import com.esri.ags.components.ContentNavigator;
private var contentNavigator:ContentNavigator = new ContentNavigator();
private function mouseOverGraphic(event:MouseEvent):void
{
var currentGraphic:Graphic = event.currentTarget as Graphic;
var mapPoint:MapPoint = (currentGraphic.geometry.type == Geometry.MAPPOINT)? (currentGraphic.geometry as MapPoint) : currentGraphic.geometry.extent.center;
contentNavigator.dataProvider = new ArrayList([ currentGraphic ]);
// Put the ContentNavigator in the info window.
map.infoWindowContent = contentNavigator;
map.zoomTo(currentGraphic.geometry);
map.infoWindow.show(mapPoint);
}
It was impossibile for me to make it possible!!!
Thanks!!
I still have some problem to populate infopopup..with the PopUpRendererSkin.mxml ...because when I select a record on search result...it works well..when I ROLL_OVER on a Graphic...it doesnt show me title and description..
Naty,
I am not sure I understand your problem. Can you provide screenshots?
Naty,
Try this instead:
private function mouseOverGraphic(event:MouseEvent):void
{
var currentGraphic:Graphic = event.currentTarget as Graphic;
var resultAttributes:ResultAttributes;
resultAttributes = graphicToResultAttributes[currentGraphic];
popUpRenderer.popUpInfo = configurePopUpInfo(resultAttributes);
popUpRenderer.graphic = currentGraphic
var mapPoint:MapPoint = (currentGraphic.geometry.type == Geometry.MAPPOINT)? (currentGraphic.geometry as MapPoint) : currentGraphic.geometry.extent.center;
map.infoWindow.content = popUpRenderer;
map.infoWindow.contentOwner = popUpRenderer.graphic;
map.infoWindow.show(mapPoint);
}
Robert, thanks, you fixed my problem...
I still have this problem when I graphically click on the feature..
Naty,
The popup that you get from clicking on a feature is not controlled by the Query widget, it is controlled by the popup you have defined for the layer in the main config, that is why there is a difference.
And can I modify it....or at least....can I disable click on the feature?
Thanks Robert,
Naty
Naty,
Sure you can just remove the popup portion that you specified for that layer in the main config.xml
In the main config.xml, I just have this line:
<widget url="widgets/Query/QueryWidget.swf" config="widgets/Query/QueryWidget_HealthEmergency.xml" label="Health and Emergency" icon="assets/images/19_icon.png"/>