Shapefile as map

Topics: General Topics, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Nov 13, 2012 at 3:15 PM

Hello! 

I use shapefiles for my map.

I added shapefile in my map:

Size picSize = new Size(600,400);		   
			Map myMap = new Map(picSize);
			myMap.MinimumZoom= 100;
			VectorLayer map_layer = new VectorLayer("MyMap");
			map_layer.DataSource = new ShapeFile("bin/Debug/land_polygons.shp",true);
			map_layer.Style.Fill = new SolidBrush(Color.Green);
            map_layer.Style.Outline = Pens.Black;
            map_layer.Style.EnableOutline = true;
            map_layer.SRID = 4326;
            myMap.Layers.Add(map_layer);

But my WindowsForm is empty... Why?

Also, I trying do this with MapBox

VectorLayer map_layer = new VectorLayer("MyMap");
			map_layer.DataSource = new ShapeFile("bin/Debug/land_polygons.shp",true);
			map_layer.Style.Fill = new SolidBrush(Color.Green);
            map_layer.Style.Outline = Pens.Black;
            map_layer.Style.EnableOutline = true;
            map_layer.SRID = 4326;
            mapBox1.Map.Layers.Add(map_layer);
But Form is empty.. Help me please. Thank you!

Editor
Nov 13, 2012 at 3:38 PM

I'm newbie in SM but try with:

mapBox1.Map.ZoomToExtents();

 

Nov 14, 2012 at 12:54 PM

Thanks, but did not help. I want at least that is displayed on my form. :) As long as it was a local map. What else can advise?I would be grateful for any help. :)

Coordinator
Nov 14, 2012 at 1:37 PM

In case of your first example you are missing

myMap.ZoomToExtents();
Form1.Image = myMap.GetMap();
//Not sure if his is necessary?
Form1.Invalidate();

In case of your second example you are missing

// as Tummi said:
mapBox1.Map.ZoomToExtents();
mapBox1.Refresh(); // or .Invalidate();
Hth FObermaier