www.pudn.com > HelloWorld_Web.zip > Default.aspx.cs, change:2011-05-13,size:4289b


´╗┐using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using ThinkGeo.MapSuite.Core; 
using ThinkGeo.MapSuite.WebEdition; 
 
namespace HelloWorld 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) 
            { 
                Map1.MapUnit = GeographyUnit.DecimalDegree; 
 
                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 5.0\Samples\CSharp Samples\SampleData\World\cntry02.shp"); 
                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; 
                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
 
                ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 5.0\Samples\CSharp Samples\SampleData\World\capital.shp"); 
                // We can customize our own Style. Here we passed in a color and a size. 
                capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown); 
                // The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore. 
                capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05; 
 
                capitalLayer.ZoomLevelSet.ZoomLevel06.DefaultPointStyle = PointStyles.Capital3; 
                // The Style we set here is available from ZoomLevel06 to ZoomLevel20. That means if we zoom out a bit more, the appearance we set here will not be visible any more. 
                capitalLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
 
                ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 5.0\Samples\CSharp Samples\SampleData\World\capital.shp"); 
                // We can customize our own TextStyle. Here we passed in the font, the size, the style and the color. 
                capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("CITY_NAME", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3); 
                // The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.  
                capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05; 
 
                capitalLabelLayer.ZoomLevelSet.ZoomLevel06.DefaultTextStyle = TextStyles.Capital3("CITY_NAME"); 
                // The TextStyle we set here is available from ZoomLevel06 to ZoomLevel20.  
                capitalLabelLayer.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
 
                capitalLabelLayer.DrawingMarginPercentage = 50; 
 
                Map1.StaticOverlay.Layers.Add(worldLayer); 
                Map1.StaticOverlay.Layers.Add(capitalLayer); 
                Map1.StaticOverlay.Layers.Add(capitalLabelLayer); 
 
                Map1.CurrentExtent = new RectangleShape(5, 78, 30, 26); 
 
                // Set the background color to make the map beautiful. 
                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); 
            } 
        } 
 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            if (!Map1.MarkerOverlay.Features.Contains("Marker")) 
            { 
                // Add a new feature as a marker 
                Map1.MarkerOverlay.Features.Add("Marker", new Feature(0, 52)); 
 
                // Set the marker style, and make it available all over the zoomlevels. 
                Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("../../theme/default/img/marker_blue.gif", 21, 25); 
                Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; 
            } 
        } 
    } 
}