[Solved]Map rotation

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Oct 7, 2010 at 3:36 PM

Hi Team,

One question Is we can we have map rotation function, to rotate the map with 0 degree, 45 degree, and 90 degree, based upon the image click for windows form.

Please provide me some code example.

Thanks for the kind help.

 

Vivek Kumar

Coordinator
Oct 7, 2010 at 3:50 PM

Hello Vivek Kumar,

you can apply a System.Drawing.Matrix to the SharpMap.Map.MapTransform property that has been initialized with some rotation angle. I assume (havn't tried) that the image will be ok, but the navigation will probably behave odd. It is likely that you'll have to work on that topic, as well as on the fact that you need to expand the BoundingBox in which to query for features.

Hth FObermaier

Oct 7, 2010 at 7:19 PM

Hi Hth FObermaier,

Please help with some code example.

Thanks,

Vivek

 

Coordinator
Oct 8, 2010 at 6:38 AM

Hello Vivek

try this:

 

...

//Zoom to extents
map.ZoomToExtents();

//Apply rotation
var mat = new System.Drawing.Drawing2D.Matrix();
mat.RotateAt(45f, map.WorldToImage(map.GetExtents().GetCentroid()));
map.MapTransform = mat;

var img = map.GetMap();
img.Save("osmexcel.bmp");

...

Hth FObermaier

 

Oct 8, 2010 at 8:44 AM

Hi Hth FObermaier,

It's works like a charm.

Thanks for the reply.

Thanks,

Vivek