コード例 #1
0
        public static Map InitializeMap()
        {
            Map map = new Map();

            //string url = "http://labs.metacarta.com/wms-c/tilecache.py?version=1.1.1&request=GetCapabilities&service=wms-c";
            string url = "http://dev:8080/geoserver/gwc/service/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=getcapabilities&TILED=true";
            //string url = "http://dev:8080/geoserver/ows?service=wms&version=1.3.0&request=GetCapabilities&tiled=true";
            //TiledWmsLayer tiledWmsLayer = new TiledWmsLayer("Metacarta", url);
            //tiledWmsLayer.TileSetsActive.Add(tiledWmsLayer.TileSets["avalon"].Name);
            //map.Layers.Add(tiledWmsLayer);
            //map.ZoomToBox(new BoundingBox(-180.0, -90.0, 180.0, 90.0));

            //WmscRequest req;
            //ITileSource tileSource;
            TileAsyncLayer tileLayer;
            //BruTile.Web.TmsTileSource source2 = new TmsTileSource(url);

            var source = new List<ITileSource>(WmscTileSource.CreateFromWmscCapabilties(new System.Uri(url)));

            //            foreach (ITileSource src in source)
            //            {
                tileLayer = new TileAsyncLayer(source[16], "tileLayer" + source[16]);
                tileLayer.MapNewTileAvaliable += map.MapNewTileAvaliableHandler;
                map.BackgroundLayer.Add(tileLayer);
            //            }
            map.ZoomToExtents();

            return map;
        }
コード例 #2
0
ファイル: Form2.cs プロジェクト: PedroMaitan/sharpmap
 private void button1_Click(object sender, EventArgs e)
 {
     TileLayer googleLayer = new TileAsyncLayer(new GoogleTileSource(new GoogleRequest(GoogleMapType.GoogleMap), new MemoryCache<byte[]>(100, 1000)), "TileLayer - Google");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(googleLayer);
     this.mapBox1.Refresh();
 }
コード例 #3
0
ファイル: MapHelper.cs プロジェクト: vz0/custom-gis-server
    public static SharpMap.Map InitializeGoogleMap(GoogleMapType mt)
    {
        SharpMap.Map map = new SharpMap.Map();

        GoogleRequest req;
        ITileSource tileSource;
        TileAsyncLayer tileLayer;

        if (mt == (GoogleMapType.GoogleSatellite | GoogleMapType.GoogleLabels))
        {
            req = new GoogleRequest(GoogleMapType.GoogleSatellite);
            tileSource = new GoogleTileSource(req);
            tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + GoogleMapType.GoogleSatellite);
            map.Layers.Add(tileLayer);
            req = new GoogleRequest(GoogleMapType.GoogleLabels);
            tileSource = new GoogleTileSource(req);
            mt = GoogleMapType.GoogleLabels;
        }
        else
        {
            req = new GoogleRequest(mt);
            tileSource = new GoogleTileSource(req);
        }

        tileLayer = new TileAsyncLayer(tileSource, "TileLayer - " + mt);
        map.BackgroundLayer.Add(tileLayer);
        map.ZoomToBox(tileLayer.Envelope);
        return map;
    }
コード例 #4
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();
            
        }
コード例 #5
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);
            GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 3857);

#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
            IMathTransform mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);
#endif

            //Adds a pushpin layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            List<IGeometry> geos = new List<IGeometry>();
            geos.Add(gf.CreatePoint(geom.Centre));
            var geoProvider = new FeatureProvider(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
ファイル: TileLayerSample.cs プロジェクト: lishxi/_SharpMap
        private static Map InitializeMapOsm()
        {
            Map map = new Map();

            TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");
            map.BackgroundLayer.Add(tileLayer);
            map.ZoomToBox(tileLayer.Envelope);
            
            return map;
        }
コード例 #7
0
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {

            //Lisbon...
#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;
            GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);
#endif


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


            this.mapBox1.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.FeatureProvider(aux);
            staticLayer.DataSource = geoProviderFixed;
            this.mapBox1.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.FeatureProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            this.mapBox1.Map.VariableLayers.Add(pushPinLayer);

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

        }
コード例 #8
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 bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "",BingMapType.Roads), "TileLayer - Bing" );
            this.mapBox1.Map.BackgroundLayer.Add(bingLayer);

            //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();

        }
コード例 #9
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.GeometryProvider(new List<SharpMap.Geometries.Geometry>());
            vl.DataSource = geoProvider;
            this.mapBox1.Map.Layers.Add(vl);

            /*
             * SharpMap.Geometries.BoundingBox geom = 
             *     ProjNet.CoordinateSystems.Transformations.GeometryTransform.TransformBox(
             *         new SharpMap.Geometries.BoundingBox(-9.205626, 38.690993, -9.123736, 38.740837), 
             *         LayerTools.Wgs84toGoogleMercator.MathTransform);
             */

