TB123


Hi... I'm trying to animate an icon/pin so that it moves along a specified route path... is this possible

Basically.. I have about 20 points on a map of places that I tracked myself with my GPS tracker. The points are at 5 minute intervals.

At the moment, I use MWS to calculate the ROUTES between these multiple points and then draw a routeline to connect it all up nicely so that the line follows the roads (instead of having straight lines). Now I want to animate an icon so that it moves smoothly along the route line to replay my path.

Are the coordinates for the route line stored anywhere at all Or is there another way to do it I did this previously with MAP24, but am moving over to VE due to performance issues. Here's a sample of how it's done in MAP24 (be patient.. the java app is really really slow to load):

http://maptp12.map24.com/fleetmap/fleetmap2.html

Click ROUTING

Click a from point (hit ¡®route from here¡¯)

Click a to point (hit ¡®route to here¡¯)

Then at the bottom on the right, click ¡®routenflug¡¯ and click the PLAY button.... that¡¯s the type of animation I want (in 2D and 3D!).




Re: Animated history?

Kartik


That's a pretty neat animation!

Unfortunately, neither MWS API nor the VE API expose the data necessary to create such a detailed animation of a pin moving along a route. I'm pretty sure that the best one can do is to use the way points of the itinerary returned by MWS / VE and use the VEMap.StartContinuousPan method to pan in a straight line between the waypoints of the itinerary.

This method takes two parameters, (x,y) which represent the pan speed in the x and y direction on the map. You then need to make a call to VEMap.EndContinuousPan in order to stop the pan after you reached the waypointon your route. You would then have to make another call to StartContinuousPan to pan along the next segment of your route.

Here is some sample code that I whipped together to show you how to do this:

Code Block

<html>
<head>
<title> Route Example </title>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">-->
<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx v=5"></script>
<script type="text/javascript">

var map = null;
var count = 0;
var x = 8;
var y = -8;

function getMap()
{
map = new VEMap('myMap');
map.LoadMap( new VELatLong(43.650174489270526,-79.38617706298831), 15);
}


function EndAnimation() {

map.EndContinuousPan();
//clearTimeout( t );

x = -1 *x/2;
y = y/2;

if ( count < 3 )
{
StartAnimation(x , y );
}
}


function StartAnimation(h,v)
{
map.StartContinuousPan( h,v );
count ++;
setTimeout( EndAnimation, 2000);
}

</script>

</head>
<body onload="getMap();">
<input id="btnAnimate" type="button" Value="Start Animation" onclick="StartAnimation(x,y);" />
<div id='myMap' style="position:absolute;width:500px;height:500px"></div>

</body>
</html>

In your scenario however, you would have to calculate the x and y values, and the length of time for the pan in order to pan between two specific latlongs... kind of a chore, but definitely possible... The other limitation of this is that the pan rate is dependent on the system speed, and if you can't guarantee the performance of the machine on which this code runs... it might go extremely fast, or extremely slow.

Here are some links to the MSDN documentation:

StartContinuousPan: http://msdn2.microsoft.com/en-us/library/bb412531.aspx

EndContinuousPan: http://msdn2.microsoft.com/en-us/library/bb429598.aspx

Hope this helps.

-Kartik






Re: Animated history?

TB123

Thanks Kartik, that's very useful.

I guess the alternative (and maybe neater) solution would be to to a route, and have a massive number of waypoints (is there a limit to the number I can plot ) and then move an icon to each waypoint.

That way wouldn't give me that cool PAN, but at least it would move the icon along the route.

How do the waypoints work Does it only draw them at intersections, or can you set it to just draw them every 100ft or so

Thanks again.

Tim






Re: Animated history?

Derek Chan

I've actually attempted to write a VE application exactly as how Kartik has described. The major issue I have with this is that panning from say segment A to B means that you'll be following a straight line path there. The segment A and B can be grabbed through the direction manager route cache which I've described in my article here:
http://www.viawindowslive.com/Articles/VirtualEarth/CustomizingRoutePushpinsinV5.aspx

However these points don't make up the entire route, only important segments in the driving direction portion (where you actually have to make a turn). The problem arises when your path from A to B isn't straight but a curve, thus causing you to pan off the route. It's those 'little' points (aka 'path') that make the route curve which you really need to pan to. If you absolutely need this kind of functionality you'll need to take it down to the VML (For Internet Explorer) and SVG (Firefox) layers and see if you can grab the points that compose a route path. An alternative is to try a really high zoom level such that the pan discrepency isn't too noticable. It really would be nice if Microsoft could automatically provide this to us especially in 3D mode.

Hope that helps clarify things,






Re: Animated history?

TB123

ok, gotcha... that gets me about 50% of the way there.

I have a few roads that are long and with a lot of bends, so I guess I'll have to take it down to the VML. Are there any useful articles on how to take the VML polyline that's created for a 'route' and get an icon to follow that exact path Or is this impossible in VE





Re: Animated history?

SoulSolutions

What is your timeframe to complete this The routing in the current API is in serious need of updating (its still V3 code I believe), there have been many requests for additional functionality and certianly the competitive product is far superior currently.

I would not invest all your effort, if you can provide something that gets you part of the way, for example just animate the waypoints that are easily accessible from the collection provides oncallback then allow some time later this year to polish it off.

There is no garrentee we will get an update in this functionlaity though, it would be very welcome.

John.






Re: Animated history?

TB123

Hi John... the timeframe is reasonably aggressive. I think we'll come up with an interim (slightly clunky) measure and hope for an update to the Routing API in the near future.

I'll escalate through our local MWS sales rep to see if I can get a timeframe on when we might see something a little better. It's a shame that the routing lets down such a brilliant product.





Re: Animated history?

SoulSolutions

Its very much an evolving product and the compitition is pushing an amazing release cycle from MSFT and new features. Talk to your rep and see what you can find out to better plan this functionality.

And let us know when you have released something I'm sure we are all keen to see your work!

John.