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

3989
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
RobertScheitlin__GISP
MVP Emeritus
Doug,

   That is correct, it will still show up in the TOC structure just unchecked. Currently there is no way to just add one layer of a map service as type dynamic and not have all the rest of the layers show up in the TOC.
0 Kudos
DougBrowning
MVP Esteemed Contributor
Someone before me was able to do that - looks like they used this.

toc.hideTopLevelItems = hideTopLevelItems;


public function set hideTopLevelItems( value:Boolean ):void
  {
   _hideTopLevelItems = value;
  
   // Propagate this property to child TOC components
   for each (var toc:TOC in _childTocs)
   {
    toc.hideTopLevelItems = _hideTopLevelItems;
   }
  }
0 Kudos
RhettZufelt
MVP Notable Contributor
Doug,

   That is correct, it will still show up in the TOC structure just unchecked. Currently there is no way to just add one layer of a map service as type dynamic and not have all the rest of the layers show up in the TOC.


Am I missing something here:

Seems that in the TOCWidget.xml 
<excludelayer mapservice="RCC WasteSites">0,2</excludelayer>
with 3 layers in my dynamic map service will only display layer id=1 in the TOC (and only draws that layer)?

Also, Doug,

I have seen some that have done similar and thier approach was to put all layers in the exclude list, then programatically remove the layers they want to see.  Depending on the amount of "work" it needs to do, might be easier than manipulating the visibleLayers array.


R_
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Rhett,

   I guess the only thing you missed is that Doug is not talking about the TOCWidget.
0 Kudos
DougBrowning
MVP Esteemed Contributor
Rhett.  This is exactly what I did at first and it worked great in my samples.  But when I started on the real one I found that I could only exclude whole map services.


Robert is correct I am talking about the MapSwitcherWidget.  But I am not tied to it.  Where is this TOCWidget?  Maybe I can use it or just use the code inside of it that is making the exclude work.

Edit:  I found the widget - Roberts.

Robert it looks like you give toc.excludelayers a Object that is the layer name, and id array, and basemap false?  Any hint into how you made this work would be great.

Thanks
0 Kudos
RhettZufelt
MVP Notable Contributor
Rhett,

   I guess the only thing you missed is that Doug is not talking about the TOCWidget.


Guess I should read the posts a little better 🙂

R_
0 Kudos
DougBrowning
MVP Esteemed Contributor
Did you modify the toc.exludelayers?

I am trying just this as a test but it is not working.


   excludedLayers = new ArrayCollection;
   
    var excludes:Object ={
     name: "MapTest",
     ids: [1,2,3,4,5],
     isbasemap: false
    }
    
    excludedLayers.addItem(excludes);
    toc.excludeLayers = excludedLayers;


Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Doug,

   You will have to dig into the code and look as there was multiple places that I added code to exclude sub layers.
0 Kudos
RhettZufelt
MVP Notable Contributor
Yes, I can succesfully manipulate the toc.excludeLayers, but is very specific about it's "needs".

If you tell it to remove a sublayer that isn't there, it ignores.
If you tell it to remove all ids, it will remove them, but keep the name in the TOC. need to exlude the layername without any sublayers defined if you want to completely remove from the TOC.

Might put a couple trace statements in as such:

      if(idsArray[0] == "")
       idsArray = null;
      var excludes:Object ={
       name: name,
       ids: idsArray,
       isbasemap: false
      }
      trace("excludes.name ",excludes.name);
      trace("excludes.name ",excludes.ids); 
             excludedLayers.addItem(excludes);


and change the excludlayer tag settings in the config to get an idea of the syntax/formatting required. But, if you get it right, it works.

I am not using any basemaps in my TOC, so I didn't have to mess with that section, I just let it add all basemaps to the exclude list, but as Robert mentioned, you would have to modify it anywhere that it getting called.

R_

On my LayerListWidget, I modified the toc.as portion of it to only add layers in the excluded layers list. Was a lot easier as my list to exclude was much larger than the list to include.
0 Kudos
RhettZufelt
MVP Notable Contributor
Doug,

Re-read the posts, and not quite sure what you need.  If you are trying to do this programatically, then you would want to have a go at the excludedLayers array.

However, it sounds kind of like you just want to be able to statically pick which layers/sublayers show in the TOC.  If that is it, Robert has the excludelayer tag in the config.xml that lets you exclude either a layer, or some/all of the sublayers.  No coding required.

R_
0 Kudos