ClemensFischer/XAML-Map-Control

Trying to follow an object on the map

Closed this issue · 4 comments

o4oren commented

I am not sure what is the right way to do this. I have an airplane which I represent via a canvas/path item on the map, and it updates it's location continuously.
It moves fine on the map.
But I want the map to follow the object. I tried several approaches, it seems that the map is only rendering a small rectangle around the original center location of the map when I do this:
` private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{

        var loc1 = new MapControl.Location(((FlightDataViewModel)this.DataContext).Position[0], ((FlightDataViewModel)this.DataContext).Position[1]);


        xMap.Center = loc1;
    }`

If I remove setting the Center, the map renders okay.

If I zoom out it looks like this:
1

The small rendered rect is at 0,0 (which is my original center in the xaml).

If I just comment out xMap.Center it renders fine, but of course, doesn't stay centered on the object:

2

o4oren commented

Thanks!
Both approaches are working, of course setting UpdateWhileViewportChanging creates a smoother experience.
Which one would you recommend? Is there a danger of app performance using UpdateWhileViewportChanging ? I am getting a constant stream of data from the source flight simulator software. I haven't noticed a problem with this so far.

It's up to you. However, I don't think it would make much sense to update the position more often than perhaps five times per second.

o4oren commented

What can I say, it's VERY smooth when I don't limit it. I get 60hz updates from the underlying code. And these are aircraft, they move fast, so with 0.2 seconds and if you zoom close enough you see jumps.
I'll play with it. What's the downside of UpdateWhileViewportChanging="true" though?

BTW, it's a great project and I appreciate your work here!