Select to view content in your preferred language

Infowindow for graphics layer

1491
17
04-26-2011 12:23 PM
codyhughes
Deactivated User
ok so the backstory is this...
i have a widget that upon selection of certain options it creates a graphics layer based on lat longs that were stored in an arraycollection. my issue is that upon clicking on that graphic on the map(lets call it gr) inside that graphics layer (call it gl) i want to display all attributes that the gr contains ideally like the identify widget so as not to have to format the "info pop up" too much or at all if i dont have to. I can not for the life of me figure out how to populate the popup .
on creation of each of the gr's i add event listener for a click on it which works.
so i guess my problem is which do i use....popup, infowindow, identitytask
and how would i implement it. could any one please help me out and at least steer me in the direction of a sample that does this. cus i have looked at alot of esri samples and they are all in mxml  and i need it in actionscript. oh and im using flexviewer 2.3

my gl creation loop
if(FullArfInfoArr.length > 0){
for (var i:int = 0;i<RecCnt-1;i++){
      if(!isNaN(FullArfInfoArr.getItemAt(i).fltSiteLON) && !isNaN(FullArfInfoArr.getItemAt(i).fltSiteLAT)){
            var point:MapPoint = new MapPoint(FullArfInfoArr.getItemAt(i).fltSiteLON,FullArfInfoArr.getItemAt(i).fltSiteLAT);
             var ptGraphic:Graphic = new Graphic(point);
  ptGraphic.geometry = WebMercatorUtil.geographicToWebMercator(point);
  ptGraphic.symbol = symMain;
      
ptGraphic.addEventListener(MouseEvent.CLICK,mapClickHandler);
        
graphicsLayer.add(ptGraphic);};
Tags (2)
0 Kudos
17 Replies
codyhughes
Deactivated User
Cody,

   The trace command is only for debugging and tells Flash Bulder to output the value to the outputs window.

Try this:

   private function configurePopUpInfo(i:int):PopUpInfo{
    var popUpInfo:PopUpInfo = new PopUpInfo;
    
    popUpInfo.title = "{strSiteName}";
    
    for each (var item:Object in FullArfInfoArr.getItemAt(i)){
     for (var field:String in item){
      popUpInfo.description += field + ": " + item[field] + "\n";
     }
    }
    return popUpInfo;
   }


so the problem is that it does not make it to the for loop. the item is actually returning the field's value so it skips the for loop .
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Cody,

    Can you post the function that makes the FullArfInfoArr?
0 Kudos
codyhughes
Deactivated User
Cody,

    Can you post the function that makes the FullArfInfoArr?


the creation is :
[Bindable]public var FullArfInfoArr:ArrayCollection = new ArrayCollection;

the population of data is from a webservice results :

public function gotFullArfInfo(e:ResultEvent):void{
    if(e.result.Tables.Table.Rows.length > 0){
     var table:* = e.result.Tables.Table.Rows;
     FullArfInfoArr = table;
     buildGLayer(1);
    }
   }

should i convert the ac into a feature set? then try that? i might have more options
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Cody,

   Have you done a trace of the FullArfInfoArr
trace(StringUtil.toString(FullArfInfoArr));


to see what the structure of the data looks like?
0 Kudos
codyhughes
Deactivated User
Cody,

   Have you done a trace of the FullArfInfoArr
trace(StringUtil.toString(FullArfInfoArr));


to see what the structure of the data looks like?


is this what you mean?

FullArfInfoArr.getItemAt(i) = mx.utils.ObjectProxy (@c8eb601)
dispatcher = flash.events.EventDispatcher (@c857ba1)
dtRequestReceived = <Fri Mar 25 17:44:00 GMT-0700 2011> (@c407481)
dtTimestamp = <Mon Apr 4 22:28:25 GMT-0700 2011> (@d4b4561)
EVENT_FK = 22 [0x16]
EVENT_ID = 2
fltSiteLAT = 47.asd
fltSiteLON = -122.sadf235467
ID = 677 [0x2a5]
_id = null
_item = Object (@a778911)
  dtRequestReceived = <Fri Mar 25 17:44:00 GMT-0700 2011> (@c407481)
  dtTimestamp = <Mon Apr 4 22:28:25 GMT-0700 2011> (@d4b4561)
  EVENT_FK = 22 [0x16]
  EVENT_ID = 2
  fltSiteLAT = 47.791228
  fltSiteLON = -122.235467
  ID = 677 [0x2a5]
  Source_FK = 0
  Status = "ASSIGNED"
  strAssistanceDescription = "sadfasdfasdf"
  strPSMA_PCN = "7"
  strRequestorEmail = "asdf"
  strRequestorName = "asdf"
  strRequestorOrganization = "asdf"
  strRequestorPhone = "asdf"
  strSiteAddress = "adsfasdfst sw"
  strSiteCity = "bothell"
  strSiteCountyFIPS = "asdf"
  strSiteName = "sadf"
  strSiteState = "wa"
  strSiteStatus = "Denied"
  strSiteZip = "asdf"
  strSOW = "asdf"
  strState = "WA"
  strStateFedRequest = "asdf"
  strStatusComments = "test"
  strUsername = "asd\\asdf"
notifiers = Object (@a778779)
object = Object (@a778911)
propertyList = [] (@c8e9f11)
proxyClass = Object (@8a4cd21)
_proxyLevel = -1 [0xffffffff]
Source_FK = 0
Status = "ASSIGNED"
strAssistanceDescription = "asdfadsfasdfadsfadsf."
strPSMA_PCN = "7"
strRequestorEmail = "asdfadsfasdf.asdf"
strRequestorName = "asdfasdf"
strRequestorOrganization = "asdfasdf"
strRequestorPhone = "asdfsadf"
strSiteAddress = "asdfasdf"
strSiteCity = "asdfl"
strSiteCountyFIPS = "asdfasdf"
strSiteName = "asdfasdf"
strSiteState = "wa"
strSiteStatus = "Denied"
strSiteZip = "asdf"
strSOW = "asdfasdfasdfasdfasdfadsf to perform the ...."
strState = "WA"
strStateFedRequest = "Federal"
strStatusComments = "test"
strUsername = "adsfasdf\\asdf"
type = null
_type = null
uid = "asdf-asdf-91D9-asdf-asdf"
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Cory,

   Maybe try :

   private function configurePopUpInfo(i:int):PopUpInfo{
    var popUpInfo:PopUpInfo = new PopUpInfo;
    
    popUpInfo.title = "{strSiteName}";
    
    for each (var item:Object in FullArfInfoArr){
     for (var field:String in item){
      popUpInfo.description += field + ": " + item[field] + "\n";
     }
    }
    return popUpInfo;
   }
0 Kudos
codyhughes
Deactivated User
Cory,

   Maybe try :

   private function configurePopUpInfo(i:int):PopUpInfo{
    var popUpInfo:PopUpInfo = new PopUpInfo;
    
    popUpInfo.title = "{strSiteName}";
    
    for each (var item:Object in FullArfInfoArr){
     for (var field:String in item){
      popUpInfo.description += field + ": " + item[field] + "\n";
     }
    }
    return popUpInfo;
   }


thats alot closer... but it gives me all the results of the ac. i only need the ones at the specific index... btw... you are awesome i really appreciate all the help
0 Kudos
codyhughes
Deactivated User
ok i got it finally!!! And thank you very much for all your great help!!!! here is the popupconfig solution for passing an ac to a graphic.attributes

popupconfig function:

public function configurePopUpInfo():PopUpInfo{
    var popUpInfo:PopUpInfo = new PopUpInfo;
   
    popUpInfo.title = "Site Name: " + "{strSiteName}";
    var content:String = "";
    //now build giant string to pass as attributes for point
    content = "<b>Event: </b> {event_name} \n"
    content += "<b>ArfID: </b>" + " {EVENT_ID}" + " \n";
    content += "<b>Site Status:</b> {strSiteStatus} \n";
    content += "<b>Site Address:</b> {strSiteAddress} \n";
    content += "<b>Site City:</b> {strSiteCity} \n";
    content += "<b>Site State:</b> {strSiteState} \n";
    content += "<b>Site Zip:</b> {strSiteZip} \n";
    content += "<b>Site County FIPS:</b> {strSiteCountyFIPS} \n";
                                                    popUpInfo.description = content;
    return popUpInfo;
   }

this works because i am passing an arraycollection to the graphic.attributes. also if you just want to loop through the entire a.c. you can use the below code instead of the manual build of the content string:

for each(var item:Object in FullArfInfoArr){
      for (var fld:String in item){
content += " <b>" + fld + ":</b>  {" + fld + "}\n "
}
}

its basically the same as the first code just it loops through all the fields.

also here is the setup for the info window that is inside the loop of creating the graphicslayer:
var infoWindowRenderer:ClassFactory = new ClassFactory(PopUpRenderer);
infoWindowRenderer.properties = {popUpInfo: configurePopUpInfo()};
graphicsLayer.infoWindowRenderer = infoWindowRenderer;
hope this helps explain my solution. Again thanks for all the help rscheitlin!
0 Kudos