Esempio n. 1
0
        public MapViewer()
        {
            InitializeComponent();
            _map = MapControl.Map;

            //MapControl.RenderMode = Mapsui.UI.Wpf.RenderMode.Wpf;

            System.Windows.Media.Color color = (System.Windows.Media.Color)FindResource("WindowBackgroundColor");
            _map.BackColor = Color.FromArgb(255, color.R, color.G, color.B);

            MapControl.PreviewMouseDown  += MapControl_PreviewMouseDown;
            MapControl.PreviewMouseWheel += MapControl_PreviewMouseWheel;

            //_map.Layers.Add(OpenStreetMap.CreateTileLayer());
            _map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.EsriWorldDarkGrayBase))
            {
                Name = "Map"
            });
            //_map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingAerial)) { Name = "Bing Aerial" });

            _positionLayer = CreatePositionLayer();
            _map.Layers.Add(_positionLayer);

            _map.Info += MapOnInfo;
        }
Esempio n. 2
0
        private static SharpMap.Map InitializeMapOsmWithVariableLayerCollection(float angle)
        {
            var map = new SharpMap.Map();

            var tileSource = KnownTileSources.Create(KnownTileSource.OpenStreetMap, userAgent: DefaultUserAgent);

            var tileLayer = new SharpMap.Layers.TileAsyncLayer(tileSource, "TileLayer - OSM with VLC");

            map.BackgroundLayer.Add(tileLayer);

            var vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Bus",
                                                     new VilniusTransportData(VilniusTransportData.TransportType.Bus));
            var pttBus = new PublicTransportTheme(System.Drawing.Brushes.DarkGreen);

            vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttBus.GetStyle);
            vl.CoordinateTransformation = GetCoordinateTransformation();
            map.VariableLayers.Add(vl);
            vl = new SharpMap.Layers.VectorLayer("Vilnius Transport Data - Trolley",
                                                 new VilniusTransportData(VilniusTransportData.TransportType.TrolleyBus));
            var pttTrolley = new PublicTransportTheme(System.Drawing.Brushes.Red);

            vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(pttTrolley.GetStyle);
            vl.CoordinateTransformation = GetCoordinateTransformation();
            map.VariableLayers.Add(vl);
            map.VariableLayers.Interval = 5000;

            map.ZoomToBox(vl.Envelope);

            return(map);
        }
Esempio n. 3
0
 public static ILayer CreateLayer()
 {
     return(new TileLayer(KnownTileSources.Create(KnownTileSource.BingAerial))
     {
         Name = "Bing Aerial"
     });
 }
Esempio n. 4
0
        public MapControl()
        {
            var canvas = new Canvas
            {
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Background          = new SolidColorBrush(Colors.Transparent),
            };

            Children.Add(canvas);
            _renderer = new Renderer(canvas);

            _tileSource = KnownTileSources.Create();
            CompositionTarget.Rendering += CompositionTargetRendering;
            SizeChanged += MapControlSizeChanged;
            MouseWheel  += MapControlMouseWheel;
            MouseMove   += MapControlMouseMove;
            MouseUp     += OnMouseUp;
            MouseLeave  += OnMouseLeave;

            ClipToBounds          = true;
            _fetcher              = new Fetcher <Image>(_tileSource, _tileCache);
            _fetcher.DataChanged += FetcherOnDataChanged;
            _invalid              = true;
        }
        /// <summary>
        /// 在线显示,图标显示轨迹
        /// </summary>
        /// <param name="angle"></param>
        /// <returns></returns>
        private static Map InitializeMapOsmWithXls2(float angle)
        {
            var map = new Map();

            var tileLayer = new TileAsyncLayer(
                KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer - OSM with XLS");

            tileLayer.SRID = 4326;
            map.BackgroundLayer.Add(tileLayer);

            //Get data from excel
            var xlsPath = string.Format(XlsConnectionString, System.IO.Directory.GetCurrentDirectory(), "GeoData\\Henan.xls", Properties.Settings.Default.OleDbProvider);
            var ds      = GetDataFromExcel(xlsPath, "Cities");
            var ct      = GetCoordinateTransformation();

            TransCoordinate(ds, ct);
            string columeName = "Rotation";

            //Add Rotation Column
            AddColumeToDataSet(ds, columeName, -angle);

            var xlsLayer = GetLayerFromDataSet2(ds, Color.GreenYellow); //Set up provider

            map.Layers.Add(xlsLayer);                                   //Add layer to map

            var xlsLabelLayer = GetLabelLayerByVectorLayer(xlsLayer, "XLSLabel");

            xlsLabelLayer.Theme = new FontSizeTheme(xlsLabelLayer, map)
            {
                FontSizeScale = 1000f
            };
            map.Layers.Add(xlsLabelLayer);
            map.ZoomToBox(xlsLayer.Envelope);
            return(map);
        }
Esempio n. 6
0
 private void BtnOSM_Click(object sender, RoutedEventArgs e)
 {
     //this.xMapControl.RenderMode = Mapsui.UI.Wpf.RenderMode.Wpf;
     this.xMapControl.Map = new Mapsui.Map();
     this.xMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingHybrid)));
     this.xMapControl.Refresh();
 }
