ThinkGeo.com    |     Documentation    |     Premium Support

Animation on Web edition

   I would like to animate an icon on web edition. 


   Following code is been used in Desktop edition, which is working fine.......


   How can I do the same in web Edition.


   timer.Interval = 100;

    timer.Tick += new EventHandler(timer_Tick);

    winformsMap1.MapUnit = GeographyUnit.DecimalDegree; 

    InMemoryFeatureLayer bitmapLayer = new InMemoryFeatureLayer();

    bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap;

    bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = new GeoImage(Application.StartupPath + @"\A090.png");

    bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.ContestedBorder2;

    bitmapLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;



    PointShape planeShape = new PointShape(55.3899993896484, 25.2433338165283);

    PointShape destinationPoint = new PointShape(77.0950012207031, 28.5666675567627);

    MultilineShape airLineShape = planeShape.GreatCircle(destinationPoint);

    bitmapLayer.InternalFeatures.Add("Plane", new Feature(planeShape));

    bitmapLayer.InternalFeatures.Add("AirLine", new Feature(airLineShape));            



    LayerOverlay planeOverlay = new LayerOverlay();

    planeOverlay.Layers.Add("BitmapLayer", bitmapLayer);

    winformsMap1.Overlays.Add("PlaneOverlay", planeOverlay);



    //winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2);

    winformsMap1.Refresh();



    timer.Start();


 


    private void timer_Tick(object sender, EventArgs e)

    {

            InMemoryFeatureLayer bitmapLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("BitmapLayer");

            PointShape pointShape = bitmapLayer.InternalFeatures[0].GetShape() as PointShape;

            LineShape airLine = ((MultilineShape)bitmapLayer.InternalFeatures[1].GetShape()).Lines[0];

            PointShape pointShape1 = bitmapLayer.InternalFeatures[2].GetShape() as PointShape;

            LineShape airLine1 = ((MultilineShape)bitmapLayer.InternalFeatures[3].GetShape()).Lines[0];

            PointShape pointShape2 = bitmapLayer.InternalFeatures[4].GetShape() as PointShape;

            LineShape airLine2 = ((MultilineShape)bitmapLayer.InternalFeatures[5].GetShape()).Lines[0];

            bitmapLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.RotationAngle = index;

            //pointShape.Rotate(pointShape,359);

            index += 1;

            index1 += 1;

            index2 += 1;

            if (index < airLine.Vertices.Count)

            {

                Vertex newPosition = airLine.Vertices[index];

                pointShape.X = newPosition.X;

                pointShape.Y = newPosition.Y;

                pointShape.Id = "Plane";

                if (pointShape.CanRotate)

                {       

                    //bitmapLayer

                    pointShape.Rotate(pointShape,180);

                }

                bitmapLayer.Open();

                bitmapLayer.EditTools.BeginTransaction();

                bitmapLayer.EditTools.Update(pointShape);

                bitmapLayer.EditTools.CommitTransaction();

                bitmapLayer.Close();

            }

            else

            {

                index = 0;

            }



            if (index1 < airLine1.Vertices.Count)

            {

                Vertex newPosition = airLine1.Vertices[index1];

                pointShape1.X = newPosition.X;

                pointShape1.Y = newPosition.Y;

                pointShape1.Id = "Plane1";



                bitmapLayer.Open();

                bitmapLayer.EditTools.BeginTransaction();

                bitmapLayer.EditTools.Update(pointShape1);

                bitmapLayer.EditTools.CommitTransaction();

                bitmapLayer.Close();

            }

            else

            {

                index1 = 0;

            }





            if (index2 < airLine2.Vertices.Count)

            {

                Vertex newPosition = airLine2.Vertices[index2];

                pointShape2.X = newPosition.X;

                pointShape2.Y = newPosition.Y;

                pointShape2.Id =  "Plane2";



                bitmapLayer.Open();

                bitmapLayer.EditTools.BeginTransaction();

                bitmapLayer.EditTools.Update(pointShape2);

                bitmapLayer.EditTools.CommitTransaction();

                bitmapLayer.Close();

            }

            else

            {

                index2 = 0;

            }

            winformsMap1.Refresh(winformsMap1.Overlays["PlaneOverlay"]);

    }


 


Thanks in advance.


Robinson C P



Hi Robinson, 
  
 First of all, Web code and Desktop code are not compatible; hope you understand. Secondly, Desktop is local application while Web is Browser/Server application which means once server side status changed, the image stream needs to transfer through the internet and update to the client side and refresh it. It depends on the network speed. Thirdly, it’s not a good solution to implement animation with the server timer events; I’m sure the performance is pretty low. 
  
 Normally, AJAX is a solution to implement animation in a web solution. Please search keyword: callback or AJAX in our forum to get more information first, and redesign a good requirement to fit a web application. 
  
 Please let me know if there is any misunderstanding. 
  
 Thanks, 
 Howard