Select to view content in your preferred language

Symbolizing layers on AGS 9.3 in Flex Viewer v2.2

3281
26
03-18-2011 10:16 AM
ChristinaKepler
Emerging Contributor
I'm using the latest v2.2 of the Flex Viewer against v9.3.1 of AGS. In my viewer, I'm using a FeatureLayer as follows:
<layer label="Wells" type="feature" visible="true" alpha="1"
                   info="widgets/InfoTemplates/SimpleInfoWinWidget.swf"
                   infoconfig="widgets/InfoTemplates/Wells_Simple.xml"
                   url="http://myServer/ArcGIS/rest/services/myService/MapServer/0"/>


The reason for this is so that I can leverage the InfoWindow functionality in the viewer, which doesn't work when the layer 'type=dynamic'.

Everything works as expected, but the layer is being symbolized with black circles (looks like a default setting) instead of the symbology from the server, as it does w/ AGS v10.

Question:  Is there a way to mimic the server-side symbology on the Flex client when using the v2.2 viewer against a v9.3.x service?
Tags (2)
0 Kudos
26 Replies
AlisonPage
Regular Contributor
Hi Robert,

I apologize for continuing to bother you with questions.  I'm trying to determine the best way to populate my popups.  I have several fields listed in my popup XML that may or may not have values depending on the project it's associated with. 

