A way to access a layer inside a map service without accessing it as a feature layer?

3986
22
Jump to solution
01-24-2013 10:39 AM
DougBrowning
MVP Esteemed Contributor
I want to access one layer of a map service to show it in a list.  I do not want to add it as a layer using /MapServer/0 in config.xml because then I lose the dynamic display properties that the /MapServer provides.  (The layer has 100,000 features so it blows up as a feature layer.) 

Can I get at it in a Map Service or is there a way to add a just layer in config.xml that is dynamic display wise?


Have tried many things. 

One was to publish a new map service each time but then there are so many map services the server bogs.

Second was to use setMaxAllowableOffset as in this post http://forums.arcgis.com/threads/49416-maxAllowableOffset-on-operationalLayers.  But the ZOOM_END does not seem to be firing in 3.1.  This blog post http://blogs.esri.com/esri/arcgis/2011/06/13/feature-layers-can-generalize-geometries-on-the-fly/ says that this concept is what ArcGIS Online does.


In the end all I want to do it be able to list layers multiple times, in multiple places, without having to create another Map Service all the time.  In other words granular control over how and where layers (not whole maps) are listed while still keeping the dynamic display properties). 

Concept: Kinda like ArcGIS Online where I am building a map up from multiple layers, each of which may be in a different map service.

Any ideas would be very appreciated, this has been struggled with for some time.

thanks
Tags (2)
0 Kudos
22 Replies
DougBrowning
MVP Esteemed Contributor
Thanks R_.  I do not think they (the ups) are going to want to use his widget so I have to recreate just that part.

I am surprised this was not build in from the beginning.  It is confusing that the <layer> tag is used for a map service.  Roberts is so much easier to understand (I have this map service and I want these layers from it). 

We will also be bringing in layers from other organizations and we may want to have one of the layers from their map service listed in one spot and another somewhere else.

I keep going to exclude layers like you say but i would really like to have a blank map and then load in layers as I go (since there will be 1,000+ layers over many map services - some in house, some not).  Just like how ArcMap works, you start with a blank TOC and then add in layers using a Add Data button - you think esri would have made them similar.  But when i drill down in the code to where a layer is actually added I eventually hit a spot where the source code is no longer supplied.  I have another feature that lets a user save the list of layers they picked out so that say the next day they can reload and keep working or send it to someone else (a save map).  I have it working with using exclude but the file is weird to look at since it actually lists the opposite of what they had.

I am trying to build the biggest web map ever but the code assumes just a little simple one is the issue I think.

I will go through Roberts code a 5th time and see if I can find it.

Thanks again.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Doug,

  I believe I have the functions named pretty straight forward... Look for stuff like filterOutSubLayer
0 Kudos
DougBrowning
MVP Esteemed Contributor
I do not have the full solution done but thought I would post this as it may help someone.

I found down in TOCMapLayerItem.as

    a function called createChildren() where the layers in the map service are added  I was able to add an if statement here to only list the layers (children) I want.  It just works off a global var for now (I know that is cheating).

my new code is under the else in the adding of dynamic map service layers section

else
            {
             /* OLD  layerInfos = _dynamicMapServiceLayerInfos;*/
    /* added by me */
    layerInfos = [];
    for each (var layerInfo:LayerInfo in _dynamicMapServiceLayerInfos)
    {
    
    
     if (Application.application.SubLayers.indexOf(layerInfo.name) != -1)
     {
      layerInfos.push(layerInfo);
     }
    
    }

I might need to add this above the else, if _isVisibleLayersSet is ever used but it does not seem to be used so far?

It does work in my demo great.  Going to work on an option to remove the map service name from the mapswitcher widget as well using toc.categories.

Thanks for the help and I will post the full solution when i get it.
0 Kudos