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


C# Map.AddLayer方法代码示例

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


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

示例1: setupShapefile

        private static void setupShapefile(HttpContext context, Map m)
        {
            GeometryServices geometryServices = new GeometryServices();

            string[] layernames = new[]
                                      {
                                          "Countries",
                                          "Rivers"/*,
                                          "Cities"*/
                                      };

            foreach (string s in layernames)
            {
                ShapeFileProvider shapeFile =
               new ShapeFileProvider(context.Server.MapPath(string.Format("~/App_Data/Shapefiles/{0}.shp", s)),
                                     geometryServices.DefaultGeometryFactory,
                                     geometryServices.CoordinateSystemFactory, false);
                shapeFile.IsSpatiallyIndexed = false;

                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(shapeFile);

                GeoJsonGeometryStyle style = RandomStyle.RandomGeometryStyle();
                /* include GeoJson styles */
                style.IncludeAttributes = false;
                style.IncludeBBox = true;
                style.PreProcessGeometries = false;
                style.CoordinateNumberFormatString = "{0:F}";

                GeometryLayer geometryLayer = new GeometryLayer(s, style, provider);
                geometryLayer.Features.IsSpatiallyIndexed = false;
                m.AddLayer(geometryLayer);
                provider.Open();
            }

        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:35,代码来源:DemoMapSetupUtility.cs

示例2: DoRedo

        public void DoRedo(Map map, D2DMapEditor d2d)
        {
            int nodeId = Redo.Peek().Id;
            int layerIndex = -1;

            if (Redo.Peek().Action == ActionType.AddLayer)
            {
                HistoryNode redo = Redo.Pop();
                Undo.Push(new HistoryNode(redo.Id, redo.LayerId, redo.Layer, redo.LayerIndex, redo.Action));
                map.AddLayer(redo.Layer, redo.LayerIndex);
                layerIndex = map.FindLayerIndexWithId(redo.LayerId);
                d2d.ReloadLayers(-1);
            }
            else if (Redo.Peek().Action == ActionType.DeleteLayer)
            {
                HistoryNode redo = Redo.Pop();
                Undo.Push(new HistoryNode(redo.Id, redo.LayerId, redo.Layer, redo.LayerIndex, redo.Action));
                layerIndex = map.FindLayerIndexWithId(redo.LayerId);
                map.Layers.RemoveAt(redo.LayerIndex);
                d2d.ReloadLayers(-1);
            }
            else if (Redo.Peek().Action == ActionType.SwapLayer)
            {
                HistoryNode redo = Redo.Pop();
                Undo.Push(new HistoryNode(redo.Id, redo.LayerIndex, redo.LayerIndex2, redo.Action));
                map.SwapLayers(map, redo.LayerIndex, redo.LayerIndex2);
                layerIndex = redo.LayerIndex;
                d2d.ReloadLayers(-1);
            }
            else
            {
                while (Redo.Count > 0 && nodeId == Redo.Peek().Id)
                {   // redo
                    HistoryNode redo = Redo.Pop();
                    layerIndex = map.FindLayerIndexWithId(redo.LayerId);

                    if (layerIndex >= 0)
                    {
                        // save current map for undo
                        Undo.Push(new HistoryNode(redo.Id, redo.LayerId, redo.X, redo.Y, map.Layers[layerIndex].LayerData[redo.X, redo.Y], redo.Action));
                        // render redo
                        map.Layers[layerIndex].LayerData[redo.X, redo.Y] = redo.Value;
                    }

                }
            }

            if (layerIndex == -1)
                MessageBox.Show("Cannot redo! Layer was removed", "Redo Failed");
        }
开发者ID:Nacheon,项目名称:2D-Map-Tool-using-C-,代码行数:50,代码来源:History.cs

示例3: SelectedLayerNullIfLayerRemoved

        public void SelectedLayerNullIfLayerRemoved()
        {
            var map = new Map();
            var path = Path.Combine("TestFiles", "test-randomPts.shp");
            var myLayer = map.AddLayer(path);

            Assert.IsNotNull(myLayer, "the added map layer should not be null.");

            myLayer.IsSelected = true;
            Assert.AreEqual(map.Layers.SelectedLayer, myLayer, "the selected layer should be equal to myLayer.");

            //now remove all layers
            map.Layers.Clear();

            //selectedLayer should be null
            Assert.IsNull(map.Layers.SelectedLayer, "SelectedLayer should be null after removing all layers");
        }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:17,代码来源:MapLayerCollectionTest.cs

示例4: SelectedLayerNullIfLayerRemoved

        public void SelectedLayerNullIfLayerRemoved()
        {
            var map = new Map();
            var path = FileTools.PathToTestFile(@"Shapefiles\Lakes\lakes.shp");
            var myLayer = map.AddLayer(path);

            Assert.IsNotNull(myLayer, "the added map layer should not be null.");

            myLayer.IsSelected = true;
            Assert.AreEqual(map.Layers.SelectedLayer, myLayer, "the selected layer should be equal to myLayer.");

            //now remove all layers
            map.Layers.Clear();

            //selectedLayer should be null
            Assert.IsNull(map.Layers.SelectedLayer, "SelectedLayer should be null after removing all layers");
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:17,代码来源:MapLayerCollectionTest.cs

示例5: GridView_IsSolid

        public void GridView_IsSolid()
        {
            Map m = new Map(256, 256);
            m.AddLayer(new Layer("test"));
            m.ZoomAll();
            Grid g = new Grid(256, 256);
            m.Render(g);
            GridView v1 = g.View(0, 0, 256, 256);
            Assert.IsTrue(v1.IsSolid());

            m.Clear();
            g.Clear();
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            m.Render(g);
            GridView v2 = g.View(0, 0, 256, 256);
            Assert.IsFalse(v2.IsSolid());
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:19,代码来源:GridViewTests.cs

示例6: Grid_Painted

        public void Grid_Painted()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Grid g = new Grid(256, 256);
            Assert.IsFalse(g.Painted());

            Map m = new Map(256, 256);
            Layer l = new Layer("test");
            m.AddLayer(l);
            m.Render(g);
            Assert.IsFalse(g.Painted());

            m.Clear();
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            var options = new Dictionary<string, object>()
            {
                {"Fields", new List<string>() { "FIPS" } },
                {"Layer", "world" }
            };
            m.Render(g);
            Assert.IsTrue(g.Painted());
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:23,代码来源:GridTests.cs

示例7: MouseMoveTile

            public void MouseMoveTile(MapEventInfo mei)
            {
                int _x0 = mei.start.tx;
                int _y0 = mei.start.ty;
                int _x1 = mei.current.tx;
                int _y1 = mei.current.ty;
                int x0 = Math.Min(_x0, _x1);
                int x1 = Math.Max(_x0, _x1);
                int y0 = Math.Min(_y0, _y1);
                int y1 = Math.Max(_y0, _y1);

                Map m = new Map();

                if (bMultilayer)
                    m = mei.editedMap.tileCopyRange(x0, y0, x1 - x0 + 1, y1 - y0 + 1);
                else
                {
                    MapLayer ml = mei.editedLayer.copyRange(x0, y0, x1 - x0 + 1, y1 - y0 + 1);
                    ml.parentmap = m;
                    m.AddLayer(ml);
                }
                m.IsBrush = true;
                m.vsp = mei.editedMap.vsp;
                Global.clipboard = m;
                mei.bDirty = true;
            }
开发者ID:mcgrue,项目名称:maped3,代码行数:26,代码来源:HardcodedPlugins.cs

示例8: LoadLayer

        private void LoadLayer(Stream stream, Map map)
        {
            string id = LoadString(stream);
            bool visible = LoadBool(stream);
            string description = LoadString(stream);
            Size layerSize = LoadSize(stream);
            Size tileSize = LoadSize(stream);

            Layer layer = new Layer(id, map, layerSize, tileSize);
            layer.Description = description;
            layer.Visible = visible;

            LoadProperties(stream, layer);

            Location tileLocation = Location.Origin;
            TileSheet tileSheet = null;
            for (; tileLocation.Y < layerSize.Height; tileLocation.Y++)
            {
                tileLocation.X = 0;

                while (tileLocation.X < layerSize.Width)
                {
                    char ch = (char)stream.ReadByte();
                    switch (ch)
                    {
                        case 'T':
                            string tileSheetId = LoadString(stream);
                            tileSheet = map.GetTileSheet(tileSheetId);
                            break;
                        case 'N':
                            int nullCount = LoadInt32(stream);
                            tileLocation.X += nullCount;
                            break;
                        case 'S':
                            layer.Tiles[tileLocation] = LoadStaticTile(stream, layer, tileSheet);
                            ++tileLocation.X;
                            break;
                        case 'A':
                            layer.Tiles[tileLocation] = LoadAnimatedTile(stream, layer);
                            ++tileLocation.X;
                            break;
                        default:
                            throw new Exception("Excpected character byte 'T', 'N', 'S' oe 'A'");
                    }
                }
            }

            map.AddLayer(layer);
        }
开发者ID:dekk7,项目名称:xEngine,代码行数:49,代码来源:TbinFormat.cs

示例9: Map_QueryMapPoint_MultipleLayers

        public void Map_QueryMapPoint_MultipleLayers()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\test.xml");

            Layer l = new Layer("world2");
            Datasource d = new Datasource(
                   new Dictionary<string, object>() {
                       { "type","shape"},
                       { "file", @".\data\world_merc.shp" }
                   }
            );
            l.Datasource = d;
            m.AddLayer(l);
            m.ZoomAll();

            IEnumerable<MapQueryResult> r;

            //query single layer
            r = m.QueryMapPoint(55, 130, "world2");
            Assert.AreEqual(r.Count(), 1);
            MapQueryResult mqr = r.ToList()[0];
            Assert.AreEqual(mqr.Layer, "world2");

            //query all
            r = m.QueryMapPoint(55, 130);
            Assert.AreEqual(r.Count(), 2);
            MapQueryResult mqr1 = r.ToList()[0];
            Assert.AreEqual(mqr1.Layer, "world");
            MapQueryResult mqr2 = r.ToList()[1];
            Assert.AreEqual(mqr2.Layer, "world2");
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:33,代码来源:MapTests.cs

示例10: Map_Clone

        public void Map_Clone()
        {
            Map m = new Map(256, 256);
            m.AddLayer(new Layer("layer"));
            Map m2 = m.Clone();
            Assert.AreEqual(m.Layers().Count(), 1);
            Assert.AreEqual(m2.Layers().Count(), 1);

            m.Clear();
            Assert.AreEqual(m.Layers().Count(), 0);
            Assert.AreEqual(m2.Layers().Count(), 1);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:12,代码来源:MapTests.cs

示例11: Map_GetSetLayer

        public void Map_GetSetLayer()
        {
            Layer l = new Layer("layer", "+init=epsg:4326");
            Map m = new Map(256, 256);
            m.AddLayer(l);

            IEnumerable<Layer> layers = m.Layers();
            Assert.AreEqual(layers.Count(), 1);

            Layer l1 = m.GetLayer("layer");
            Assert.AreEqual(l1.Name, "layer");
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:12,代码来源:MapTests.cs

示例12: LoadLayer

        private void LoadLayer(XmlHelper xmlHelper, Map map)
        {
            string id = xmlHelper.GetAttribute("Id");

            bool visible = bool.Parse(xmlHelper.GetAttribute("Visible"));

            xmlHelper.AdvanceStartElement("Description");
            string description = xmlHelper.GetCData();
            xmlHelper.AdvanceEndElement("Description");

            xmlHelper.AdvanceStartElement("Dimensions");
            Size layerSize = Size.FromString(xmlHelper.GetAttribute("LayerSize"));
            Size tileSize = Size.FromString(xmlHelper.GetAttribute("TileSize"));
            xmlHelper.AdvanceEndElement("Dimensions");

            Layer layer = new Layer(id, map, layerSize, tileSize);
            layer.Description = description;
            layer.Visible = visible;

            xmlHelper.AdvanceStartElement("TileArray");

            Location tileLocation = Location.Origin;
            TileSheet tileSheet = null;
            XmlReader xmlReader = xmlHelper.XmlReader;
            while (xmlHelper.AdvanceStartRepeatedElement("Row", "TileArray"))
            {
                tileLocation.X = 0;

                while (xmlHelper.AdvanceNode() != XmlNodeType.EndElement)
                {
                    if (xmlReader.Name == "Null")
                    {
                        int nullCount = xmlHelper.GetIntAttribute("Count");
                        tileLocation.X += nullCount % layerSize.Width;
                    }
                    else if (xmlReader.Name == "TileSheet")
                    {
                        string tileSheetRef = xmlHelper.GetAttribute("Ref");
                        tileSheet = map.GetTileSheet(tileSheetRef);
                    }
                    else if (xmlReader.Name == "Static")
                    {
                        layer.Tiles[tileLocation] = LoadStaticTile(xmlHelper, layer, tileSheet);

                        ++tileLocation.X;
                    }
                    else if (xmlReader.Name == "Animated")
                    {
                        layer.Tiles[tileLocation] = LoadAnimatedTile(xmlHelper, layer, tileSheet);

                        ++tileLocation.X;
                    }
                }

                ++tileLocation.Y;
            }

            LoadProperties(xmlHelper, layer);

            xmlHelper.AdvanceEndElement("Layer");

            map.AddLayer(layer);
        }
开发者ID:dekk7,项目名称:xEngine,代码行数:63,代码来源:TideFormat.cs

示例13: setupMsSqlSpatial

        private static void setupMsSqlSpatial(Map m)
        {
            string[] layernames = new[]
                                      {"Rivers",
                                          "Countries"
                                          /*,
                                          "Cities"*/
                                      };

            string sridstr = SridMap.DefaultInstance.Process(4326, "");

            foreach (string lyrname in layernames)
            {
                string tbl = lyrname;


                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(
                    new MsSqlSpatialProvider(
                        new GeometryServices()[sridstr],
                        ConfigurationManager.ConnectionStrings["db"].ConnectionString,
                        "st",
                        "dbo",
                        tbl,
                        "oid",
                        "Geometry")
                        {
                            DefaultProviderProperties
                                = new ProviderPropertiesExpression(
                                new ProviderPropertyExpression[]
                                    {
                                        new WithNoLockExpression(true)
                                    })
                        });


                GeoJsonGeometryStyle style = new GeoJsonGeometryStyle();

                switch (tbl)
                {
                    case "Rivers":
                        {
                            StyleBrush brush = new SolidStyleBrush(StyleColor.Blue);
                            StylePen pen = new StylePen(brush, 1);
                            style.Enabled = true;
                            style.EnableOutline = true;
                            style.Line = pen;
                            style.Fill = brush;
                            break;
                        }

                    case "Countries":
                        {
                            StyleBrush brush = new SolidStyleBrush(new StyleColor(0, 0, 0, 255));
                            StylePen pen = new StylePen(brush, 2);
                            style.Enabled = true;
                            style.EnableOutline = true;
                            style.Line = pen;
                            style.Fill = new SolidStyleBrush(StyleColor.Green);

                            break;
                        }

                    default:
                        {
                            style = RandomStyle.RandomGeometryStyle();
                            style.MaxVisible = 100000;
                            break;
                        }
                }


                /* include GeoJson styles */
                style.IncludeAttributes = false;
                style.IncludeBBox = true;
                style.PreProcessGeometries = false;
                style.CoordinateNumberFormatString = "{0:F}";
                GeometryLayer layer = new GeometryLayer(tbl, style, provider);
                layer.Features.IsSpatiallyIndexed = false;
                layer.AddProperty(AppStateMonitoringFeatureLayerProperties.AppStateMonitor, provider.Monitor);
                m.AddLayer(layer);
            }
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:82,代码来源:DemoMapSetupUtility.cs

示例14: GetPastureByFilter

        public IMap GetPastureByFilter(string strFilter)
        {
            string strSearchePattern = @"*" + strFilter + ".shp";
            IMap pastureMap = new Map();
            pastureMap.Name = strFilter;
            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();

            foreach (GrassFamily family in m_grassFamilys)
            {
                foreach (Pasture pasture in family.pastures)
                {
                    IFeatureWorkspace workspace =
                            (IFeatureWorkspace)workspaceFactory.OpenFromFile(pasture.strDataDir, 0);

                    DirectoryInfo pastureDir = new DirectoryInfo(pasture.strDataDir);
                    FileInfo[] files = pastureDir.GetFiles(strSearchePattern);
                    foreach (FileInfo file in files)
                    {
                        IFeatureLayer featureLayer = new FeatureLayerClass();
                        featureLayer.Name = pasture.strPasture+"_"+file.Name;
                        featureLayer.Visible = true;
                        featureLayer.FeatureClass = workspace.OpenFeatureClass(file.Name);

                        pastureMap.AddLayer(featureLayer);
                    }
                }
            }

            //m_mapcontrol.Map = pastureMap;

            return pastureMap;
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:32,代码来源:DataSource.cs


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