diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs
index 953a95cf..ca2b4989 100644
--- a/MapControl/Shared/MapProjection.cs
+++ b/MapControl/Shared/MapProjection.cs
@@ -19,6 +19,11 @@ namespace MapControl
///
/// Defines a map projection between geographic coordinates and cartesian map coordinates.
///
+#if UWP || WINUI
+ [Windows.Foundation.Metadata.CreateFromString(MethodName = "Parse")]
+#else
+ [System.ComponentModel.TypeConverter(typeof(MapProjectionConverter))]
+#endif
public abstract class MapProjection
{
public const double Wgs84EquatorialRadius = 6378137d;
@@ -131,5 +136,18 @@ namespace MapControl
return rotatedRect;
}
+
+ public override string ToString()
+ {
+ return CrsId;
+ }
+
+ ///
+ /// Creates a MapProjection instance from a CRS id string.
+ ///
+ public static MapProjection Parse(string crsId)
+ {
+ return MapProjectionFactory.Instance.GetProjection(crsId);
+ }
}
}
diff --git a/MapControl/Shared/TypeConverters.cs b/MapControl/Shared/TypeConverters.cs
index 70730d36..348b0e7f 100644
--- a/MapControl/Shared/TypeConverters.cs
+++ b/MapControl/Shared/TypeConverters.cs
@@ -32,7 +32,7 @@ namespace MapControl
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
{
- return Location.Parse(value.ToString());
+ return ConvertFrom(value.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
@@ -55,7 +55,7 @@ namespace MapControl
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
{
- return LocationCollection.Parse(value.ToString());
+ return ConvertFrom(value.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
@@ -78,7 +78,7 @@ namespace MapControl
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
{
- return BoundingBox.Parse(value.ToString());
+ return ConvertFrom(value.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
@@ -101,7 +101,30 @@ namespace MapControl
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
{
- return TileSource.Parse(value.ToString());
+ return ConvertFrom(value.ToString());
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
+ {
+ return value.ToString();
+ }
+ }
+
+ public class MapProjectionConverter : TypeConverter, IValueConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ return sourceType == typeof(string);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ return MapProjection.Parse(value.ToString());
+ }
+
+ public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
+ {
+ return ConvertFrom(value.ToString());
}
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)