dragging the map 'out' of the control

May 12, 2010 at 6:08 PM


Does anyone know a way to prevent a user from dragging the map out of the control - to snap it back into the control, or to wrap it?

It seems like if you get overzealous with your dragging that you can lose the map for good, not to mention when dragging it around you can get ugly blank space when you drag a corner of the map to the center of the control. 

May 12, 2010 at 6:10 PM

what do you mean? Disable dragging? Set boundaries?

May 12, 2010 at 6:17 PM
Edited May 12, 2010 at 6:23 PM

Check out this screen shot:


Is there a way to prevent that behaviour?  I checked out the OnMapDrag event, but the delegate sub doesn't allow any overloads that might help you control it. 

If you do something like this.. myGmap.BoundsOfMap = New GMap.NET.RectLatLng(New GMap.NET.PointLatLng(90, -180), New GMap.NET.SizeLatLng(-90, 180)) you can't drag the map anymore.

May 12, 2010 at 6:26 PM
Edited May 12, 2010 at 6:27 PM

can you share the actual demo, i don't catch what's wrong, sorry ;}

May 12, 2010 at 6:33 PM

Umm, hmm.. In that screen shot I dragged the corner of the map to the middle of the GMap control - it's just showing that there's empty space between the corner of the control and the corner of the map.. Maybe I should have drawn a border around it hehe.

Is there a way to make the map wrap around or prevent that empty space?  If you still don't get it I'll figure out a way to send it to you.

May 12, 2010 at 6:36 PM
Edited May 12, 2010 at 6:39 PM


It's a WPF Application



<Window x:Class="MainWindow"
    Title="MainWindow" Height="379" Width="432" xmlns:my="clr-namespace:System.Windows.Controls;assembly=GMap.NET.WindowsPresentation" xmlns:my1="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation" WindowStyle="ThreeDBorderWindow" ResizeMode="CanMinimize">
        <my:GMapControl Height="302" HorizontalAlignment="Left" Name="traceMap" VerticalAlignment="Top" Width="420" />




Imports GMap.NET
Imports GMap.NET.WindowsPresentation

Class MainWindow
    Public Sub New()
        ' This call is required by the designer.
        With traceMap
            .MapType = MapType.BingHybrid
            .MinZoom = 1.5
            .MaxZoom = 12
            .Zoom = 1.5
            .CurrentPosition = New GMap.NET.PointLatLng(40, 0)
            .CanDragMap = True
            .DragButton = MouseButton.Left
            .MouseWheelZoomType = MouseWheelZoomType.MousePositionWithoutCenter
            '.BoundsOfMap = New GMap.NET.RectLatLng(New GMap.NET.PointLatLng(90, -180), New GMap.NET.SizeLatLng(-90, 180))
        End With

        AddHandler traceMap.OnMapDrag, AddressOf mapDragged
        ' Add any initialization after the InitializeComponent() call.
    End Sub

#Region "Map Events"
    Private Sub mapDragged()

    End Sub
#End Region
End Class


May 12, 2010 at 6:48 PM

demo just crash ;/

May 13, 2010 at 9:38 AM

any luck making working demo? ;}

May 13, 2010 at 8:00 PM
No, after looking at google maps and bing maps it looks like it has the same behaviour, they just wrap the map around and redraw the points to get around it. I've just made my control a fixed size and set the map in it. If you zoom in and out you can still break it so I'll probably remove that as well. I don't know why the demo was crashing.. do you have the GMap libs in your GAC or did you run the executable with them in the same folder? It works fine for me if I do that.
May 13, 2010 at 8:04 PM

libs are changing ;} if you do not provide your version, i can't use my version, which is latest ;}