Esempio n. 7
0
        public MainWindow()
        {
            InitializeComponent();

            RouteController = new RouteController(this);

            UpdateRoute(RouteController.Route);

            // MapControl.Map.Layers.Add(GetKaagTileLayer());
            MapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap)));
            MapControl.Map.Layers.Add(RouteLayer);
            MapControl.Map.Layers.Add(RoutePointsLayer);
            MapControl.Map.Layers.Add(SectionsLayer);
            MapControl.Map.Layers.Add(SectionPointsLayer);

            MapControl.Map.Home = navigator => navigator.NavigateTo(SphericalMercator.FromLonLat(4.55835, 52.22002), 6);

            var wayPointEditor = new WaypointEditor(MapControl, RouteController);
            var sectionEditor  = new SectionEditor(MapControl, RouteController);

            sectionEditor.OnDeselected();

            WaypointModeOption.Checked += (sender, args) => SetEditor(wayPointEditor);
            SectionModeOption.Checked  += (sender, args) => SetEditor(sectionEditor);
            ScreenshotButton.Click     += (sender, args) => Screenshot();

            WaypointModeOption.IsChecked = true;
        }
Esempio n. 8
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var knownTileSource in Enum.GetValues(typeof(KnownTileSource)).Cast <KnownTileSource>())
            {
                var httpTileSource = KnownTileSources.Create(knownTileSource);
                Layers.Children.Add(ToRadioButton(knownTileSource.ToString(), () => httpTileSource));
            }

            Layers.Children.Add(ToRadioButton("Google Map", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=m@130&hl=en&x={x}&y={y}&z={z}")));
            Layers.Children.Add(ToRadioButton("Google Terrain", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=t@125,r@130&hl=en&x={x}&y={y}&z={z}")));

            Layers.Children.Add(ToRadioButton("WMS called through tile schema", TileSourceForWmsSample.Create));

            Layers.Children.Add(ToRadioButton("Here Maps", () =>
                                              new HttpTileSource(new GlobalSphericalMercator(0, 18),
                                                                 "https://{s}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g",
                                                                 new[] { "1", "2", "3", "4" }, name: "Here Maps Source")));

            //Layers.Children.Add(ToRadioButton("LM topowebb", LantMaterietTopowebbTileSourceTest.Create));
            //using (var stream = System.IO.File.OpenRead(Path.Combine("Resources", "wmtsc2.xml")))
            //{
            //    //var tileSources = WmtsParser.Parse(stream);
            //    Layers.Children.Add(ToRadioButton("my tianditu2", () => WmtsParser.Parse(stream).First()));
            //}
            Layers.Children.Add(ToRadioButton("my 本地WmtsParser", () => CreateTDTTileSource()));
            Layers.Children.Add(ToRadioButton("my  WmtsParser", TDTTrans.Create));
            Layers.Children.Add(ToRadioButton("my  HttpTileSourceTDT", TDTTrans.Create2));
            Layers.Children.Add(ToRadioButton("my 本地WmscTileSource", () => CreateWmscSource()));
        }
Esempio n. 9
0
 public static ILayer CreateLayer()
 {
     return(new TileLayer(KnownTileSources.Create())
     {
         Name = "OSM"
     });
 }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var knownTileSource in Enum.GetValues(typeof(KnownTileSource)).Cast<KnownTileSource>())
            {
                if (knownTileSource.ToString().ToLower().Contains("cloudmade")) continue; // Exclude CloudMade

                KnownTileSource source = knownTileSource;
                var radioButton = ToRadioButton(knownTileSource.ToString(), () => KnownTileSources.Create(source, "soep"));
                Layers.Children.Add(radioButton);
            }
            
            Layers.Children.Add(ToRadioButton("Google Map", () => 
                CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=m@130&hl=en&x={x}&y={y}&z={z}")));
            Layers.Children.Add(ToRadioButton("Google Terrain", () => 
                CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=t@125,r@130&hl=en&x={x}&y={y}&z={z}")));

            Layers.Children.Add(ToRadioButton("WMS called through tile schema", TileSourceForWmsSample.Create));

            Layers.Children.Add(ToRadioButton("Here Maps", () =>
                new HttpTileSource(new GlobalSphericalMercator(0, 18),
                    "https://{s}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g",
                    new[] { "1", "2", "3", "4" }, name: "Here Maps Source")));
        }
Esempio n. 12
0
        public App()
        {
            InitializeComponent();

            MyTileLayer = new TileLayer(KnownTileSources.Create());
            MainPage    = new MainPage();
        }
Esempio n. 13
0
 public static Map CreateMap()
 {
     var map = new Map();
     map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingAerial)) { Name = "Bing Aerial" });
     map.Layers.Add(CreateMbTilesLayer(Path.Combine(MbTilesSample.MbTilesLocation, "torrejon-de-ardoz.mbtiles")));
     return map;
 }
        private void InitBackground(Map map)
        {
            var lyr = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoads), "Async TileLayer [Bing]");

            lyr.SRID = 3857;
            map.BackgroundLayer.Add(lyr);
        }
