How to determine the vectorlayer's shape type??

Mar 2, 2012 at 10:47 AM

Hi guys!

I am working on a project using Dotspatial. but I got stucked-up because I need to decide the vectorlayer's shape type between the program but I am not getting the way to do it. Any suggestion are acceptable!!! 

Mar 4, 2012 at 10:46 AM

Hi,

I am not sure if this is exactly what you need, but here goes a try...
Supposed that you have a form with a map component (map1) and a legend (legend1), put the code below inside legend1's mouseClick event. Run it and load some point, line and polygons layers in your map. When you click on the layer name in legend, it should show a message with the type of vector.

Regards,

Evemar

        private void legend1_MouseClick(object sender, MouseEventArgs e)
        {
            foreach (IMapLayer lay in map1.GetAllLayers())
            {
                IMapFeatureLayer fLayer = lay as IMapFeatureLayer;
                if (fLayer != null)
                {
                    if (fLayer.IsSelected == true)
                    {
                        if (lay as IMapPolygonLayer != null)
                        {
                            MessageBox.Show("polygon");
                        }
                        else if (lay as IMapLineLayer != null)
                        {
                            MessageBox.Show("line");
                        }
                        else if (lay as IMapPointLayer != null)
                        {
                            MessageBox.Show("point");
                        }
                        else
                        {
                            MessageBox.Show("other vector type?");
                        }
                    }
                }
            }
        }

Mar 5, 2012 at 5:16 AM

Thanx for the code Evemar!

This has really helped me a lot.