This project has moved. For the latest updates, please go here.


Topics: SharpMap v0.9 / v1.x
May 18, 2011 at 9:46 AM

i'm new to sharpmap and i've this simple code from WinFormSamples.Samples in the sharpmap distribution:

            //Initialize a new map of size 'imagesize'
            SharpMap.Map map = new SharpMap.Map();

            //Set up the countries layer
            SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("FABBRICATI");

            //Set the datasource to a shapefile in the App_data folder
            layCountries.DataSource = new SharpMap.Data.Providers.PostGIS(Properties.Settings.Default.PostGisConnectionString, "foglio31_plg","the_geom", "gid");

            //Set fill-style to green
            layCountries.Style.Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
            //Set the polygons to have a black outline
            layCountries.Style.Outline = System.Drawing.Pens.Black;
            layCountries.Style.EnableOutline = true;

            //Add the layers to the map object.
            //The order we add them in are the order they are drawn, so we add the rivers last to put them on top

            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            //map.Zoom = 200;
            map.BackColor = System.Drawing.Color.LightBlue;

            map.ZoomToExtents(); // = 360;
            map.MinimumZoom = 100;
            map.Center = new SharpMap.Geometries.Point(0, 0);

            Matrix mat = new Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            return map;


but the map is not displayed...

the table in the data provider is correctly displayed with Quantum Gis

i use sharp map v 0.9

what I have wrong?

sorry for my english


May 18, 2011 at 11:18 AM

You are missing a call to map.ZoomToExtents()

May 18, 2011 at 11:36 AM

oh no...

now is ok...

thanks :)