ThinkGeo.com    |     Documentation    |     Premium Support

Placing locations on a map from an SQL server table

HI,


I have just downloaded the evaluation edition and I need to see what is involved in using it for our project. We have names and addresses of locations scattered across many countries. We have the long. and lat. of each location in this table. We need to show the locations on a world map, zoom in by country and display associated data (also from the same table) of a picked location. 


I assume this is a basic requirement but I cant quickly see a relevant sample (web VB but C# will do).


Regards


 


Richard


 



 Hi Richard,


Here is the code you can look at


 



InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay("MarkerOverlay");
                markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("../../theme/default/img/marker_blue.gif", 21, 25);
                markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                markerOverlay.Click += new EventHandler<MarkerOverlayClickEventArgs>(markerOverlay_Click);
                Map1.CustomOverlays.Add(markerOverlay);

                Collection<Feature> result = new Collection<Feature>();
                string connectionString = ConfigurationManager.AppSettings["SqlConnectionString"];
                OleDbConnection connection = new OleDbConnection(connectionString);
                try
                {
                    connection.Open();
                    string sql = string.Format("select * from marker");
                    OleDbCommand command = new OleDbCommand(sql, connection);
                    OleDbDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        double x = (double)reader["latitude"];
                        double y = (double)reader["longitude"];
                        markerOverlay.Features.Add(new Feature(new Vertex(x, y)));
                    }
                }
                finally
                {
                    connection.Close();
                }

 


James


 



Thanks, I worked it all out now.

Hello Richard, 
  
 Please feel free to let us know your problems. 
  
 Regards, 
  
 Gary