You are here: > ESRI Forums > arcgis server forums > Thread Replies

ArcGIS Server Forums

ArcGIS API for Flex forum

tool tip renderer for a graphic   Jan Klosinski Feb 11, 2010
Re: tool tip renderer for a graphic   Dasa Paddock Feb 11, 2010
Re: tool tip renderer for a graphic   Jan Klosinski Feb 12, 2010
Re: tool tip renderer for a graphic   Robert Scheitlin Feb 12, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject tool tip renderer for a graphic 
Author Jan Klosinski 
Date Feb 11, 2010 
Message hi there,

is it possible to have a custom item renderer for the tool tips displayed for the graphic objects?

cheers,
Jan 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: tool tip renderer for a graphic 
Author Dasa Paddock 
Date Feb 11, 2010 
Message Yes, see the second sample under "Creating custom ToolTips" at
http://livedocs.adobe.com/flex/3/html/tooltips_4.html

e.g. 
 
protected var ptt:PanelToolTip = new PanelToolTip();

            protected function statesLayer_graphicAddHandler(event:GraphicEvent):void
            {
                var graphic:Graphic = event.graphic;
                graphic.toolTip = " ";
                graphic.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, stateToolTipCreateHandler, false, 0, true);
            }
            
            protected function stateToolTipCreateHandler(event:ToolTipEvent):void
            {
                var graphic:Graphic = event.target as Graphic;
                ptt.title = graphic.attributes["STATE_NAME"];
                ptt.population = graphic.attributes["POP2007"];
                event.toolTip = ptt;
            }
 
  Dasa Paddock
ArcGIS API for Flex
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: tool tip renderer for a graphic 
Author Jan Klosinski 
Date Feb 12, 2010 
Message thanks,

could you post sample implementation of the tooltip itself (this panel) please? 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: tool tip renderer for a graphic 
Author Robert Scheitlin 
Date Feb 12, 2010 
Message Jan,

Here is a simple implementation of the sample that Dasa recommended attached to a graphics layer. 
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:esri="http://www.esri.com/2008/ags"
    pageTitle="Custom tooltip">
	
	<mx:Script><![CDATA[
        import PanelToolTip;
        import mx.events.ToolTipEvent;
        
        private function createCustomTip(title:String, body:String, event:ToolTipEvent):void {
           var ptt:PanelToolTip = new PanelToolTip();
           ptt.title = title;
           ptt.bodyText = body;
           event.toolTip = ptt;
        }
    ]]></mx:Script>

    <esri:SimpleFillSymbol id="sfs_default" />
    <esri:Map id="map" crosshairVisible="true">
        <esri:extent>
            <esri:Extent xmin="-45" ymin="-25" xmax="45" ymax="35">
                <esri:SpatialReference wkid="4326"/>
            </esri:Extent>
        </esri:extent>
        <esri:ArcGISTiledMapServiceLayer
            url="http://server.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer" />
        <esri:GraphicsLayer>
            <esri:Graphic symbol="{sfs_default}" toolTip=" " 
        		toolTipCreate="createCustomTip('Hello','I am a custom tooltip.', event)">
                <esri:geometry>
                    <esri:Polygon spatialReference="{new SpatialReference(4326)}">
                        <mx:Array>
                            <mx:Array>
                                <esri:MapPoint x="-30" y="20"/>
                                <esri:MapPoint x="-40" y="20"/>
                                <esri:MapPoint x="-40" y="30"/>
                                <esri:MapPoint x="-30" y="30"/>
                                <esri:MapPoint x="-30" y="20"/>
                            </mx:Array>
                        </mx:Array>
                    </esri:Polygon>
                </esri:geometry>
            </esri:Graphic >
		</esri:GraphicsLayer>
    </esri:Map>
</mx:Application>


/////////////////////
///Seperate file/////
/////////////////////

<?xml version="1.0"?>
<!-- PanelToolTip.mxml -->
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" 
    implements="mx.core.IToolTip" 
    width="200" 
    alpha=".8" 
    borderThickness="2"
    backgroundColor="0xCCCCCC"
    dropShadowEnabled="true" 
    borderColor="black"
    borderStyle="solid"
    title="feh"
>
    <mx:Script><![CDATA[
        [Bindable]
        public var bodyText:String = "";
    
        //  Implement required methods of the IToolTip interface; these 
        //  methods are not used in this example, though.
        public var _text:String;

        public function get text():String { 
            return _text; 
        } 
        public function set text(value:String):void {
        } 
    ]]></mx:Script>

    <mx:Text text="{bodyText}" percentWidth="100"/>

</mx:Panel>
 
  Robert Scheitlin
GIS Manager
Calhoun County, Alabama