Select to view content in your preferred language

Symbolizing layers on AGS 9.3 in Flex Viewer v2.2

3029
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
RobertScheitlin__GISP
MVP Emeritus
Christina,

   Yes but it involves changing the MapManager.mxml code.
0 Kudos
ChristinaKepler
Emerging Contributor
Thanks for the quick response Robert.

After a quick search I couldn't find any other forum threads where the changes to MapManager.mxml were explained.  And it looks like the only references to symbology in MapManager.mxml are for drawing tools.  Do you know if these changes have done elsewhere and if so, where I could get additional details?

Barring that, is the FeatureLayer/AGS MapServer service the only option I have for displaying InfoWindows in v2.2 of the Flex Viewer w/ a 9.3.1 AGS service?  Or has someone else overcome that as well?

Thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Christina,

  I couldn't remember if you were one of those who was not using the source code.

So here is a snippet of what I do in my MapManager.mxml in the addLayerToMap function.

                    case "feature":
                    {
                        var featureLayer:FeatureLayer = new FeatureLayer(url);
                        featureLayer.addEventListener(FlexEvent.HIDE, featureLayer_hideHandler);
                        featureLayer.alpha = alpha;
                        featureLayer.id = label;
                        featureLayer.name = label;
                        featureLayer.outFields = [ '*' ];
                        featureLayer.token = token;
                        featureLayer.visible = visible;
                        featureLayer.useMapTime = useMapTime;
      if (label == "Traffic Cameras")
      {
       var picSymbol:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_camera.png",30,30,0,0,0);
       var rend:Renderer = new SimpleRenderer(picSymbol);
       featureLayer.renderer = rend;
      }
      if (label == "Louisville Police Facilities")
      {
       var picSymbol0:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_policestation.png",30,30,0,0,0);
       var rend0:Renderer = new SimpleRenderer(picSymbol0);
       featureLayer.renderer = rend0;
      }
      if (label == "Louisville Places")
      {
       var picSymbol2:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/bat.png",30,30,0,0,0);
       var picSymbol3:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/horse.png",30,30,0,0,0);
       var picSymbol4:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/mansion.png",30,30,0,0,0);
       var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer();
       uniqueValuerenderer.attribute = "NAME";
       var uniqueValueInfos:Array = [];
       uniqueValueInfos.push(new UniqueValueInfo(picSymbol3, "Chuchhill Downs"));
       uniqueValueInfos.push(new UniqueValueInfo(picSymbol2, "louisville slugger factory"));
       uniqueValueInfos.push(new UniqueValueInfo(picSymbol4, "Whitehall Mansion"));
       uniqueValuerenderer.infos = uniqueValueInfos;
       featureLayer.renderer = uniqueValuerenderer;
      }
                        if (useAMF)
                        {
                            featureLayer.useAMF = useAMF == "true";
                        }
                        if (mode)
                        {
                            featureLayer.mode = mode;
                        }
                        if (definitionExpression && definitionExpression != "")
                        {
                            featureLayer.definitionExpression = definitionExpression;
                        }
                        if (proxyUrl && useProxy)
                        {
                            featureLayer.proxyURL = proxyUrl;
                        }
                        if (operationalLayer)
                        {
                            layerObject.layer = featureLayer;
                        }
                        map.addLayer(featureLayer);
                        break;
                    }
0 Kudos
ChristinaKepler
Emerging Contributor
Works like a charm, thanks Robert!

And thanks especially for the UniqueValueRenderer example which is exactly what I needed.
0 Kudos
AlisonPage
Regular Contributor
I had problems with this method working in viewer 2.4.  Is there a new set of code for 2.4?

Thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alison,

  This is what I have working in 2.4:

                    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 == "Louisville Places")
                        {
                            var picSymbol2:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/bat.png",30,30,0,0,0);
                            var picSymbol3:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/horse.png",30,30,0,0,0);
                            var picSymbol4:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/mansion.png",30,30,0,0,0);
                            var uniqueValuerenderer:UniqueValueRenderer = new UniqueValueRenderer();
                            uniqueValuerenderer.attribute = "NAME";
                            var uniqueValueInfos:Array = [];
                            uniqueValueInfos.push(new UniqueValueInfo(picSymbol3, "Chuchhill Downs"));
                            uniqueValueInfos.push(new UniqueValueInfo(picSymbol2, "louisville slugger factory"));
                            uniqueValueInfos.push(new UniqueValueInfo(picSymbol4, "Whitehall Mansion"));
                            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);
                        //featureLayer.addEventListener(GraphicEvent.GRAPHIC_ADD, addGraListeners);
                        map.addLayer(featureLayer);
                        break;
                    }
0 Kudos
AlisonPage
Regular Contributor
Hi Robert,
Thank you for the updated code. Is it possible to assign multiple pop-up XMLs to a single feature layer and use the definitionexpression property to distinguish the fields that are displayed in each pop-up?
Thank you,
Alison
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Alison,

   I don't know of a way for that to work.
0 Kudos
AlisonPage
Regular Contributor
Thanks for responding, at least I know I can rule that method out.

-Alison
0 Kudos