ThinkGeo.com    |     Documentation    |     Premium Support

Urgent: Dynamic Shapes and Data Layers

Im trying to display dynamic shapes from a datatable connected to SQL database , the code i have reached so far reads the data from a form view and stores it in a Data Table then its loops throug but only display the first row of the table " one shape is drawn and its the first shape " this my code sample :


this is the form view section :


private DataTable GetTruckData()

        {

            

          DataTable dataTable = new DataTable();

           

            dataTable.Columns.Add("LAT");

            dataTable.Columns.Add("LONG");

            dataTable.Columns.Add("Direction");

            dataTable.Columns.Add("NAME");

            double lat;

            double longP;

            double direction;

            string entityName;

            int i = 0;

  

            // Read the next line with GPS data in it.

            while (i <= FormView1.PageCount)

            {

                Label latPosition = FormView1.FindControl("LPositionLatLabel") as Label;

                Label longPosition = FormView1.FindControl("LpostionLongLabel") as Label;

                Label dir = FormView1.FindControl("LPositionDirectionLabel") as Label;

                Label trackEntity = FormView1.FindControl("TrackingEntityNameLabel") as Label;

                Label trackingID = FormView1.FindControl("TrackingEntityIDLabel") as Label;


                index = Convert.ToInt32(trackingID.Text);

                longP = Convert.ToDouble(longPosition.Text);

                lat = Convert.ToDouble(latPosition.Text);

                direction = Convert.ToDouble(dir.Text);

                entityName = Convert.ToString(trackEntity.Text);


                dataTable.Rows.Add(new object[4] { Convert.ToString(lat), Convert.ToString(longP), Convert.ToString(direction), entityName});

                i++;

                FormView1.PageIndex = FormView1.PageIndex + 1;

                

            }

            return dataTable;

        }


 


---------------------------------------------------------------


and this is the drawing method:


//Call a custom function that returns the data in a datatable.

                DataTable fleets = GetTruckData();

                //Create a new DynamicLayer to store the point data.

                DynamicLayer customerfleets = new DynamicLayer();

                foreach (DataRow fleet in fleets.Rows)

                {


                    //Create the point based on the Longitude & Latitude values from the database.

                    PointMapShape truckPoint = new PointMapShape(new PointShape(Convert.ToDouble(fleet["LONG"]), Convert.ToDouble(fleet["LAT"])));

                    //Create a Red Star Symbol for the point

                    PointSymbol truckSymbol = new PointSymbol(PointStyleEnum.Star, new SolidBrush(Color.Red), 15);

                    //Associate the red start symbol with the point.

                    truckPoint.Symbols.Add(truckSymbol);

                    //Add the point map shape to the Dynamiclayer

                    customerfleets.MapShapes.Add(truckPoint);


                }

                //Add the DynamicLayer to the map

                Map1.DynamicLayers.Add(customerfleets);

                //Refresh the map to show the new DynamicLayer

                Map1.RefreshDynamic();

            


 


can any one help me in this


 


Regards



Sheree, 
  
 Seems you are using Map Suite 2.0, right? Anyway, your code seems right. Can you check customerfleets.MapShapes.Count to make sure it is not only one, and check some of the MapShapes to make sure the position is not the same? Also please make sure the current extent is large enough to cover all the points not only one. If you still have that problem, please provide us some info about the lat/lon of the points to help us to recreate. 
  
 PS: do you mind if I moved this post under the topic of Map Suite Desktop 2.0? 
  
 Thanks, 
  
 Ben