예제 #1
0
        public void TestLayer()
        {
            var map = new SharpMap.Map(new System.Drawing.Size(500, 500));
            var gp  = new SharpMap.Data.Providers.GeometryProvider(
                new[]
            {
                Factory.CreatePolygon(
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(0, 0),
                                               new System.Drawing.SizeF(40, 30)),
                    new[]
                {
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(90, 55),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(77, 24),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-80, 41),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-45, -36),
                                               new System.Drawing.SizeF(40, 30)),
                })
            });
            var gl = new SharpMap.Layers.VectorLayer("GeometryLayer", gp);

            map.Layers.Add(gl);
            map.ZoomToExtents();
            var mapimage = map.GetMap();

            mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png);
        }
예제 #2
0
파일: Form2.cs 프로젝트: lishxi/_SharpMap
        private void Form2_Load(object sender, EventArgs e)
        {

            
            //TileAsyncLayer osmLayer= new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");
            TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "",BingMapType.Roads), "TileLayer - Bing" );
            
            this.mapBox1.Map.BackgroundLayer.Add(bingLayer);

#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), 
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), 
                mathTransform);
#endif

            //Adds a pushpin layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            List<SharpMap.Geometries.Geometry> geos = new List<SharpMap.Geometries.Geometry>();
            geos.Add(geom.GetCentroid());
            SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            //this.mapBox1.Map.Layers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Map.Zoom = 8500;
           
            this.mapBox1.Refresh();
            
        }
예제 #3
0
        public void TestXml1()
        {
            var xml         = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<root>
  <Points>
    <Point>
    <X>13457786.5961983</X>
    <Y>1629064.58490612</Y>
    </Point>
  </Points>
</root>";
            var xmlFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), "xml");

            using (var sw = new System.IO.StreamWriter(System.IO.File.OpenWrite(xmlFileName)))
                sw.Write(xml);

            var factory = new NetTopologySuite.Geometries.GeometryFactory();

            SharpMap.Data.Providers.GeometryProvider p = null;
            using (var fs = System.IO.File.OpenRead(xmlFileName))
            {
                p = new SharpMap.Data.Providers.GeometryProvider(PointsFromXml(factory, fs));
                NUnit.Framework.Assert.IsNotNull(p);
                NUnit.Framework.Assert.AreEqual(1, p.Geometries.Count);
            }

            System.IO.File.Delete(xmlFileName);
        }
예제 #4
0
        private static VectorLayer CrearCapaInfoEst(VectorLayer capaBase)
        {
            //Layer reservada para consultas con el botón info (vacia)
            VectorLayer capaInfoEst = new SharpMap.Layers.VectorLayer(NOMCAPA_INFO);

            //Atención: si Envelope de capaBase es nulo (i.e. no hay geometrías en la capaBase)
            //proporcionar un punto al proveedor para evitar error en tiempo de ejecución
            SharpMap.Data.Providers.GeometryProvider provGeo;
            if (capaBase.Envelope == null)
            {
                provGeo = new SharpMap.Data.Providers.GeometryProvider(new SharpMap.Geometries.Point(0.0, 0.0));
            }
            else
            {
                provGeo = new SharpMap.Data.Providers.GeometryProvider(capaBase.Envelope.GetCentroid());
            }

            provGeo.SRID           = capaBase.SRID;
            capaInfoEst.DataSource = provGeo;
            SimbLayInfoEst s = new SimbLayInfoEst();

            capaInfoEst.Enabled = s.visible;
            capaInfoEst.Style   = ObtenerEstilo(TipoPaleta.predeterminada, s);
            AsignarEntradaLeyendaInformacion(NOMCAPA_INFO, capaInfoEst, s.titulo);
            return(capaInfoEst);
        }
예제 #5
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //TileAsyncLayer osmLayer= new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");
            TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing");

            this.mapBox1.Map.BackgroundLayer.Add(bingLayer);

#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform);
#endif

            //Adds a pushpin layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            List <SharpMap.Geometries.Geometry> geos = new List <SharpMap.Geometries.Geometry>();
            geos.Add(geom.GetCentroid());
            SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            //this.mapBox1.Map.Layers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Map.Zoom = 8500;

            this.mapBox1.Refresh();
        }
