greatmaps icon indicating copy to clipboard operation
greatmaps copied to clipboard

Fractional Zoom using WinForms version

Open TAlecksen opened this issue 7 years ago • 5 comments

It appears the fractional zoom capability is not working as stated in the code itself. I have attempted to resolve this for a few days now with no luck. Although it works fine when zooming from a 'centered' location, once the map is panned a little and then I attempt to zoom in (with fractional zoom on) the map appears to be off center until the zoom level reaches a whole number again, at which point it gets centered to the correct location.

Does anyone have any insight on how to resolve this? I suspect the fix is in the DrawGraphics method, but I still have a long way to go to understand how the Core.renderOffset is utilized in order to resolve the problem itself.

TAlecksen avatar Mar 16 '17 21:03 TAlecksen

..yes its a tricky business, offset and scaling matrix is at play

radioman avatar Mar 17 '17 00:03 radioman

Fantastic control by the way!

Based on what I can see, it looks like the panning is handled by the TranslateTransform. The scaling is handled by the two lines in FromLatLngToLocal:

ret.X = (int)(Core.renderOffset.X + ((Core.renderOffset.X - ret.X) * -MapRenderTransform.Value));
ret.Y = (int)(Core.renderOffset.Y + ((Core.renderOffset.Y - ret.Y) * -MapRenderTransform.Value));

The thing I have not yet figured out is why the Core.renderOffset gets updated correctly when zooming in whole number, but not when the zooming is fractional. Anyone get anywhere with this?

TAlecksen avatar Mar 17 '17 15:03 TAlecksen

check https://github.com/radioman/greatmaps/blob/master/GMap.NET.Core/GMap.NET.Internals/Core.cs#L670

compensationOffset is equal positionPixel on zoom

radioman avatar Mar 17 '17 22:03 radioman

@TAlecksen, please do share your work if you come across any solution. I've the same issue, and trying to use ScaleTransform but it's tricky and only limited to WPF.

AliFlux avatar Mar 23 '17 08:03 AliFlux

@AliFlux I most certainly will if I manage to get anywhere.

TAlecksen avatar Mar 27 '17 19:03 TAlecksen