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

How to Pan by dragging the picturebox?

Topics: General Topics, SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Jun 15, 2010 at 1:40 AM

Hi, everyone

I'm totally a fresher. I want to pan a map by dragging the picture box.

And I've already knew how to relocate the center of a map by the belowing code:

                thisMap.Center = thisMap.ImageToWorld(pbMap.PointToClient(MousePosition));
                pbMap.Image = thisMap.GetMap();
//pbMap is the picturebox

But what I want is not this kind of effect.

Please help me! I'm waiting online.


Jun 15, 2010 at 10:49 AM

Hello ichelite,

why don't you use MapImage- or MapBox-Control of the SharpMap.UI assembly? They provide a set of interactivity tools, including Pan/Zoom/Query.

Hth FObermaier


Jun 16, 2010 at 7:54 AM

Hi, Fobermaier

Thank you for your advise:)

you mean I'd better importing the SharpMap.UI namespace and using the method and funtion of the UI assembly?

I'm going to try tonight.

Ps: I've never used the UI assembly before.


Jun 16, 2010 at 8:15 AM

that's the idea...

You should have no problems. If you have trouble getting started, have a look at the WinFormsSample or DemoWinForm project.

Hth FObermaier