DotSpatial Library : MapWindow Discussion Forum
Hi everyone, We have added a Plug-in into the MapWindow. Now, we open several layers. Some layers are chosen and some not. How to get the file name of layers which have been opened, and how to judge which layers have been chosen? Who can give me a example? thanks!
about layers open and choose
Posted by:
usename2012 ()
Date: September 27, 2010 03:07PM
Hi everyone,
We have added a Plug-in into the MapWindow. Now, we open several layers. Some layers are chosen and some not. How to get the file name of layers which have been opened, and how to judge which layers have been chosen?
Who can give me a example? thanks!
Edited 1 time(s). Last edit at 09/27/2010 06:35PM by usename2012.
We have added a Plug-in into the MapWindow. Now, we open several layers. Some layers are chosen and some not. How to get the file name of layers which have been opened, and how to judge which layers have been chosen?
Who can give me a example? thanks!
Edited 1 time(s). Last edit at 09/27/2010 06:35PM by usename2012.
Re: about layers open and choose
Posted by:
Shade1974 ()
Date: September 29, 2010 10:59AM
What do you mean chosen? Selected? The code for accessing data objects doesn't need to be this complex if you just want the name in the legend, but I don't know that the "Name" property on the low level dataset will have the complete path information that you might want. If it did, then you could just use that in all cases, but I think you need the Filename property which doesn't exist until you clarify that the DataSet is a FeatureSet, Raster, or ImageData object. In each of those cases, the "Filename" is what you are looking for.
Shade1974 (Ted)
Dr. Harold A Dunsford Jr.
MapWindow 6.0 & DotSpatial Initial Developer
GEI Consultants
string[] GetSelectedFilenames() { List<string> result = new List<string>(); List<ILayer> layers = map1.GetLayers(); foreach (ILayer layer in layers) { // Only worry about selected layers if (!layer.IsSelected) continue; // Just adding the text from the legend: // result.Add(layer.LegendText); // Adding full path filenames: IFeatureLayer fl = layer as IFeatureLayer; if(fl != null) { // Shapefile filename result.Add(fl.DataSet.Filename); } else { IRasterLayer rl = layer as IRasterLayer; if(rl != null) { result.Add(rl.DataSet.Filename); } else { IImageLayer il = layer as IImageLayer; if(il != null) { result.Add(il.DataSet.Filename); } } } } return result.ToArray(); }
Shade1974 (Ted)
Dr. Harold A Dunsford Jr.
MapWindow 6.0 & DotSpatial Initial Developer
GEI Consultants
Re: about layers open and choose
Posted by:
usename2012 ()
Date: September 30, 2010 07:28AM
Hello Ted
Thanks for your reply.
We read data from the graphics file carrying out other mathematical computation. This is the case which we often deal with. For example, we open a project with several layers: a,b ,c,d and e. Sometimes we need to read data from the all layers, and sometimes we only adopt the data from the layers such as a,b,d or c,e.
I have tried the above code, but it always shows " map1 is not declared. It may be inaccessible due to its protection level". I am working with vb2010.net and MapWindow.dll. Could you give a further suggestion?
Thank you in advance.
Best Regards.
Edited 2 time(s). Last edit at 09/30/2010 07:44AM by usename2012.
Thanks for your reply.
We read data from the graphics file carrying out other mathematical computation. This is the case which we often deal with. For example, we open a project with several layers: a,b ,c,d and e. Sometimes we need to read data from the all layers, and sometimes we only adopt the data from the layers such as a,b,d or c,e.
I have tried the above code, but it always shows " map1 is not declared. It may be inaccessible due to its protection level". I am working with vb2010.net and MapWindow.dll. Could you give a further suggestion?
Thank you in advance.
Best Regards.
Edited 2 time(s). Last edit at 09/30/2010 07:44AM by usename2012.
Sorry, you do not have permission to post/reply in this forum.


