
Hi
I am trying to add a utm grid on my map layers (something like gray horizontal and vertical lines that each one shows a specific utm coordinate).
But i couldn't find something in dotspatial or its extensions out of the box.
So i need help for adding this feature on top of map layers.
Thanks.
for example like these blue lines:



I am also looking for a way to draw grid lines on map..Is there any idea how to do it?



I think first you need to draw some graphic lines from coordinates, starting from the origin of the coordinate system and then generate this line at constant interval say the grid spacing DX and DY to give the grid lines and finally label these lines with
the X or Y values at each location.
I guess you can draw a line with this code
void DrawLine( double x1, double y1, double x2, double y2, int pixelWidth, Color color)
{
//Set point 1 as x = 100, y = 100
x1 = 50
y1 = 50
'Set point2 as x = 500, y = 500
x2 = 100
y2 = 100
//Set pixel width for the line as 1
width = 1
//Set the color for the line as green
col = RGB(0, 255, 0)
//Create new drawing layer on map
draw_hndl = Map1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlScreenReferencedList)
'Draw green line from point 1 to point 2
Map1.DrawLine x1, y1, x2, y2, width, col
}
lets try and figure out the rest



I do it ..
Go to map Control find Onpaint override method
paste this code after existing code
System.Drawing.Point pt1, pt2;
System.Drawing.Graphics mapGridHorizentalLine = map1.CreateGraphics();
Pen pen = new Pen(Color.LightGray);
float[] dashValues = { 2, 2, 2, 2 };
pen.DashPattern = dashValues;
Font lblFont = new Font("tahoma", 8);
Brush lblBrush = new SolidBrush(Color.Cyan);
Coordinate startPoint = new Coordinate();
startPoint = map1.PixelToProj(new System.Drawing.Point(0, 0));
Coordinate endPoint = new Coordinate();
endPoint = map1.PixelToProj(new System.Drawing.Point(map1.Width, map1.Height));
Coordinate st1 = new Coordinate(startPoint);
Coordinate en1 = new Coordinate(endPoint);
for (int i = (int)endPoint.Y + 1; i < startPoint.Y; i += 2)
{
st1.Y = i;
en1.Y = i;
pt1 = map1.ProjToPixel(new Coordinate(st1));
pt2 = map1.ProjToPixel(new Coordinate(en1));
mapGridHorizentalLine.DrawLine(pen, pt1, pt2);
mapGridHorizentalLine.DrawString(Convert.ToString(i) + "°", lblFont, lblBrush, pt1);
}
//Vertical UTM Grid Line
st1 = new Coordinate(startPoint);
en1 = new Coordinate(endPoint);
for (int i = (int)startPoint.X + 1; i < endPoint.X; i += 2)
{
st1.X = i;
en1.X = i;
pt1 = map1.ProjToPixel(new Coordinate(st1));
pt2 = map1.ProjToPixel(new Coordinate(en1));
mapGridHorizentalLine.DrawLine(pen, pt1, pt2);
mapGridHorizentalLine.DrawString(Convert.ToString(i) + "°", lblFont, lblBrush, pt1);
}

