using System.Collections.ObjectModel; using System.Web.Mvc; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.MvcEdition; namespace CSharp_HowDoISamples { public partial class InteractiveOverlaysController : Controller { // // GET: /DrawEditShapes/ public ActionResult DrawEditShapes() { return View(); } [MapActionFilter] public void SaveMap(Map map, GeoCollection args) { Collection features = MapHelper.ConvertJsonToFeatures(args[0].ToString()); LayerOverlay dynamicOverlay = (LayerOverlay)map.CustomOverlays["DynamicOverlay"]; InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"]; sqlLayer.Open(); sqlLayer.FeatureSource.BeginTransaction(); foreach (Feature feature in features) { (sqlLayer.FeatureSource as MsSql2008FeatureSource).UpdateFeature(feature); } sqlLayer.FeatureSource.CommitTransaction(); sqlLayer.Close(); map.EditOverlay.Features.Clear(); } MsSql2008FeatureLayer sqlLayer = new MsSql2008FeatureLayer(yourconnectionstring, yourtablename, yourfeaturesourceidcolumn); Collection featureIds = new Collection() { "1" }; [MapActionFilter] public string EditShape(Map map, GeoCollection args) { sqlLayer.Open(); string featuresJson = MapHelper.ConvertFeaturesToJson(sqlLayer.FeatureSource.GetFeaturesByIds(featureIds, ReturningColumnsType.NoColumns)); sqlLayer.Close(); return featuresJson; } } }