예제 #6
0
        public void TestXml1()
        {
            var xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
            <root>
              <Points>
            <Point>
            <X>13457786.5961983</X>
            <Y>1629064.58490612</Y>
            </Point>
              </Points>
            </root>";
            var xmlFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), "xml");

            using (var sw = new System.IO.StreamWriter(System.IO.File.OpenWrite(xmlFileName)))
                sw.Write(xml);

            var factory = new NetTopologySuite.Geometries.GeometryFactory();

            SharpMap.Data.Providers.GeometryProvider p = null;
            using (var fs = System.IO.File.OpenRead(xmlFileName))
            {
                p = new SharpMap.Data.Providers.GeometryProvider(PointsFromXml(factory, fs));
                NUnit.Framework.Assert.IsNotNull(p);
                NUnit.Framework.Assert.AreEqual(1, p.Geometries.Count);
            }

            System.IO.File.Delete(xmlFileName);
        }
예제 #7
0
        private static VectorLayer CrearCapaSelPlanta(VectorLayer capaBase, List <Geometry> lp)
        {
            VectorLayer capaSelPlanta = new SharpMap.Layers.VectorLayer(NOMCAPA_CONSULTA);

            SharpMap.Data.Providers.GeometryProvider provGeo = new SharpMap.Data.Providers.GeometryProvider(lp);
            provGeo.SRID             = capaBase.SRID;
            capaSelPlanta.DataSource = provGeo;
            SimbLaySelPlanta s = new SimbLaySelPlanta();

            capaSelPlanta.Enabled = s.visible;
            capaSelPlanta.Style   = ObtenerEstilo(TipoPaleta.predeterminada, s);
            AsignarEntradaLeyendaConsulta(NOMCAPA_CONSULTA, capaSelPlanta, s.titulo);
            return(capaSelPlanta);
        }
예제 #8
0
        private static VectorLayer CrearCapaSelEst(VectorLayer capaBase, Estancia est)
        {
            //Layer de la estancia seleccionada en el arbol de estancias
            VectorLayer capaSelEst = new SharpMap.Layers.VectorLayer(est.Codigo);

            SharpMap.Data.Providers.GeometryProvider provGeo = new SharpMap.Data.Providers.GeometryProvider(est.Geometria);
            provGeo.SRID          = capaBase.SRID;
            capaSelEst.DataSource = provGeo;
            SimbLaySelEst s = new SimbLaySelEst();

            capaSelEst.Enabled = s.visible;
            capaSelEst.Style   = ObtenerEstilo(TipoPaleta.predeterminada, s);
            AsignarEntradaLeyendaSeleccion(capaSelEst.LayerName, capaSelEst, s.titulo);
            return(capaSelEst);
        }
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {
            //Lisbon...
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;

            GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);

            var map = new SharpMap.Map();
            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoads), "TileLayer - Bing");

            map.BackgroundLayer.Add(layer2);

            var gf = new GeometryFactory(new PrecisionModel(), 3857);

            //Adds a static layer
            var staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            var aux = new List <IGeometry>();

            aux.Add(gf.CreatePoint(geom.Centre));
            staticLayer.Style.Symbol = Resources.PumpSmall;
            var geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux);

            staticLayer.DataSource = geoProviderFixed;
            map.Layers.Add(staticLayer);


            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");

            position = geom.Centre;
            geos.Add(gf.CreatePoint(position));
            pushPinLayer.Style.Symbol = Resources.OutfallSmall;
            var geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);

            pushPinLayer.DataSource = geoProvider;
            map.VariableLayers.Add(pushPinLayer);

            map.ZoomToBox(geom);


            this.mapBox1.Map = map;

            this.mapBox1.Refresh();
        }
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {

            //Lisbon...
#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform);
#endif


            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");


            this.mapBox1.Map.BackgroundLayer.Add(layer2);

            //Adds a static layer
            VectorLayer staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            List<SharpMap.Geometries.Geometry> aux = new List<SharpMap.Geometries.Geometry>();
            aux.Add(geom.GetCentroid());
            staticLayer.Style.Symbol = Resources.PumpSmall;
            SharpMap.Data.Providers.GeometryProvider geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux);
            staticLayer.DataSource = geoProviderFixed;
            this.mapBox1.Map.Layers.Add(staticLayer);

            
            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            position = geom.GetCentroid();
            geos.Add(position);
            pushPinLayer.Style.Symbol = Resources.OutfallSmall;
            SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            this.mapBox1.Map.VariableLayers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Refresh();

        }
