private void CreateTileLayerCollection() { _tileLayers = new TileLayerCollection(); _tileLayers.Add(new KFlyTileLayer() { Icon = new BitmapImage(new Uri("../../Resources/OpenStreetMap-logo.jpg", UriKind.Relative)), SourceName = "OpenStreetMap", Description = "© {y} OpenStreetMap Contributors, CC-BY-SA", TileSource = new TileSource("http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png") }); _tileLayers.Add(new KFlyTileLayer() { Icon = new BitmapImage(new Uri("../../Resources/OpenCycleMap_icon.png", UriKind.Relative)), IsAvailable = true, SourceName = "OpenCycleMap", Description = "OpenCycleMap - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA", TileSource = new TileSource("http://{c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png") }); /* _tileLayers.Add(new KFlyTileLayer() { Icon = new BitmapImage(new Uri("../../Resources/OpenCycleMap-icon.png", UriKind.Relative)), SourceName = "OCM Landscape", Description = "OpenCycleMap Landscape - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA", TileSource = new TileSource("http://{c}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png") }); _tileLayers.Add(new KFlyTileLayer() { Icon = new BitmapImage(new Uri("../../Resources/OpenCycleMap-icon.png", UriKind.Relative)), SourceName = "OCM Transport", Description = "OpenCycleMap Transport - © {y} Andy Allen & OpenStreetMap Contributors, CC-BY-SA", TileSource = new TileSource("http://{c}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png") });*/ _tileLayers.Add(new KFlyTileLayer() { Icon = new BitmapImage(new Uri("../../Resources/MapQuest_icon.png", UriKind.Relative)), SourceName = "MapQuest OSM", Description = "MapQuest OSM - © {y} MapQuest & OpenStreetMap Contributors", TileSource = new TileSource("http://otile{n}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png") }); // Following only for demo, not available /* _tileLayers.Add(new KFlyTileLayer() { IsAvailable = false, SourceName = "Google Maps", Description = "Google Maps - © {y} Google", TileSource = new TileSource("http://mt{i}.google.com/vt/x={x}&y={y}&z={z}"), MaxZoomLevel = 20 }); _tileLayers.Add(new KFlyTileLayer() { IsAvailable = false, SourceName = "Google Images", Description = "Google Maps - © {y} Google", Background = Brushes.LightGray, Foreground = Brushes.White, TileSource = new TileSource("http://khm{i}.google.com/kh/v=144&x={x}&y={y}&z={z}"), MaxZoomLevel = 20 });*/ _tileLayers.Add(new KFlyTileLayer() { IsAvailable = false, Icon = new BitmapImage(new Uri("../../Resources/BingMaps_icon.png", UriKind.Relative)), SourceName = "Bing Maps", Description = "Bing Maps - © {y} Microsoft Corporation", Background = Brushes.LightGray, Foreground = Brushes.White, TileSource = new TileSource("http://ecn.t{i}.tiles.virtualearth.net/tiles/r{q}.png?g=0&stl=h"), MinZoomLevel = 1, MaxZoomLevel = 19 }); _tileLayers.Add(new KFlyTileLayer() { IsAvailable = false, Icon = new BitmapImage(new Uri("../../Resources/BingMaps_icon.png", UriKind.Relative)), SourceName = "Bing Images", Description = "Bing Maps - © {y} Microsoft Corporation", Background = Brushes.LightGray, Foreground = Brushes.White, TileSource = new TileSource("http://ecn.t{i}.tiles.virtualearth.net/tiles/a{q}.jpeg?g=0"), MinZoomLevel = 1, MaxZoomLevel = 19 }); _tileLayers.Add(new KFlyTileLayer() { IsAvailable = false, Icon = new BitmapImage(new Uri("../../Resources/BingMaps_icon.png", UriKind.Relative)), SourceName = "Bing Hybrid", Description = "Bing Maps - © {y} Microsoft Corporation", Background = Brushes.LightGray, Foreground = Brushes.White, TileSource = new TileSource("http://ecn.t{i}.tiles.virtualearth.net/tiles/h{q}.jpeg?g=0&stl=h"), MinZoomLevel = 1, MaxZoomLevel = 19 }); }
private void TileLayersPropertyChanged(TileLayerCollection oldTileLayers, TileLayerCollection newTileLayers) { tileContainer.ClearTileLayers(); if (oldTileLayers != null) { oldTileLayers.CollectionChanged -= TileLayerCollectionChanged; } if (newTileLayers != null) { newTileLayers.CollectionChanged += TileLayerCollectionChanged; tileContainer.AddTileLayers(0, newTileLayers); } UpdateTileLayer(); }
public MapBase() { SetParentMap(); TileLayers = new TileLayerCollection(); InternalChildren.Add(tileContainer); Initialize(); Loaded += OnLoaded; }
private void TileLayerPropertyChanged(TileLayer tileLayer) { if (tileLayer != null) { if (TileLayers == null) { TileLayers = new TileLayerCollection(); } if (TileLayers.Count == 0) { TileLayers.Add(tileLayer); } else if (TileLayers[0] != tileLayer) { TileLayers[0] = tileLayer; } } if (tileLayer != null && tileLayer.Background != null) { if (storedBackground == null) { storedBackground = Background; } Background = tileLayer.Background; } else if (storedBackground != null) { Background = storedBackground; storedBackground = null; } if (tileLayer != null && tileLayer.Foreground != null) { if (storedForeground == null) { storedForeground = Foreground; } Foreground = tileLayer.Foreground; } else if (storedForeground != null) { Foreground = storedForeground; storedForeground = null; } }