当前位置: 首页>>代码示例>>C#>>正文


C# Map.ZoomToExtents方法代码示例

本文整理汇总了C#中Map.ZoomToExtents方法的典型用法代码示例。如果您正苦于以下问题:C# Map.ZoomToExtents方法的具体用法?C# Map.ZoomToExtents怎么用?C# Map.ZoomToExtents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map.ZoomToExtents方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureMap

 public void ConfigureMap(Map map)
 {
     map.Size = this.OutputSize;
     if (this.RealWorldBounds == null)
         map.ZoomToExtents();
     else
         map.ZoomToBox(this.RealWorldBounds);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:BasicMapRequestConfig.cs

示例2: InitializeControls

        private void InitializeControls()
        {
            geometryEditorForm = new Form();
            // Create map and map control
            Map map = new Map();

            mapControl = new MapControl {Map = map};
            mapControl.Resize += delegate { mapControl.Refresh(); };
            mapControl.ActivateTool(mapControl.PanZoomTool);
            mapControl.Dock = DockStyle.Fill;
            // disable dragdrop because it breaks the test runtime
            mapControl.AllowDrop = false;

            // Create listbox to show all registered tools
            listBoxTools = new ListBox {Dock = DockStyle.Left};
            listBoxTools.SelectedIndexChanged += listBoxTools_SelectedIndexChanged;

            map.ZoomToExtents();

            mapControl.MoveTool.FallOffPolicy = FallOffPolicyRule.Linear;

            geometryEditorForm.Controls.Add(listBoxTools);
            geometryEditorForm.Controls.Add(mapControl);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:NewLineToolTest.cs

示例3: GetMap_GeometryProvider_ReturnImage

        public void GetMap_GeometryProvider_ReturnImage()
        {
            var map = new Map(new Size(400, 200));
            var vLayer = new VectorLayer("Geom layer", CreateTestFeatureProvider())
                {
                    Style =
                        {
                            Outline = new Pen(Color.Red, 2f),
                            EnableOutline = true,
                            Line = new Pen(Color.Green, 2f),
                            Fill = Brushes.Yellow
                        }
                };
            map.Layers.Add(vLayer);

            var vLayer2 = new VectorLayer("Geom layer 2", vLayer.DataSource);
            vLayer.Style.SymbolOffset = new PointF(3, 4);
            vLayer.Style.SymbolRotation = 45;
            vLayer.Style.SymbolScale = 0.4f;
            map.Layers.Add(vLayer2);

            var vLayer3 = new VectorLayer("Geom layer 3", vLayer.DataSource)
                {
                    Style = {SymbolOffset = new PointF(3, 4), SymbolRotation = 45}
                };
            map.Layers.Add(vLayer3);

            var vLayer4 = new VectorLayer("Geom layer 4", vLayer.DataSource)
                {
                    Style = {SymbolOffset = new PointF(3, 4), SymbolScale = 0.4f}
                };
            vLayer4.ClippingEnabled = true;
            map.Layers.Add(vLayer4);

            map.ZoomToExtents();

            var img = map.Render();
            Assert.IsNotNull(img);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:39,代码来源:MapTest.cs

示例4: TestMap

        public void TestMap()
        {
            var m = new Map(new Size(1024, 786)) {BackColor = Color.FloralWhite};
            const string samplePath = @"D:\GIS\FileGDB\samples\data\Topo.gdb";

            var p = new FileGdbProvider(samplePath);

            foreach (var fc in p.GetFeatureClasses("\\USA"))
            {
                if (fc.StartsWith("\\USA\\T"))
                    continue;

                Console.WriteLine(fc);
                var pUse = new FileGdbProvider(samplePath) { Table = fc };
                var vl = new VectorLayer("Layer:" + fc, pUse)
                             {
                                 SmoothingMode = SmoothingMode.HighQuality,
                                 Style = {Fill = RandomBrush(), Line = RandomPen()}
                             };
                m.Layers.Add(vl);

                var fds = new FeatureDataSet();
                vl.ExecuteIntersectionQuery(vl.Envelope, fds);
                fds.Tables[0].TableName = fc;
                var res = fds.Tables[0].Rows[0].ItemArray;
                foreach (DataColumn col in fds.Tables[0].Columns)
                    Console.Write(string.Format("{0} [{1}], ", col.ColumnName, col.DataType));
                Console.WriteLine();

                foreach (var item in res)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                Console.WriteLine();

                Console.WriteLine(pUse.GetGeometryByID(1));

                var r = pUse.GetFeature(1);
                foreach (var item in r.ItemArray)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));

                Console.WriteLine();
                Console.WriteLine();
            }
            Console.WriteLine();

            p.Dispose();

            m.ZoomToExtents();
            var b = m.GetMap();
            b.Save("fgdb-usa-states.bmp");

            //var fds = new FeatureDataSet();
            //lc.ExecuteIntersectionQuery(m.GetExtents().GetCentroid(), fds);
            //fds.Tables[0].TableName = lc.LayerName;
            //fds.Tables[0].WriteXml(Console.Out);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:55,代码来源:FileGdbProviderTest.cs

示例5: CreateGenericSymbol

        /// <summary>
        /// Method to create a generic symbol for the layer
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        private Image CreateGenericSymbol(ILayer layer)
        {
            if (LegendSettings.SymbolSize == Size.Empty)
                return null;

            Image tmp;
            using (var m = new Map(new Size(10*LegendSettings.SymbolSize.Width, 10*LegendSettings.SymbolSize.Height)))
            {
                m.Layers.Add(layer);
                m.ZoomToExtents();
                tmp = m.GetMap();
                //tmp.Save("map.png");
                //System.Diagnostics.Process.Start("map.png");
                m.Layers.Remove(layer);
            }
            
           var res = new Bitmap(LegendSettings.SymbolSize.Width, LegendSettings.SymbolSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
           using (var g = Graphics.FromImage(res))
           {
           		g.DrawImage(tmp, new Rectangle(0, 0, LegendSettings.SymbolSize.Width, LegendSettings.SymbolSize.Height),
           	                 	 new Rectangle(0, 0, tmp.Width, tmp.Height), GraphicsUnit.Pixel);
           }
                   
            return res;
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:30,代码来源:LegendFactory.cs

示例6: GetMap_GeometryProvider_ReturnImage

        public void GetMap_GeometryProvider_ReturnImage()
        {
            Map map = new Map(new System.Drawing.Size(400, 200));
            SharpMap.Layers.VectorLayer vLayer = new SharpMap.Layers.VectorLayer("Geom layer", CreateTestFeatureProvider());
            vLayer.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.Red, 2f);
            vLayer.Style.EnableOutline = true;
            vLayer.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Green, 2f);
            vLayer.Style.Fill = System.Drawing.Brushes.Yellow;
            map.Layers.Add(vLayer);

            SharpMap.Layers.VectorLayer vLayer2 = new SharpMap.Layers.VectorLayer("Geom layer 2", vLayer.DataSource);
            vLayer.Style.SymbolOffset = new System.Drawing.PointF(3, 4);
            vLayer.Style.SymbolRotation = 45;
            vLayer.Style.SymbolScale = 0.4f;
            map.Layers.Add(vLayer2);

            SharpMap.Layers.VectorLayer vLayer3 = new SharpMap.Layers.VectorLayer("Geom layer 3", vLayer.DataSource);
            vLayer3.Style.SymbolOffset = new System.Drawing.PointF(3, 4);
            vLayer3.Style.SymbolRotation = 45;
            map.Layers.Add(vLayer3);

            SharpMap.Layers.VectorLayer vLayer4 = new SharpMap.Layers.VectorLayer("Geom layer 4", vLayer.DataSource);
            vLayer4.Style.SymbolOffset = new System.Drawing.PointF(3, 4);
            vLayer4.Style.SymbolScale = 0.4f;
            vLayer4.ClippingEnabled = true;
            map.Layers.Add(vLayer4);

            map.ZoomToExtents();

            var img = map.Render();
            Assert.IsNotNull(img);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:MapTest.cs

示例7: TestStandardLayers

		public void TestStandardLayers()
		{
			using (var map = new Map())
			{
				map.Layers.Add(
					new TileLayer(new OsmTileSource(new OsmRequest(KnownOsmTileServers.Mapnik)),
						"OSM - Mapnik"));


                //var wfs = new SharpMap.Web.Wfs.Client(@"http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?version=1.0.0&request=getcapabilities&service=wfs");
                //var p = new SharpMap.Data.Providers.WFS(
                //    new WfsFeatureTypeInfo { SRID = "EPSG:42304", Geometry = new WfsFeatureTypeInfo.GeometryInfo{}});
                
                map.Layers.Add(
					new VectorLayer("Lineal VectorLayer",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreateLineString(
					                		new [] { new GeoAPI.Geometries.Coordinate(0, 0), new GeoAPI.Geometries.Coordinate(10, 0)}))));
				var l = map.Layers[1] as VectorLayer;
				l.Style = SharpMap.Styles.VectorStyle.CreateRandomLinealStyle();
				
				map.Layers.Add(
					new VectorLayer("Puntal VectorLayer",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(
					                		new GeoAPI.Geometries.Coordinate(5, 5)))));
				l = map.Layers[2] as VectorLayer;
				l.Style = SharpMap.Styles.VectorStyle.CreateRandomPuntalStyle();
				map.Layers.Add(
					new VectorLayer("Polygonal VectorLayer",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePolygon(null, null))));
				l = map.Layers[3] as VectorLayer;
				l.Style = SharpMap.Styles.VectorStyle.CreateRandomPolygonalStyle();

				map.Layers.Add(
					new VectorLayer("Geometry VectorLayer",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(
					                		new GeoAPI.Geometries.Coordinate(5, 5)))));
				l = map.Layers[4] as VectorLayer;
				l.Style = SharpMap.Styles.VectorStyle.CreateRandomStyle();

				map.Layers.Add(
					new VectorLayer("Geometry VectorLayer with theme",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(
					                		new GeoAPI.Geometries.Coordinate(5, 5)))));
				l = map.Layers[5] as VectorLayer;

				var dict = new Dictionary<int, SharpMap.Styles.IStyle>();
				dict.Add(1, SharpMap.Styles.VectorStyle.CreateRandomLinealStyle());
				dict.Add(2, SharpMap.Styles.VectorStyle.CreateRandomLinealStyle());
				dict.Add(3, SharpMap.Styles.VectorStyle.CreateRandomLinealStyle());
				dict.Add(4, SharpMap.Styles.VectorStyle.CreateRandomLinealStyle());
				l.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme<int>("test", dict,
				                                                                  SharpMap.Styles.VectorStyle.CreateRandomLinealStyle());

				map.Layers.Add(
					new VectorLayer("Geometry VectorLayer with gradient theme",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(
					                		new GeoAPI.Geometries.Coordinate(5, 5)))));
				l = map.Layers[6] as VectorLayer;
				l.Theme = new SharpMap.Rendering.Thematics.GradientTheme("test", -100, 100,
				                                                         SharpMap.Styles.VectorStyle.CreateRandomPolygonalStyle(),
				                                                         SharpMap.Styles.VectorStyle.CreateRandomPolygonalStyle());
				((SharpMap.Rendering.Thematics.GradientTheme)l.Theme).FillColorBlend = SharpMap.Rendering.Thematics.ColorBlend.RainbowMOHID;

				var ct = new SharpMap.Rendering.Thematics.CategoryTheme<int>();
				ct.ColumnName = "test";
				ct.Default = new SharpMap.Rendering.Thematics.CategoryThemeValuesItem<int> { Title = "standard", Style =
						SharpMap.Styles.VectorStyle.CreateRandomPolygonalStyle()};
				ct.Add(new SharpMap.Rendering.Thematics.CategoryThemeValuesItem<int> { Title = "Line", Style =
				       		SharpMap.Styles.VectorStyle.CreateRandomLinealStyle()});
				ct.Add(new SharpMap.Rendering.Thematics.CategoryThemeValuesItem<int> { Title = "Point", Style =
				       		SharpMap.Styles.VectorStyle.CreateRandomPuntalStyle()});
				
				map.Layers.Add(
					new VectorLayer("Geometry VectorLayer with category theme",
					                new SharpMap.Data.Providers.GeometryFeatureProvider(
					                	NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreatePoint(
					                		new GeoAPI.Geometries.Coordinate(5, 5)))));
				l = map.Layers[7] as VectorLayer;
				l.Theme = ct;
				
				try
				{

					map.ZoomToExtents();
					var factory = new LegendFactory();
					((LegendSettings)factory.LegendSettings).SymbolSize = new Size(16, 16);
                    ((LegendSettings)factory.LegendSettings).HeaderFont = new Font("Times New Roman", 8, FontStyle.Italic);
					var legend = factory.Create(map, null);
					((MapDecoration)legend).BackgroundColor = System.Drawing.Color.White;
					legend.Root.Label = "This is a super long legend title";
					using (var img = legend.GetLegendImage())
					{
						img.Save("legendimage.png");
						System.Diagnostics.Process.Start("legendimage.png");
//.........这里部分代码省略.........
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:101,代码来源:LegendTests.cs

示例8: TestSymbolizerLayers

	    public void TestSymbolizerLayers()
	    {
            using (var map = new Map())
            {
                map.SRID = 4326;

                map.Layers.Add(new PuntalVectorLayer("Puntal with CharacterPointSymbolizer",
                    new GeometryProvider(map.Factory.CreatePoint(new Coordinate(0, 0))),
                    new CharacterPointSymbolizer
                    {
                        Font = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Pixel),
                        CharacterIndex = 65,
                        Foreground = new SolidBrush(Color.Violet),
                        Halo = 2,
                        HaloBrush = new SolidBrush(Color.Silver)
                    }));

                map.Layers.Add(new PuntalVectorLayer("Puntal with PathPointSymbolizer",
                    new GeometryProvider(map.Factory.CreatePoint(new Coordinate(0, 0))),
                    PathPointSymbolizer.CreateCircle(Pens.Aquamarine, Brushes.BurlyWood, 24)));

                try
                {

                    map.ZoomToExtents();
                    var factory = new LegendFactory();
                    ((LegendSettings)factory.LegendSettings).SymbolSize = new Size(24, 24);
                    ((LegendSettings)factory.LegendSettings).HeaderFont = new Font("Times New Roman", 14, FontStyle.Italic, GraphicsUnit.Pixel);
                    var legend = factory.Create(map, null);
                    ((MapDecoration)legend).BackgroundColor = System.Drawing.Color.White;
                    legend.Root.Label = "This is a super long legend title";
                    using (var img = legend.GetLegendImage(300))
                    {
                        img.Save("legendimage2.png");
                        System.Diagnostics.Process.Start("legendimage2.png");
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:43,代码来源:LegendTests.cs


注:本文中的Map.ZoomToExtents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。