Calling InfoPop (or PopUpRenderer) - Question for ArcGIS Flex Viewer

474
1
05-14-2012 11:04 AM
AbeHendricks
New Contributor
I have a graphics layer. Upon selecting (mouse click) the graphic, I'd like to remove the graphic AND bring up the pop up info window for that particular underlying feature class all in one single click of the mouse. Currently, the application requires two clicks: One click to remove the graphic, and a second click to bring up the info window. When I use the following call to AppEvent.SHOWINFOWINDOW, it simply brings up the info for the last item shown, instead of the feature class beneath the graphic (I hope that makes sense). I know I'm missing something... Hard to find any documentation on using this AppEvent. Any and all help is surely appreciated. See code block below.

protected function graphicClickEvent(event:MouseEvent):void
{
// removes selected graphic
var selGraphic:Graphic = event.target as Graphic;
myGraphicsLayer.remove(selGraphic);

// show info window
AppEvent.dispatch(AppEvent.SHOW_INFOWINDOW);

}

I've also tried something like the following and got the same results:
protected function graphicClickEvent(event:MouseEvent):void
{
// removes selected graphic
var selGraphic:Graphic = event.target as Graphic;
myGraphicsLayer.remove(selGraphic);

// show info window
const gMapPoint:MapPoint = event.target.geometry.extent.center;
hostComponent.map.infoWindow.show(gMapPoint);

}
Tags (2)
0 Kudos
1 Reply
BenKane
New Contributor III
You could try something like this - it worked for me:

actionscript:
 
                        public var pointDeleted:Boolean = new Boolean(false);
   public var mp:MapPoint = new MapPoint();
   
   protected function graphicClickEvent(event:MouseEvent):void
   {
    // removes selected graphic
    var selGraphic:Graphic = event.currentTarget as Graphic;
    myGraphicsLayer.remove(selGraphic);
    mp = selGraphic.geometry.extent.center; 
    
    // call query for underlying layer
    pointDeleted = true;
    underlyingLayer_clickHandler(new MapMouseEvent(MapMouseEvent.MAP_CLICK,myMap,mp));
   }
   
   protected function underlyingLayer_clickHandler(event:MapMouseEvent):void
   {
    if (pointDeleted == false){mp = event.mapPoint;}
    else{/** keep same mapPoint as first selection */}
    myMap.infoWindow.content = popupForm;   
    queryMapClick.geometry = mp;
    underlyingLayer.selectFeatures(queryMapClick); // default selectionMethod is FeatureLayer.SELECTION_NEW
   }   
   
   protected function underlyingLayer_selectionCompleteHandler(event:FeatureLayerEvent):void
   {
    // only show infoWindow if a feature was found
    if (event.featureLayer.numGraphics > 0){myMap.infoWindow.show(queryMapClick.geometry as MapPoint);}
    else{/**Don't do anything if no features are returned by query*/}
   }
   
   protected function attrInsp_faultHandler(event:FaultEvent):void
   {
    Alert.show(event.fault.message, "Fault");
   }


This is for the infowindow content for the underlying layer - just an example, use yours instead
declarations:
                <s:Form id="popupForm">
   <s:VGroup id="formVGRP" horizontalAlign="center">
    <esri:AttributeInspector id="attrInsp" featureLayers="{[underlyingLayer]}"/>
   </s:VGroup>
  </s:Form>  
  <esri:Query id="queryMapClick" />


mxml:
                <esri:ArcGISDynamicMapServiceLayer id="underlyingLayerDYN" url="http://140.160.114.190/ArcGIS/rest/services/YourInstance/YourLayer/MapServer"/>
  <esri:FeatureLayer id="underlyingLayer" 
         url="http://140.160.114.190/ArcGIS/rest/services/YourInstance/YourLayer/MapServer/0"
         outFields="*"
         mode="selection"
         selectionColor="0x000000"
         selectionComplete="underlyingLayer_selectionCompleteHandler(event)" /> 
  <esri:GraphicsLayer id="myGraphicsLayer"  load="addGraphicClickListener()"/>


-Ben
0 Kudos