mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Changed ImageTileSource
This commit is contained in:
parent
2fd3f5f8f6
commit
d368c9358c
|
|
@ -138,10 +138,11 @@ namespace MapControl
|
||||||
private void BeginGetTilesAsync(object newTilesList)
|
private void BeginGetTilesAsync(object newTilesList)
|
||||||
{
|
{
|
||||||
List<Tile> newTiles = (List<Tile>)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 =>
|
newTiles.ForEach(tile =>
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel)));
|
Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel)));
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
{
|
{
|
||||||
|
|
@ -156,12 +157,16 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides the image of a map tile. ImageTileSource bypasses downloading
|
/// Provides the image of a map tile. ImageTileSource bypasses download and
|
||||||
/// and caching of tile images that is performed by TileImageLoader.
|
/// cache processing in TileImageLoader. By overriding the GetImage method,
|
||||||
|
/// an application can provide tile images from an arbitrary source.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
|
|
||||||
<map:TileLayer Name="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
|
<map:TileLayer Name="OSM Uncached" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
|
||||||
<map:TileLayer.TileSource>
|
<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.TileSource>
|
||||||
</map:TileLayer>
|
</map:TileLayer>
|
||||||
</ComboBox.Items>
|
</ComboBox.Items>
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="ImageTileSource.cs" />
|
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue