protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")); Map1.CurrentExtent = new RectangleShape(-140, 60, 140, -60); Map1.MapUnit = GeographyUnit.DecimalDegree; loadShapefilePosition(); storePositionToDatabase(getFeaturesFromShapefile()); getMarkersFromDatabase(); } } string connString = "......."; private void loadShapefilePosition() { ShapeFileFeatureLayer shpLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/MajorCities.shp")); shpLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1; shpLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel= ApplyUntilZoomLevel.Level20; shpLayer.Open(); LayerOverlay overlay = new LayerOverlay(); overlay.Layers.Add(shpLayer); Map1.CustomOverlays.Add(overlay); } private Collection getFeaturesFromShapefile() { ShapeFileFeatureLayer shpLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/MajorCities.shp")); shpLayer.Open(); return shpLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); } private void storePositionToDatabase(Collection features) { SqlConnection sConn = new SqlConnection(connString); sConn.Open(); string sql = string.Empty; SqlCommand sCmd = new SqlCommand(); sCmd.Connection = sConn; foreach (Feature feature in features) { PointShape point = new PointShape(feature.GetWellKnownText()); string imagename = "circle"; sql = "insert into pointposition(longitude,latitude,imagename)values(" + point.X.ToString() + "," + point.Y.ToString() + ",'" + imagename + "')"; sCmd.CommandText = sql; sCmd.ExecuteNonQuery(); } sConn.Close(); } private void getMarkersFromDatabase() { SqlConnection sConn = new SqlConnection(connString); sConn.Open(); string sql = string.Empty; SqlCommand sCmd = new SqlCommand(); sCmd.Connection = sConn; sCmd.CommandText = "select * from pointposition"; SqlDataReader reader = sCmd.ExecuteReader(); SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay(); while (reader.Read()) { double longitude = Convert.ToDouble(reader["longitude"]); double latitude = Convert.ToDouble(reader["latitude"]); string imagename = reader["imagename"].ToString(); markerOverlay.Markers.Add(new Marker(longitude, latitude, new WebImage("../../theme/default/samplepic/"+imagename+".png"))); } sConn.Close(); Map1.CustomOverlays.Add(markerOverlay); }