This project has moved and is read-only. For the latest updates, please go here.

Map center point animation

Feb 12, 2013 at 3:50 PM
Hi Clemens.

Good job on your control. Sure saved me a lot of work and grief.

I have a question on your map animation. I'm writing an application that tracks the progress of the user on the map using a cursor. As the cursor gets close to the edge of the map my application nudges the map over to keep the cursor visible. I am doing this by changing map.Center. The code all works but the map snaps over to the new location rather than engaging the animation.

First, am I using the Center property as intended? I've stepped thru the code and it seems the condition is never met that creates the animation. The code around TargetCenterPropertyChanged never seems to get to the centerAnimation = new PointAnimation line.
Feb 12, 2013 at 5:38 PM
Hi Ernie,
you have to set the TargetCenter property instead of Center to get an animated transition of the map center.
Sooner or later I'll have to write some documentation...
Feb 13, 2013 at 3:24 PM
Seems that I tried that as well with the same result. If I step thru the code and ‘correct’ what I think is a bug<br>
private bool CoerceCenterProperty(DependencyProperty property, ref Location center)<br>
Location coercedValue = CoerceLocation(center);<br>
if (!coercedValue.Equals(TargetCenter))<br>
Changed the original ‘center’ to ‘TargetCenter’ otherwise the coercedValue always equals ‘center’ because ‘center has already been set to the value that your wanting to coerce to.<br>
With the change, the code tries to coerce TargetCenter and will then go to TargetCenterPropertyChanged. Problem is, it never gets past the
if (!internalPropertyChange)<br>
so that it can create a new PointAnimation.<br>
Maybe I’m misunderstanding what your code has in mind, in which case you can/will set me right. <br>
Ernie friesen<br>
From: ClemensF [mailto:[email removed] <br>
Sent: Tuesday, February 12, 2013 9:39 AM<br>
To: [email removed]<br>
Subject: Re: Map center point animation [xamlmapcontrol:432854]<br>
From: ClemensF<br>
Hi Ernie, <br>
you have to set the TargetCenter property instead of Center to get an animated transition of the map center.
Sooner or later I'll have to write some documentation...<br>
Read the full discussion online.<br>
To add a post to this discussion, reply to this email ([email removed])<br>
To start a new discussion for this project, email [email removed]<br>
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on<br>
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at
Feb 13, 2013 at 5:31 PM
Edited Feb 13, 2013 at 6:30 PM
Hard to read, why don't you just write plain text? Figured it out anyway.

The code
Location coercedValue = CoerceLocation(center);
if (!coercedValue.Equals(center))
simply checks if the CoerceLocation call returned a changed, i.e. coerced value, which happens only rarely. Under most circumstances coercedValue equals center.

The only thing that might be confusing here is that the method returns a boolean value which is never used anywhere. I'm going to change that now.
Oct 15, 2013 at 9:50 PM
It is not easy to read, but I think it does what I'm trying to do.

I want to move the map to a point I just created.

I modifed the center, it did not move.
        map.Center.Latitude = latitude;
        map.Center.Longitude = longitude;

        map.TargetCenter.Latitude = latitude;
        map.TargetCenter.Longitude = longitude;
Thanks for the support.
Oct 15, 2013 at 10:20 PM
Pat, it's the same mistake you made before. You have to assign a new Location instance to the Center or TargetCenter property:
map.Center = new Location(latitude, longitude);
map.TargetCenter = new Location(latitude, longitude);