Select to view content in your preferred language

Where can I find code?

1674
11
01-20-2011 09:27 AM
TrixieRife
Emerging Contributor
I am looking for code for a mouse over for the US. I want to be able to move the mouse over a state and have an info block pop up with specific info in it. Can someone direct me to where I might be able to find such a thing? I've looked through the samples on the API for Flex and there is one for South Carolina that is close to what I need, but I can't figure out how to get state borders as the boundaries instead of counties in SC. I've also downloaded the API's into Flash builder and there are things that are close, but not quite. And I'm too new at this to figure out how to change the code without getting a plethora of errors. Thanks for any help!
Tags (2)
0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus
Trixie,

   In that case then here is the code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="FeatureLayer - show InfoWindow on mouseOver">
 <!--
 This sample shows you how to display an InfoWindow on a mouse over ("map tips").
 -->
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.events.GraphicEvent;
   import com.esri.ags.geometry.Extent;
   import com.esri.ags.geometry.MapPoint;
   
   protected function fLayer_graphicAddHandler(event:GraphicEvent):void
   {
    event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
    event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
   }
   
   private function onMouseOverHandler(event:MouseEvent):void
   {
    var gr:Graphic = Graphic(event.target);
    gr.symbol = mouseOverSymbol;
    myTextArea.htmlText = "<b>2000 Population: </b>" + gr.attributes.POP2000.toString() + "\n"
     + "<b>2000 Population per Sq. Mi.: </b>" + gr.attributes.POP00_SQMI.toString() + "\n"
     + "<b>2007 Population: </b>" + gr.attributes.POP2007 + "\n"
     + "<b>2007 Population per Sq. Mi.: </b>" + gr.attributes.POP07_SQMI;
    myMap.infoWindow.label = gr.attributes.STATE_NAME;
    myMap.infoWindow.closeButtonVisible = false;
    myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
   }
   
   private function onMouseOutHandler(event:MouseEvent):void
   {
    var gr:Graphic = Graphic(event.target);
    gr.symbol = defaultsym;
    myMap.infoWindow.hide();
   }
  ]]>
 </fx:Script>
 
 <fx:Style>
  @namespace s "library://ns.adobe.com/flex/spark";
  @namespace mx "library://ns.adobe.com/flex/mx";
  @namespace esri "http://www.esri.com/2008/ags";
  @namespace components "com.esri.ags.components.*";
  
  components|InfoWindow
  {
   content-background-alpha : 0;
   background-color : yellow;
   background-alpha : 0.8;
   border-style : solid;
  }
 </fx:Style>
 
 <fx:Declarations>
  <esri:SimpleFillSymbol id="mouseOverSymbol" alpha="0.5">
   <esri:SimpleLineSymbol width="0" color="0xFF0000"/>
  </esri:SimpleFillSymbol>
  <esri:SimpleFillSymbol id="defaultsym" alpha="0.2">
   <esri:SimpleLineSymbol width="0" color="0xEEEEEE"/>
  </esri:SimpleFillSymbol>
 </fx:Declarations>
 
 <s:layout>
  <s:VerticalLayout/>
 </s:layout>
 
 <esri:Map id="myMap" level="4"
     load="myMap.centerAt(new MapPoint(-11713000, 4822000))">

  <esri:infoWindowContent>
   <mx:TextArea id="myTextArea"
       width="250" height="75"/>
  </esri:infoWindowContent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:FeatureLayer id="fLayer"
         graphicAdd="fLayer_graphicAddHandler(event)"
         mode="snapshot"
         outFields="*"
         symbol="{defaultsym}"
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/>
 </esri:Map>
</s:Application>
0 Kudos
TrixieRife
Emerging Contributor
Thanks Robert! It worked. I'm not sure what I had different. When I went through the codes, mine was almost identical. But odviously there was something out of place. thanks again.
0 Kudos