This project has moved. For the latest updates, please go here.


Topics: General Topics
Aug 6, 2012 at 1:39 PM


I have built the example outlined in the SharpMap tutorial and have it running in my project. All I need for it to do is to center on ( and eventually place a marker on ) a set of user input geodetic coordinates ( WGS 84 coordinate system ).  This seems to me like it should be an extremely simple task, but so far I have been unable to find it here.  I am able to move the map to any position and zoom using the:

mapBox1.Map.Center.X = ####;

mapBox1.Map.Center.Y = ####;

mapBox1.Map.Zoom = ####;


So I figured all I needed to do was find a method that converted my latitude and longitude to image coordinates. Like this one outlined in the How To secion, "Transforming between image coordinates and world coordinates."



System.Drawing.PointF p = mapBox1.Map.WorldToImage(new SharpMap.Geometries.Point(30, -95));

 Where I input my geodetic coordinates expected to get image coordinates to put back into here:

 mapBox1.Map.Center.X = p.X;

 mapBox1.Map.Center.Y = p.Y;

But the point p comes out equalling (0,0), so I have to assume for now that it is a little more complicated than this?  If anyone could push me in the right direction it would be helpful,


Aug 16, 2012 at 11:50 AM

Is the code that is not working being executed on an already initialized and displayed map?

As you can see here, if there is no valid map.Zoom  and map.Center value you are not getting the right result.
These functions are called internally if you invoke Map.WorldToImage.

If that is not the source of your problem, this is the first place to look for a solution to your problem.

Hth FObermaier