Select to view content in your preferred language

Where can I find code?

1662
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
DasaPaddock
Esri Regular Contributor
0 Kudos
TrixieRife
Emerging Contributor
thanks. the only problem is, when I use the link, then launch my project, nothing shows up.
0 Kudos
andrewj_ca
Frequent Contributor
When you add this to the Flexviewer did you add it to the config file like this:

<layer label="States" type="feature" visible="true" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/>
0 Kudos
TrixieRife
Emerging Contributor
This is the code that I tried to use, although i subbed in the other URL, and had nothing showing.

<esri:Map id="myMap" load="zoomToUnitedStates()">
  <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"/>

Do I need to put the layer label tag and the other stuff in there somewhere? And if so, where? I tried taking out this entire thing and using the code you wrote, but I got all kinds of errors. I'm really bad at this and need all the help I can get
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Trixie,

   Andrew thought that you were using FlexViewer.

  Try this code:

 <esri:Map id="myMap" load="zoomToUnitedStates()">
  <esri:infoWindowContent>
   <mx:TextArea id="myTextArea" width="250" height="75"/>
  </esri:infoWindowContent>
  <esri:FeatureLayer id="fLayer"
         mode="snapshot"
         outFields="
  • "
  •          graphicAdd="fLayer_graphicAddHandler(event)"          url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5">    <esri:renderer>     <esri:SimpleRenderer>      <esri:symbol>       <esri:SimpleFillSymbol id="fillsym" style="solid" color="0x00FF00" alpha="0.6">        <esri:SimpleLineSymbol width="2" color="0x00FF00" alpha="1"/>       </esri:SimpleFillSymbol>      </esri:symbol>     </esri:SimpleRenderer>    </esri:renderer>   </esri:FeatureLayer> </esri:Map>


    import com.esri.ags.events.GraphicEvent;
       
       protected function fLayer_graphicAddHandler(event:GraphicEvent):void
       {
        // just so we can add tool tips
        event.graphic.toolTip = event.graphic.attributes.STATE_NAME + "\n";
        event.graphic.toolTip += "2007 Population " + event.graphic.attributes.POP2007;
       }
    0 Kudos
    TrixieRife
    Emerging Contributor
    Thanks Robert, that worked, at least I now get a map. But now, how do I get the states to light up/change color/display info box, when I mouse over them? I have a mouse over handler in the code, but I am missing something. Do I need a specific map for this to work? Or do I need to have code to tell it what to do? Thanks for the help!
    0 Kudos
    RobertScheitlin__GISP
    MVP Emeritus
    Trixie,

       The sample for how to do that is here:

    http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=FeatureLayer_MouseOver_Snapshot

    If you are wanting to get into development then you are going to have to learn how to look at the different code sample and determine what you need from them to use in your custom app.
    0 Kudos
    TrixieRife
    Emerging Contributor
    Thanks for the link Robert! Nope, not planning on getting into development. Just pinch hitting/cross training.... because I was asked to.
    0 Kudos
    TrixieRife
    Emerging Contributor
    This map is the one I've been trying to copy. I've tried to put the US map in, instead of the SC map. I can't get it to highlight on mouse overs, i get an error. Hence the oringal question, and the subsequent coding that has improved, but not solved my problem. Thanks
    0 Kudos