Delayed redraw when changing position

Topics: WPF
Feb 29, 2012 at 2:46 AM

I set Position and Zoom through code. When the zoom changes, the map redraws immediately. But when I change only the position, for instance during a pan operation, the map redraw is delayed.

Made this simple work around where I set the zoom twice, to ensure that it changes:



_gMapControl.Position = new GMap.NET.PointLatLng(latitude, longitude);

 _gMapControl.Zoom = zoom + 0.000001;

_gMapControl.Zoom = zoom;


where  _gMapControl is a GMap.NET.WindowsPresentation.GMapControl


That is a bit ugly. What to do?

Feb 29, 2012 at 8:28 AM

what do you mean 'redraw is delayed' ?

Mar 13, 2012 at 2:07 AM

I apologize for not replying. Forgot to tick the e-mail notification.

When I change the zoom, the map is redrawn immediately. I do not know the internals of your map update code, but it is like the redraw have been done when the Zoom property setter returns.

When I change only the position, then the map is not redrawn immediately. The rest of the application renders to reflect the new location, but the GMap control catches up later. It is like the redraw in this case is put on the dispatcher queue with a low priority or something.

 Made this improved hach to avoid setting the Zoom twice per frame

_gMapControl.Position = p;

_doAddEpsilonToZoomHack = !_doAddEpsilonToZoomHack;

_gMapControl.Zoom = _doAddEpsilonToZoomHack ? z + 0.00000001 : z;



 But still a bit smelly...

Mar 13, 2012 at 11:15 AM

i still don't get it, missing tiles are always loaded async, you can't avoid it

Mar 14, 2012 at 1:08 AM

I understand about the async loading of tiles. That is not the issue.

I took a look at the code.

I see that when I set the Zoom property, InvalidateVisual(true) is called. When I set the Position property, it is not.

Adding InvalidateVisual(true) to the Position property setter solves the problem.

Mar 14, 2012 at 2:00 PM

..strange, i get instant redraw even without calling invalidate, what OS do you use?

Mar 14, 2012 at 2:14 PM

Windows 7 SP 1

Machine type: 64 bit
OS version: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR version: 4.0.30319.261