#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

            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);
        }
コード例 #10
0
ファイル: LayerHelper.cs プロジェクト: haoye1985/Oasis-V1.2
        public static void LoadTileWebLayer(MapBox mapbox, TileWebObjectType tileType)
        {

            if (mapbox != null)
            {
                try
                {
                    switch (tileType)
                    {
                        case TileWebObjectType.GoogleMap:
                            maplayer = new TileAsyncLayer(new GoogleTileSource(GoogleMapType.GoogleMap), "TileLayer - Google");
                            break;

                        case TileWebObjectType.OpenStreetMap:
                            maplayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");
                            break;

                        case TileWebObjectType.BingMap:
                            maplayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing");
                            break;

                        default:
                            break;
                    }

                    mapbox.Map.BackgroundLayer.Add(maplayer);
                    IMathTransform mathTransform = ProjectionHelper.Wgs84toGoogleMercator.MathTransform;
                    Envelope geom = GeometryTransform.TransformBox(new Envelope(-9.205626, -9.123736, 38.690993, 38.740837), mathTransform);
                    mapbox.Map.ZoomToBox(geom);
                    mapbox.Map.Zoom = 20000;
                    mapbox.Invalidate();
                }
                catch
                {
                    throw new Exception("The mapbox doesnot exist!");
                }
 
            }
        }
コード例 #11
0
ファイル: Form2.cs プロジェクト: lishxi/_SharpMap
 private void button6_Click(object sender, EventArgs e)
 {
     TileAsyncLayer osmLayer= new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(osmLayer);
     this.mapBox1.Refresh();
 }
コード例 #12
0
ファイル: TileLayerSample.cs プロジェクト: lishxi/_SharpMap
        private static Map InitializeMapOsmWithXls(float angle)
        {
            Map map = new Map();

            TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM with XLS");
            map.BackgroundLayer.Add(tileLayer);

            //Get data from excel
            string xlsPath = string.Format(XlsConnectionString, Directory.GetCurrentDirectory(), "GeoData\\Cities.xls");
            DataSet ds = new DataSet("XLS");
            using (OleDbConnection cn = new OleDbConnection(xlsPath))
            {
                cn.Open();
                using (OleDbDataAdapter da = new OleDbDataAdapter(new OleDbCommand("SELECT * FROM [Cities$]", cn)))
                    da.Fill(ds);
            }

#if !DotSpatialProjections

            //The SRS for this datasource is EPSG:4326, therefore we need to transfrom it to OSM projection
            CoordinateTransformationFactory ctf = new CoordinateTransformationFactory();
            CoordinateSystemFactory cf = new CoordinateSystemFactory();
            ICoordinateSystem epsg4326 = cf.CreateFromWkt("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]");
            ICoordinateSystem epsg3857 = cf.CreateFromWkt("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]");
            ICoordinateTransformation ct = ctf.CreateFromCoordinateSystems(epsg4326, epsg3857);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue;
                double[] coords = new[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])};
                coords = ct.MathTransform.Transform(coords);
                row["X"] = coords[0];
                row["Y"] = coords[1];
            }

#else
            var epsg4326 = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            var epsg3857 = DotSpatial.Projections.ProjectionInfo.FromEsriString("PROJCS[\"Popular Visualisation CRS / Mercator\", GEOGCS[\"Popular Visualisation CRS\", DATUM[\"Popular Visualisation Datum\", SPHEROID[\"Popular Visualisation Sphere\", 6378137, 0, AUTHORITY[\"EPSG\",\"7059\"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY[\"EPSG\",\"6055\"]],PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9102\"]], AXIS[\"E\", EAST], AXIS[\"N\", NORTH], AUTHORITY[\"EPSG\",\"4055\"]], PROJECTION[\"Mercator\"], PARAMETER[\"False_Easting\", 0], PARAMETER[\"False_Northing\", 0], PARAMETER[\"Central_Meridian\", 0], PARAMETER[\"Latitude_of_origin\", 0], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"East\", EAST], AXIS[\"North\", NORTH], AUTHORITY[\"EPSG\",\"3857\"]]");
            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                if (row["X"] == DBNull.Value || row["Y"] == DBNull.Value) continue;
                var coords = new[] { Convert.ToDouble(row["X"]), Convert.ToDouble(row["Y"])};
                DotSpatial.Projections.Reproject.ReprojectPoints(coords, null, epsg4326, epsg3857, 0, 1);
                row["X"] = coords[0];
                row["Y"] = coords[1];
            }

