Changed ImageTileSource

This commit is contained in:
ClemensF 2012-07-21 09:09:58 +02:00
parent 2fd3f5f8f6
commit d368c9358c
5 changed files with 13 additions and 21 deletions

View file

@ -138,10 +138,11 @@ namespace MapControl
private void BeginGetTilesAsync(object newTilesList)
{
List<Tile> newTiles = (List<Tile>)newTilesList;
ImageTileSource imageTileSource = tileLayer.TileSource as ImageTileSource;
if (imageTileSource != null)
if (tileLayer.TileSource is ImageTileSource)
{
ImageTileSource imageTileSource = (ImageTileSource)tileLayer.TileSource;
newTiles.ForEach(tile =>
{
Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel)));

View file

@ -8,6 +8,7 @@ using System.Globalization;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MapControl
{
@ -156,12 +157,16 @@ namespace MapControl
}
/// <summary>
/// Provides the image of a map tile. ImageTileSource bypasses downloading
/// and caching of tile images that is performed by TileImageLoader.
/// Provides the image of a map tile. ImageTileSource bypasses download and
/// cache processing in TileImageLoader. By overriding the GetImage method,
/// an application can provide tile images from an arbitrary source.
/// </summary>
public abstract class ImageTileSource : TileSource
public class ImageTileSource : TileSource
{
public abstract ImageSource GetImage(int x, int y, int zoomLevel);
public virtual ImageSource GetImage(int x, int y, int zoomLevel)
{
return new BitmapImage(GetUri(x, y, zoomLevel));
}
}
/// <summary>

View file

@ -1,13 +0,0 @@
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace SampleApplication
{
public class ImageTileSource : MapControl.ImageTileSource
{
public override ImageSource GetImage(int x, int y, int zoomLevel)
{
return new BitmapImage(GetUri(x, y, zoomLevel));
}
}
}

View file

@ -144,7 +144,7 @@
<map:TileLayer Name="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
<map:TileLayer.TileSource>
<local:ImageTileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
<map:ImageTileSource UriFormat="http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
</map:TileLayer.TileSource>
</map:TileLayer>
</ComboBox.Items>

View file

@ -54,7 +54,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ImageTileSource.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>