Mapsui: NavigateTo animation ?

Created on 24 Oct 2018  路  8Comments  路  Source: Mapsui/Mapsui

Hello,
Any update on NavigateTo or ViewPort.Transform smooth animation ?

question

Most helpful comment

Hey, this is an open source project. Every one would be happy to see this. So join the community and make a PR for this.

All 8 comments

Not there yet. It should be possible to create your own Navigator implementation that does some kind of animation.

It is not possible yet to set your own INavigator implementation on the MapControl.

I was hoping mapsui had this feature as well.

Hey, this is an open source project. Every one would be happy to see this. So join the community and make a PR for this.

I see the Navigator is set only. This is because the Navigator needs the current instance of the MapControls Viewport and Map. If this was settable there would be a lot of options for mistakes where the Navigator could point to a different instance of the Map or Viewport. Not sure how to solve this. Perhaps Map and Viewport should be properties of the Navigator, so it does not need to be newed in MapControl.

In general I tend to use a lot of constructor injection in my other projects, but not yet in Mapsui. Should be thinking about this.

Let me know if I'm way off track here or not, but I think this feature is just like whenever a user on android or ios is pinching to zoom and panning while zooming, or scrolling the mouse on the map in wpf. I checked out out the code for that which gets all the parameters for that then feeds it into this method over and over again while zooming/touched and I think I could just pretty much copy this. Could I just proportion out 100 or so extents that gets from current extent to desired extent over 0.5 seconds then it'll pretty much just give it the look of zooming to the new location? I assume I'll have to watch out for any map iterations that will cause this to be canceled immediately. Like if while panning to a new extent someone taps on the map it'll need to just stop navigating.

_viewport.Transform is used for pinchzoom and is the more complicated case. The methods within Navigator do not use it. My idea was to change the methods of Navigator to do a gradual change over, say, 300 ms. Lets look CenterOn first. It now sets the center immediately. It should set center several times over 300 ms.

Timer
If you want 50 frames per second the interval should be (1000 ms / 50 = ) 20 ms. So, you could start a timer with a 20 second interval. I think it is best to not calculate all the immediate positions in advance but on the fly. So preserve the original center and the new center. On each timer update calculate the current center. In the first version use a linear interpolation.

Easing functions
Nice animations use some easing function. This is what I use in WPF scroll zoom and in animated-points. Take a look at the CalculateProgress method in AnimatedFeatures. It returns a value between 0 and 1 to indicate how far along the animation it is. If you use this progress value for interpolation it will look a lot nicer.

Canceling
Canceling during animation will be necessary at some point but let's ignore it for now. If we keep the animations short (300 ms?) it will not be a big problem.

I am going to create a new issue for this.

@mattmiley It's over here: https://github.com/Mapsui/Mapsui/issues/579

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kayumiy picture Kayumiy  路  9Comments

TarasParashchuk picture TarasParashchuk  路  4Comments

lukaszpitulski picture lukaszpitulski  路  8Comments

lukaszpitulski picture lukaszpitulski  路  5Comments

willy40 picture willy40  路  6Comments