Esempio n. 15
0
        private void LoadMap()
        {
            Map map = new Map();

            ITileSource    tileSource = KnownTileSources.Create(KnownTileSource.OpenStreetMap);
            TileAsyncLayer tileLayer  = new TileAsyncLayer(tileSource, "Basemap");

            map.BackgroundLayer.Add(tileLayer);


            VectorLayer shpLayer = new VectorLayer("Points");

            shpLayer.DataSource                      = new ShapeFile("Data/indian_points.shp", true);
            shpLayer.Style.SymbolScale               = 0.8f;
            shpLayer.CoordinateTransformation        = Wgs84toGoogleMercator; //Here it re-projects our degree decimal data to Google mercator
            shpLayer.ReverseCoordinateTransformation = GoogleMercatorToWgs84;
            shpLayer.SRID = 4326;

            map.Layers.Add(shpLayer);

            mapBox1.Map = map;

            mapBox1.Map.ZoomToExtents();

            mapBox1.Refresh();
        }
Esempio n. 16
0
        private void Form2_Load(object sender, EventArgs e)
        {
            var tileLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging), "TileLayer");

            this.mapBox1.Map.BackgroundLayer.Add(tileLayer);
            GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 3857);

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

            //Adds a pushpin layer
            VectorLayer      pushPinLayer = new VectorLayer("PushPins");
            List <IGeometry> geos         = new List <IGeometry>();

            geos.Add(gf.CreatePoint(geom.Centre));
            GeometryProvider geoProvider = new GeometryProvider(geos);

            pushPinLayer.DataSource = geoProvider;
            //this.mapBox1.Map.Layers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Map.Zoom = 8500;
            this.mapBox1.Refresh();
        }
