Identify Widget for FlexViewer 2.1

46069
266
09-23-2010 11:34 AM
RobertScheitlin__GISP
MVP Emeritus
All,

   I have been waiting for the Final release of the FlexViewer 2.1 before I started to push out some widgets I have been working on.

Here is my Identify Widget for Flex Viewer 2.1. I have tested to ensure proper functioning with FlexViewer 2.1 and am now releasing it to you since the API Team did not get one into the FlexViewer.

Here is the link:

http://www.arcgis.com/home/item.html?id=39cf66d58c234279ba728c50461a1a89

More FlexViewer 2.1 widgets to come stay tuned...
Tags (2)
0 Kudos
266 Replies
RobertScheitlin__GISP
MVP Emeritus
Pascal,

   I will look into this.
0 Kudos
PaulPetersen
New Contributor III
Robert - thanks for this widget; it's a great tool!

I like how easy it is to set up a single link field, but it is possible to set up multiple link fields? We want some of our data to hyperlink to several different documents and other multimedia, so being able to have two or more link fields would be wonderful.

I apologize if I've missed something obvious, and thanks again for all your time!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

   Begin by removing all your layers from the IdentifyWidget.xml. There is no need to specify your layer in the identify widgets xml unless you want to limit the fields that are returned or specify a hyperlink field. If you are going to specify a hyperlink field that it has to be included in the fields list as stated in the text instruction of the IdentifyWidget.xml. That would mean that if you want a hyperlink field and all the other fields to show then you have to manually list all the fields in the field attribute.

   For testing purposes just remove all your layers from the IdentifyWidget.xml. Next ensure that your manholes are visible on the map and then attempt to identify them. Let me know the outcome.
0 Kudos
JasonNielsen
Occasional Contributor
I am working with Robert's latest Identify widget for Flex Viewer 2.1 and I have modified the code to exclude showing data from layers and fields not defined in the IdentifyWidget.xml configuration file. 

In the IdentifyWidget.mxml file, down in the function called processIdentifyResults there is a conditional if(IdentFields) which includes an else block.  I commented out that entire else block.  I believe that IdentFields holds all the fields that come from the configuration file, so blocking out anything not in IdentFields keeps all data not specified in the configuration file from being displayed. 

You'll need to be using Flash Builder or some other solution to modify and recompile the code, of course.

This may not be an elegant solution, and Robert may cringe at it, but it works for me.

Marc


I was trying to duplicate the results you had on the excluding all layers not in the IdentifyWidget.xml by commenting out the else block in the function called processIdentifyResults. I then recomplied it but i still get the layers to show up that are not in the IdentifyWidget.xml.

Here is the function with the code i commented out. I've try to clean the project, and build but i still get the layers to show up i didn't want to see.

 
   //process identify results
   private function processIdentifyResults(identifyResults:Array):void
   {
    if(!identifyArrayCollection)
     identifyArrayCollection = new ArrayCollection();
    for each (var identifyResult:IdentifyResult in identifyResults)
    {
     var title:String = identifyResult.layerName;
     var obj:Object = identifyResult.feature.attributes;
     var content:String = "";
     var fld:String;
     var value:String;
     var link:String = "";
     var linkicon:String = "";
     var identFields:String = "";
     var identLinkPre:String = "";
     var identLinkField:String = "";
     var identLinkSuffix:String = "";
     var identLinkIcon:String = "";
     var identLinkIconPre:String = "";
     var identLinkIconSuffix:String = "";
     var identZoom:Number = 0;
     var identForceScale:Boolean = false;
     
     for(var i:int=0; i<configIdentFields.length; i++)
     {
      if (identifyResult.layerName == configIdentFields.label)
      {
       identLinkField = configIdentFields.linkfield;
       identFields = configIdentFields.fields;
       identLinkPre = configIdentFields.linkpre;
       identLinkSuffix = configIdentFields.linksuffix;
       identLinkIconPre = configIdentFields.linkiconpre;
       identLinkIcon = configIdentFields.linkicon;
       identLinkIconSuffix = configIdentFields.linkiconsuffix;
       identZoom = configIdentFields.zoomscale;
       identForceScale = configIdentFields.forcescale;
      }
     }
     
     if(identFields) {
      var fldArr:Array = identFields.split(",");
      for (var f:Number = 0; f < fldArr.length; f++) {
       try{                            
        value = obj[fldArr].toString();
       } catch (error: Error){
        value = "";
       }
       if (fldArr.toUpperCase() == identLinkField.toUpperCase()){
        //concatenate
        link = identLinkPre + value + identLinkSuffix;
       } else if (fldArr.toUpperCase() == identLinkIcon.toUpperCase()){
        //concatenate
        linkicon = identLinkIconPre + value + identLinkIconSuffix;
       } else {
        content += fldArr + ": " + value + "\n";
       } 
      }
     } /* else {
      for (fld in obj)
      {
       try{                            
        value = obj[fld].toString();
       } catch (error: Error){
        value = "";
       }
       
       if (fld.toUpperCase() == identLinkField.toUpperCase())
       {
        link = value;
       } else {
        content += fld + ": " + value + "\n";
       }
      }  
     } */

     var idResult:IdResult = new IdResult();
     idResult.icon = widgetIcon;
     idResult.title = identifyResult.layerName;
     idResult.content = content;
     if(link!="")
      idResult.link = link;
     idResult.point = identifyPoint;
     idResult.geometry = identifyPoint;
     idResult.zoomScale = identZoom;
     idResult.zoom2msg = zoom2Msg;
     if(linkicon!="")
      idResult.linkicon = linkicon;
     idResult.forceScale = identForceScale;
     identifyArrayCollection.addItem(idResult);

    }
    clearMessage();
   }


It's probably something simple that i'm not seeing. Any Ideas? Also, i'm using Flash builder 4 to rebuild the mxml.

Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

    The next thing to check is in the ArcMap MXD do you have the objectID and Shapefield visible?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,


   When you go to the REST Service Directory Page for that map service and then one of the layers do you have an identify hyperlink option at the bottom of the page?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sorry that is what it is suppose to be. I am running out of ideas here and so far you are the only one reporting having an issue? Can you try to publish the MXD/MSD again under a different service name? I have seen rare occasions where the publish has just gone bad.
0 Kudos
SamBishop
New Contributor
Rob,

This is a really great widget, functionality I'm sure should be included in the viewer by default!  Would love to see some of the possible improvements already mentioned though, specifically:

1) The ability to exclude layers from the identify widget - perhaps only show info for those layers for which fields are defined in the config?

2) The ability to define multiple link fields

Thanks
Sam
0 Kudos
TimMcKinney
New Contributor
Robert,

I get the following error when using this widget:

Application Error
http response status: 200
Fault Code: Client.CouldNotDecode
Fault Info: Error #1085
Fault Details: null

Do you have any suggestions?

Thank you,
Tim
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tim,

    That normally indicates that you have a syntax error in one of your xml files.
0 Kudos