private void animatePlane()
        {
            // Configure the animation timer and events
            Timer animationTimer = new Timer(16) //~ 60 fps
            {
                Enabled   = true,
                AutoReset = true
            };

            animationTimer.Elapsed += (_, __) =>
            {
                // Increment the progress along the route
                double newProgress = progressOnRoute + (routeLength / 60 / 60);

                if (newProgress > routeLength)
                {
                    newProgress = 0;
                }

                // Move the plane along the path
                planeGraphic.Geometry = GeometryEngine.CreatePointAlong(routePath, newProgress);

                // Update the plane's heading
                planeGraphic.Attributes["HEADING"] = (progressOnRoute / routeLength) * 360;

                // Save the current progress
                progressOnRoute = newProgress;
            };

            animationTimer.Start();
        }
示例#2
0
        public MapPoint UpdateUiPosition(double speedMPS, double seconds)
        {
            SingleRoute route = Route;

            if (route == null)
            {
                return(Graphic.Geometry as MapPoint);
            }

            double partDistPerc = speedMPS * seconds / route.Length;

            route.Progress += partDistPerc;

            if (route.Progress > 1.0)
            {
                Console.WriteLine("{0} finished route", this.ToString());
                route.Progress = 1.0;
                State          = MobileUnitState.FINISHED;
            }

            double   sumDistDegrees = route.Progress * route.Length * GeoUtil.TEMP_METER_TO_DEGREE;
            MapPoint newPos         = GeometryEngine.CreatePointAlong(route.Graphic.Geometry as Polyline, sumDistDegrees);

            Graphic.Geometry = newPos;

            return(newPos);
        }