Esempio n. 17
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var knownTileSource in Enum.GetValues(typeof(KnownTileSource)).Cast <KnownTileSource>())
            {
                var httpTileSource = KnownTileSources.Create(knownTileSource);
                Layers.Children.Add(ToRadioButton(knownTileSource.ToString(), () => httpTileSource));
            }

            var httpClient         = new HttpClient();
            var stream             = httpClient.GetStreamAsync("https://bertt.github.io/wmts/capabilities/michelin.xml").Result;
            var michelinTileSource = WmtsParser.Parse(stream).First();

            Layers.Children.Add(ToRadioButton("Michelin Map", () => michelinTileSource));

            Layers.Children.Add(ToRadioButton("Google Map", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=m@130&hl=en&x={x}&y={y}&z={z}")));
            Layers.Children.Add(ToRadioButton("Google Terrain", () =>
                                              CreateGoogleTileSource("http://mt{s}.google.com/vt/lyrs=t@125,r@130&hl=en&x={x}&y={y}&z={z}")));

            Layers.Children.Add(ToRadioButton("WMS called through tile schema", TileSourceForWmsSample.Create));

            Layers.Children.Add(ToRadioButton("Here Maps", () =>
                                              new HttpTileSource(new GlobalSphericalMercator(0, 18),
                                                                 "https://{s}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g",
                                                                 new[] { "1", "2", "3", "4" }, name: "Here Maps Source")));

            Layers.Children.Add(ToRadioButton("LM topowebb", LantMaterietTopowebbTileSourceTest.Create));
        }
Esempio n. 18
0
 public CustomMapView() : base()
 {
     Map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap))
     {
         Name = "OpenStreetMap"
     });
     Map.Widgets.Add(new ScaleBarWidget(Map));
 }
Esempio n. 19
0
        private void button6_Click(object sender, EventArgs e)
        {
            TileAsyncLayer osmLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.OpenStreetMap), "TileLayer - OSM");

            this.mapBox1.Map.BackgroundLayer.Clear();
            this.mapBox1.Map.BackgroundLayer.Add(osmLayer);
            this.mapBox1.Refresh();
        }
Esempio n. 20
0
        public MainWindow()
        {
            InitializeComponent();

            MyMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create()));
            setup     = new Setup(Logs);
            backupMap = MyMapControl;
        }
Esempio n. 21
0
        private void InitializeMap(Map map)
        {
            var layers = map.Layers;
            //layers.Add(_countryLayerOrganizer.CreateLayer(_countryShape));
            var osmLayer = new TileLayer(KnownTileSources.Create());

            layers.Add(osmLayer);
        }
Esempio n. 22
0
        private void button5_Click(object sender, EventArgs e)
        {
            TileAsyncLayer bingLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingRoadsStaging), "TileLayer - Bing");

            this.mapBox1.Map.BackgroundLayer.Clear();
            this.mapBox1.Map.BackgroundLayer.Add(bingLayer);
            this.mapBox1.Refresh();
        }
Esempio n. 23
0
        private void button1_Click(object sender, EventArgs e)
        {
            var googleLayer = new TileAsyncLayer(KnownTileSources.Create(KnownTileSource.BingHybridStaging), "TileLayer - Bing");

            this.mapBox1.Map.BackgroundLayer.Clear();
            this.mapBox1.Map.BackgroundLayer.Add(googleLayer);
            this.mapBox1.Refresh();
        }
Esempio n. 24
0
        private static TileLayer CreateTileLayer()
        {
            var tileLayer = new TileLayer(KnownTileSources.Create(KnownTileSource.EsriWorldReferenceOverlay))
            {
                Name = "OSM"
            };

            return(tileLayer);
        }
