Markers move on map

Sep 28, 2010 at 8:03 PM

I was using version of GMap.Net WinForm edition. I would draw rectangles on the map by overriding the GMapMarker class as such:

Private RectWidth, RectHeight As Double

Public Sub New(ByVal topLeft As PointLatLngByVal bottomRight As PointLatLng)
        Dim pntTopLeft As New Drawing.Point(GMap.FromLatLngToLocal(topLeft).X, GMap.FromLatLngToLocal(topLeft).Y)
        Dim pntBottomRight As New Drawing.Point(GMap.FromLatLngToLocal(bottomRight).X, GMap.FromLatLngToLocal(bottomRight).Y)
        RectWidth = pntBottomRight.X - pntTopLeft.X
        RectHeight = pntTopLeft.Y - pntBottomRight.Y
End Sub

Public Overrides Sub OnRender(ByVal g As Graphics)
        Dim scaledWidth As Integer = RectWidth / mGMap.Projection.GetGroundResolution(mGMap.Zoom, Position.Lat
        Dim scaledHeight As Integer = RectWidth / mGMap.Projection.GetGroundResolution(mGMap.Zoom, Position.Lat
       g.FillRectangle(FillBrush, New System.Drawing.Rectangle(LocalPosition.X, LocalPosition.Y, scaledWidth, scaledHeight))
End Sub

This worked great. If I centered the map on a point using:

GMapControl.Position = New PointLatLng(Y, X)

The rectangles would move with the map and so remain in their correct location. (i.e. if I drew a rectangle on a street intersection, when I used CenterAt the rectangle would remain at that intersection).

Then I upgraded to the latest version of GMap.Net (changeset a58a060485bd) and now when I draw the rectangles, if I use the CenterAt method, the rectangles don't move with the map! They remain in their absolute X/Y positions - i.e. the map moves beneath them. If I pan with the right mouse button it is fine - the rectangles follow the map. But if I use the CenterAt command, they don't. And when using the CenterAt command - and therefore mesing up the rectangle locations - if I pan the map using the right mouse button, or if I zoom in or out, the rectangles return to their correct locations. Is there a change in functionality between the stable version and the latest changeset that I'm not aware of?

Thanks ;)

Sep 28, 2010 at 8:37 PM

what do you mean 'CenterAt' ?

Sep 28, 2010 at 8:52 PM

Oops sorry, it's getting late here in South Africa and I'm not thinking very clearly anymore. CenterAt is just the name of a subroutine I have in my app. What I mean is that if I center the map using the Position method, such as:

GMapControl.Position = New PointLatLng(Y, X)

Then the rectangles I drew don't follow the map. (They used to in version But as soon as I pan using the right mouse button, or if I zoom in or out, then the rectangles snap to their correct places.

Sep 28, 2010 at 11:28 PM

oh, i see, thats a bug, thanks for reporting this ;}

Sep 29, 2010 at 9:02 AM

Hehe, no prob. Just glad it's not something I was doing wrong!! :)

Sep 29, 2010 at 9:04 AM

P.s. thanks again for a fantastic product and fantastic support!

Sep 29, 2010 at 9:39 AM

it's fixed now, carry on! ;}