Select to view content in your preferred language

Tool Tip and two different years

912
7
Jump to solution
03-28-2012 05:52 AM
ionarawilson1
Deactivated User
I am working on a web application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year. I have two years and a bunch of measure for each year.
I want to create a tool tip that when you mouse over the county you see a measure for that specific year. However when I mouse over the counties either I just see a measure for just one year, so even if I choose a year of 2007 it still shows the data for 2009 in the map tip.  Can you guys help me with what I need to do different in my code? Here is the snippet of the functions for the map tool tip:

private function onMouseOverHandler(event:MouseEvent):void
   {
    var gr:Graphic = Graphic(event.target);
    gr.symbol = mouseOverSymbol;
   
    if (yearcombo.selectedItem.year == "2007" && gr.attributes.YEAR_DATA == "2007")
    {
    
     myTextArea.htmlText =  "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
    
    } 
    else if (yearcombo.selectedItem.year == "2009")
    {
    
     myTextArea.htmlText =  "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
    
    }
    myMap.infoWindow.closeButtonVisible = false;
    myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
   }
  


And here is the feature layer I am using:



<esri:FeatureLayer id="fLayer"
             graphicAdd="fLayer_graphicAddHandler(event)"
            
             mode="snapshot"
             outFields="*"
             symbol="{defaultsym}"
             url= "http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/feature_layer_0709_four/FeatureServer/0" />
     
Thank you for any help!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Ionara,

    Where are you actually setting the map.infoWindow.content? I think that you need to change the content of the infoWindow when you change the data of myTextArea.

View solution in original post

0 Kudos
7 Replies
ionarawilson1
Deactivated User
I tried this  code below but when I click on 2009 and when I mouse over any county, it gives me the value for the first county I moused over when I had selected 2007. This makes me believe I need to do some kind of refresh to clear the graphics before I choose 2009. Any ideas?

private function onMouseOverHandler(event:MouseEvent):void
   {
    var gr:Graphic = Graphic(event.target);
    gr.symbol = mouseOverSymbol;
   
   
    if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0)
    {
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
     myTextArea.htmlText =  "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
    
    } 
   
   
    else if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 4)
    {
    
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
     myTextArea.htmlText =  "<b>Measure: </b>" + gr.attributes.ForDirIndOut.toString()
    
    }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ionara,

    Where are you actually setting the map.infoWindow.content? I think that you need to change the content of the infoWindow when you change the data of myTextArea.
0 Kudos
ionarawilson1
Deactivated User
I had defined in mxml

<esri:infoWindowContent>
       <mx:TextArea id="myTextArea"
          
           width="250" height="135"/>
      </esri:infoWindowContent>-->

However, when I try to create the same component with ActionScript (below) I get an error message saying 1120 - Access of undefined property - MyTextArea

if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1)
    {
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
    
     var graphic:Graphic = Graphic(event.currentTarget);
     var htmlText:String = graphic.attributes.htmlText;
     var mytextArea:TextArea = new TextArea();
     myTextArea.htmlText =  "<b>Measure: </b>" + myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
     myMap.infoWindow.content=myTextArea
     myMap.infoWindow.label = graphic.attributes.NAME;
     myMap.infoWindow.closeButtonVisible = false;
     myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
    } 
   
  
What is wrong with the code above?
0 Kudos
ionarawilson1
Deactivated User
I realized I had to import the TextArea class! Thank  you Robert!!!

Now, I have two other questions:

The tables have null values so I get an error message when I click on them. How could I make the null values not to prompt the error?

Also, on the previous code, when I created the htmText2 for 2009, it did not let me use to say mytextArea2.htmlText2, because I get a     1119: Access of possibly undefined property reference with static type Class
, but If I create a var htlmText to use it, it says it is a duplicate variable because I had create the same variable for 2007.  Here is the code again:

   if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0)
    {
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
    
     var graphic:Graphic = Graphic(event.currentTarget);
     var htmlText:String = graphic.attributes.htmlText;
     var textArea:TextArea = new TextArea();
     textArea.htmlText =  "<b>Measure: </b>" + graphic.attributes.ForDirIndOut.toString()
     myMap.infoWindow.content=textArea
     myMap.infoWindow.label = graphic.attributes.NAME;
     myMap.infoWindow.closeButtonVisible = false;
     myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
    } 
   
   
    else if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0)
    {
     fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
     var graphic2:Graphic = Graphic(event.currentTarget);
     var htmlText2:String = graphic2.attributes.htmlText;
     var mytextArea2:TextArea = new TextArea();
     mytextArea2.htmlText2 =  "<b>Measure: </b>" + graphic2.attributes.ForDirIndOut.toString()
     myMap.infoWindow.content=mytextArea2
     myMap.infoWindow.label = graphic2.attributes.NAME;
     myMap.infoWindow.closeButtonVisible = false;
     myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
    }
0 Kudos
ionarawilson1
Deactivated User
Here is the error when I click on the null value:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
0 Kudos
YungKaiChin
Regular Contributor
Let's simplify it a bit ...

=============
var graphic:Graphic = new Graphic(event.currentTarget);
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();

if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0){
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
}
else if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0){
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
}
mytextArea.htmlText = "<b>Measure: </b>" + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=mytextArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
0 Kudos
ionarawilson1
Deactivated User
Thank  you Yungkai!

It makes sense not having to repeat the same thing again! Thanks!!!
0 Kudos