예제 #11
0
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {
            //Lisbon...
#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            SharpMap.Geometries.BoundingBox geom = GeometryTransform.TransformBox(
                new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837),
                mathTransform);
#endif


            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");


            this.mapBox1.Map.BackgroundLayer.Add(layer2);

            //Adds a static layer
            VectorLayer staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            List <SharpMap.Geometries.Geometry> aux = new List <SharpMap.Geometries.Geometry>();
            aux.Add(geom.GetCentroid());
            staticLayer.Style.Symbol = Resources.PumpSmall;
            SharpMap.Data.Providers.GeometryProvider geoProviderFixed = new SharpMap.Data.Providers.GeometryProvider(aux);
            staticLayer.DataSource = geoProviderFixed;
            this.mapBox1.Map.Layers.Add(staticLayer);


            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            position = geom.GetCentroid();
            geos.Add(position);
            pushPinLayer.Style.Symbol = Resources.OutfallSmall;
            SharpMap.Data.Providers.GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            this.mapBox1.Map.VariableLayers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Refresh();
        }
예제 #12
0
        protected override void OnMapControlChangedInternal(EventArgs e)
        {
            base.OnMapControlChangedInternal(e);

            if (MapControl == null)
            {
                _layer.Dispose();
                _layer  = null;
                Enabled = false;
                return;
            }

            _geometryProvider = new SharpMap.Data.Providers.GeometryProvider((GeoAPI.Geometries.IGeometry)null);
            _layer            = new SharpMap.Layers.VectorLayer("_tmp_Geometries", _geometryProvider);

            MapControl.ActiveToolChanged += OnMapControlActiveToolChanged;
            MapControl.GeometryDefined   += OnGeometryDefined;
        }
예제 #13
0
        public void TestIssue116()
        {
            string rasterFile = TestUtility.GetPathToTestFile("world.topo.bathy.200412.3x21600x10800.jpg");

            if (!System.IO.File.Exists(rasterFile))
            {
                Assert.Ignore("Test file {0} not present.", rasterFile);
            }

            using (var map = new SharpMap.Map())
            {
                var rasterLyr = new SharpMap.Layers.GdalRasterLayer("Raster", rasterFile);
                map.Layers.Add(rasterLyr);

                var linePoints = new[] { new GeoAPI.Geometries.Coordinate(0, 0), new GeoAPI.Geometries.Coordinate(10, 10) };
                var line       = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(4326).CreateLineString(linePoints);
                var linealDs   = new SharpMap.Data.Providers.GeometryProvider(line);
                var linealLyr  = new SharpMap.Layers.VectorLayer("Lineal", linealDs)
                {
                    SRID = 4326
                };
                linealLyr.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Red, 2f)
                {
                    EndCap = System.Drawing.Drawing2D.LineCap.Round
                };
                map.Layers.Add(linealLyr);

                map.ZoomToExtents();
                var centerMap = new System.Drawing.PointF(map.Size.Width / 2f, map.Size.Height / 2f);
                for (float f = -180; f <= 180; f += 5)
                {
                    var mapTransform = new System.Drawing.Drawing2D.Matrix();
                    mapTransform.RotateAt(f, centerMap);

                    map.MapTransform = mapTransform;

                    using (var img = map.GetMap())
                        img.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), $"TestIssue116.{(f < 0 ? "N" : "P")}{((int)Math.Abs(f)):D3}deg.png"));
                }
            }
        }
