This project has moved and is read-only. For the latest updates, please go here.

mouse can move the map in out of boundary

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Sep 21, 2010 at 3:08 PM

   Helow every one

please help me in this bug in my project

my sharpmap (WorldMap) properties is the ActiveTool is pan , when i put the cursor on the map and click continuously and move the mouse up, down, left,...,etc the map is move with the cursor.

The problem is when i click outside of the map and move the mouse the map is moving also and it can go out of screen to be dissapeared.

So if there are any solutions please help me, i hope the problem is clear for u.

(hint: my proj in visaul studio(C#)).

Sep 21, 2010 at 11:06 PM

hello banderes,

there is currently no way to prevent this. You can always call Map.ZoomToExtents() to get it back in

Hth FObermaier

Sep 22, 2010 at 6:59 AM

FObermaier thank u for ur reply,

so what are the suggestions of this bug?

Sep 22, 2010 at 8:08 AM

Add a toolbarbutton/menuitem to your application that invokes


and you should be all set.

Hth FObermaier

Sep 22, 2010 at 8:32 AM

FObermaier thank u very much and sorry if i bothered u

i try this function but the problem is i want to keep the zooming of the map

(i.e when the user zooming in the map and moving the map to find a place, it's big problem when the zoom backed to the default)

what i want is when the user move the map outside of boundary , the map doesn't response or when the map dissapear it is directly return to center of map view control.

Sep 22, 2010 at 8:51 AM


you could test if the resulting BoundingBox of the pan operation intersects at all with the extent of the map. If not, adjust the new GeoCenter so that the bounding boxes overlap by e.g. 10%.

Unfortunately I have no time whatsoever to implement that. If you have it worked out, submit a patch.

Hth FObermaier

Sep 22, 2010 at 9:59 AM

i'm not sure if this implementation is correctly or not but i set it in my project:

	   SharpMap.Geometries.Point lowerLeft = mapViewControl.Map.ImageToWorld(new PointF(mapViewControl.Location.X, mapViewControl.Location.Y + 1));
            SharpMap.Geometries.Point upperRight = mapViewControl.Map.ImageToWorld(new PointF(mapViewControl.Location.X + 1, mapViewControl.Location.Y));
            SharpMap.Geometries.BoundingBox box = new SharpMap.Geometries.BoundingBox(lowerLeft, upperRight);