private void loadLayers(ref IMap pMap, Dictionary <string, string> dctLayers, Collection <string> colOnLayers) { Collection <string> colMissingLayers = new Collection <string>(); CSpatialSubs oSpatialSubs = new CSpatialSubs(); try { foreach (KeyValuePair <string, string> pair in dctLayers) { if (CMedToolsSubs.layerExists(dctLayers[pair.Key].ToString(), "I://GIS//Layers//")) // SConst.LayerLocation)) { pMap.AddLayer(oSpatialSubs.returnLayer(dctLayers[pair.Key].ToString(), "I://GIS//Layers//")); // SConst.LayerLocation)); } else { colMissingLayers.Add(pair.Key); } } for (int i = 0; i < pMap.LayerCount; i++) { ILayer pLayer = pMap.get_Layer(i); if (!colMissingLayers.Contains(pLayer.Name)) { if (!colOnLayers.Contains(pLayer.Name)) { pLayer.Visible = false; } } } } catch (Exception ex) { } finally { oSpatialSubs.Dispose(); } }