SharpMap apparantly Renders Shapefile but doesn't Show them...

Topics: SharpMap v0.9 / v1.x
May 27, 2010 at 1:42 PM

Hello everybody

I am currentl working on a very simple application that simply puts out shapefiles out a picture box. My Code looks as follows:

##################

 public void renderMap()
        {
            SharpMap.Layers.VectorLayer VLayer = new SharpMap.Layers.VectorLayer("TestLayer");

            SharpMap.Data.Providers.ShapeFile testFile = new SharpMap.Data.Providers.ShapeFile(@"E:\Schule\Baustellenkoord\salzburg shape\wa_la.shp");
            VLayer.DataSource = testFile;
            testMap.Layers.Add(VLayer);
            System.Drawing.Image imgMap = testMap.GetMap();
            pbOutput.Image = imgMap;
        }

#################

//Map Declaration in the Constructor of my WinForm

testMap = new SharpMap.Map(new Size(1000, 1000));

testMap.Size = new Size(1000, 1000);

#################

 

It appearantly does something because it is not giving a ErrorMEssage nor a Exception, but the map doesnt show up on the screen.

Thank you for every Help!

 

 

Coordinator
May 27, 2010 at 3:49 PM
Edited May 27, 2010 at 4:29 PM

In your code a call to

testMap.ZoomToExtents();

or some  other function defining the view bounds is missing.

It should be placed right before the call to testMap.GetMap() function.

Hth FObermaier

May 28, 2010 at 7:43 AM

I added the ZoomToExtension() now right before the getMap() function,

I also had it after the Map Declaration, but it still wont work.

I still get a blank screen, it is definitely not a problem with the shapefile

I already managed to output it via SharpMap in an earlier project, which was basically

the same, which is why I am so confused....

Coordinator
May 28, 2010 at 8:33 AM

Is that the only layer in the map? If not, the other layer might have a different coordinate system and you have to set up coordinate transformation.

Hth FObermaier

 

May 28, 2010 at 11:39 AM

Up to now it is the only layer that is inserted into the Map.

The next step would have been to add multiple layers , so thank you for the tipp anyway!