diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs
index 20cac65e..65c400ee 100644
--- a/Caching/FileDbCache/Properties/AssemblyInfo.cs
+++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs
index 97575eaf..8fb62034 100644
--- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs
+++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/IMapElement.cs b/MapControl/IMapElement.cs
index 33faaa3b..9c8d5b55 100644
--- a/MapControl/IMapElement.cs
+++ b/MapControl/IMapElement.cs
@@ -6,6 +6,8 @@ namespace MapControl
{
public interface IMapElement
{
- MapBase ParentMap { get; set; }
+ MapBase ParentMap { get; }
+
+ void SetParentMap(MapBase parentMap);
}
}
diff --git a/MapControl/ImageFileCache.WinRT.cs b/MapControl/ImageFileCache.WinRT.cs
index 500d9473..2639b0ae 100644
--- a/MapControl/ImageFileCache.WinRT.cs
+++ b/MapControl/ImageFileCache.WinRT.cs
@@ -22,6 +22,11 @@ namespace MapControl
public ImageFileCache(IStorageFolder folder)
{
+ if (folder == null)
+ {
+ throw new ArgumentNullException("The parameter folder must not be null.");
+ }
+
rootFolder = folder;
}
diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs
index d2e91e51..c86820ef 100644
--- a/MapControl/MapBase.cs
+++ b/MapControl/MapBase.cs
@@ -198,16 +198,6 @@ namespace MapControl
set { SetValue(TargetHeadingProperty, value); }
}
- ///
- /// Gets the scaling factor from cartesian map coordinates to viewport coordinates.
- ///
- public double ViewportScale { get; private set; }
-
- ///
- /// Gets the scaling factor from meters to viewport coordinate units (pixels) at the Center location.
- ///
- public double CenterScale { get; private set; }
-
///
/// Gets the transformation from geographic coordinates to cartesian map coordinates.
///
@@ -249,23 +239,21 @@ namespace MapControl
}
///
- /// Gets the conversion factor from longitude degrees to meters, at latitude = 0.
+ /// Gets the scaling factor from cartesian map coordinates to viewport coordinates.
///
- public double MetersPerDegree
- {
- get
- {
- return (TileLayer != null && TileLayer.TileSource != null) ?
- TileLayer.TileSource.MetersPerDegree : (TileSource.EarthRadius * Math.PI / 180d);
- }
- }
+ public double ViewportScale { get; private set; }
+
+ ///
+ /// Gets the scaling factor from meters to viewport coordinate units (pixels) at the Center location.
+ ///
+ public double CenterScale { get; private set; }
///
/// Gets the map scale at the specified location as viewport coordinate units (pixels) per meter.
///
public double GetMapScale(Location location)
{
- return mapTransform.RelativeScale(location) * Math.Pow(2d, ZoomLevel) * TileSource.TileSize / (MetersPerDegree * 360d);
+ return mapTransform.RelativeScale(location) * Math.Pow(2d, ZoomLevel) * TileSource.TileSize / (TileSource.MetersPerDegree * 360d);
}
///
@@ -446,7 +434,12 @@ namespace MapControl
break;
}
- UpdateTileLayer();
+ var firstTileLayer = TileLayers.FirstOrDefault();
+
+ if (TileLayer != firstTileLayer)
+ {
+ TileLayer = firstTileLayer;
+ }
}
private void TileLayersPropertyChanged(TileLayerCollection oldTileLayers, TileLayerCollection newTileLayers)
@@ -462,9 +455,18 @@ namespace MapControl
{
newTileLayers.CollectionChanged += TileLayerCollectionChanged;
tileContainer.AddTileLayers(0, newTileLayers);
- }
- UpdateTileLayer();
+ var firstTileLayer = TileLayers.FirstOrDefault();
+
+ if (TileLayer != firstTileLayer)
+ {
+ TileLayer = firstTileLayer;
+ }
+ }
+ else
+ {
+ TileLayer = null;
+ }
}
private void TileLayerPropertyChanged(TileLayer tileLayer)
@@ -517,21 +519,6 @@ namespace MapControl
}
}
- private void UpdateTileLayer()
- {
- TileLayer tileLayer = null;
-
- if (TileLayers != null)
- {
- tileLayer = TileLayers.FirstOrDefault();
- }
-
- if (TileLayer != tileLayer)
- {
- TileLayer = tileLayer;
- }
- }
-
private void InternalSetValue(DependencyProperty property, object value)
{
internalPropertyChange = true;
@@ -828,7 +815,7 @@ namespace MapControl
}
}
- CenterScale = ViewportScale * mapTransform.RelativeScale(center) / MetersPerDegree; // Pixels per meter at center latitude
+ CenterScale = ViewportScale * mapTransform.RelativeScale(center) / TileSource.MetersPerDegree; // Pixels per meter at center latitude
SetTransformMatrixes();
OnViewportChanged();
diff --git a/MapControl/MapGraticule.Silverlight.WinRT.cs b/MapControl/MapGraticule.Silverlight.WinRT.cs
index db47839f..5bac310e 100644
--- a/MapControl/MapGraticule.Silverlight.WinRT.cs
+++ b/MapControl/MapGraticule.Silverlight.WinRT.cs
@@ -31,7 +31,7 @@ namespace MapControl
public MapGraticule()
{
IsHitTestVisible = false;
- Stroke = new SolidColorBrush(Color.FromArgb(127, 0, 0, 0));
+ StrokeThickness = 0.5;
path = new Path
{
diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs
index e17fd437..a54cda3a 100644
--- a/MapControl/MapImageLayer.cs
+++ b/MapControl/MapImageLayer.cs
@@ -86,13 +86,12 @@ namespace MapControl
{
var p1 = ParentMap.MapTransform.Transform(new Location(south, west));
var p2 = ParentMap.MapTransform.Transform(new Location(north, east));
- var arc = TileSource.EarthRadius * Math.PI / 180d;
uri = uri.
- Replace("{W}", (arc * p1.X).ToString(CultureInfo.InvariantCulture)).
- Replace("{S}", (arc * p1.Y).ToString(CultureInfo.InvariantCulture)).
- Replace("{E}", (arc * p2.X).ToString(CultureInfo.InvariantCulture)).
- Replace("{N}", (arc * p2.Y).ToString(CultureInfo.InvariantCulture));
+ Replace("{W}", (TileSource.MetersPerDegree * p1.X).ToString(CultureInfo.InvariantCulture)).
+ Replace("{S}", (TileSource.MetersPerDegree * p1.Y).ToString(CultureInfo.InvariantCulture)).
+ Replace("{E}", (TileSource.MetersPerDegree * p2.X).ToString(CultureInfo.InvariantCulture)).
+ Replace("{N}", (TileSource.MetersPerDegree * p2.Y).ToString(CultureInfo.InvariantCulture));
}
else
{
diff --git a/MapControl/MapOverlay.Silverlight.WinRT.cs b/MapControl/MapOverlay.Silverlight.WinRT.cs
index aeed4db4..caba01f1 100644
--- a/MapControl/MapOverlay.Silverlight.WinRT.cs
+++ b/MapControl/MapOverlay.Silverlight.WinRT.cs
@@ -65,48 +65,44 @@ namespace MapControl
private Binding foregroundBinding;
private Binding strokeBinding;
- public override MapBase ParentMap
+ protected override void SetParentMapOverride(MapBase parentMap)
{
- get { return base.ParentMap; }
- set
+ if (foregroundBinding != null)
{
- if (foregroundBinding != null)
- {
- foregroundBinding = null;
- ClearValue(ForegroundProperty);
- }
-
- if (strokeBinding != null)
- {
- strokeBinding = null;
- ClearValue(StrokeProperty);
- }
-
- if (value != null)
- {
- if (Foreground == null)
- {
- foregroundBinding = new Binding
- {
- Source = value,
- Path = new PropertyPath("Foreground")
- };
- SetBinding(ForegroundProperty, foregroundBinding);
- }
-
- if (Stroke == null)
- {
- strokeBinding = new Binding
- {
- Source = value,
- Path = new PropertyPath("Foreground")
- };
- SetBinding(StrokeProperty, strokeBinding);
- }
- }
-
- base.ParentMap = value;
+ foregroundBinding = null;
+ ClearValue(ForegroundProperty);
}
+
+ if (strokeBinding != null)
+ {
+ strokeBinding = null;
+ ClearValue(StrokeProperty);
+ }
+
+ if (parentMap != null)
+ {
+ if (Foreground == null)
+ {
+ foregroundBinding = new Binding
+ {
+ Source = parentMap,
+ Path = new PropertyPath("Foreground")
+ };
+ SetBinding(ForegroundProperty, foregroundBinding);
+ }
+
+ if (Stroke == null)
+ {
+ strokeBinding = new Binding
+ {
+ Source = parentMap,
+ Path = new PropertyPath("Foreground")
+ };
+ SetBinding(StrokeProperty, strokeBinding);
+ }
+ }
+
+ base.SetParentMapOverride(parentMap);
}
}
}
diff --git a/MapControl/MapPanel.cs b/MapControl/MapPanel.cs
index e8726f57..f50da6f3 100644
--- a/MapControl/MapPanel.cs
+++ b/MapControl/MapPanel.cs
@@ -44,23 +44,29 @@ namespace MapControl
private MapBase parentMap;
- public virtual MapBase ParentMap
+ public MapBase ParentMap
{
get { return parentMap; }
- set
+ }
+
+ void IMapElement.SetParentMap(MapBase map)
+ {
+ SetParentMapOverride(map);
+ }
+
+ protected virtual void SetParentMapOverride(MapBase map)
+ {
+ if (parentMap != null && parentMap != this)
{
- if (parentMap != null && parentMap != this)
- {
- parentMap.ViewportChanged -= OnViewportChanged;
- }
+ parentMap.ViewportChanged -= OnViewportChanged;
+ }
- parentMap = value;
+ parentMap = map;
- if (parentMap != null && parentMap != this)
- {
- parentMap.ViewportChanged += OnViewportChanged;
- OnViewportChanged();
- }
+ if (parentMap != null && parentMap != this)
+ {
+ parentMap.ViewportChanged += OnViewportChanged;
+ OnViewportChanged();
}
}
@@ -108,7 +114,7 @@ namespace MapControl
if (mapElement != null)
{
- mapElement.ParentMap = e.NewValue as MapBase;
+ mapElement.SetParentMap(e.NewValue as MapBase);
}
}
diff --git a/MapControl/MapPath.cs b/MapControl/MapPath.cs
index 665a2101..a25a5d28 100644
--- a/MapControl/MapPath.cs
+++ b/MapControl/MapPath.cs
@@ -20,11 +20,12 @@ namespace MapControl
public MapBase ParentMap
{
get { return parentMap; }
- set
- {
- parentMap = value;
- UpdateData();
- }
+ }
+
+ void IMapElement.SetParentMap(MapBase map)
+ {
+ parentMap = map;
+ UpdateData();
}
protected virtual void UpdateData()
@@ -33,10 +34,10 @@ namespace MapControl
protected override Size MeasureOverride(Size constraint)
{
- // base.MeasureOverride in WPF and Windows Runtime sometimes return a Size with zero
- // width or height, whereas base.MeasureOverride in Silverlight occasionally
- // throws an ArgumentException, as it tries to create a Size from a negative
- // width or height, apparently resulting from a transformed Geometry.
+ // base.MeasureOverride in WPF and Windows Runtime sometimes return a Size
+ // with zero width or height, whereas in Silverlight it occasionally throws
+ // an ArgumentException, as it tries to create a Size from a negative width
+ // or height, apparently resulting from a transformed Geometry.
// In either case it seems to be sufficient to simply return a non-zero size.
return new Size(1, 1);
}
diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs
index e25ef18a..fa261b79 100644
--- a/MapControl/Properties/AssemblyInfo.cs
+++ b/MapControl/Properties/AssemblyInfo.cs
@@ -14,8 +14,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs
index 97d0da98..d2bb78d6 100644
--- a/MapControl/TileSource.cs
+++ b/MapControl/TileSource.cs
@@ -19,14 +19,13 @@ namespace MapControl
public partial class TileSource
{
public const int TileSize = 256;
- public const double EarthRadius = 6378137d; // WGS 84 semi major axis
+ public const double MetersPerDegree = 6378137d * Math.PI / 180d; // WGS 84 semi major axis
private Func getUri;
private string uriFormat = string.Empty;
public TileSource()
{
- MetersPerDegree = EarthRadius * Math.PI / 180d;
}
public TileSource(string uriFormat)
@@ -35,8 +34,6 @@ namespace MapControl
UriFormat = uriFormat;
}
- public double MetersPerDegree { get; protected set; }
-
public string UriFormat
{
get { return uriFormat; }
@@ -44,7 +41,7 @@ namespace MapControl
{
if (string.IsNullOrWhiteSpace(value))
{
- throw new ArgumentException("The value of the UriFormat property must not be null or empty or white-space only.");
+ throw new ArgumentException("The value of the UriFormat property must not be null or empty or white-space only.", "value");
}
uriFormat = value;
@@ -164,12 +161,11 @@ namespace MapControl
private Uri GetBoundingBoxUri(int x, int y, int zoomLevel)
{
- var m = MetersPerDegree;
var n = (double)(1 << zoomLevel);
- var x1 = m * ((double)x * 360d / n - 180d);
- var x2 = m * ((double)(x + 1) * 360d / n - 180d);
- var y1 = m * (180d - (double)(y + 1) * 360d / n);
- var y2 = m * (180d - (double)y * 360d / n);
+ var x1 = MetersPerDegree * ((double)x * 360d / n - 180d);
+ var x2 = MetersPerDegree * ((double)(x + 1) * 360d / n - 180d);
+ var y1 = MetersPerDegree * (180d - (double)(y + 1) * 360d / n);
+ var y2 = MetersPerDegree * (180d - (double)y * 360d / n);
return new Uri(uriFormat.
Replace("{W}", x1.ToString(CultureInfo.InvariantCulture)).
diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs
index 06d513f6..72eb776b 100644
--- a/MapControl/WinRT/Properties/AssemblyInfo.cs
+++ b/MapControl/WinRT/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
index 6d68e14f..3d543212 100644
--- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
index 55acdecf..b3e071f4 100644
--- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
index f333e9fb..aa9dedf7 100644
--- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/StoreApplication/MainPage.xaml b/SampleApps/StoreApplication/MainPage.xaml
index b959e6ce..c99f6c27 100644
--- a/SampleApps/StoreApplication/MainPage.xaml
+++ b/SampleApps/StoreApplication/MainPage.xaml
@@ -22,12 +22,12 @@
-
+
@@ -196,8 +196,8 @@
OCM Transport
OCM Landscape
MapQuest OSM
- Bing Maps
- Bing Images
+
diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
index 317d64de..0c757a8d 100644
--- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
index a3470caa..dc94a58a 100644
--- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
@@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2014 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("2.1.0")]
-[assembly: AssemblyFileVersion("2.1.0")]
+[assembly: AssemblyVersion("2.2.0")]
+[assembly: AssemblyFileVersion("2.2.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]