This project is read-only.

Adding Group and Layer

Feb 21, 2011 at 10:29 PM

There are two ways to add a group and layer to the map in DotSpatial:

method one:

 

//new map group
MapGroup grp = new MapGroup();
grp.LegendText = "group1";
map.Layers.Add(grp);

//new map layer
FeatureSet fs = new FeatureSet();
fs.Open(filename);
MapPointLayer l = new MapPointLayer(fs);

//add layer to group
grp.Layers.Add(l);

 

method two:

 

//new map group added to map
MapGroup grp = new MapGroup(map, "group1");

//new map layer added to group
FeatureSet fs = new FeatureSet();
fs.Open(filename);
MapPointLayer l = new MapPointLayer(fs);

//add layer to group
grp.Layers.Add(l);

 

When using method one, the MapFrame property of the group and layer is NULL. Only when using method two, grp.MapFrame and layer.MapFrame are not null.

Is this behavior by design, or is this a bug?

Regards,

Jiri

Aug 23, 2012 at 3:50 AM
Edited Aug 23, 2012 at 4:12 AM

How to remove group and layer....

            Try
                For Each sewerGroup As MapGroup In AppManager.Map.MapFrame.GetAllGroups()
                    If sewerGroup.LegendText="NameGroupThen
                        'Remove group
                        AppManager.Map.Layers.Remove(TryCast(sewerGroup,IMapLayer))
                        'Remove all layers inside of group
                        'For j As Integer=sewerGroup.Count-1 To 0 Step -1
                        '    Dim layerMap As ILayer =TryCast(sewerGroup.Item(j),ILayer)
                        '    sewerGroup.Remove(layerMap)
                        'Next
                    End If            
                Next
            Catch ex As Exception
                MsgBox("Error: " & ex.Message)
            End Try   

 

camiza

Feb 16, 2013 at 12:38 PM
Edited Feb 16, 2013 at 12:40 PM
Hi,
Can you tell me the exact difference between the Map Group and the Map Frame.
I can have more than one map groups, can I have more than one Map frames at the same map control?
The map group is a subset of the map frame?
Frame 1 can have group 1 and group 4 and Frame 2 can have group1, 2 and 3?
How I create a new Map Frame?
The command on the legend popup menu Remove Map Frame seems to do nothing.
After execute I see the same result if I call Zoom to Map Frame as before.

Thank you

Thomas