What I would like is to write an "if, else" script (I assume that's the best way) that will change the field to visible="false" if there are no values for that field.  Basically if there is no value, I don't want anything displayed for that field in my popup.  Is there a good way to do this?  I hope I explained it sufficiently.

Thank you,
Alison
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alison,

   I don't know the particulars of your workflow but why don't you have a particular config-Project1.xml that has popup xml files defined for the exact fields that will be there and another config-Project2.xml for the other project?
0 Kudos
AlisonPage
Regular Contributor
Hi Robert,

I thought about doing that but I can't have multiple popup xml files for one layer.  What I'm trying to do is something like this (Please excuse my lack of scripting language knowledge):

if { fieldname value="<null>" fieldname visible="false"; }
else { fieldname visible="true" }

Can you mold that into something that I could actually put in the <![CDATA[ ]]> area of the popup xml?

Thank you,
Alison
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alison,

   There actually is no CDATA portion that can be used in the PopUp xml. So that is not an option. You would have to create or extend your own PopUpRendererSkin.mxml and add the logic to that.

I thought about doing that but I can't have multiple popup xml files for one layer.


I still think you or I are missing something here. If you have a unique MAIN config.xml that is used for each project than that main config file can have a unique popup config xml for a particular layer.
0 Kudos
AlisonPage
Regular Contributor
I'm sorry when I said "project" earlier, I wasn't talking about a FlashBuilder project, I meant "estuary restoration projects" which are what I'm mapping.  Some restoration projects have photos that I want to show and some do not. As it turns out as I was pasting the code into this comment, I realized I had coded part of the xml wrong.  Everything is working as expected now.

Thanks for putting up with me,
Alison
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alison,

   I am interested in what you came up with.
0 Kudos
AlisonPage
Regular Contributor
So, here is my code for the pop-ups:
<?xml version="1.0" ?>
<configuration>
    <title>{PROJECT_NAME}:  {NEP_NAME}</title>
    <description>
        <![CDATA[]]>
    </description>
    <medias>
     <media type="image" title="{HEADER1}" imagesource="{IMAGE1}" caption="Photo by: {CREDIT1}" />
        <media type="image" title="{HEADER2}" imagesource="{IMAGE2}" caption="Photo by: {CREDIT2}" />
        <media type="image" title="{HEADER3}" imagesource="{IMAGE3}" caption="Photo by: {CREDIT3}" />
    </medias>
    <showattachments>false</showattachments>
</configuration>

And it works the way I'd like. When there is an image to show, the header, image, and photo credit appear with it.  When there is no image to show, none of the media fields show up.  I'm in the process of editing the mapmanager to put a camera icon on the points with images and a standard point on the ones without. I wanted to attached is a screenshot of a popup with images but couldn't put it in this forum unless it was a public URL (sorry). I also have to look into the popup skin to see about sizing my images to fill the borders.

Thanks,Alison
0 Kudos
AlisonPage
Regular Contributor
Hi Robert,
I'm getting the following errors when I try to do an export build for my flexviewer after I added the code to MapManager.mxml.  Please tell me what I'm doing wrong.

Errors:
See details for more information.
  Encountered errors or warnings while building project index.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
  Encountered errors or warnings while building project SearchWidget.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
  Encountered errors or warnings while building project WidgetContainerWidget.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
  Encountered errors or warnings while building project TOCWidget.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
  Encountered errors or warnings while building project MapSwitcherWidget.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
  Encountered errors or warnings while building project LayerListWidget.mxml.
    MapManager.mxml: Type was not found or was not a compile-time constant: UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueRenderer.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.
    MapManager.mxml: Call to a possibly undefined method UniqueValueInfo.


Code I added to my MapManager.mxml:
case "feature":
                    {
   var featureLayer:FeatureLayer = new FeatureLayer(url);
   featureLayer.addEventListener(FlexEvent.HIDE, featureLayer_hideHandler);
   featureLayer.alpha = alpha;
   featureLayer.id = label;
   featureLayer.name = label;
   featureLayer.maxAllowableOffset = maxAllowableOffset;
   featureLayer.outFields = [ '*' ]; // TODO: be smarter
   featureLayer.token = token;
   featureLayer.visible = visible;
   featureLayer.useMapTime = useMapTime;
   featureLayer.clusterer = clusterer;
             if (label == "NEP_Projects")
                           {
                               var picSymbol1:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_camera.png",30,30,0,0,0);
                               var picSymbol2:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_target.png",30,30,0,0,0);
                               var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer();
                               uniqueValuerenderer.attribute = "PHOTO";
                               var uniqueValueInfos:Array = [];
                               uniqueValueInfos.push(new UniqueValueInfo(picSymbol1, "Y"));
                               uniqueValueInfos.push(new UniqueValueInfo(picSymbol2, "N"));
                               uniqueValuerenderer.infos = uniqueValueInfos;
                               featureLayer.renderer = uniqueValuerenderer;
                          }
                          if (useAMF)
                          {
                               featureLayer.useAMF = (useAMF == "true");
                          }
                          if (mode)
                          {
                               featureLayer.mode = mode;
                          }
                          if (definitionExpression)
                          {
                              featureLayer.definitionExpression = definitionExpression;
                          }
                          if (proxyUrl && useProxy)
                          {
                              featureLayer.proxyURL = proxyUrl;
                          }
                             // example for hard-coding layer symbology, e.g. for pre-10.0 ArcGIS Servers
                            /* if (label == "Traffic Cameras") // the layer label in main configuration file
                          {
                              var picSymbol:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_camera.png",30,30,0,0,0);
                              var rend:Renderer = new SimpleRenderer(picSymbol);
                              featureLayer.renderer = rend;
                        } */
         layerObject.layer = featureLayer;
         featureLayer.addEventListener(LayerEvent.LOAD_ERROR, layer_loadErrorEvent);
         featureLayer.addEventListener(LayerEvent.LOAD, layer_loadEvent);
                              map.addLayer(featureLayer);
                              break;

-Alison
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Allison,

   You are simply missing the imports for those components:

import com.esri.ags.renderers.UniqueValueRenderer;
            import com.esri.ags.renderers.supportClasses.UniqueValueInfo;
0 Kudos
AlisonPage
Regular Contributor
Hi Robert,

It's been a while.. I was pulled away on a different project and now I'm back to my mapping application.  Thank you for the last post, with that code addition I was able to get the MapManager updated and do a project release build without it failing. I can't seem to get the icons I've set for my symbology to actually appear on my map though. Any thoughts?
Here is my code for specifying the icons:
if (label == "NEP_Projects")
      {
       var picSymbol1:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_camera.png",30,30,0,0,0);
       var picSymbol2:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_target.png",30,30,0,0,0);
       var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer();
       uniqueValuerenderer.attribute = "PHOTO";
       var uniqueValueInfos:Array = [];
       uniqueValueInfos.push(new UniqueValueInfo(picSymbol1, "Y"));
       uniqueValueInfos.push(new UniqueValueInfo(picSymbol2, "N"));
       uniqueValuerenderer.infos = uniqueValueInfos;
       featureLayer.renderer = uniqueValuerenderer;
      }

And in my xml file, I've added the following in the opening configuration tag:
<configuration label="NEP_Projects">


Is all that correct?
Thanks again,
Alison
0 Kudos