Dynamic Layer's visibleLayers property bug

2452
11
04-15-2011 07:47 AM
MichaelHaggerty
New Contributor
Hello.

I'm having trouble displaying this map service in the out-of-the-box 2.2 Flex Viewer: http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer

The service consists of one layer group that contains two child layers.  Here is a clip of the map service's REST interface:

"layers": [
        {
            "id": 0,
            "name": "Street Lights",
            "parentLayerId": -1,
            "defaultVisibility": false,
            "subLayerIds": [
                1,
                2
            ]
        },
        {
            "id": 1,
            "name": "Street Lights OH Feed",
            "parentLayerId": 0,
            "defaultVisibility": true,
            "subLayerIds": null
        },
        {
            "id": 2,
            "name": "Street Lights UG Feed",
            "parentLayerId": 0,
            "defaultVisibility": true,
            "subLayerIds": null
        }
]


The behavior that I'm seeing in the default out-of-the-box Flex Viewer 2.2 is as follows:

  1. Click checkbox next to each child layer

  2. Click checkbox next to layer group

  3. Click checkbox next to dynamic layer name

  4. No features are displayed on map


However, if only one of the child layers is turned on, then you can see that layer's features.

Here's a couple screenshots of the problem:
http://www.screencast.com/users/MikeHaggerty/folders/Jing/media/e6cb6f8d-2036-4bf4-ad4c-74412ceef2aa
http://www.screencast.com/users/MikeHaggerty/folders/Jing/media/ecacdbe3-d733-497f-8b8c-07bbe21ecb26

When debugging the application, I can see the visibleLayers property of the target layer being set correctly to [1,2] on line 115 of com.esri.viewer.components.toc.tocClasses.TocMapLayerItem.refreshLayer() after the layer group is turned on and both child layers are on.  However, when inspecting the Export Map operation URL, I notice that there is no layers URL param: http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer/...

If I manually manipulate the Export Map operation URL to include "layers=show:1,2", then the image is rendered just fine: http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer/...

By the way, I've tested this map service on ArcGIS.com, and it works fine.  Here's a map w/ this layer setup already: http://www.arcgis.com/home/webmap/viewer.html?webmap=adbf558f561c4c21a537dc0b70537673

Thanks for any help you can offer!
Mike
Tags (2)
0 Kudos
11 Replies
BjornSvensson
Esri Regular Contributor
This  should be fixed in version 2.3 that we released today.

  • Turning grouped layers on/off work as expected. (from the "What's New)

0 Kudos
MichaelHaggerty
New Contributor
Thanks, Bjorn.  I should have remembered that from the holistic testing.

Do you know of any workarounds to this problem that have been used before the API bug fix in case upgrading the API from 1.x isn't feasible?

Thanks!

p.s. Congrats on the 2.3 release!
0 Kudos
MichaelHaggerty
New Contributor
Bjorn,

I am experiencing the same issue w/ Flex Viewer 2.3.  Here's a screenshot.

0 Kudos
BjornSvensson
Esri Regular Contributor
Mike, what does the REST requests look like?  Is there anything "funky" with the map service? 🙂  Does the service work in other applications? Can you try running your app on the webserver (i.e. http://...) instead of the file system?
0 Kudos
MichaelDoolen
New Contributor
I tested the map service using agslib-2.3-2011-04-14 and the TOC from the latest flexviewer-2.3.  It behaved as Mike H. described above.  Note:  the map service group layer 0 defaultVisibility=false.  The two child layer's (1,2) defaultVisiblity=true. 

In my test I added another map service (service B) containing a group layer.  I did not find the same behaviour when toggling the TOC layers of service B.  Service B's group layer defaultVisibility=true as are the child layers. 

To test, can you either:

  • Set the defaultVisiblity=true on group layer 0

  • Set child layers 1 and 2 defaultVisibility=false.

0 Kudos
MichaelHaggerty
New Contributor
Bjorn,

The REST request looks like the URL that I pasted above.  http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer/...

I have placed the Flex Viewer configured w/ this layer out in my dropbox public directory.  I won't assure that this link will work for all time and eternity, but it should for the next few weeks at least. http://dl.dropbox.com/u/14170337/sh-issue-april-2011/index.html

Thanks for your help with this!

Mike
0 Kudos
BjornSvensson
Esri Regular Contributor
http://dl.dropbox.com/u/14170337/sh-issue-april-2011/index.html


httpfox shows a 404 error for http://secure.sterling-heights.net:32457/crossdomain.xml

Also, using the Adobe Flash Player debug version, I get the following error:
SecurityError: Error #2048: Security sandbox violation: http://dl.dropbox.com/u/14170337/sh-issue-april-2011/index.swf cannot load data from http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer?....

Try adding a crossdomain.xml file on your ArcGIS Server machine and see if that helps 🙂
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Michael,

Strange I can get this url to work:

http://secure.sterling-heights.net:32457/ArcGIS/rest/services/GIS_Maps/City_Utilities_Map/MapServer/...

Maybe the API team will know why the request is not coming back the way that they are sending it from the API.
0 Kudos
MichaelHaggerty
New Contributor
@bjorn,

I am not seeing the same 404 as you.  See attachment #1.

@rscheitlin,

Yes, adding the layers query param to the URL will export the image.  The problem is that the API is not adding that query param to the URL.  See attachment #2.  How did you get that URL above?  Did you manually add the &layers=show%3A1%2C2 part, or is that how the Flex API constructed the URL?

Thanks,
Mike
0 Kudos