Hi,
I have a new problem.In my project,I have a shape file to save a point layer,shape file over Google Map.Now,I can add a point to shape file when I click to any point in Google Map.But my problem is I don’t know how to add data to fields of DBF file.I want to add information of NAME,IMAGE,LAT,LONG…to DBF file(this information can be given at TextBox).
This is my code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//Load ban do Hanoi tu Google Map
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(11774455.3817, 2398364.63617, 11786513.32291, 2389421.50386);
Map1.MapUnit = GeographyUnit.Meter;
Map1.MapTools.PanZoomBar.Enabled = true;
Map1.MapTools.MouseCoordinate.Enabled = true;
GoogleOverlay google = new GoogleOverlay(“Google Map”);
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings[“GoogleUri”]);
google.GoogleMapType = GoogleMapType.Normal;
Map1.CustomOverlays.Add(google);
InMemoryFeatureLayer inMemoryLayer = new InMemoryFeatureLayer();
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(180, 255, 255, 255), GeoColor.StandardColors.White, 1); ;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 5, true);
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.DynamicOverlay.Layers.Add(inMemoryLayer);
/*Collection<DbfColumn> dbfColumns = new Collection<DbfColumn>();
dbfColumns.Add(new DbfColumn(“id”, DbfColumnType.String, 16, 0));
dbfColumns.Add(new DbfColumn(“name”, DbfColumnType.String, 16, 0));
dbfColumns.Add(new DbfColumn(“image”, DbfColumnType.String, 16, 0));
dbfColumns.Add(new DbfColumn(“feature”, DbfColumnType.String, 20, 0));
ShapeFileFeatureSource.CreateShapeFile(ShapeFileType.Point, “D:\PointDrawn.shp”, dbfColumns);*/
}
}
protected void Map1_TrackShapeFinished(object sender, EventArgs e)
{
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)Map1.DynamicOverlay.Layers[0];
foreach (Feature feature in Map1.EditOverlay.Features)
{
shapeLayer.InternalFeatures.Add(feature.Id, feature);
// Save shapes to ShapeFile
ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(“D:\PointDrawn.shp”,ShapeFileReadWriteMode.ReadWrite );
featureSource.Open();
featureSource.BeginTransaction();
featureSource.AddFeature(feature);
featureSource.CommitTransaction();
featureSource.Close();
}
Map1.EditOverlay.Features.Clear();
Map1.DynamicOverlay.Redraw();
}
protected void buttonDrawPoint_Click(object sender, EventArgs e)
{
Map1.EditOverlay.TrackMode = TrackMode.Point;
}
protected void buttonNormal_Click(object sender, EventArgs e)
{
Map1.EditOverlay.TrackMode = TrackMode.None;
}
}
Please help me!
Thanks a lot!