예제 #1
0
        public MapControl()
        {
            _canvas = new Canvas
            {
                VerticalAlignment   = VerticalAlignment.Stretch,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Background          = new SolidColorBrush(Colors.Transparent),
            };

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

            _tileSource = TileSource.Create(KnownTileServers.Mapnik);
            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;
        }
예제 #2
0
        public static byte[] GetTile(string layer, string level, int col, int row)
        {
            var tileServer = (KnownTileServers)Enum.Parse(typeof(KnownTileServers), layer, true);
            var tilesource = TileSource.Create(tileServer);

            return(GetTile(tilesource, level, col, row));
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            foreach (var layer in  Enum.GetValues(typeof(KnownTileServers)).Cast <KnownTileServers>())
            {
                var radioButton = new RadioButton {
                    Content = layer.ToString(), Tag = layer
                };
                radioButton.Click += (sender, args) => MapControl.SetTileSource(TileSource.Create((KnownTileServers)((RadioButton)sender).Tag));
                Layers.Children.Add(radioButton);
            }
        }
예제 #4
0
        public static ServiceProvider Create(string name, string url = null)
        {
            var servEq = (Func <string, bool>)
                             (s => name.Equals(s, StringComparison.InvariantCultureIgnoreCase));

            var fileCache =
                (Func <ITileCache <byte[]> >)
                    (() => new FileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                      "TileCache", name), "", new TimeSpan(30, 0, 0, 0)));

            if (servEq(Resources.EsriWorldHydroBasemap))
            {
                return(new BrutileServiceProvider(name, TileSource.Create(KnownTileServers.EsriWorldHydroBasemap), fileCache()));
            }
            if (servEq(Resources.EsriHydroBaseMap))
            {
                return(new BrutileServiceProvider(name,
                                                  new ArcGisTileSource("http://bmproto.esri.com/ArcGIS/rest/services/Hydro/HydroBase2009/MapServer/",
                                                                       new GlobalSphericalMercator()), fileCache()));
            }
            if (servEq(Resources.EsriWorldStreetMap))
            {
                return(new BrutileServiceProvider(name, new ArcGisTileSource("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/",
                                                                             new GlobalSphericalMercator()), fileCache()));
            }
            if (servEq(Resources.EsriWorldImagery))
            {
                return(new BrutileServiceProvider(name,
                                                  new ArcGisTileSource("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/",
                                                                       new GlobalSphericalMercator()), fileCache()));
            }
            if (servEq(Resources.EsriWorldTopo))
            {
                return(new BrutileServiceProvider(name, TileSource.Create(KnownTileServers.EsriWorldTopo), fileCache()));
            }
            if (servEq(Resources.BingHybrid))
            {
                return(new BrutileServiceProvider(name, new BingTileSource(new BingRequest(BingRequest.UrlBingStaging, String.Empty, BingMapType.Hybrid)), fileCache()));
            }
            if (servEq(Resources.BingAerial))
            {
                return(new BrutileServiceProvider(name, new BingTileSource(new BingRequest(BingRequest.UrlBingStaging, String.Empty, BingMapType.Aerial)), fileCache()));
            }
            if (servEq(Resources.BingRoads))
            {
                return(new BrutileServiceProvider(name, new BingTileSource(new BingRequest(BingRequest.UrlBingStaging, String.Empty, BingMapType.Roads)), fileCache()));
            }
            if (servEq(Resources.GoogleSatellite))
            {
                return(new BrutileServiceProvider(name, new GoogleTileSource(GoogleMapType.GoogleSatellite), fileCache()));
            }
            if (servEq(Resources.GoogleMap))
            {
                return(new BrutileServiceProvider(name, new GoogleTileSource(GoogleMapType.GoogleMap), fileCache()));
            }
            if (servEq(Resources.GoogleLabels))
            {
                return(new BrutileServiceProvider(name, new GoogleTileSource(GoogleMapType.GoogleLabels), fileCache()));
            }
            if (servEq(Resources.GoogleTerrain))
            {
                return(new BrutileServiceProvider(name, new GoogleTileSource(GoogleMapType.GoogleTerrain), fileCache()));
            }
            if (servEq(Resources.YahooNormal))
            {
                return(new BrutileServiceProvider(name, new YahooTileSource(YahooMapType.Normal), fileCache()));
            }
            if (servEq(Resources.YahooSatellite))
            {
                return(new BrutileServiceProvider(name, new YahooTileSource(YahooMapType.Satellite), fileCache()));
            }
            if (servEq(Resources.YahooHybrid))
            {
                return(new BrutileServiceProvider(name, new YahooTileSource(YahooMapType.Hybrid), fileCache()));
            }
            if (servEq(Resources.OpenStreetMap))
            {
                return(new BrutileServiceProvider(name, TileSource.Create(), fileCache()));
            }
            if (servEq(Resources.WMSMap))
            {
                return(new WmsServiceProvider(name));
            }

            // No Match
            return(new OtherServiceProvider(name, url));
        }