ThinkGeo.com    |     Documentation    |     Premium Support

Retrieve ShapeFileFeatureLayer key

Hi all,


I'm new to whole Map Suite scene, and so far am having a great time with it.  One problem I've run into, however, is how to acess the key of a ShapeFileFeatureLayer.  Essentially, when I load up my map, I want several layers to be displayed.  When a particular check box is checked, I want the layer to be removed/dropped/invisible.  If there's a better way to do this than removing it from the map via key, though, I'd love to hear it.  Thanks in advance!


-DL



Dustin, 
  
   There is an easy way to do this.  On every Layer object there is an .IsVisible property.  Simply set this to false and the layer will not draw anymore.  In this way you can keep the order of your layers but show or hide them.  I think you will find we have a great community here so ask question anytime you get stuck. 
  
 David

Thanks David, that’s very helpful.  However, I still can’t figure out how one actually obtains the ‘layer’ past the initialization.  I’m assuming they would be store in the map they are placed in, but I’m at a loss on how to retrieve them from it.  Any advice?

Dustin, 
  
   What property are you using to add the layer to the map?  When you add the layer there should be an overload that allows you to add it with a key like : Map1.StaticLayer.Add("MyKey",myLayer).  Then when you want it back you can go back to the property and use something like : Map1.StaticLayers["MyKey"] and get it back.  You may have to cast it back to the ShapeFilefeatureLayer if you need special properties on it.  is this what you need?  Sorry I don;t have the API in front of me right now.  maybe I am missing the point all together, happens sometimes! :-) 
  
 David

Ah, that’s great David.  I never realized that the Add method was overloaded. I’m certain I looked at every other property and method I could find, but never thought to look there.  Thanks for the help!

Dustin, 
  
   No problem, let me know if you need any other help. 
  
 David