Пример #1
0
        private void FormDemoDrawGeometries_Load(object sender, EventArgs e)
        {
            //this.mapBox1.Map = ShapefileSample.InitializeMap(0);
            //Google Background
            TileAsyncLayer bingLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging), "TileLayer - Bing");

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


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

            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            var geom          = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);

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