FDiri
12/16/2015 - 9:38 PM

displaying polygons on google maps from sql server geography data type

SqlCommand cmd = new SqlCommand("SELECT STATEMENT",ConnectionString);
connectionString.Open();
SqlDataReader polygon = cmd.ExecuteReader();

While (polygon.read())
{
  string kmlCoordinates = string.Empty;
  SqlGeography geo = (SqlGeography)polygon["GeoColumn"];
  for(int i = 1; i <= geo.STNumPoints(); i++)
  {
       SqlGeography point = geo.STPointN(i);
       kmlCoordinates += point.Long + "," + point.Lat + " ";
  }
{

ConnectionString.Close();