Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: How can I convert pixel coordinate to map coordinate for a gridline?

$
0
0
I have written a code to generate a gridline on the map1 but I am not able to convert the coordinate values to the map coordinate. Please can someone help me get this working.

I know its something line this "map1.PixelToProj(pixel X, pixel.Y, ref projected x, ref projected y);" but it does not seem to work for me at all
My code is below

System.Drawing.Graphics g = map1.CreateGraphics();
        System.Drawing.Graphics g = map1.CreateGraphics();
        Bitmap img = new Bitmap(100, 100);
        //System.Drawing.Graphics g = Graphics.FromImage(img);
        Pen drawingPen = new Pen(Color.Black, 1);

        int GridScrollOffset = 5;
        int GridSpacingX = 100;
        // Draw all visible, vertical gridlines
        for (int i = this.map1.Width - GridScrollOffset;
            i >= 0; i -= GridSpacingX)
        {
            g.DrawLine(drawingPen, i, 0, i, this.map1.Height);
        }       
        int GridSpacingY=200;

        //Draw all horizontal lines.
         //Pen p = new Pen(Color.FromName(YGridColor.Name));

        // Draw all visible, horizontal gridlines
         for (int j = this.map1.Height;
            j >= 0; j -= GridSpacingY)
        {
            g.DrawLine(drawingPen, 0, j, this.map1.Width, j);
        }

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>