#endif
            //Add Rotation Column
            ds.Tables[0].Columns.Add("Rotation", typeof (float));
            foreach (DataRow row in ds.Tables[0].Rows)
                row["Rotation"] = -angle;

            //Set up provider
            DataTablePoint xlsProvider = new DataTablePoint(ds.Tables[0], "OID", "X", "Y");
            VectorLayer xlsLayer = new VectorLayer("XLS", xlsProvider)
                               {Style = {Symbol = VectorStyle.DefaultSymbol}};

            //Add layer to map
            map.Layers.Add(xlsLayer);
            LabelLayer xlsLabelLayer = new LabelLayer("XLSLabel")
                                    {
                                        DataSource = xlsProvider,
                                        LabelColumn = "Name",
                                        PriorityColumn = "Population",
                                        Style =
                                            {
                                                CollisionBuffer = new SizeF(2f, 2f),
                                                CollisionDetection = true
                                            },
                                        LabelFilter =
                                            LabelCollisionDetection.ThoroughCollisionDetection
                                    };
            map.Layers.Add(xlsLabelLayer);

            map.ZoomToBox(tileLayer.Envelope);

            return map;
        }
コード例 #13
0
ファイル: TileLayerSample.cs プロジェクト: lishxi/_SharpMap
        private static Map InitializeMapOsmWithVariableLayerCollection(float angle)
        {
            Map map = new Map();

            TileAsyncLayer tileLayer = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM with VLC");
            map.BackgroundLayer.Add(tileLayer);

            VectorLayer vl = new VectorLayer("Vilnius Transport Data - Bus", 
                new VilniusTransportData(VilniusTransportData.TransportType.Bus));
            PublicTransportTheme pttBus = new PublicTransportTheme(Brushes.DarkGreen);
            vl.Theme = new CustomTheme(pttBus.GetStyle);
            vl.CoordinateTransformation = GetCoordinateTransformation();
            map.VariableLayers.Add(vl);
            vl = new VectorLayer("Vilnius Transport Data - Trolley", 
                new VilniusTransportData(VilniusTransportData.TransportType.TrolleyBus));
            PublicTransportTheme pttTrolley = new PublicTransportTheme(Brushes.Red);
            vl.Theme = new CustomTheme(pttTrolley.GetStyle);
            vl.CoordinateTransformation = GetCoordinateTransformation();
            map.VariableLayers.Add(vl);
            VariableLayerCollection.Interval = 5000;

            map.ZoomToBox(vl.Envelope);

            return map;
        }
コード例 #14
0
ファイル: Form2.cs プロジェクト: lishxi/_SharpMap
 private void button1_Click(object sender, EventArgs e)
 {
     TileLayer googleLayer = new TileAsyncLayer(new BingTileSource(new BingRequest(BingRequest.UrlBingStaging, string.Empty, BingMapType.Hybrid )), "TileLayer - Bing");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(googleLayer);
     this.mapBox1.Refresh();
 }
コード例 #15
0
ファイル: Form2.cs プロジェクト: lishxi/_SharpMap
 private void button7_Click(object sender, EventArgs e)
 {
     ITileSchema schema = new SphericalMercatorInvertedWorldSchema();
     ILayer[] layers = CreateLayers();
     SharpMapTileSource source = new SharpMapTileSource(schema, layers);
     TileAsyncLayer osmLayer = new TileAsyncLayer(source, "TileLayer - SharpMap");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(osmLayer);
     this.mapBox1.Refresh();
 }
コード例 #16
0
ファイル: Form2.cs プロジェクト: lishxi/_SharpMap
 private void button5_Click(object sender, EventArgs e)
 {
     
     TileAsyncLayer bingLayer = new TileAsyncLayer(new BingTileSource(BingRequest.UrlBing, "", BingMapType.Roads), "TileLayer - Bing");
     this.mapBox1.Map.BackgroundLayer.Clear();
     this.mapBox1.Map.BackgroundLayer.Add(bingLayer);
     this.mapBox1.Refresh();
 }
コード例 #17
0
ファイル: MapExporter.cs プロジェクト: Johkar/Hajk2
        public void AddWMTSLayers(List<WMTSInfo> wmtsLayers, Action callback)
        {
            if (wmtsLayers == null || wmtsLayers.Count == 0)
            {
                callback.Invoke();
                return;
            }

            var i = 0;
            List<TileAsyncLayer> layers = new List<TileAsyncLayer>();
            wmtsLayers.ForEach((layer) =>
            {
                var tileSource = this.createTileSource(layer);
                TileAsyncLayer wmtsLayer = new TileAsyncLayer(tileSource, "wmts_layer_" + i);
                layers.Add(wmtsLayer);
                map.BackgroundLayer.Add(wmtsLayer);

                wmtsLayer.MapNewTileAvaliable += (ITileAsyncLayer sender, Envelope bbox, Bitmap bm, int sourceWidth, int sourceHeight, System.Drawing.Imaging.ImageAttributes imageAttributes) =>
                {
                    if (layers.All(w => w.NumPendingDownloads <= 1))
                    {
                        callback.Invoke();
                    };
                };
                i++;
            });
        }