2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2014-01-10 20:11:39 +01:00
|
|
|
|
// Copyright © 2014 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2013-11-12 21:14:53 +01:00
|
|
|
|
using System;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Collections.Generic;
|
2013-11-12 21:14:53 +01:00
|
|
|
|
using System.Diagnostics;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#if WINDOWS_RUNTIME
|
2013-11-12 21:14:53 +01:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using Windows.UI.Xaml.Media.Imaging;
|
|
|
|
|
|
#else
|
2013-11-12 21:14:53 +01:00
|
|
|
|
using System.Windows.Media;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2013-11-12 21:14:53 +01:00
|
|
|
|
/// Loads map tile images.
|
2012-11-22 21:42:29 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class TileImageLoader
|
|
|
|
|
|
{
|
2013-11-12 21:14:53 +01:00
|
|
|
|
internal void BeginGetTiles(TileLayer tileLayer, IEnumerable<Tile> tiles)
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2013-11-12 21:14:53 +01:00
|
|
|
|
var imageTileSource = tileLayer.TileSource as ImageTileSource;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
if (imageTileSource != null)
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
foreach (var tile in tiles)
|
2013-11-12 21:14:53 +01:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
try
|
2013-11-12 21:14:53 +01:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
var image = imageTileSource.LoadImage(tile.XIndex, tile.Y, tile.ZoomLevel);
|
|
|
|
|
|
tile.SetImageSource(image, tileLayer.AnimateTileOpacity);
|
2013-11-12 21:14:53 +01:00
|
|
|
|
}
|
2014-07-01 18:57:44 +02:00
|
|
|
|
catch (Exception ex)
|
2013-11-12 21:14:53 +01:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
Debug.WriteLine("Loading tile image failed: {0}", ex.Message);
|
2013-11-12 21:14:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-01 18:57:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var tile in tiles)
|
2013-08-29 15:49:48 +02:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var uri = tileLayer.TileSource.GetUri(tile.XIndex, tile.Y, tile.ZoomLevel);
|
|
|
|
|
|
var image = uri != null ? new BitmapImage(uri) : null;
|
|
|
|
|
|
tile.SetImageSource(image, tileLayer.AnimateTileOpacity);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.WriteLine("Creating tile image failed: {0}", ex.Message);
|
|
|
|
|
|
}
|
2013-08-29 15:49:48 +02:00
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
public void CancelGetTiles()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|