add ROLL_OVER on QueryWidget

1668
20
Jump to solution
08-21-2014 03:46 AM
NatashaManzuiga
Occasional Contributor

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

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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);

            }

View solution in original post

20 Replies
RobertScheitlin__GISP
MVP Emeritus

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);

            }

NatashaManzuiga
Occasional Contributor

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..

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

   I am not sure I understand your problem. Can you provide screenshots?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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);

            }

NatashaManzuiga
Occasional Contributor

Robert, thanks, you fixed my problem...

I still have this problem when I graphically click on the feature..

Untitled.png

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
NatashaManzuiga
Occasional Contributor

And can I modify it....or at least....can I disable click on the feature?

Thanks Robert,

Naty

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Naty,

   Sure you can just remove the popup portion that you specified for that layer in the main config.xml

0 Kudos
NatashaManzuiga
Occasional Contributor

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"/>

0 Kudos