Esempio n. 25
0
        public override void OnClick()
        {
            var mxdoc      = (IMxDocument)_application.Document;
            var tileSource = KnownTileSources.Create(KnownTileSource.BingHybrid);
            var wmtsLayer  = WmtsHelper.GetWmtsLayer(_application, tileSource, "Bing Hybrid");
            var map        = mxdoc.FocusMap;

            ((IMapLayers)map).InsertLayer(wmtsLayer, true, 0);
        }
Esempio n. 26
0
        static void Main()
        {
            // Dear BruTile maintainer,
            // If the code in this file does not compile and needs changes you
            // also need to update the 'getting started' sample in the wiki.

            // 1) Create a tile source

            // This is an example that creates the OpenStreetMap tile source:
            var tileSource = new HttpTileSource(new GlobalSphericalMercator(0, 18),
                                                "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
                                                new[] { "a", "b", "c" }, "OSM");

            // 2) Calculate which tiles you need

            // the extent of the visible map changes but lets start with the whole world
            var extent = new Extent(-20037508, -20037508, 20037508, 20037508);
            var screenWidthInPixels = 400; // The width of the map on screen in pixels
            var resolution          = extent.Width / screenWidthInPixels;
            var tileInfos           = tileSource.Schema.GetTileInfos(extent, resolution);

            // 3) Fetch the tiles from the service

            Console.WriteLine("Show tile info");
            foreach (var tileInfo in tileInfos)
            {
                var tile = tileSource.GetTile(tileInfo);

                Console.WriteLine(
                    $"tile col: {tileInfo.Index.Col}, " +
                    $"tile row: {tileInfo.Index.Row}, " +
                    $"tile level: {tileInfo.Index.Level} , " +
                    $"tile size {tile.Length}");
            }

            // 4) Try some of the known tile sources

            // You can easily create an ITileSource for a number of predefined tile servers
            // with single line statements like:
            var tileSource1 = KnownTileSources.Create(); // The default is OpenStreetMap
            var tileSource2 = KnownTileSources.Create(KnownTileSource.BingAerial);
            var tileSource3 = KnownTileSources.Create(KnownTileSource.BingHybrid);
            var tileSource4 = KnownTileSources.Create(KnownTileSource.StamenTonerLite);
            var tileSource5 = KnownTileSources.Create(KnownTileSource.EsriWorldShadedRelief);

            // 6) Use MBTiles, the sqlite format for tile data, to work with tiles stored on your device.

            var mbtilesTilesource = new MbTilesTileSource(new SQLiteConnectionString("Resources/world.mbtiles", false));
            var mbTilesTile       = mbtilesTilesource.GetTile(new TileInfo {
                Index = new TileIndex(0, 0, 0)
            });

            Console.WriteLine();
            Console.WriteLine("MBTiles");
            Console.WriteLine($"This is a byte array of an image file loaded from MBTiles with size: {mbTilesTile.Length}");
        }
Esempio n. 27
0
        public MainWindow()
        {
            InitializeComponent();

            MyMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create()));
            walker      = new Walker();
            nodeChooser = new NodeChooser();

            _ = InitMap().ConfigureAwait(false);
        }
Esempio n. 28
0
        public MainWindow()
        {
            InitializeComponent();
            mainVM           = new MainWindowViewModel();
            this.DataContext = mainVM;

            MyMapControl.Map.Layers.Add(new TileLayer(KnownTileSources.Create(source: KnownTileSource.OpenStreetMap)));

            // MyMapControl.Map.Se
        }
Esempio n. 29
0
        public static Map CreateMap()
        {
            var map = new Map();

            map.Layers.Add(new TileLayer(KnownTileSources.Create(KnownTileSource.BingAerial))
            {
                Name = "Bing Aerial"
            });
            return(map);
        }
Esempio n. 30
0
        public void TestOsmTileSource()
        {
            var ts1 = KnownTileSources.Create(KnownTileSource.OpenStreetMap, null, new FakePersistentCache <byte[]>());
            var ts2 = SandD(ts1);

            Assert.NotNull(ts2);
            string message;
            var    equal = EqualTileSources(ts1, ts2, out message);

            Assert.IsTrue(equal, message);
        }