diff --git a/src/Controls/Maps/src/HandlerImpl/Pin.Impl.cs b/src/Controls/Maps/src/HandlerImpl/Pin.Impl.cs index a8c4359d7aa4..79a6b48df7b1 100644 --- a/src/Controls/Maps/src/HandlerImpl/Pin.Impl.cs +++ b/src/Controls/Maps/src/HandlerImpl/Pin.Impl.cs @@ -4,5 +4,9 @@ namespace Microsoft.Maui.Controls.Maps { public partial class Pin : IMapPin { + /// + /// Explicit implementation of IMapPin.ImageSource to convert from ImageSource to IImageSource. + /// + IImageSource? IMapPin.ImageSource => ImageSource; } } diff --git a/src/Controls/Maps/src/Pin.cs b/src/Controls/Maps/src/Pin.cs index dc9120108b91..b4b065cb3abd 100644 --- a/src/Controls/Maps/src/Pin.cs +++ b/src/Controls/Maps/src/Pin.cs @@ -30,6 +30,9 @@ public partial class Pin : Element /// Bindable property for . public static readonly BindableProperty ClusteringIdentifierProperty = BindableProperty.Create(nameof(ClusteringIdentifier), typeof(string), typeof(Pin), DefaultClusteringIdentifier); + /// Bindable property for . + public static readonly BindableProperty ImageSourceProperty = BindableProperty.Create(nameof(ImageSource), typeof(ImageSource), typeof(Pin), default(ImageSource)); + private object? _markerId; /// @@ -81,6 +84,22 @@ public PinType Type set { SetValue(TypeProperty, value); } } + /// + /// Gets or sets the custom image source for this pin's icon. + /// When set, this image will be used instead of the default platform pin icon. + /// This is a bindable property. + /// + /// + /// Supported image sources include file-based images, embedded resources, URIs, and streams. + /// The image will be scaled by the underlying platform to a platform-defined size (32x32 points on iOS, 64x64 pixels on Android). + /// Provide images that look clear when scaled to these sizes. + /// + public ImageSource? ImageSource + { + get { return (ImageSource?)GetValue(ImageSourceProperty); } + set { SetValue(ImageSourceProperty, value); } + } + /// /// Gets or sets the platform counterpart of this pin element. /// diff --git a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index ddbf4e1c505d..6e5dcb340de6 100644 --- a/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Controls/Maps/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -18,6 +18,8 @@ Microsoft.Maui.Controls.Maps.MapElement.ZIndex.get -> int Microsoft.Maui.Controls.Maps.MapElement.ZIndex.set -> void Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.get -> string! Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifier.set -> void +Microsoft.Maui.Controls.Maps.Pin.ImageSource.get -> Microsoft.Maui.Controls.ImageSource? +Microsoft.Maui.Controls.Maps.Pin.ImageSource.set -> void Microsoft.Maui.Controls.Maps.Polygon.PolygonClicked -> System.EventHandler? Microsoft.Maui.Controls.Maps.Polyline.PolylineClicked -> System.EventHandler? const Microsoft.Maui.Controls.Maps.Pin.DefaultClusteringIdentifier = "maui_default_cluster" -> string! @@ -26,3 +28,4 @@ static readonly Microsoft.Maui.Controls.Maps.Map.RegionProperty -> Microsoft.Mau static readonly Microsoft.Maui.Controls.Maps.MapElement.IsVisibleProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.MapElement.ZIndexProperty -> Microsoft.Maui.Controls.BindableProperty! static readonly Microsoft.Maui.Controls.Maps.Pin.ClusteringIdentifierProperty -> Microsoft.Maui.Controls.BindableProperty! +static readonly Microsoft.Maui.Controls.Maps.Pin.ImageSourceProperty -> Microsoft.Maui.Controls.BindableProperty! diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/CustomPinIconGallery.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/CustomPinIconGallery.xaml new file mode 100644 index 000000000000..d440e026c28e --- /dev/null +++ b/src/Controls/samples/Controls.Sample/Pages/Controls/MapsGalleries/CustomPinIconGallery.xaml @@ -0,0 +1,16 @@ + + + + +