예제 #14
0
        public static Estancia RefrescaCapaInfoEst(Map mapa, string codEst)
        {
            object[] parametros = new object[1] {
                codEst
            };
            DataSet ds = DBUtils.GetDataSet(DB.dbOrigen.PGSQL, "SELECT * FROM quest_estancias WHERE codigo = :param1", parametros);

            try
            {
                List <Estancia> l = ObjectFactory.generarListaEstancias(ds);
                if (l != null)
                {
                    if (l.Count > 0)
                    {
                        //Resaltar lo seleccionado mediante el botón info en una nueva capa
                        VectorLayer capaInfoEst = (SharpMap.Layers.VectorLayer)mapa.GetLayerByName(NOMCAPA_INFO);
                        SharpMap.Data.Providers.GeometryProvider provGeo = new SharpMap.Data.Providers.GeometryProvider(l[0].Geometria);
                        capaInfoEst.DataSource = provGeo;
                        capaInfoEst.Enabled    = true;
                        return(l[0]);
                    }
                    else
                    {
                        throw new ApplicationException("No se encontró ninguna estancia");
                    }
                }
                else
                {
                    throw new ApplicationException("No se encontró ninguna estancia");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #15
0
        private void LoadParcels(List<PointD> pt, Color color, string labelname)
        {
            SharpMap.Map map = new SharpMap.Map();
            List<GeoAPI.Geometries.Coordinate> vertices = new List<GeoAPI.Geometries.Coordinate>();

            foreach (PointD i in pt)
            {
                GeoAPI.Geometries.Coordinate p = new GeoAPI.Geometries.Coordinate();
                p.X = i.X;
                p.Y = i.Y;
                vertices.Add(p);
            }
            GeoAPI.Geometries.Coordinate l = new GeoAPI.Geometries.Coordinate();
            l.X = pt[0].X;
            l.Y = pt[0].Y;
            vertices.Add(l);

            //Collection<GeoAPI.Geometries.IGeometry> geom = new Collection<GeoAPI.Geometries.IGeometry>();

            GeometryFactory gf = new NetTopologySuite.Geometries.GeometryFactory();
            GeoAPI.Geometries.ILinearRing shell = gf.CreateLinearRing(vertices.ToArray());

            GeoAPI.Geometries.IPolygon polygon = gf.CreatePolygon(shell, null);

            SharpMap.Data.Providers.GeometryProvider geomProvider= new SharpMap.Data.Providers.GeometryProvider(polygon);

            SharpMap.Layers.VectorLayer layerParcels = new SharpMap.Layers.VectorLayer("Parcels");

            SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();

            style.Fill = new SolidBrush(Color.FromArgb(200,color));
            style.Outline = new Pen(new SolidBrush(color));

            layerParcels.Style = style;
            layerParcels.Style.EnableOutline = true;

            layerParcels.DataSource = geomProvider;
            layerParcels.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;

            var fdt = new SharpMap.Data.FeatureDataTable();
            fdt.Columns.Add(new System.Data.DataColumn("id", typeof(uint)));
            fdt.Columns.Add(new System.Data.DataColumn("label", typeof(string)));
            var fdr = (SharpMap.Data.FeatureDataRow)fdt.NewRow();
            fdr.ItemArray = new object[] { 1, labelname };
            fdr.Geometry =  polygon;
            fdt.AddRow(fdr);

            var dataprovider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);

            var ll = new SharpMap.Layers.LabelLayer("llayer");
            ll.DataSource = dataprovider;
            ll.LabelColumn = "label";
            ll.Style.Font = new Font("Eurostile Extended", 16,FontStyle.Bold);

            mapBox1.Map.Layers.Add(layerParcels);
            mapBox1.Map.Layers.Add(ll);

            mapBox1.Map.ZoomToExtents();
            mapBox1.Refresh();
        }
예제 #16
0
 public void TestLayer()
 {
     var map = new SharpMap.Map(new System.Drawing.Size(500, 500));
     var gp = new SharpMap.Data.Providers.GeometryProvider(
         new SharpMap.Geometries.Geometry[]
             {
                 new SharpMap.Geometries.Polygon(ShapeFactory.CreateEllipse(new SharpMap.Geometries.Point(0, 0), new System.Drawing.SizeF(40, 30))),
                 ShapeFactory.CreateEllipse(new SharpMap.Geometries.Point(90, 55), new System.Drawing.SizeF(40, 30)),
                 ShapeFactory.CreateEllipse(new SharpMap.Geometries.Point(77, 24), new System.Drawing.SizeF(40, 30)),
                 ShapeFactory.CreateEllipse(new SharpMap.Geometries.Point(-80, 41), new System.Drawing.SizeF(40, 30)),
                 ShapeFactory.CreateEllipse(new SharpMap.Geometries.Point(-45, -36), new System.Drawing.SizeF(40, 30)),
             });
     var gl = new SharpMap.Layers.VectorLayer("GeometryLayer", gp);
     map.Layers.Add(gl);
     map.ZoomToExtents();
     var mapimage = map.GetMap();
     mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png);
 }
        protected override void OnMapControlChangedInternal(EventArgs e)
        {
            base.OnMapControlChangedInternal(e);

            if (MapControl == null)
            {
                _layer.Dispose();
                _layer = null;
                Enabled = false;
                return;
            }

            _geometryProvider = new SharpMap.Data.Providers.GeometryProvider((GeoAPI.Geometries.IGeometry)null);
            _layer = new SharpMap.Layers.VectorLayer("_tmp_Geometries", _geometryProvider);

            MapControl.ActiveToolChanged += OnMapControlActiveToolChanged;
            MapControl.GeometryDefined += OnGeometryDefined;
        }
예제 #18
0
        private void LoadParcels(List <PointD> pt, Color color, string labelname)
        {
            SharpMap.Map map = new SharpMap.Map();
            List <GeoAPI.Geometries.Coordinate> vertices = new List <GeoAPI.Geometries.Coordinate>();


            foreach (PointD i in pt)
            {
                GeoAPI.Geometries.Coordinate p = new GeoAPI.Geometries.Coordinate();
                p.X = i.X;
                p.Y = i.Y;
                vertices.Add(p);
            }
            GeoAPI.Geometries.Coordinate l = new GeoAPI.Geometries.Coordinate();
            l.X = pt[0].X;
            l.Y = pt[0].Y;
            vertices.Add(l);

            //Collection<GeoAPI.Geometries.IGeometry> geom = new Collection<GeoAPI.Geometries.IGeometry>();



            GeometryFactory gf = new NetTopologySuite.Geometries.GeometryFactory();

            GeoAPI.Geometries.ILinearRing shell = gf.CreateLinearRing(vertices.ToArray());

            GeoAPI.Geometries.IPolygon polygon = gf.CreatePolygon(shell, null);


            SharpMap.Data.Providers.GeometryProvider geomProvider = new SharpMap.Data.Providers.GeometryProvider(polygon);

            SharpMap.Layers.VectorLayer layerParcels = new SharpMap.Layers.VectorLayer("Parcels");

            SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();



            style.Fill    = new SolidBrush(Color.FromArgb(200, color));
            style.Outline = new Pen(new SolidBrush(color));

            layerParcels.Style = style;
            layerParcels.Style.EnableOutline = true;


            layerParcels.DataSource    = geomProvider;
            layerParcels.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;

            var fdt = new SharpMap.Data.FeatureDataTable();

            fdt.Columns.Add(new System.Data.DataColumn("id", typeof(uint)));
            fdt.Columns.Add(new System.Data.DataColumn("label", typeof(string)));
            var fdr = (SharpMap.Data.FeatureDataRow)fdt.NewRow();

            fdr.ItemArray = new object[] { 1, labelname };
            fdr.Geometry  = polygon;
            fdt.AddRow(fdr);

            var dataprovider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);

            var ll = new SharpMap.Layers.LabelLayer("llayer");

            ll.DataSource  = dataprovider;
            ll.LabelColumn = "label";
            ll.Style.Font  = new Font("Eurostile Extended", 16, FontStyle.Bold);



            mapBox1.Map.Layers.Add(layerParcels);
            mapBox1.Map.Layers.Add(ll);



            mapBox1.Map.ZoomToExtents();
            mapBox1.Refresh();
        }