ThinkGeo.com    |     Documentation    |     Premium Support

How to get all the layers' PathFileNames opened?

Hi,


Is there a easy way in Map Suite 3.0 to get all the static overlay's  PathFileNames opened in the map window?


In Map Suite 2.0, I looped through all the Image layers first, then looped through all the layers to store the PathFileNames of the layers, so next time when the application starts, it will automatically open them one by one.


Here is the code snippet I did in Map Suite 2.0, how to do the same job in ver 3.0? Thx!


 For Each lyr As ImageLayer In Map1.ImageLayers




  swSave.WriteLine(lyr.PathFileName)




Next


For Each lyr As Layer In Map1.Layers 


    swSave.WriteLine(lyr.ShapeFile)


Next



Rose, 
  
 Here is the corresponding codes for 3.0. Vector Layers and Raster Layers are both added to an overlay, so you need only one loop and so some checking for the type. 
 
For Each lyr As Layer In winformsMap1.StaticOverlay.Layers 
   If TypeOf lyr Is GdiPlusRasterLayer Then 
       sw.WriteLine(DirectCast(lyr, GdiPlusRasterLayer).PathFilename) 
   ElseIf TypeOf lyr Is ShapeFileFeatureLayer Then 
       sw.WriteLine(DirectCast(lyr, ShapeFileFeatureLayer).ShapePathFileName) 
   End If 
Next 
 
 Thanks, 
  
 Ben