DataTableLayer Sample

6/11/2013 8:54:49 AM
Total Posts 3

DataTableLayer Sample

is there any example code of how to useĀ DataTableLayer Class (aspmap 4.8.1) using C# ?

6/11/2013 9:45:23 AM
Total Posts 3

Re: DataTableLayer Sample

is this code corect ?

public void IzinPrinsipFindBuilding(Map Peta, int IdBuilding, int Radius)
{
String TSQL = "exec dbo.SP_Cari_Buffer_Bangunan @IdBuilding, @Radius";
conn.Open();
SqlCommand sqlcommand = new SqlCommand(TSQL, conn);
sqlcommand.Parameters.Add("@IdBuilding", SqlDbType.Int).Value = IdBuilding;
sqlcommand.Parameters.Add("@Radius", SqlDbType.Int).Value = Radius;
sqlcommand.CommandTimeout = 30;
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = sqlcommand;
DataTable dt = new DataTable("TampilBangunan");
sda.Fill(dt);
conn.Close();
DataTableLayer LayerBuilding = new DataTableLayer(dt, "Building");
Layer layar = Peta.AddLayer(LayerBuilding);
layar.Name = "Bangunan";
layar.Description = "Layer Bangunan";
layar.LabelField = "kode";
layar.ShowLabels = true;
layar.LabelFont.Name = "Arial";
layar.LabelFont.Bold = true;
layar.LabelFont.Size = 12;
}

6/11/2013 1:02:13 PM
MVP
Total Posts 323

Re: DataTableLayer Sample

The resulting DataTable should contain a field with WKB data.

MSSQL supports the STAsBinary() method for the geometry/geography data types:

"SELECT NAME, geometry.STAsBinary() AS Wkb FROM sometable"

DataTableLayer dtLayer = new DataTableLayer(dataTable, "Wkb");
Layer layer = map1.AddLayer(dtLayer);