This project has moved and is read-only. For the latest updates, please go here.

Draw coordinate grid

Topics: SharpMap Project, WinForms Controls
Dec 12, 2010 at 4:21 PM

Help me, please. How i can draw a coordinate grid to a map with a SharpMap library?

Dec 13, 2010 at 12:23 PM

Can you give some more details on what you want to do?

What do you mean by a coordinate grid? What kind of data is it and do you have an example of this data?

Dec 13, 2010 at 7:44 PM

I just want to show coordinate grid - intersections of longitute and latitude with some fixed distance between intersections. Distance are changing depending of map zoom( if zoom larger - cell is large ). I hope You understand me. :(
And sorry for offtop - i want to use SharpMap v.2 - where i can get compiled binaries?

Dec 13, 2010 at 9:37 PM
Edited Dec 13, 2010 at 9:42 PM

This code should get you started i think

SharpMap.Geometries.Point firstPoint = new SharpMap.Geometries.Point(0,0);
SharpMap.Geometries.Point middlePoint = new SharpMap.Geometries.Point(1,1);
 SharpMap.Geometries.Point lastPoint = new SharpMap.Geometries.Point(2,2);
//a vertice is composed of several nodes
IList<SharpMap.Geometries.Point> verticesNodes = new List<SharpMap.Geometries.Point>();
 SharpMap.Geometries.LineString ls = new SharpMap.Geometries.LineString(verticesNodes);
//add this line and all the other lon/lat lines to a geometrycollection
SharpMap.Geometries.GeometryCollection gc = new SharpMap.Geometries.GeometryCollection();
//make a dataprovider with the geometrycollection
SharpMap.Data.Providers.GeometryProvider gp = new SharpMap.Data.Providers.GeometryProvider(gc);
//make a layer
 SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("lineLayer");
//set the datasource of the layer to the geometryprovider
vl.DataSource = gp;
//do some styling
vl.Style.Line.Color = Color.Black;
vl.Style.EnableOutline = true;
//add it to your map, which is already created elsewhere here


this is done with 0.9 code by the way. You can get this one as a compiled one and all the other versions you will have to build yourself.

Please have a look at the documentation for more about for instance the styling of your map etc.