using System.Web.Mvc; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.MvcEdition; namespace CSharp_HowDoISamples { public partial class BackgroundMapsController : Controller { public ActionResult DisplayASimpleMap() { Map map = new Map("Map1", new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage)); map.MapUnit = GeographyUnit.DecimalDegree; map.CurrentExtent = new RectangleShape(-125, 72, 50, -46); map.MapBackground = new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))); map.CustomOverlays.Add(new WorldMapKitWmsWebOverlay()); map.AdornmentOverlay.Layers.Add(BuildLegend()); return View(map); } private static LegendAdornmentLayer BuildLegend() { LegendItem legendItem1 = new LegendItem(); legendItem1.ImageStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(100, 120, 200, 140)), 16); legendItem1.TextStyle = new TextStyle("Current", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black)); LegendItem legendItem2 = new LegendItem(); legendItem2.ImageStyle = new PointStyle(PointSymbolType.Triangle, new GeoSolidBrush(GeoColor.StandardColors.Blue), 16); //TextWrap legendItem2.TextStyle = new TextStyle("Assetdfaaa\naaaaadfef", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black)); legendItem2.TextStyle = new TextStyle("Assetdfa", new GeoFont("Arial", 8), new GeoSolidBrush(GeoColor.SimpleColors.Black)); LegendAdornmentLayer legendLayer = new LegendAdornmentLayer(); legendLayer.BackgroundMask = AreaStyles.CreateLinearGradientStyle(new GeoColor(255, 255, 255, 255), new GeoColor(255, 230, 230, 230), 90, GeoColor.SimpleColors.Black); legendLayer.LegendItems.Add(legendItem1); legendLayer.LegendItems.Add(legendItem2); legendLayer.Width = 100; legendLayer.Height = 80; LegendItem title = new LegendItem(); title.TextStyle = new TextStyle("Symbols", new GeoFont("Arial", 10, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black)); title.RightPadding = 0; title.ImageJustificationMode = LegendImageJustificationMode.JustifyImageLeft; title.TextLeftPadding = 0; legendLayer.Title = title; legendLayer.Location = AdornmentLocation.LowerLeft; return legendLayer; } } }