Select to view content in your preferred language

Clustering Sample doesn't display InfoWindow for non-clustered points

988
3
06-17-2011 07:52 AM
KarlWilson
Frequent Contributor
Hi,

Does anyone know how I could modify the Clustering Sample so that when you zoom into individual points and click on them they display an InfoWindow.

Currently in the example above, an InfoWindow only appears when you click on one of the green points that are part of a cluster. When you click on an individual red point you don't get the InfoWindow.

Thanks,
Karl
Tags (2)
0 Kudos
3 Replies
AlexJones
Emerging Contributor
Not tested, but you should just be able to add a click event to the feature layer or another event listener on the map. Try it out.

map.addEventListener(MouseEvent.CLICK,mouseClickHandler);

  
private function mouseClickHandler(event:MouseEvent):void
   { 
    showInfoWindow(Graphic(event.target),event.stageX, event.stageY);    
        
   }



or

 <esri:FeatureLayer id="featureLayer"
         clusterer="{clusterer}"
         definitionExpression="POP1990 &gt; 75000"
         mode="snapshot"
         outFields="*"
         symbol="{defaultsym}" click="mouseClickHandler(event)"
...
0 Kudos
AlexJones
Emerging Contributor
This sample shows a better way to handle the events. It uses a Graphic event and should help you avoid any type coercion errors.

protected function fLayer_graphicAddHandler(event:GraphicEvent):void
   {
    event.graphic.addEventListener(MouseEvent.CLICK,mouseClickHandler);
   }


<esri:FeatureLayer id="featureLayer"
         clusterer="{clusterer}" graphicAdd="fLayer_graphicAddHandler(event)"
         definitionExpression="POP1990 &gt; 75000"
         mode="snapshot"
         outFields="*"
         symbol="{defaultsym}" 


the mouseClickHandler would be the same as above.
0 Kudos
KarlWilson
Frequent Contributor
That's great Alex, thanks.

Both methods work for me.

Karl
0 Kudos