示例#1
0
        private void FormDemoDrawGeometries_Load(object sender, EventArgs e)
        {
            //this.mapBox1.Map = ShapefileSample.InitializeMap(0);
            //Google Background
            TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing");

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


            SharpMap.Layers.VectorLayer vl = new VectorLayer("My Geometries");
            geoProvider   = new SharpMap.Data.Providers.FeatureProvider(new List <IGeometry>());
            vl.DataSource = geoProvider;
            this.mapBox1.Map.Layers.Add(vl);

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

            this.mapBox1.Map.ZoomToExtents(); //(geom);
            this.mapBox1.Refresh();

            this.mapBox1.GeometryDefined += new SharpMap.Forms.MapBox.GeometryDefinedHandler(mapBox1_GeometryDefined);

            this.mapBox1.ActiveToolChanged += new SharpMap.Forms.MapBox.ActiveToolChangedHandler(mapBox1_ActiveToolChanged);

            this.mapBox1.MouseMove += new SharpMap.Forms.MapBox.MouseEventHandler(mapBox1_MouseMove);
        }
        private void FormDemoDrawGeometries_Load(object sender, EventArgs e)
        {



            //this.mapBox1.Map = ShapefileSample.InitializeMap(0);
            //Google Background
            TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing");
            this.mapBox1.Map.BackgroundLayer.Add(bingLayer);


            SharpMap.Layers.VectorLayer vl = new VectorLayer("My Geometries");
            geoProvider = new SharpMap.Data.Providers.FeatureProvider(new List<IGeometry>());
            vl.DataSource = geoProvider;
            this.mapBox1.Map.Layers.Add(vl);

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

            this.mapBox1.Map.ZoomToExtents(); //(geom);
            this.mapBox1.Refresh();

            this.mapBox1.GeometryDefined += new SharpMap.Forms.MapBox.GeometryDefinedHandler(mapBox1_GeometryDefined);

            this.mapBox1.ActiveToolChanged += new SharpMap.Forms.MapBox.ActiveToolChangedHandler(mapBox1_ActiveToolChanged);

            this.mapBox1.MouseMove += new SharpMap.Forms.MapBox.MouseEventHandler(mapBox1_MouseMove);
        }